/* AS-38 */
var gSiteLanguage = "en";
var gTeaser = false;
var gBrandColumnContent = null;
var submenuWidth = 160;
function locateCallProxy(pageName) {
	var reqPath = document.location.pathname;
	var re = new RegExp("(.+)/" + gSiteLanguage + "/([^/]+)/([^/]+)/([^/]+)(/.+)?","ig");
	re.exec(reqPath);
	if (RegExp.lastMatch != null) {
		var proxyPath = RegExp.$1 + '/' + gSiteLanguage + '/' + RegExp.$2 + '/' + RegExp.$3 + '/';
		if (RegExp.$5 != null && RegExp.$5 != '') {
			proxyPath += RegExp.$4 + '/';
		}
		proxyPath += pageName;
		return proxyPath;
	}
	else return null;
}
function search(path,searchstring) {
	var path = "" + path + "&qt=" + searchstring;
	window.location.href = path;
}
function oArrowLittle(imgid){
	document.getElementById(imgid).src = "/images/sandoz/assets/link_o_little.gif";
}
function bArrowLittle(imgid){
	document.getElementById(imgid).src = "/images/sandoz/assets/link_b_little.gif";
}
function oArrow(imgid){
	document.getElementById(imgid).src = "/images/sandoz/assets/link_o.gif";
}
function wArrow(imgid){
	document.getElementById(imgid).src = "/images/sandoz/assets/link_w.gif";
}
function bArrow(imgid){
	document.getElementById(imgid).src = "/images/sandoz/assets/link_b.gif";
}
var menuTimer = null;
var menuSelection = null;
var menuTimeout = 400;
function submenu_clear_timer() {
	if (menuTimer != null) {
		window.clearTimeout(menuTimer);
		menuTimer = null;
	}
}
function submenu_set_timer() {
	submenu_clear_timer();
	menuTimer = window.setTimeout('submenu_hide_menu(true);',menuTimeout);
}
function submenu_hide_menu(restore) {
	if (menuSelection == null) return;
	var subMenu = document.getElementById('brunch' + menuSelection);
	if (subMenu != null) {
		subMenu.style.visibility = 'hidden';
	}
	menuSelection = null;
}
function submenu_show_menu(selection) {
	submenu_clear_timer();
	if (menuSelection == selection) return;
	submenu_hide_menu(false);
	var subMenu = document.getElementById('brunch' + selection);
	if (subMenu != null) {
		var td = document.getElementById('td_' + selection);
		var span = document.getElementById('span_' + selection);
		var elm = td;
		var x = 0;
		var y = 0;
		while (elm.offsetParent != null) {
			x += elm.offsetLeft;
			y += elm.offsetTop;
			elm = elm.offsetParent;
		}
		if (document.all) {
			subMenu.style.pixelLeft = x - (subMenu.clientWidth - span.offsetLeft) / 2; /* td.clientWidth) / 2;*/
			subMenu.style.pixelTop = y + td.clientHeight + 1;
			subMenu.style.visibility = "visible";
			menuSelection = selection;
		} else {
			subMenu.style.left = x - 10; /*(submenuWidth - td.clientWidth) / 2;*/
			subMenu.style.visibility = "visible";
			menuSelection = selection;
		}
	}
}
var initChain = new Array();
function registerInitHook(f) {
	initChain.push(f);
}
function tsr_mouse_out(id) {
	if (gBranchNumber == 1 || gBranchNumber == 2 || gBranchNumber == 4) {
		wArrow(id);
	} else {
		bArrow(id);
	}
}
function do_init_chain() {
	if (gBrandColumnContent != null) {
		document.getElementById('idBrandColumn').innerHTML = gBrandColumnContent;
	}
	document.getElementById('idBrandColumn').style.visibility = "visible";
	if (window['hideMainMenu'] == null) {
		var x = document.getElementById('idMainMenuRow');
		if (x != null) {
			x.style.visibility = "visible";
		}
	}
	if (gTeaser == true) {
		/* teaser tuning */
		if (gBranchNumber == 1 || gBranchNumber == 2 || gBranchNumber == 4) {
			headClass = 'teaserhead';
			textClass = 'teasertext';
			imgSrc = '/images/sandoz/assets/link_w.gif';
		} else {
			headClass = 'teaserhead_blue';
			textClass = 'teasertext_blue';
			imgSrc = '/images/sandoz/assets/link_b.gif';
		}
		var x = document.getElementsByName("tsr_head");
		if (x != null) {
			for (i = 0; i < x.length; ++i) {
				x(i).className = headClass;
			}
		}
		x = document.getElementsByName("tsr_text");
		if (x != null) {
			for (i = 0; i < x.length; ++i) {
				x(i).className = textClass;
			}
		}
		x = document.getElementsByName("tsr_image");
		if (x != null) {
			for (i = 0; i < x.length; ++i) {
				x(i).src = imgSrc;
			}
		}
		x = document.getElementById("tsr_table");
		if (x != null) {
			x.className = 'bereich' + gBranchNumber;
		}
		x = document.getElementById("tsr_cell");
		if (x != null) {
			x.style.visibility = 'visible';
		}
	}
	for (i=0; i<initChain.length; ++i) {
		f = initChain[i];
		f.call();
	}
}

function generateDivContent(divNo) {
	var content = "";
	var array = null;
	switch(divNo) {
		case 1: array = document.getElementById('ifrMenu').contentWindow.entries0; break;
		case 2: array = document.getElementById('ifrMenu').contentWindow.entries1; break;
		case 3: array = document.getElementById('ifrMenu').contentWindow.entries2; break;
		case 4: array = document.getElementById('ifrMenu').contentWindow.entries3; break;
		case 5: array = document.getElementById('ifrMenu').contentWindow.entries4; break;
		case 6: array = document.getElementById('ifrMenu').contentWindow.entries5; break;
		case 7: array = document.getElementById('ifrMenu').contentWindow.entries6; break;
		case 8: array = document.getElementById('ifrMenu').contentWindow.entries7; break;
	}

	
	content += "<table cellspacing='0' cellpadding='0' border='0'>";
	for (i = 0; i < array.length; i++) {
		if (!endsWith(array[i][0], ".jpg") && !endsWith(array[i][0], ".gif") && !endsWith(array[i][0], ".pdf") && !endsWith(array[i][0], "_files")) {
			content += "	<tr>";
			content += "		<td align='left'>";
			content += "			<a href='" + array[i][1] + "' onmouseover='oArrow(\"div_1_" + i + "\")' onmouseout='wArrow(\"div_1_" + i + "\")' class='menuwhite'>";
			content += "				<img src='/images/sandoz/assets/link_w.gif' width='10' height='7' border='0' id='div_1_" + i + "'>";
			content += "				<img src='/images/sandoz/assets/nix.gif' width='6' height='1' border='0'>" + array[i][0];
			content += "			</a>";
			content += "		</td>";
			content += "	</tr>";
		}
	}
	content += "</table>";
	document.getElementById("div" + divNo).innerHTML = content;
}

function endsWith(source, target) {
	return (source.substring(source.length - target.length) == target);
}

function mprint() {
	var pw=window.open("","","toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=480,screenX=200,screenY=50");
	var d = pw.document;
	d.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">');
	d.write('<link rel="stylesheet" type="text/css"  href="/commons/css/content.css">');
	d.write('<style type="text/css" media="screen">BODY { margin: 2cm }; .mediaDependent { display: block }</style>');
	d.write('<style type="text/css" media="print"> .mediaDependent { display: none }</style>');

	d.write('<' + 'script' + '>');
	d.write('function mprint() {  window.print(); } ');
	d.write('');
	d.write('function on_load() { var img = document.getElementById("printIconId"); if (img != null && img.alt != null) img.alt = "Print"; }');
	d.write('<' + '/' + 'script' + '>');
	d.write('</head>');
	d.write('<body onload="on_load()">');
	d.write('<table border="0" width="100%" cellspacing="0" cellpadding="0">');
	d.write('<tr><td width="90%" valign="bottom"><img border="0" src="/images/sandoz/logo_cont.gif"></td><td width="10%" align="right">www.sandoz.com</td></tr>');
	d.write('<tr><td colspan="2"><table width="100%"><tr><td colspan="2" height="40"><img border="0" src="/images/sandoz/assets/nix.gif" width="1" height="40"></td></tr>');
	d.write('<tr><td width="5%">&nbsp;</td>');
	d.write('<td width="95%">' + document.getElementById('printablePart').innerHTML + '</td></tr>');
	d.write('<tr><td colspan="2" class="footline" height="20">&nbsp;</td></tr>');
	d.write('<tr><td colspan="2" class="footline" height="20">&nbsp;</td></tr>');
	d.write('<tr><td width="5%"></td><td class="footline">&nbsp;&copy;Sandoz 2006, Industriestrasse 25, 83607 Holzkirchen, Germany, Phone +49 (0) 8024 476 0</td></tr>');
	d.write('</table></td></tr></table>');
	d.write('</body></html>');
	d.close();
	pw.focus();
}
