/*** Graceful degrade for non-javascript users & some event capture for livesearch ***/
window.onload = addscript; // Graceful degrade stuff for non-javascript users
document.onclick = hidelivesearch; // Onclick capturing for closing live search box
function addscript() {
// check to see that the browser supports the getElementById method
if (!document.getElementById) {
return false;
} else {
if (document.getElementById('countriesanchor')) { document.getElementById('countriesanchor').href = "#"; } // Replace conventional url in countries footer link
if (document.getElementById('searchfield')) { document.getElementById('searchfield').value= " Search"; }
if (document.getElementById('popupclose')) { document.getElementById('popupclose').innerHTML = "close window
"; } //Add close window link for popup template
}
if (((BrowserDetect.browser)=="Firefox")&((BrowserDetect.version)=="3.5")) { document.getElementById('searchsubmit').style.marginBottom = "-10px"; }
if (((BrowserDetect.browser)=="Firefox")&((BrowserDetect.version)=="3.6")&(BrowserDetect.OS)=="Mac") { document.getElementById('searchsubmit').style.marginBottom = "-8px"; }
}
function openpopup() {
window.open('popup.html','popup','width=500,height=500');
}
function popup(url)
{
newwindow=window.open(url,'_blank');
if (window.focus) {newwindow.focus()}
}
/*** START Primary nav hover function for IE ***/
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i
"
document.getElementById('countriesboxhead').innerHTML = countriesheader;
document.getElementById('countriescontents').innerHTML = countriesoutput;
}
function countrieshide() { // Clear the contents of the box and hide the div
document.getElementById('countriescontents').innerHTML = "";
document.getElementById('countriesbox').style.visibility = 'hidden';
}
/*** START Live search ***/
var xmlHttp
function showResult(str) {
// Clear the suggestions box when no chars
if (str.length<=minchars) {
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.visibility="hidden";
return
}
if (livesearchon!="true") {
return
}
// Place the AJAX loading gif. Replaced with the clear icon after the request is complete (below)
document.getElementById("livesearchbutton").src= "http://www.pwc.com/en_GX/webadmin/assets/image/ajaxload.gif";
document.getElementById("livesearchbutton").className="";
xmlhttp=null;
url = suggestionsfile; // Suggestions xml file taken from local.js
if (window.XMLHttpRequest) {// code for IE7, Firefox, Mozilla, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject) {// code for IE5, IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null) {
xmlhttp.onreadystatechange=processsearch;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else {
//alert("Your browser does not support XMLHTTP.");
clearlivesearch();
return;
}
}
function processsearch() { // Check if file is valid & if so do something with its contents
// Take the current search string
var str = document.getElementById("searchfield").value.toLowerCase();
// Break the loop when http call is complete or there's an error
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200) {
//alert("Problem retrieving XML data");
clearlivesearch();
return;
}
// Locate the link element to traverse
x=xmlhttp.responseXML.documentElement.getElementsByTagName("link");
var searchoutput = "";
var searchoutputheader = "";
var searchoutputfooter = "";
if (str.length > minchars) {
// Loop through all link elements
for (i=0;i" + xtitles[0].firstChild.nodeValue + "
";
} else {
searchoutput = searchoutput + "";
}
}
catch (er) { searchoutput = searchoutput + ""; }
}
}
}
if (searchoutput=="") {
// Collapse the suggestions box when no matches & halt the ajax loading gif
document.getElementById("livesearch").style.visibility="hidden";
document.getElementById("livesearchbutton").src="http://www.pwc.com/en_GX/webadmin/assets/image/icon_close.gif"; // Show the close button, replacing the ajax gif
document.getElementById("livesearchbutton").className="livesearchclose";
} else {
// Return the response, only when xml http call is done. Show the close button, replacing the ajax gif
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") {
document.getElementById("livesearch").style.visibility="visible";
document.getElementById("livesearch").innerHTML=searchoutputheader + searchoutput + searchoutputfooter;
document.getElementById("livesearchbutton").src="http://www.pwc.com/en_GX/webadmin/assets/image/icon_close.gif";
document.getElementById("livesearchbutton").className="livesearchclose";
}
}
}
function clearsearch() { //Clear from initial focus
document.getElementById("searchfield").value="";
}
function clearlivesearch() { // Clear from the button & also hide the button
document.getElementById("searchfield").value=" Search";
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.visibility="hidden";
document.getElementById("livesearchbutton").src= "tran.gif";
document.getElementById("livesearchbutton").className="";
}
// Hide the livesearch box on a click outside its div
function hidelivesearch(evt) {
evt = evt || window.event;
var targ = evt.target || evt.srcElement;
// If the livesearch box is open, clear it
if (targ.id=="livesearch" || targ.id=="livesearchheader" || targ.id=="livesearchfooter" || targ.id=="searchsubmit") {
return;
} else {
if (document.getElementById("livesearch").style.visibility=="visible") {
clearlivesearch();
}
}
}
/*** START Send & share global defaults ***/
if (sharetitle === undefined) { var sharetitle = "Share"; }
function writesharelink() {
document.write("" + sharetitle + "");
}
// Icon, Pre-URL, Post-URL, Description/alt tag, Onlick. Only declare them if they don't already exist from local.js
if (arr_ss [0] === undefined) {
// Twitter
arr_ss [0] = new Array()
arr_ss [0][0] = varCurDb + "share_twitter.gif";
arr_ss [0][1] = "http://twitter.com/home?status=" + escape(window.location);
arr_ss [0][2] = ""; // E.G. arr_ss [0][2] = "¶m=something";
arr_ss [0][3] = "Twitter";
arr_ss [0][4] = "";
}
if (arr_ss [1] === undefined) {
// Facebook
arr_ss [1] = new Array()
arr_ss [1][0] = varCurDb + "share_facebook.gif";
arr_ss [1][1] = "http://www.facebook.com/share.php?u=" + escape(window.location);
arr_ss [1][2] = "";
arr_ss [1][3] = "Facebook";
arr_ss [1][4] = "";
}
if (arr_ss [2] === undefined) {
// Linkedin
arr_ss [2] = new Array()
arr_ss [2][0] = varCurDb + "share_linked.gif";
arr_ss [2][1] = "http://www.linkedin.com/shareArticle?mini=true&url=" + escape(window.location);
arr_ss [2][2] = "";
arr_ss [2][3] = "Linkedin";
arr_ss [2][4] = "";
}
if (arr_ss [3] === undefined) {
// Mixx
arr_ss [3] = new Array()
arr_ss [3][0] = varCurDb + "share_mixx.gif";
arr_ss [3][1] = "http://www.mixx.com/submit?page_url=" + escape(window.location);
arr_ss [3][2] = "";
arr_ss [3][3] = "Mixx";
arr_ss [3][4] = "";
}
if (arr_ss [4] === undefined) {
// Digg
arr_ss [4] = new Array()
arr_ss [4][0] = varCurDb + "share_digg.gif";
arr_ss [4][1] = "http://digg.com/submit?phase=2&url=" + escape(window.location);
arr_ss [4][2] = "";
arr_ss [4][3] = "Digg";
arr_ss [4][4] = "";
}
if (arr_ss [5] === undefined) {
// Google buzz
arr_ss [5] = new Array()
arr_ss [5][0] = varCurDb + "share_googlebuzz.gif";
arr_ss [5][1] = "http://www.google.com/reader/link?url=" + escape(window.location);
arr_ss [5][2] = "";
arr_ss [5][3] = "Google buzz";
arr_ss [5][4] = "";
}
function shareboxreveal() { // Show, hide or add to territory selector box
document.getElementById('sharebox').style.display = 'block';
}
function shareboxhide() { // Clear the contents of the box and hide the div
document.getElementById('sharebox').style.display = 'none';
}
function writesharebox() { // Taken from HTML for 3rd party templates
var sendshare = ""
if (window.sendsharetitle === undefined) { window.sendsharetitle = escape("Page title here"); }
for (i=0;i
" + arr_ss[i][3] + "";
}
sendshare = sendshare + "
";
document.write(sendshare);
}
// Default R2 forms validation message (translatable))
if (formvalidationmsg === undefined) { var formvalidationmsg = "Please complete the highlighted fields"; }
/*** START Lightweight browser detection ***/
//alert(BrowserDetect.browser + ' ' + BrowserDetect.version + ' on ' + BrowserDetect.OS);
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i