var popupLinkConfig = new Array;

popupLinkConfig["NoClass"] = new Array ( "", "width=800,height=550,resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes");

// ==========================================================================
window.onload = initPage;

function initPage() {
	initPopupLinks();
  //initMenu();
	initBM();
  
  //initialize search button
	initChImg();
}

function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
}

// for sub-menus
//=====================
var time = 3000;
var numofitems = 5;

//testing
//menu constructor
  function menu(allitems,thisitem,startstate){ 
  callname= "gl"+thisitem;
  divname="subglobal"+thisitem;  
  this.numberofmenuitems = allitems;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.display = startstate;
}

//menu methods
function ehandler(event,theobj){
  for (var i=1; i<=theobj.numberofmenuitems; i++){
    var shutdiv =eval( "menuitem"+i+".thediv");
    shutdiv.style.display="none";
  }
  theobj.thediv.style.display="block";
}

function closesubnav(event){
	if(navigator.appName=="Microsoft Internet Explorer"){
		if ((event.clientY <2)||(event.clientY > 250)){ 
			for (var i=1; i<= numofitems; i++){
			  var shutdivn =eval("subglobal"+i);
			  shutdivn.style.display="none";
			}
	  	}
	}
	else { 
		if ((event.clientY <2)||(event.clientY > 250)){ 
			for (var i=1; i<= numofitems; i++){
			  var shutdiv =eval("menuitem"+i+".thediv");
			  shutdiv.style.display="none";
			}
		}
	}
}
// onmousemove="closesubnav(event);"

// for know-how areas divs
//=================================
function menu2(allitems,thisitem,startstate){ 
  callname = "kham"+thisitem;
  divname = "bsec"+thisitem;  
  this.numberofmenuitems = allitems;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.display = startstate;
}

//menu methods
function checkchn(event,theobj){
  for (var i=1; i<= theobj.numberofmenuitems; i++){
    var shutdiv =eval( "khamenu"+i+".thediv");
    shutdiv.style.display="none";
  }
  theobj.thediv.style.display="block";
}

// for performance improvement program for pumps divs
//=================================
function startpd(allitems,thisitem,startstate){ 
  callname="disp"+thisitem;
  divname="pip"+thisitem;  
  this.numberofmenuitems = allitems;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.display = startstate;
}
function showpd(event,theobj){
  for (var i=1; i<= theobj.numberofmenuitems; i++){
    var shutdiv =eval( "showpdesc"+i+".thediv");
    shutdiv.style.display="none";
  }
  theobj.thediv.style.display="block";
}
function closedp(event,theobj){ 
	for (var i=1; i<= theobj.numberofmenuitems; i++){
      var shutdiv =eval("showpdesc"+i+".thediv");
      shutdiv.style.display="none";
	}
}

//for bookmark link
function CreateBookmarkLink() {
	/* var xtitle = "Belzona - One Solution";
	var xurl = "http://www.belzona.com/";
	if(navigator.appName=="Microsoft Internet Explorer") {
		window.external.addFavorite(xurl, xtitle);
	} else if(navigator.appName=="Netscape") {
		window.sidebar.addPanel(xtitle, xurl,"");
	} else {
		return true;
	} */
}
function initBM(){
	/* if(navigator.userAgent.indexOf("MSIE") == -1 && navigator.userAgent.indexOf("Firefox") == -1){
		document.getElementById("bmLnk").style.display="none";
	}
	if(navigator.userAgent.indexOf("Firefox") > 1){
		document.getElementById("bmLnkTxt").innerHTML = "add bookmark";
	} */
	//document.getElementById("langsel").innerHTML = document.getElementById("langDiv").innerHTML;

}
function initChImg(){
	if(document.getElementById("srchBttn"))
	{
		document.getElementById("srchBttn").onmouseover = chImg;
		document.getElementById("srchBttn").onmouseout = chImgout;
		document.getElementById("srcBox").onmouseover = chImg;
		document.getElementById("srcBox").onmouseout = chImgout;
	}
	if(document.getElementById("cmdSearch"))
	{
		document.getElementById("txtQuery").onmouseover = chImg;
		document.getElementById("txtQuery").onmouseout = chImgout;
		document.getElementById("cmdSearch").onmouseover = chImg;
		document.getElementById("cmdSearch").onmouseout = chImgout;	
	}
}
function chImg()
{
	if(document.getElementById("srchBttn"))
	{
		document.getElementById("srchBttn").src = "/images/srcButtonHover.gif";
		document.getElementById("srchBttn").style.borderColor = "#093";
		document.getElementById("srcBox").style.borderColor = "#093";
	}
	if(document.getElementById("cmdSearch"))
	{
		document.getElementById("cmdSearch").src = "/images/srcButtonHover.gif";
		document.getElementById("cmdSearch").style.borderColor = "#093";
		document.getElementById("txtQuery").style.borderColor = "#093";
	}
}
function chImgout()
{
	if(document.getElementById("srchBttn"))
	{
		document.getElementById("srchBttn").src = "/images/srcButton.gif";
		document.getElementById("srchBttn").style.borderColor = "#aaa";
		document.getElementById("srcBox").style.borderColor = "#aaa";
	}
	if(document.getElementById("cmdSearch"))
	{
		document.getElementById("cmdSearch").src = "/images/srcButton.gif";
		document.getElementById("cmdSearch").style.borderColor = "#aaa";
		document.getElementById("txtQuery").style.borderColor = "#aaa";
	}
}