﻿// JScript File
function ShowHelp(div, title, desc,pos)
{
	var tblWidth = 750;
	
	div = document.getElementById(div);	
	div.style.display = 'inline';
	div.style.position = 'absolute';
	div.style.width = '175';	
	div.style.backgroundColor = '#bfd6f9';
	div.style.border = 'dashed 1px #3163BD';
	div.style.padding = '5px';
	div.innerHTML = '<b>' + title + '</b><br><div>' + desc + '</div>';
	
	if (document.body.offsetWidth>tblWidth){
		var x = (document.body.offsetWidth-tblWidth) / 2;
		div.style.left=x+pos;
	}else{
		div.style.left=pos+25;
	}
	
}
function HideHelp(div)
{
	div = document.getElementById(div);
	div.style.display = 'none';
}
function popUp(url,scroll,width,height) {
	popUpScreen=window.open(url,"pop",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scroll+',resizable=1,width='+width+',height='+height+'');
	popUpScreen.focus();
}


function subHelp(div,vis,pos) {
	var tblWidth = 750;
	var o = document.getElementById(navID);
	o.style.visibility=vis;
	if ((vis=='visible')&&(document.body.offsetWidth>tblWidth)){
		var x = (document.body.offsetWidth-tblWidth) / 2;
		o.style.left=x+pos;
	}else{
		o.style.left=pos+25;
	}
}

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];}
}
/**
 * This function allows the programmer to retrieve objects biased on the class name you 
 * want to retrieve. Similar to the GetElementByID and GetElementByTagName.
 * @member UtilNS
 * @param {object} oElm The object you want to search, could be a whole document or something more specific.
 * @param {string} strTagName The string containing the name of the tag name i.e. "a", "div", "span" what ever the class name is attached to.
 * If no tag is given it will search all elements.
 * @param {string} strClassName The string containing the class name you're searching for
 * @returns An array filled with the class names found in the search
 * @type Array
 * {@link  http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/#more-256 getElementsByClassName} Utility Function
 */


function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}	
	}
	return arrReturnElements;
}

//-->
/** BGT **/
var ieModel = false;

if (window.addEventListener){
    //if(document.getElementById("ctl00_ContentPlaceHolder1_WUC_ZipCodeLocator_txtZipCode"))
	//{
	window.addEventListener('load', readyZipSearch, false );
	//}
	window.addEventListener('load', readyZipContactSearch, false );
	window.addEventListener('load', readySearchBox, false );
}
else {
    //if(document.getElementById("ctl00_ContentPlaceHolder1_WUC_ZipCodeLocator_txtZipCode"))
	//{
   	window.attachEvent('onload', readyZipSearch);
   	// }
   	window.attachEvent('onload', readyZipContactSearch);
	window.attachEvent('onload', readySearchBox);
	
	ieModel = true;
}

function readyZipSearch() {
    var zip = document.getElementById("ctl00_ContentPlaceHolder1_WUC_ZipCodeLocator_txtZipCode");

    if(zip != null) {
        if(ieModel) {
            zip.attachEvent('onfocus', zipInput);
            zip.attachEvent('onblur', zipInput);
        }else{
            zip.addEventListener('blur', zipInput, false);
            zip.addEventListener('focus', zipInput, false);	
        }
    }		
}

function zipInput() {
	var zip = document.getElementById("ctl00_ContentPlaceHolder1_WUC_ZipCodeLocator_txtZipCode");
	
	if(zip != null) {
        zip.value = ( zip.value.toLowerCase() == "enter us zip code") ? "" : ((zip.value.length == 0 ) ? "Enter US Zip code" : zip.value);
    }
}
function readyZipContactSearch() {

    var zip = document.getElementById("ctl00_ContentPlaceHolder1_WUC_ZipCodeSearch_txtZipCodeSearch");

    if(zip != null) {
        if(ieModel) {
            zip.attachEvent('onfocus', zipContactInput);
            zip.attachEvent('onblur', zipContactInput);
        }else{
            zip.addEventListener('blur', zipContactInput, false);
            zip.addEventListener('focus', zipContactInput, false);	
        }
    }		
}

function zipContactInput() {
	var zip = document.getElementById("ctl00_ContentPlaceHolder1_WUC_ZipCodeSearch_txtZipCodeSearch");
	
	if(zip != null) {
        zip.value = ( zip.value.toLowerCase() == "enter us zip code") ? "" : ((zip.value.length == 0 ) ? "Enter US Zip code" : zip.value);
    }
}
function readySearchBox() {
    var searchBox = document.getElementById("ctl00_Header1_txtSearch");
        
    if(searchBox != null) {
        if(ieModel) {
            searchBox.attachEvent('onfocus', searchInput);
            searchBox.attachEvent('onblur', searchInput);
        }else{
            searchBox.addEventListener('blur', searchInput, false);
            searchBox.addEventListener('focus', searchInput, false);	
        }    
    }
}

function searchInput() {
    var searchBox = document.getElementById("ctl00_Header1_txtSearch");
    
    if(searchBox != null) {      
       searchBox.value = (searchBox.value.toLowerCase() == "search") ? "" : ((searchBox.value.length == 0) ? "Search": searchBox.value );
	}
}
// Required by Search Results Paging
function GotoPage(pageNum) {
    var theForm = document.forms[0];
    var thePage = document.getElementById('hdnActualPage');
        thePage.value = pageNum;
        theForm.submit();         
}
// for flash locator to work
function searchzipcode(zipNum)
{
	
	if(zipNum)
		{
			
			var inputBox = document.getElementById("ctl00_ContentPlaceHolder1_WUC_ZipCodeLocator_txtZipCode");
			var inputBtn = document.getElementById("ctl00_ContentPlaceHolder1_WUC_ZipCodeLocator_ibtZipCodeSearch");

			inputBox.value = zipNum;
			inputBox.blur();
			inputBtn.click();
		}
}
