// Change Language

function  changelang() {  
	var str = window.location.href;
	var where = str.indexOf('investors.benettongroup.com');
	var CMID = str.indexOf('114079');

	if (where != -1) { 
	  var pre = str.substring(0,where);
	  var subs  = str.substring(where,where+50);
	  var post = str.substring(where+50,120);
	  var result = pre + 'investorsit.benettongroup.com/phoenix.zhtml?c=142748' + post;
	  window.location.href = result;
	  }
	  else  { 
	  CMID = str.indexOf('114079');
	  var pre = str.substring(0,CMID);
	  // alert (pre)
	  var subs  = str.substring(CMID,CMID+6);
	  // alert (subs)
	  var post = str.substring(CMID+6,120);
	  // alert (post)
	  var nuovo = pre + '142748' + post;
	  //alert (nuovo)
	  window.location.href = nuovo;
	  }
}

// Unobtrusive Popup

window.onload = function() {
	// check to see that the browser supports the getElementsByTagName method
	// if not, exit the loop 
	if (!document.getElementsByTagName) {
		return false; 
	} 
	// create an array of objects of each link in the document 
	var popuplinks = document.getElementsByTagName("a");
	// loop through each of these links (anchor tags) 	
	for (var i=0; i < popuplinks.length; i++) {	
		// if the link has a class of "popupLink"...	
		if (popuplinks[i].className == "slideShow") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpSlideShow(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if (popuplinks[i].className == "slideShow750x550") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpSlideShow750x550(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if (popuplinks[i].className == "slideShow774x393") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpSlideShow7741x393(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if ((popuplinks[i].className == "blank") || (popuplinks[i].className == "webExternal") || (popuplinks[i].className == "pdf") || (popuplinks[i].className == "excel") || (popuplinks[i].className == "panelButtonPDF") || (popuplinks[i].className == "picExternal") || (popuplinks[i].className == "icoFactsheet")) {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpBlank(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if (popuplinks[i].className == "audioWebcast") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpAudioWebcast(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if (popuplinks[i].className == "audioWebcastSlideShow") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpAudioWebcastSlideShow(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if (popuplinks[i].className == "audioWebcastSlideShow900x750") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpaudioWebcastSlideShow900x750(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if (popuplinks[i].className == "privacyPopup") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpPrivacy(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if (popuplinks[i].className == "webcast") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpwebcast(this.getAttribute("href"));	
			return false; 	
			} 	
		}
		else if (popuplinks[i].className == "icoSMS") {	
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp 	
			popuplinks[i].onclick = function() {	
			openPopUpSMS(this.getAttribute("href"));	
			return false; 	
			} 	
		}
	} 
} 

function openPopUpPrivacy(linkURL) {
window.open(linkURL,'popup','width=450,height=340,scrollbars=yes')
}

function openPopUpSlideShow(linkURL) {
window.open(linkURL,'popup','width=740,height=390,resizable=yes')
}

function openPopUpSlideShow750x550(linkURL) {
window.open(linkURL,'popup','width=700,height=600,resizable=yes')
}

function openPopUpSlideShow774x393(linkURL) {
window.open(linkURL,'popup','width=744,height=393,resizable=yes')
}

function openPopUpAudioWebcast(linkURL) {
window.open(linkURL,'popup','width=435,height=260,resizable=yes')
}

function openPopUpAudioWebcastSlideShow(linkURL) {
window.open(linkURL,'popup','width=700,height=680,scrollbars=yes,resizable=yes')
}

function openPopUpaudioWebcastSlideShow900x750(linkURL) {
window.open(linkURL,'popup','width=900,height=750,scrollbars=yes,resizable=yes')
}

function openPopUpwebcast(linkURL) {
window.open(linkURL,'popup','width=700,height=680,scrollbars=yes,resizable=yes')
}

function openPopUpSMS(linkURL) {
window.open(linkURL,'popup','width=425,height=400,scrollbars=yes,resizable=yes')
}

function openPopUpBlank(linkURL) {
window.open(linkURL,'popup')
}

// Bookmark Site

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

// Accessibility
function setContrast() {
	if (getActiveStyleSheet()=='' || getActiveStyleSheet()=='contrast') {
		setActiveStyleSheet('small');
		//alert ("1");
	}
	var c = document.getElementById("contrast");
	// alert (c.className);
	// alert (blContrast);
	if(blContrast){
		blContrast = false;
		c.className = c.className.replace("active","");
	} else {
		blContrast = true;
		c.className = "active";
	}
	
	setActiveStyleSheet(getActiveStyleSheet());
}

function setActiveStyleSheet(title) {
  var i, a, main;
  var aFont = document.getElementById(title);
  var s = document.getElementById("small");
  var m = document.getElementById("medium");
  var l = document.getElementById("large");
  var c = document.getElementById("contrast");
    
  if(aFont != null) {
	  s.className = s.className.replace("active","");
	  m.className = m.className.replace("active","");
	  l.className = l.className.replace("active","");
	  aFont.className = "active";
	  //if(blContrast)c.className = "active";
	  
  }
  
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
	  if(blContrast && a.getAttribute("title") == "contrast") a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

/*
window.onload = function(e) {
  var cookie = readCookie("style");
  var cookie2 = readCookie("styleContrast");
  if(cookie2 == "true") {
    var blContrast = true;
  } else {
	var blContrast = false;
  }
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}
*/

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  createCookie("styleContrast", blContrast, 365);
}

var cookie = readCookie("style");
var cookie2 = readCookie("styleContrast");
if(cookie2 == "true") {
	var blContrast = true;
} else {
	var blContrast = false;
}
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
if (title==null) setActiveStyleSheet('small'); 
