// keyvisual rotation
function keyvisual_rotation(entrypage, imgNumber) {
	
	// list of images
	keyvisual = new Array();
	for (i=0; i < imgNumber; i++) {
		keyvisual[i] = "/images/" + entrypage + "/keyvisuals/keyvisual_rotate_" + i + ".jpg";
	}
 		
	// random action and number of images
	random_num = (Math.round(Math.random() * (imgNumber-1) ) )

	// result
	document.getElementById("keyvisualRotate").innerHTML = "<img src=\"" + keyvisual[random_num] + "\" border=\"\" alt=\"\">";
}

// start function
function CheckIfCountryIsRequired()
{
if (document.Suche.Land.value == "Country")
	{
	alert ("Please select a Roche Diagnostics Country.");
	return false;
	}		
var win;
win=window.open("/servicebox/search_info.html","searchinfo","width=250,height=150");
win.setTimeout('window.close()',5000);
return true;
}
// end function

// start function HiliteOnLocation 
var currentHiliteLocation = 0;
var currentHilite = 0;
var hiliteArray = new Array();

function HiliteOnLocation (id,hicolor){
HiliteOff(id);
if (document.layers) { 
	himg = id+"_img";
	document.embeds["flashplayer"].SetVariable("hilite", id);
} else {
	document.getElementById(id).style.border = "1px solid #CC0000";
	document.getElementById(id+"_img").style.backgroundColor = "#FF0000";	
	document.flashplayer.SetVariable("hilite", id);
}
currentHiliteLocation = id;
hiliteArray.push(id);
}
// end function HiliteOnLocation
			     
// start function HiliteOn 
function HiliteOn (id,hicolor) {
	HiliteOff(id);
	if (document.layers) { 
		document.embeds["flashplayer"].SetVariable("hilite", id);
	} else {
		if(id.indexOf('x_')!=0) {
			document.getElementById(id).style.border = "1px solid #8C6544";
		}
		   //////////////////////////////////////////////////////////////////////////////////////////
		  // NEW Hilite for images without background                                             //
		 // document.getElementById(id+"_new").src = "/images/countries/arrow_countries_on.gif"; //
		//////////////////////////////////////////////////////////////////////////////////////////
		
		document.getElementById(id+"_img").style.backgroundColor = "#8C6441";
		document.flashplayer.SetVariable("hilite", id);
	}
	hiliteArray.push(id);
	currentHilite = id;
} // end function HiliteOn

// start function HiliteOff
function HiliteOff (id){
	
if (document.layers) { 
	document.embeds["flashplayer"].SetVariable("hilite", "0");
} else {
	while (hiliteArray.length > 0) {
		x = hiliteArray.pop();
		document.getElementById(x).style.border = "1px solid #FFFFFF";
		
		   /////////////////////////////////////////////////////////////////////////////////////////////
		  // NEW Hilite for images without background                                                //
		 // document.getElementById(id + "_new").src = "/images/countries/arrow_countries_off.gif"; //
		/////////////////////////////////////////////////////////////////////////////////////////////
		
		document.getElementById(x+"_img").style.backgroundColor = "#A3A327";
	}
	document.flashplayer.SetVariable("hilite", "0");
} 
}
// end function HiliteOff 

//Open Search Popup

function opensearchpopup()
{
var win;
win=window.open("/servicebox/search_info.html","searchinfo","width=250,height=150");
win.setTimeout('window.close()',5000);
return true;
}

//PrintLink

var path = window.location.pathname;
var path1 = window.location.search;
//var print_link = "/tools/print_page/print.php?filepath=" + path + "&page=http://" + window.location.host + path;
var print_link = "/tools/print_page/print.php?filepath=" + path + "&page=http://localhost" + path + path1;

// start PopUp-Window function
function openWindow(URL) {
	newWindow = window.open(URL, 'print', 'width=640,height=560,scrollbars=yes,resizable=yes,menubar=yes,statusbar=yes');
	newWindow.focus();
}

function openPrintWindow(URL) {
	alert(URL);
	//document.write(path);
	URL = URL + window.location.href.substring(starter);
	//document.write(URL);
	newPrintWindow = window.open(URL, 'print', 'width=640,height=560,scrollbars=yes,resizable=yes,menubar=yes,statusbar=yes');
	newPrintWindow.focus();
}

function openWindownew(which_url, which_name, features) {
	window.open(which_url, which_name, features);
//	popup.focus();
// 	return 1;
}
// end PopUp-Window function


//MouseOver

var restoreArray = new Array;
var restoreCount = 0;
var restoreTimer = 0;

function  preloadImages  ()
{
 if  (preloadArray == null)  return;
 var imageObject;
 var fileName;
 count = preloadArray.length;
 for (index=0; index<count; index++)
     {
     fileName = preloadArray [index];
     imageObject = new Image;
     imageObject.src = fileName;
     preloadArray [index] = imageObject;
     }
}

function  replaceImage  (ImageName, FileName)
 {
 imageObject = eval ('document.' + ImageName);
 if  ((imageObject == null) || (FileName == null) || (FileName == ''))  return;
 if  (restoreArray != null)
     {
     restoreArray [restoreCount++] = imageObject.src;
     restoreArray [restoreCount++] = imageObject;
     }
 imageObject.src = FileName;
 }

function  clearRestoreList  ()
 {
 restoreCount = 0;
 }

function  restoreImages  (DelaySeconds)
 {
 if  (restoreTimer > 0)
     {
     clearTimeout (restoreTimer);
     restoreTimer = 0;
     }
 if  ((restoreArray == null) || (restoreCount < 1))  return;
 if  (DelaySeconds > 0)
     {
     restoreTimer = window.setTimeout ('restoreImages ();', DelaySeconds * 1000);
     return;
     }
 while (restoreCount > 0)
     {
     imageObject = restoreArray [--restoreCount];
     fileName = restoreArray [--restoreCount];
     if  ((imageObject != null) && (fileName != null) && (fileName != ''))  imageObject.src = fileName;
     }
 }

//Aktualisierungsdatum
	    
function ladate ()
{
var jahr, monat, tag;
var datum = new Date();

  var jahr = datum.getYear();
  var monat = datum.getMonth() + 1;
  var tag = datum.getDate();
if (tag==1)
   {
   tag=tag-2;
   }
if (tag==0)
   {
   tag=tag-2;
   }
	else
	{
	tag=tag-1
	}
  if (jahr<=200) jahr += 1900;
  if (jahr<=1999) jahr += 100;
  
  tag = (tag < 10 ? "0" : "") + tag;
  monat = (monat < 10 ? "0" : 0) + monat;
  return (tag+ "." + monat+ "." + jahr);
}



var win = null;
function NewWindow(url,name,w,h,scroll,menu,rezi,tool,stat,direct){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) { winl = 0};
  if (wint < 0) { wint = 0};
  var settings  ='height='+h+',';
			settings +='width='+w+',';
			settings +='top='+wint+',';
			settings +='left='+winl+',';
			settings +='scrollbars='+scroll+',';
			settings +='menubar='+menu+',';
			settings +='resizable='+rezi+',';
			settings +='toolbar='+tool+',';
			settings +='status='+stat+',';
			settings +='directories='+direct+',';
			win=window.open(url,name,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


//Open What's New Popup

function OpenNewsPopup(){

  var url = 'http://www.roche.com/';
  var name = 'News';
  var w = '350';
  var h = '475';
  var scroll = 'no';
  var menu = 'no';
  var rezi = 'no';
  var tool = 'no';
  var stat = 'no';
  var direct = 'no';

  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) { winl = 0};
  if (wint < 0) { wint = 0};
  var settings  ='height='+h+',';
			settings +='width='+w+',';
			settings +='top='+wint+',';
			settings +='left='+winl+',';
			settings +='scrollbars='+scroll+',';
			settings +='menubar='+menu+',';
			settings +='resizable='+rezi+',';
			settings +='toolbar='+tool+',';
			settings +='status='+stat+',';
			settings +='directories='+direct+',';
			win=window.open(url,name,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


//Open Glossary Popup

function OpenGlossaryPopup(){

  var url = 'http://www.roche-diagnostics.com/servicebox/glossary/glossary.php?char=A';
  // var url = '/servicebox/glossary/glossary.php?char=A';
  var name = 'Glossary';
  var w = '547';
  var h = '560';
  var scroll = 'yes';
  var menu = 'no';
  var rezi = 'no';
  var tool = 'no';
  var stat = 'no';
  var direct = 'no';

  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
			settings +='width='+w+',';
			settings +='top='+wint+',';
			settings +='left='+winl+',';
			settings +='scrollbars='+scroll+',';
			settings +='menubar='+menu+',';
			settings +='resizable='+rezi+',';
			settings +='toolbar='+tool+',';
			settings +='status='+stat+',';
			settings +='directories='+direct+',';
			win=window.open(url,name,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

// redirect of the selectbox in startpage
function redirectURL(targetURL) {
	if(targetURL.indexOf('http')>-1) {
		window.open(targetURL,'roche','width=1030,height=768,left=0,top=0,scrollbars=yes,menubar=yes,resizable=yes,location=yes,status=yes,toolbar=yes');
		return false;
	} else {
		window.location.href=targetURL;
	}
}
function showSurvey() {
	if (document.cookie.indexOf("stopSurvey") == -1) {
		document.getElementById("milkglass").style.display = 'block';
		document.getElementById("milkglass").style.height = document.getElementsByTagName('body')[0].scrollHeight;
		document.getElementById("behindSurvey").style.display = 'block';
		document.getElementById("startSurvey").style.display = 'block';
		hideSelects("hidden");
	}
}
function closeSurvey() {
	var lapse = new Date();
	var period = lapse.getTime() + (30 * 24 * 60 * 60 * 1000);
	lapse.setTime(period);
	document.cookie = "name=stopSurvey; expires=" + lapse.toGMTString();
	document.getElementById("milkglass").style.display = 'none';
	document.getElementById("behindSurvey").style.display = 'none';
	document.getElementById("startSurvey").style.display = 'none';
	hideSelects("visible");
}
function openSurvey() {
	window.open('http://www.surveymonkey.com/s.aspx?sm=wpy6TFKSmlEwwZ5BOsl0bA_3d_3d','surveyPopup','width=768,height=576,scrollbars=yes,resizable=no,status=no,location=no,menubar=no,toolbar=no');
	return false;
}
function hideSelects(visibility){
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) {
		selects[i].style.visibility = visibility;
	}
}