/***************************************************
 determine the x position for each pulldown 
 menu based on browser type and width 
****************************************************/




function goPrint(){

	var l = document.location.toString();
	var u = null;
	
	if (l.indexOf("?") > -1){
	
		u = l + "&printable=true";
		
	} else {
	
		u = l + "?printable=true";
	}
	
	if( u != null){
	
		window.open(u);
	
	}

}

	
function searchHandler(f){

	if(f.search_entireSite != null){
		if(f.search_entireSite.checked){
			document.getElementById("google").q.value = f.searchFor.value;
			document.getElementById("google").submit();
			return false;
		} 
	}
	
	return true;
		

} 


// determine width of browser in px
function base_x(){
	var x;
	if(document.all){
		x = document.body.clientWidth;
	} else {
		x = window.innerWidth;
	}	
	return x;
}








// determine width of browser in px
function base_y(){
	var y;
	if(document.all){
		y = document.body.clientHeight;
	} else {
		y = window.innerHeigth;
	}	
	return y;
}







function bswPopUp(url, name, width, height, scroll) {
	var properties = "scrollbars=" + scroll + ",width=" + width + ",height=" + height; 
	var bswPopUpWin = window.open(url, name, properties);
	bswPopUpWin.focus();
}

function clearSearch(ele){
	
	if(ele.value == "Enter Catalog or Model #" || ele.value == "Enter Keyword(s)"){
		ele.value = "";
	}	
	ele.style.color = "#000000";

}	

function UpdateSearchBox(e)
{
	if(e.id == 'search_catalogs')
	{
		
		e.form.elements["searchFor"].value = 'Enter Catalog or Model #' ; 
		
	}
	
	else if (e.id == 'search_products')
	{
		
		e.form.elements["searchFor"].value = 'Enter Keyword(s)' ; 
		
	}
}

function ValidateForm(form)
{

var returnval;

if (form.elements["searchFor"].value != 'Enter Keyword(s)' && form.elements["searchFor"].value != 'Enter Catalog or Model #' && form.elements["searchFor"].value != '') 
{
	returnval = true;
}
else
{
	alert("Please enter Catalog# or Model# or Keyword(s) for search.");
	returnval = false;
}									

return returnval;
}					






//functions for search box

// determine width of browser in px
function base_x(){
	var x;
	if(document.all){
		x = document.body.clientWidth;
	} else {
		//if(scrollbars are visible){
			x = window.innerWidth - 20;
		//} else {
		//	x = window.innerWidth;
		//}		
	}	
	return x;
}

//repositionSearchBox();

function showSearchBox(){	
	if (document.getElementById("searchBoxOpen")){
		document.getElementById("searchBtn").src = site_root + "/images/searchbox/seachbox_top_open.gif";
		document.getElementById("searchBoxOpen").style.visibility = "visible";
	}
}
function hideSearchBox(){
	if (document.getElementById("searchBoxOpen")){
		document.getElementById("searchBtn").src = site_root + "/images/searchbox/seachbox_top_closed.gif";
		document.getElementById("searchBoxOpen").style.visibility = "hidden";
	}
}
// position searchbox
function repositionSearchBox(){
	if (document.getElementById("searchBox")){
		document.getElementById("searchBox").style.left=((base_x() - 751)/ 2) + 509;
	}
}




// advanced search 


var currentCatID = "0";
function updatePulldown(catID){
	//alert(currentCatID);
	if(currentCatID != null){
		
		document.getElementById("cat"+currentCatID).style.display = "none";
	
	}
	
	document.getElementById("cat"+catID).style.display = "block";
	currentCatID = catID;

}


// Locations 

var currentLocation = null;

function showLocation(id){
	
	if(currentLocation != null){
		
		document.getElementById("l"+currentLocation).style.display = "none";
	
	}
	
	document.getElementById("l"+id).style.display = "block";
	currentLocation = id;

}

//Location for International offices
function ShowCountryLocation(ele){
	
	document.SalesOfficSearch.code.value = "Enter Zip/Postal Code"
	ele.style.color = "#000000";
	
	if(document.getElementById("tblInternationalOffice")!=null)
	{
		document.getElementById("tblInternationalOffice").style.display = "none";
	}
	
	
	
	/*
	if(document.SalesOfficSearch.cmbCountryList.value == "00000")
	{
		document.getElementById("USCanada").style.display = "inline";
		return;
	}
	else
	{
		document.getElementById("USCanada").style.display = "none";
	
	}
	*/
	
	
	//hide currently displayed Sales office address

	if(currentLocation != null)
	{
		arrCurrentLocation = new Array(currentLocation.split(',').length);
		arrCurrentLocation = currentLocation.split(',');
		
		for(k=0;k<arrCurrentLocation.length;k++)
		{
			if(document.getElementById("l"+arrCurrentLocation[k])!=null)
			{	
				document.getElementById("l"+arrCurrentLocation[k]).style.display = "none";
			}
		}	
	}
	
	var SalesOfficeIDs = ele.value;
	var arrSalesOfficeIDs = new Array(SalesOfficeIDs.split(',').length);
	arrSalesOfficeIDs = SalesOfficeIDs.split(',');
	
	for(i=0;i<arrSalesOfficeIDs.length;i++)
	{
		//alert(document.getElementById("l"+arrSalesOfficeIDs[i])!=null);
		
		//display current Sales office address
		if(document.getElementById("l"+arrSalesOfficeIDs[i])!=null)
		{
			document.getElementById("l"+arrSalesOfficeIDs[i]).style.display = "block";
			currentLocation = SalesOfficeIDs;
		}
	
	
	}	
	

}


function clearSearchContactUs(ele){
	

	if(document.SalesOfficSearch != null)
	{
		document.SalesOfficSearch.cmbCountryList[0].selected = true;
	}
	//hide currently displayed Sales office address

	if(currentLocation != null)
	{
		arrCurrentLocation = new Array(currentLocation.split(',').length);
		arrCurrentLocation = currentLocation.split(',');
		
		for(k=0;k<arrCurrentLocation.length;k++)
		{
			if(document.getElementById("l"+arrCurrentLocation[k])!=null)
			{	
				document.getElementById("l"+arrCurrentLocation[k]).style.display = "none";
			}
		}	
	}	
	
	if(ele.value == "Enter Zip/Postal Code"){
		ele.value = "";
	}
	ele.style.color = "#000000";

}


// Email this page


function emailThisPage(){

	var url =  "/emailthispage.aspx?TITLE=" + escape(document.title) + "&URL=" + escape(document.location);
	
	 bswPopUp(url, "email", 560, 500, "no");
	
}


//Added for index pages skin changes for HoffmanOnline.
function DisplayDIV(d) { 
    document.getElementById('PC_Div_1').style.display = "none";
    document.getElementById('PC_Div_2').style.display = "none";
    document.getElementById('PC_Div_3').style.display = "none";
    document.getElementById('PC_Div_4').style.display = "none";
    document.getElementById(d).style.display = "block"; 
}
