var prodList;
var prodButton;
var searchBut;
var searchForm;
var imgPath = "/layout/ahlstrom06/images/";
var endUseList;
var endUseDiv;
var endUseButton;
;

// ul_MENU_1_main_nav --> ul_MENU_1_main_nav

// 

var Arr_ObjMenu_codes = new Array(); 
// var Arr_PortalLst = new Array(); 

function tbl_H_Drop_formatMenu(unit)
{

if (unit)
{
	if (document.all&&document.getElementById) 
	{

		var navRoot = document.getElementById("ul_"+unit+"_main_nav");
	
		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];
		 
			if (node.nodeName=="LI") 
			{
				node.onmouseover=function() {
				this.className+=" over";
				}
				node.onmouseout=function() {
				 	this.className=this.className.replace(" over", "");
				}
			   }
		}
		navRoot = null;
		
	 }
}
}
/*
function printActivePrtMenu1()
{
 
	if (Arr_PortalLst.length)
		for (var i=0; i<Arr_PortalLst.length; i++) 
  		document.write(((Arr_PortalLst[i]==strCurPrtId) ? '<style> #ul_MENU_1_main_nav li.selected'+i+' {background:#7D7D7D;} </style>'  :'' )); 
	 
// selected"&Level1COunt&
// Arr_PortalLst
}
*/


////////////////////////////////////
// AHLSTROM 


 function setUpElements06(){
 
 
// d_products_list --> menu4 tai menu3, jos etusivulla jossa vaan 3 valikkoa
	 if(document.getElementById("menu4")) {
		endUseList = document.getElementById("menu3");
		prodList = document.getElementById("menu4");
	} else {
		endUseList = document.getElementById("menu2");
		prodList = document.getElementById("menu3");
	}
		
	 prodDiv = document.getElementById("d_atoz_products");
	 prodButton = document.getElementById("but_products");
 
	 endUseDiv = document.getElementById("d_atoz_end_use");
	 endUseButton = document.getElementById("but_applications");
	


	searchBut = document.getElementById("search_but");
	searchForm = document.getElementById("searchForm");
	searchInput = document.getElementById("searchInput");
	
var relatedTimeout, prodListTimeout, endUseListTimeout, endUseListTimeout2;

		if (document.getElementById('relatedLinkListHeader')) {
			document.getElementById('relatedLinkListHeader').onmouseover = function () {
				clearTimeout(relatedTimeout);
				document.getElementById('relatedLinkList').style.display='block';
			}
			document.getElementById('relatedLinkListHeader').onmouseout = function () {
				relatedTimeout = setTimeout('document.getElementById(\'relatedLinkList\').style.display=\'none\'',1000);
			}
		}


	prodDiv.onmouseover = function(){
		clearTimeout(prodListTimeout);
		clearTimeout(endUseListTimeout);
		endUseList.style["display"] = "none";
		prodList.style["display"] = "block";
		//prodButton.src = imgPath + "a-z_products_over.gif";
	}
	
	prodDiv.onmouseout = function(){
		prodListTimeout=setTimeout('prodList.style["display"] = "none"',1000);
		//prodButton.src = imgPath + "a-z_products.gif";
	}
 
	endUseDiv.onmouseover = function(){
		clearTimeout(endUseListTimeout);
		clearTimeout(prodListTimeout);
		prodList.style["display"] = "none";
		endUseList.style["display"] = "block";
		//endUseButton.src = imgPath + "a-z_end-use_over.gif";
	}
	
	endUseDiv.onmouseout = function(){
		endUseListTimeout=setTimeout('endUseList.style["display"] = "none"',1000);
		//endUseButton.src = imgPath + "a-z_end-use.gif";
	}
	searchBut.onclick = function(){
		searchBut.style["display"] = "none";
		searchForm.style["display"] = "block";
		searchInput.focus();		
	}
	
//give action to buy now buttons
	var fooArray = new Array();
	var _divroot = document.getElementById('d_atoz_end_use');
	fooArray = _divroot.getElementsByTagName('li');

	for(var i=0;i<fooArray.length;i++){
		if(fooArray[i].className == "end_use_button") {
			fooArray[i].onmouseover = function() {
				this.style['background']= "#ff0000";
				endUseShow(this,'block');
				};
			fooArray[i].onmouseout = function() {
				this.style['background']= "#979596";
				endUseShow(this,'none');
				};
			
			}//end if
	}//end for
	
}


endUseShow = function(_element,_displayType){
	_e = _element.getElementsByTagName('ul');
	_e[0].style["display"] = _displayType;
}

////////////////////////////////////////////////////


 
window.onload = function(){
	if (Arr_ObjMenu_codes.length)
		for (var i=0; i<Arr_ObjMenu_codes.length; i++) 
			tbl_H_Drop_formatMenu(Arr_ObjMenu_codes[i]);
	

		setUpElements06();		
	}
	
	
	
	
	
	
	
	
	
	
		
//////////////////////////////////////////////////////////////

 // createCookie("Cookie06IsDone", "sdfdff", 1000);
 var txtCookieName = "CookiesG54JsdsddfhydjfJad2"; 
var  intCookieTIme06 = 120000; 


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;
}

function SetNowCookie(txtCookiename)
{
 
 	var date = new Date();
	var txt = date.getUTCFullYear() + '.'; 
	txt+= date.getMonth() + '.'; 
	txt+= date.getDate() + '.'; 
	txt+= date.getHours() + '.'
	txt+= date.getMinutes() + '.'
	txt+= date.getSeconds();
 
	createCookie(txtCookiename,txt,1000)
}

/*

function openPopupGallup06(language)
{
	
	
	var popupwindow = null;

 
    var strF;

    strF = "toolbar=yes"
    strF = strF + ",location=yes"
    strF = strF + ",directories=no"
    strF = strF + ",status=yes"
    strF = strF + ",menubar=yes"
    strF = strF + ",scrollbars"
    strF = strF + ",resizable=yes"
	  strF = strF + ",width=650"
	  	  strF = strF + ",height=600"


    popupwindow=window.open('','popupwindow',strF);

    if ( navigator.appCodeName.indexOf("Mozilla") != -1 && (navigator.appVersion.charAt(0) > 2 || navigator.appVersion.charAt(1) != '.') )
    {
     	popupwindow.focus();
    }
	 
	var strUrl; 
	if (language == 'fin') 
		strUrl = 'http://digiumenterprise.com/answer/?sid=49361&chk=7X5RX8WR' 
	else
		strUrl = 'http://digiumenterprise.com/answer/?sid=49351&chk=QDZNX6CU'; 
		
	
	popupwindow.location.href=strUrl;
 
	
	
	
	 createCookie(txtCookieName,"done",1000);
}

*/




function openPopupGallup06(language)
{ 
			
			
	var strUrl; 
	if (language == 'fin') 
		strUrl = 'http://digiumenterprise.com/answer/?sid=49361&chk=7X5RX8WR' 
	else
		strUrl = 'http://digiumenterprise.com/answer/?sid=49351&chk=QDZNX6CU'; 
		
			
			
var objLstPopup06 =  window.open(strUrl, "lstbro06", "status=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,location=no,width=650, height=600"); 	
objLstPopup06.focus();

 createCookie(txtCookieName,"done",1000);
 				
}
			 




function TheCOkkieShow()
{



 
 var Cookie06IsDone =  readCookie(txtCookieName);

 
 
 
  if (Cookie06IsDone!="done"  || Cookie06IsDone==null || Cookie06IsDone=="null") 
 {
	  
	  var intTimeouttmp =  intCookieTIme06; 
	  if (Cookie06IsDone==null || Cookie06IsDone=="null")
	  {
			SetNowCookie(txtCookieName);
	  }		
	  else
	  {
	  	var dateBeg = new Date();
		var splArr=Cookie06IsDone.split(".");
		dateBeg.setYear(parseInt(splArr[0])); 
		dateBeg.setMonth(parseInt(splArr[1])); 
		dateBeg.setDate(parseInt(splArr[2])); 
		dateBeg.setHours(parseInt(splArr[3])); 
		dateBeg.setMinutes(parseInt(splArr[4])); 
		dateBeg.setSeconds(parseInt(splArr[5])); 
	 
		 var now = new Date();
	  
	  // alert(Cookie06IsDone)
		if ((dateBeg.getTime() + intCookieTIme06) < now.getTime())
		{
			intTimeouttmp =  1; 
		}
		else
		{
			intTimeouttmp =    (dateBeg.getTime() + intCookieTIme06) - now.getTime(); 
		}
		 var now = null; 
		 var dateBeg = null; 		 
	  }
	  


  
	   setTimeout('openPopupGallup06("'+strPortalLanguage+'")', intTimeouttmp);  
	//  alert(intTimeouttmp);
	 
 }
 /*
 else
 {
 	alert('galluppi on jo tehty / avattu ');
 }
 */
 
  
  
  
  }
  
   //setTimeout('TheCOkkieShow();', 1000);  
 