//////////////////////////////////////////////////////////////////////////////
var server = document.URL;

var qs = unescape(location.search);
qs = qs.substring(1); /* knock-off the first '?' */

var args = new Array; /* 'hash' to hold name value pairs from querystring */
var qsarr = qs.split('&');
var atmp = new Array; /* this one loads the names and values into a hash (of sorts) */  

for(i=0; i<qsarr.length; i++) {  
     atmp = qsarr[i].split('=');  
     args[atmp[0]] = atmp[1];
}
//////////////////////////////////////////////////////////////////////////////
// measurement
var pageSource = window.location.href;
if(pageSource.lastIndexOf("#")==(pageSource.length-1)){
	pageSource = pageSource.substring(0,pageSource.length-1);
}
// redirector - to log openwindow jumps
function openWin(url){
	if(url.indexOf("seo")!=-1){
		url = "/exitpage.html?source=" + pageSource + "&site=" + url;
	}else{
		url = location.pathname+"?pagename=Bayer/external/pext/pextMaster/templates/pagelets/elements/redirector&source=" + pageSource + "&site=" + url;
	}
	var newWin = window.open(url,"Redirector","width=800,height=500,left=170,top=50,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,location=yes,resizable=yes");
	newWin.focus();
}

//for the disclaimer pop up page - strips out the url and goes there if yes is selected
function go(click) { 
	var url;
	var w = window.opener;
	if (w != null) {
		origUrl = w.location.href;
	}
	
	if (args['site']){
		url = args['site'];
		url = "ContentServer?pagename=Bayer/external/pext/pextMaster/templates/pagelets/elements/redirector&site=" + url + "&source=" + origUrl;
	} else {
		url = args['page'];
	}
			
	if (click == 1) {
		var newWin = window.open(url,"Redirector","width=750,height=500,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,location=yes,resizable=yes");
		newWin.focus();
	}
	window.close();
	return true;
}

//used for the link on the site page - opens disclaimer page with the url appended as a query string
function check (url) {
	var newWin = window.open(url,"newWin",'height=240,width=320,status=no,toolbar=no,menubar=no,location=no,resizable=no');
	newWin.focus();
	//return false;
}

//single image window opener
function openImage(url, pagename, width, height) {
	if(url.indexOf(".html")!=-1){
		var newWin = window.open(url, pagename.replace(/\W/g, "_"),'width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=auto,location=no,resizable=yes');
		newWin.focus();
	}else{
		var newWin = window.open('ContentServer?pagename=' + url, pagename.replace(/\W/g, "_"),'width='+width+',height='+height+',toolbar=no,status=no,menubar=no,scrollbars=auto,location=no,resizable=yes');	
		newWin.focus();
	}
}
//pdf window opener for site   
function openPdf(URL) {
	//if(URL.indexOf('http://') == -1) { URL = "http://" + URL;}
	var newWin = window.open(URL,"BayerPharma","width=750,height=500,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,location=yes,resizable=yes");
	newWin.focus();
}
//printerFriendlyPopup
function popup (url) {
	//alert(url.substring(30));
	var newWin = window.open(url,"popupWin",'width=418,height=450,top=150,left=300,toolbar=yes,status=no,menubar=yes,scrollbars=yes,location=yes,resizable=yes');
	newWin.focus();
	//return false;
}

function openWindow(url) {
	if(url.indexOf('http://') == -1) { url = "http://" + url;}
	var thisWin = window.open(url,"exportWin",'width=750,height=500,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,location=yes,resizable=yes');
	thisWin.focus();
	//return false;
}

function openWindowInLocation (URL, winName, winWidth, winHeight, location) {
    var scrw    = screen.availWidth;
    var scrh    = screen.availHeight;
    var leftPos = ((scrw-winWidth)/2);
	var topPos  = 0;

	if(location=='Center'){
		topPos  = ((scrh-winHeight)/2);
	}
	if(location=='Bottom'){
		topPos  = scrh-winHeight; 
	}

	var winStats='toolbar=no,location=yes,directories=no,menubar=no,scrollbars=yes,resizable=no,width='+winWidth+',height='+winHeight+',';
	if(navigator.appName.indexOf("Microsoft")>=0){
		winStats+='left='+leftPos+',top='+topPos;
	}
	else{
		winStats+='screenX='+leftPos+',screenY='+topPos;
	}
	var mainWindow=window.open(URL,winName,winStats);
	mainWindow.window.focus();
}
//-->
