// function for rollovers

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Preload Images

MM_preloadImages('/app/images/nof_hdr_nav_on_ff.gif','/app/images/nof_hdr_nav_on_cp.gif',
				'/app/images/nof_hdr_nav_on_industry.gif','/app/images/nof_hdr_nav_on_about.gif',
				'/app/images/nof_hdr_nav_on_smrkt.gif','/app/images/nof_hdr_nav_on_servcs.gif',
				'/app/images/nof_hdr_nav_on_etools.gif','/app/images/nof_nav_spacer.gif');

// Check Monitor Resolution
//function addPadding(){
//	var objBody = document.getElementById("bodyObj");
//	if ((screen.width<=800) && (screen.height<=600)){
//		objBody.style.marginTop  = "0";
//	} else {
//		objBody.style.marginTop = "10";
//	}
//}

// Check Monitor Resolution
function addPadding(){
	/*var objBodyHeight = document.getElementById('bodyHeight');
	if ((screen.width<=800) && (screen.height<=600)){
		objBodyHeight.style.height  = "0";
		document.getElementById('bodyHeight').bgColor = "#CF9B4F";
	} else {
		objBodyHeight.style.height = "10";		
		document.getElementById('bodyHeight').bgColor = "#FFFFFF";
	}*/
}

// code for the show hide tables starts here 
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function showTable(objNo){
	objDiv = document.getElementById("table"+objNo);
	objImg = document.getElementById("img"+objNo);	
	objTd = document.getElementById("td"+objNo);
	if(objDiv.style.visibility == "hidden"){
		objDiv.style.position = "relative";
		objDiv.style.visibility = "visible";
		objImg.src = "/app/images/nof_icon_title.gif"; 
		objTd.height=10;
		openBlks += 1;
	} 
	else {		
		objDiv.style.position = "absolute";
		objDiv.style.visibility = "hidden";
		objTd.height = 1;
		objImg.src = "/app/images/nof_icon_title_open.gif";
		openBlks -= 1;
	}	
	if(openBlks == iSliderCount){
		document.getElementById("allEle").innerHTML = '<a href="#" onClick="showAll(0)"><img src="/app/images/nof_button_collapse_all.gif" alt="Collapse All" width="89" height="20" border="0" /></a>';
		document.getElementById("allEle1").innerHTML = '<a href="#" onClick="showAll(0)"><img src="/app/images/nof_button_collapse_all.gif" alt="Collapse All" width="89" height="20" border="0" /></a>';
	} 
	else {
		document.getElementById("allEle").innerHTML = '<a href="#" onClick="showAll(1)"><img src="/app/images/nof_button_expantall.gif" alt="Expand All" width="77" height="20" hspace="2" border="0" /></a>';
		document.getElementById("allEle1").innerHTML = '<a href="#" onClick="showAll(1)"><img src="/app/images/nof_button_expantall.gif" alt="Expand All" width="77" height="20" hspace="2" border="0" /></a>';
	}	
	return true;
}


function showAll(no){	
	divList = document.getElementsByTagName("div");
	if(no==1){
		document.getElementById("allEle").innerHTML = '<a href="#" onClick="showAll(0)"><img src="/app/images/nof_button_collapse_all.gif" alt="Collapse All" width="89" height="20" border="0" /></a>';
		document.getElementById("allEle1").innerHTML = '<a href="#" onClick="showAll(0)"><img src="/app/images/nof_button_collapse_all.gif" alt="Collapse All" width="89" height="20" border="0" /></a>';
		for (i = 0; i < divList.length; i++){			
			document.getElementById("img"+(i+1)).src = "/app/images/nof_icon_title.gif";
			divId = divList[i].id;
			if(divId.substring(0,5)=="table"){
					divList[i].style.position = "relative";
					divList[i].style.visibility = "visible";
					document.getElementById("td"+(i+1)).height=10;					
			}
		}
		openBlks = iSliderCount;
	} else {
		document.getElementById("allEle").innerHTML = '<a href="#" onClick="showAll(1)"><img src="/app/images/nof_button_expantall.gif" alt="Expand All" width="77" height="20" hspace="2" border="0" /></a>';
		document.getElementById("allEle1").innerHTML = '<a href="#" onClick="showAll(1)"><img src="/app/images/nof_button_expantall.gif" alt="Expand All" width="77" height="20" hspace="2" border="0" /></a>';
		for (i = 0; i < divList.length; i++){
			document.getElementById("img"+(i+1)).src = "/app/images/nof_icon_title_open.gif";
			divId = divList[i].id;
			if(divId.substring(0,5)=="table"){
				divList[i].style.position = "absolute";
				divList[i].style.visibility = "hidden";
				document.getElementById("td"+(i+1)).height=1;
			}
		}
		openBlks = 0;
	}
	return false
}

function showCompTable(objNo){
	objPL_ID = document.getElementById("hPL_ID1");	
	if (objPL_ID.value == ""){
		alert("Please select a product first!")
			return false;
	}
	objDiv = document.getElementById("compTable"+objNo);
	objImg = document.getElementById("img"+objNo);
	objTd = document.getElementById("td"+objNo);
	if(objDiv.style.visibility == "hidden"){
		objDiv.style.position = "relative";
		objDiv.style.visibility = "visible";
		objImg.src = "/app/images/nof_icon_title.gif"; 
		objTd.height=10;
		//objImg.src = "/app/images/img"+objNo+"_on.gif"; 
		openBlks += 1;
	} else {
		objDiv.style.position = "absolute";
		objDiv.style.visibility = "hidden";
		objImg.src = "/app/images/nof_icon_title_open.gif"; 
		//objImg.src = "/app/images/img"+objNo+".gif"; 
		objTd.height=1;
		openBlks -= 1;
	}	
	
	if(openBlks == document.getElementById("hNoOfSliders").value){
		document.getElementById("StartOver1_allEle").innerHTML = '<a href="#" onClick="showAllCompTabs(0)"><img src="/app/images/nof_button_collapse_all.gif" alt="Collapse All" width="89" height="20" border="0" /></a>';
		document.getElementById("Startover2_allEle").innerHTML = '<a href="#" onClick="showAllCompTabs(0)"><img src="/app/images/nof_button_collapse_all.gif" alt="Collapse All" width="89" height="20" border="0" /></a>';
	} else {
		document.getElementById("StartOver1_allEle").innerHTML = '<a href="#" onClick="showAllCompTabs(1)"><img src="/app/images/nof_button_expantall.gif" alt="Expand All" width="77" height="20" hspace="2" border="0" /></a>';
		document.getElementById("Startover2_allEle").innerHTML = '<a href="#" onClick="showAllCompTabs(1)"><img src="/app/images/nof_button_expantall.gif" alt="Expand All" width="77" height="20" hspace="2" border="0" /></a>';
	}
}


function showAllCompTabs(no){
	objPL_ID = document.getElementById("hPL_ID1");	
	if (objPL_ID.value == ""){
		alert("Please select a product first!")
			return false;
	}
	if(no==1){		
		for (j = 1; j <= 7; j++){
			objDivv = document.getElementById("compTable"+j);
			objImg = document.getElementById("img"+j);
			objTd = document.getElementById("td"+j);
			objImg.src = "/app/images/nof_icon_title.gif";
			//objImg.src = "/app/images/img"+j+"_on.gif"; 
			objTd.height=10;
			objDivv.style.position = "relative";
			objDivv.style.visibility = "visible";
		}
		document.getElementById("StartOver1_allEle").innerHTML = '<a href="#" onClick="showAllCompTabs(0)"><img src="/app/images/nof_button_collapse_all.gif" alt="Collapse All" width="89" height="20" border="0" /></a>';
		document.getElementById("Startover2_allEle").innerHTML = '<a href="#" onClick="showAllCompTabs(0)"><img src="/app/images/nof_button_collapse_all.gif" alt="Collapse All" width="89" height="20" border="0" /></a>';
		openBlks = 7; //document.getElementById("hNoOfSliders").value;
	} else {
		for (j = 1; j <= 7; j++){
			objDivv = document.getElementById("compTable"+j);
			objImg = document.getElementById("img"+(j));
			objTd = document.getElementById("td"+j);
			objImg.src = "/app/images/nof_icon_title_open.gif";
			//objImg.src = "/app/images/img"+j+".gif";
			objDivv.style.position = "absolute";
			objTd.height=1;
			objDivv.style.visibility = "hidden";
		}
		document.getElementById("StartOver1_allEle").innerHTML = '<a href="#" onClick="showAllCompTabs(1)"><img src="/app/images/nof_button_expantall.gif" alt="Expand All" width="77" height="20" hspace="2" border="0" /></a>';
		document.getElementById("Startover2_allEle").innerHTML = '<a href="#" onClick="showAllCompTabs(1)"><img src="/app/images/nof_button_expantall.gif" alt="Expand All" width="77" height="20" hspace="2" border="0" /></a>';
		openBlks = 0;
	}
}

//  code for the show hide tables ends here
var actSubDiv;
var actLowestDiv;
function activateMenu(){

	if(actSubDiv == undefined){ 
		actSubDiv=0; 
	}
	objActDiv = document.getElementById("leftMenu"+actDiv);
	objActMenu = document.getElementById("lMenu"+actMenu);
	if(actDiv != 0){
	  if (objActDiv !== null) {
		objActDiv.style.position = "relative";
		objActDiv.style.visibility = "visible";
  	  }
	}
	if(actSubDiv != 0){
		objActSubDiv = document.getElementById("leftMenu"+actSubDiv);
		if (objActSubDiv !== null){
		  objActSubDiv.style.position = "relative";
		  objActSubDiv.style.visibility = "visible";
		}
	} 
	if(actLowestDiv != 0){
		objActLowestDiv = document.getElementById("leftMenu"+actLowestDiv);
		if (objActLowestDiv !== null){
		  objActLowestDiv.style.position = "relative";
		  objActLowestDiv.style.visibility = "visible";
		}
	} 
	if(actMenu != 0){
	  if (objActMenu !== null) {
	   objActMenu.className = "leftnavactive";
	  }
	}
}
//  code for the show hide tables ends here
/* Function to open a PDF File */
function openPdf(pdfFileName){

	try {
	//var pageTracker = _gat._getTracker("UA-9878006-1");
	
	//pageTracker._trackPageview('/NOF_Data/pdf/sustainability/print_version_national_sustainability_information.pdf');
	
	pdfFileName = pdfFileName.toLowerCase();
	pageTracker._trackEvent("Downloads", "PDF", pdfFileName.toString());
	
	//pageTracker._trackPageview(pdfFileName);
	//window.open(pageTracker._getLinkerUrl(pdfFileName),'popupwindow','toolbar=no,menubar=no,resizable =yes, width=600px, height=700px; scrollbars=auto');
	//pageTracker._link(pdfFileName);
	//alert(pdfFileName);
	} catch(err) {
	//alert("Error with Google Analytics.");
	}
	
	window.open(pdfFileName,null,'toolbar=no,menubar=no,resizable =yes, width=600px, height=700px; scrollbars=auto');
}

/* Function to open a popups File */
function openPopup(popupFileName){
	window.open(popupFileName,'','toolbar=no,menubar=no,resizable =yes, width=450, height=390');
}

function openPopup1(popupFileName){
	window.open(popupFileName,'','toolbar=yes,menubar=no,resizable=yes, width=550, height=590');
}

function openPop(objId){
	document.imgFrm.imgNam.value = objId.id;
	window.open("/app/dealer/etools/gallery_popup.aspx","","toolbar=no,menubar=no,resizable =yes, width=426, height=408")
}

function imgInit(){
	objImg=document.getElementById("imgDisp");
	objTtlImg=document.getElementById("imgTtlDisp");
	imgName = window.opener.document.imgFrm.imgNam.value;
	objImg.src = "/app/images/etools/emagine/ph_"+ imgName +".jpg";
	objTtlImg.src = "/app/images/nof_ttl_"+ imgName +".gif";
}

/*Girish Konaraddi's custon  JavaScript methods*/
function browserName()
{
	var strBrowser=navigator.userAgent.toLowerCase();
	if(strBrowser.indexOf("msie") > -1)
		strBrowser = "msie";
	else if(strBrowser.indexOf("firefox") > -1)
		strBrowser = "firefox";
	else if(strBrowser.indexOf("netscape") > -1)
		strBrowser = "netscape";
	else
		strBrowser = "other";
	return strBrowser;
}

// this allows for the hiding/showing of elements
function CollapseExpand (obj) 
{
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
}

function ToggleImage(img_name, url1, url2) 
{
	var imgURL = document[img_name].src;
	
	var hostName = GetHostFromURL(imgURL);
	
	url1 = hostName + url1;
	url2 = hostName + url2;
	
	if(imgURL == url1)
	{
		document[img_name].src = url2;
	}
	else
	{
		document[img_name].src = url1;
	}
	
}


function GetHostFromURL(url)
{
	var host1 = url.substring(0, url.indexOf("/"));
	
	var host2 = url.substring(url.indexOf("/"), url.len);
	host2 = host2.substring(2, host2.length);
	host2 = host2.substring(0, host2.indexOf("/"));
		
	return host1 + "//" + host2;
}







