	function genericToggleAll(elem,subelem,pattern,showall) {
	var reg = new RegExp(pattern + '-.*');
	if (!document.getElementsByTagName) return null;
	if (!showall) showall = "";
	var divs = document.getElementById(elem).getElementsByTagName(subelem);
	for(var i=0; i < divs.length; i++){
		var div = divs[i];
		var id = div.id;
		if (reg.test(id)) {
			if (showall == "show"){
				div.style.display = "block";
			} else {
				div.style.display = "none";
			}	
		}
	}
}
function faqToggle(showall) {genericToggleAll("faqlist","div","faqanswer",showall);}
function productsToggle(showall) {genericToggleAll("productlist","div","productgroup",showall);}
function photoarchiveToggle(showall) {genericToggleAll("photo_list","li","asset",showall);}
function photoarchiveToggleSegment(showall,segment) {genericToggleAll("photo_list","li","asset-" + segment,showall);}

function genericToggle(elem) {
	if (elem.style.display=="block"){
		elem.style.display = "none";
	} else {
		elem.style.display = "block";
	}	
}
function faqToggleSingle(id) {genericToggle(document.getElementById(id));}
function dirindexToggleSingle(id) {genericToggle(document.getElementById(id));}
function toggle(id) {genericToggle(document.getElementById(id));}

function replaceTeaserSelect() {
	var reg = new RegExp('dropdown-.*');
	if (!document.getElementsByTagName) return null;
	var lists = document.getElementsByTagName("ul");
	for(var i=0; i < lists.length; i++) {
		var oList = lists[i];
		var id = oList.id;
		if (reg.test(id)) {
			replaceSelect(id);
		}
	}
}

function replaceSelect(id) {
	var oList = document.getElementById(id);
	if (oList) {
		var oEntries = oList.getElementsByTagName('a');
		var oSelectBox = document.createElement('select');
		var oDefaultOption = document.createElement('option');
		var local_term = unescape("S%E9lectionnez un pays");
		var oDefaultTxt = document.createTextNode(local_term);
		oDefaultOption.setAttribute('value', null);
		oDefaultOption.appendChild(oDefaultTxt);
		oSelectBox.appendChild(oDefaultOption);
		for (var i=0; i < oEntries.length; i++) {
			var oOption = document.createElement('option');
			oOption.setAttribute('value', oEntries[i].href);
			var oOptText = document.createTextNode("- " + oEntries[i].firstChild.nodeValue);
			oOption.appendChild(oOptText);
			oSelectBox.appendChild(oOption);
		}
		oList.parentNode.insertBefore(oSelectBox,oList);
		var oSelect = oList.parentNode.getElementsByTagName('select')[0];
		addEvent(oSelect, 'change', submitForm);
	}
}

function submitForm() {
	if(this.value != null) {
		window.location = this.value;
	}
}

function replacePhotoarchiveSelect(id) {
	var oList = document.getElementById(id);
	if (oList) {
		var oEntries = oList.getElementsByTagName('a');
		var oSelectBox = document.createElement('select');
		for (var i=0; i < oEntries.length; i++) {
			var oOption = document.createElement('option');
			var segmentId = oEntries[i].href.replace(/.*-([^\-])\-1/, "$1");
			oOption.setAttribute('value', segmentId);
			var oOptText = document.createTextNode(oEntries[i].firstChild.nodeValue);
			oOption.appendChild(oOptText);
			oSelectBox.appendChild(oOption);
		}
		oList.parentNode.insertBefore(oSelectBox,oList);
		var oSelect = oList.parentNode.getElementsByTagName('select')[0];
		addEvent(oSelect, 'change', submitFormPhotoarchive);
	}
}

function submitFormPhotoarchive() {
	if(this.value != null && !(this.value.match(/photo_list/))) {
		photoarchiveToggle('hide');
		photoarchiveToggleSegment('show',this.value);
	} else {
		photoarchiveToggle('show');
  }
}

function navHoverIE(id) {
	var lis = document.getElementById(id).getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
			this.firstChild.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
			this.firstChild.className=this.firstChild.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}

var EventCache = function() {
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
		}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

// Cookies
function getCookie(cookiename) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(cookiename + "=");
		if (c_start!=-1) { 
			c_start=c_start + cookiename.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return null;
}

function setCookie(cookiename,value,days) {
	var expire=new Date();
	expire.setDate(expire.getDate()+days);
	document.cookie=cookiename+ "=" + escape(value) + ";expires=" + expire.toGMTString() + ";path=/";
}

function fSize(i){;var r;if(isNaN(parseInt(i))){r=i;var i=prompt(i,"");if(i)if(isNaN(parseInt(i))){fSize(r,"");}}var c=document.body.style.fontSize;if(!c){c="62.5%";}var n=c.split("%");document.body.style.fontSize=(parseInt(n[0]))+(parseInt(i))+"%";} 

function setFontsize(change) {
  if (change=='d') {
    if (parseInt(document.body.style.fontSize)>50) {
      fSize('-10'); setCookie('fontSize',document.body.style.fontSize,365);}
  } else if (change=='i') {
    if (parseInt(document.body.style.fontSize)<90) {
      fSize('10'); setCookie('fontSize',document.body.style.fontSize,365);}
  } else {
  	document.body.style.fontSize='62.5%';
    setCookie('fontSize',document.body.style.fontSize,-10);
  }
}

var currentURL = document.location.toString();
currentURL = currentURL.replace(/^.*(\/site\/.*)/,'$1');
var areaImg= currentURL.replace(/^\/site\/([^\/]+)\/([^\/]+)\/.*/,'/assets/content/$1/header_img/$2.jpg');
var testURL = currentURL.replace(/^.*(\/site\/[^\/]+\/[^\/]+\/).*/,'$1');
var urlFlag = currentURL.match(/^.*\/site\/[^\/]+\/[^\/]+\/.*/);
addEvent(window, 'load', init);
function init() {
	replaceTeaserSelect();
	if (document.getElementById("photoarchive-selectlist")) {
		replacePhotoarchiveSelect("photoarchive-selectlist");
	}	
  	if (document.getElementById("menu") != null){
    if ((navigator.appName=="Microsoft Internet Explorer") && (parseFloat(navigator.appVersion)<=6)) {
		  navHoverIE("menu");
		}
		var mainNav = document.getElementById("menu");
  	for (var i = 0; i < mainNav.childNodes.length; i++) {
  		if (mainNav.childNodes[i].tagName == "UL") {
  			var mainUL = mainNav.childNodes[i];
  			for (var j = 0; j < mainUL.childNodes.length; j++) {
  				if (mainUL.childNodes[j].tagName == "LI") {
  					var myLI = mainUL.childNodes[j];
  					for (var k = 0; k < myLI.childNodes.length; k++) {
  						if (myLI.childNodes[k].tagName == "A" && myLI.childNodes[k].getAttribute('href').match(testURL)) {
  							mainUL.childNodes[j].className = 'selected';
  						}
  					}
  				}
        }
  		}
  	}
	}
	if (getCookie('fontSize')!='' && getCookie('fontSize')!=null) {
	  document.body.style.fontSize=getCookie('fontSize'); }
	else {
  	  document.body.style.fontSize='62.5%'; }
	if (document.getElementById("worldmap_menu") != null && (navigator.appName=="Microsoft Internet Explorer") && (parseFloat(navigator.appVersion)<=6)){
    navHoverIE("worldmap_menu");
  }	
}

//Show popup when users click external links (indicate they're leaving the Sandoz website)
function showPopup(link_url){
	var css_p = "";
	var popup = "";
	var popup_text = "";
	var content_ending = "";
	var content_beginning = ""; 
	var final_url = ""; 
	
	//Adapt URL to valid format
	if(link_url.indexOf("http://") == -1){
		final_url = "http://" + link_url;	
	}
	else{
		final_url = link_url;	
	}	
	
	//Customize styles
	content_beginning = "<html><head><title>Sandoz.fr</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><link href=\"/assets/layout/common/css/clear.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" /><link href=\"/assets/layout/common/css/common.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" /><!--[if IE 6]><link href=\"/assets/layout/common/css/default_ie6.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" /><![endif]--><link href=\"/assets/layout/common/css/print.css\" rel=\"stylesheet\" type=\"text/css\" media=\"print\" /></head><body style=\"font-size: 62.5%;\"><p style=\"font-size: 1.2em; padding:4px 7px 0px 7px;\">";
		
	//IE
	if(navigator.appName.indexOf("Microsoft") != -1){
		content_ending = "<a href=\"" + final_url + "\" onClick=\"self.close()\" target=\"_blank\">Continuer</a></td></tr></table></body></html>";
	}
	//self.close - Bug within FF, workaround opening html-file in a new window that contains nothing but a JS-close-command
	else{
		content_ending = "<a href=\"" + final_url + "\" onClick=\"window.open('/assets/layout/common/js/close.html', '_self');\" target=\"_blank\">Continuer</a></td></tr></table></p></body></html>";
	}
	
	popup_text = content_beginning + "<table style=\"border: 0px; width: 100%; margin-top: 11px;\"><tr><td style=\"padding-left: 168px;\"><img src=\"/assets/content/common/img_content/Sandoz_Logo_regular_1.jpg\" alt=\"Sandoz\" style=\"border: 0px;\" /></td></tr></table><br/>A toutes fins utiles, nous vous offrons sur notre site <a href=\"http://www.sandoz.fr\" target=\"_blank\">www.sandoz.fr</a> la possibilit&eacute; d'acc&eacute;der &agrave; des sites &eacute;dit&eacute;s par des tiers. Aussi, en activant les liens hypertextes, vous quitterez notre site <a href=\"http://www.sandoz.fr\" target=\"_blank\">www.sandoz.fr</a>. Sandoz fournit ses liens pour votre commodit&eacute;. <br/><br/>Si vous d&eacute;cidez de visiter tout site d&eacute;sign&eacute; par un lien hypertexte &agrave; partir de notre site <a href=\"http://www.sandoz.fr\" target=\"_blank\">www.sandoz.fr</a>, vous assumez l'ensemble des risques li&eacute;s &agrave; cette visite, et il est de votre responsabilit&eacute; de prendre toutes les mesures n&eacute;cessaires &agrave; votre protection, notamment contre les virus. <br/><br/>Nous excluons toute garantie en ce qui concerne les sites accessibles par un lien ou les informations apparaissant sur ces sites, les changements ou mises &agrave; jour qui leur sont apport&eacute;es ou tout produit ou service d&eacute;crit sur ces sites, sur lesquels nous n'exer&ccedil;ons aucun contr&ocirc;le. De tels liens n'impliquent pas que nous encourageons, approuvons, soyons affili&eacute;s ou associ&eacute;s &agrave; ces sites ni que nous soyons l&eacute;galement autoris&eacute;s &agrave; faire usage de toute marque, tout logo, tout nom commercial, ou symbole de copyright figurant sur de tels liens ou sur les sites accessibles par leur interm&eacute;diaire.<br/><table style=\"width: 100%; border: 0px; font-size:1.0em; margin-top: 10px;\"><tr><td style=\"text-align: right; padding-right: 5px;\"><a href=\"#\" onClick=\"self.close()\" target=\"_self\">Annuler</a></td><td style=\"text-align: left; padding-left: 5px;\">" + content_ending;
		
	//Generate popup window
	popup = window.open('','','width=500,height=321,location=no,menubar=no,resizable=no,toolbar=no,left=245,top=250');		
	popup.document.write(popup_text);
	popup.focus();
}