// *** DO NOT MODIFY ***
// $Id: ws_functions.js,v 1.21 2004/12/20 05:41:52 aparna Exp $
// *** DO NOT MODIFY ***

var netscape4;

if (navigator.appName == 'Netscape' && parseInt(navigator.appVersion) == 4){

	netscape4 = true;

	var origWidth = innerWidth;

	var origHeight = innerHeight;

}

function reDo() {

	if (innerWidth != origWidth || innerHeight != origHeight){

		location.reload();

	}

}

if (netscape4){

	onresize = reDo;

}



	// preloading images

		businesson = new Image();

		businesson.src = "/wholesale/images/nav_business1.gif";

		businessoff = new Image();

		businessoff.src = "/wholesale/images/nav_business0.gif";

		productson = new Image();

		productson.src = "/wholesale/images/nav_products1.gif";

		productsoff = new Image();

		productsoff.src = "/wholesale/images/nav_products0.gif";

		systemson = new Image();

		systemson.src = "/wholesale/images/nav_systems1.gif";

		systemsoff = new Image();

		systemsoff.src = "/wholesale/images/nav_systems0.gif";

		libraryon = new Image();

		libraryon.src = "/wholesale/images/nav_library1.gif";

		libraryoff = new Image();

		libraryoff.src = "/wholesale/images/nav_library0.gif";



	function rollOn(iName) { // rollovers at top of all pages

		if (document.images) {

		document[iName].src = eval(iName + "on.src");

		}

	}



	function rollOff(iName) {

		if (document.images) {

		document[iName].src = eval(iName + "off.src");

		}

	}



	function jumper(thelink) { // for pulldowns which are used for navigation, see systems and systems support for example

	i = document.pulldown[thelink].selectedIndex;

	x = document.pulldown[thelink].options[i].value;

	if (x != "") {

		window.top.location.href = x;

		}

	}



	function popupInfo (URL) { // standard popup for more information

		moreInfo = window.open(URL,"VerizonInfo","width=400,height=300,toolbar=no,location=no,resizable=no,scrollbars=no,top=70,left=100")

		moreInfo.focus ();

	}

	

	function popupPrint (URL) { // standard popup for more information

		printWin = window.open(URL,"VerizonPrintWindow","width=641,height=500,toolbar=no,location=no,resizable=yes,scrollbars=yes,top=70,left=100")

		printWin.focus ();

	}

	

	function popupAnysize (URL,ww,wh) { // standard popup for various window sizes

		moreInfo = window.open(URL,"VerizonInfo","width=" + ww + ",height=" + wh + ",toolbar=no,location=no,resizable=yes,scrollbars=auto,top=10,left=40")

		moreInfo.focus();

	}

	

	function defineRegions() { // pops up set url and window size for region definitions

		region = window.open("/wholesale/region/regionpopup/","VerizonRegions","width=205,height=190,toolbar=no,location=no,resizable=no,scrollbars=no,top=70,left=100")

		region.focus ();

	}

	

	function defineDetailRegions() { // pops up set url and window size for region definitions

		region = window.open("/wholesale/regiondetailpopup/","VerizonDetailRegions","width=305,height=150,toolbar=no,location=no,resizable=no,scrollbars=no,top=70,left=100")

		region.focus ();

	}

	

	function gotoRegion() { // region toggle

		var form = document.selectregion;

		for (var i = 0; i < form.region.length; i++) {

			if (form.region[i].checked) { break }

		}

		var regionURL = form.region[i].value;

		window.location = regionURL;

	}

	

	function getSitemap() { // temp sitemap toggle on home page. identical to above script

		var form = document.mapform

		for (var i = 0; i < form.sitemap.length; i++) {

			if (form.sitemap[i].checked) { break }

		}

		var pickMap = form.sitemap[i].value;

		window.location = pickMap;

	}

	

var isNS = navigator.appName == "Netscape";

var version = parseInt(navigator.appVersion);

var timeoutCode;

var curDiv;



function showInfoLayer(id, top) {

	clearTimeout(timeoutCode);

	version = parseInt(version);

	var div = isNS ? (version == 4 ? document.layers[id] : document.getElementById(id).style) : document.all[id].style;

	curDiv = id;

	if (isNS && version == 4) {

		div.top = top; div.visibility = "show";

	} else {

		div.pixelTop = top; div.visibility = "visible";

	}

	hideInfoLayer(id);

}



function hideInfoLayer(id) {

	version = parseInt(version);

	for (var i = 0; i < divArray.length; i++)

		if (divArray[i] != id) {

			var div = isNS ? (version == 4 ? document.layers[divArray[i]] : document.getElementById(divArray[i]).style) : document.all[divArray[i]].style;

			div.visibility = (isNS && version == 4) ? "hide" : "hidden";

		}

}



function startClock(id) {

	if (id == curDiv)

		timeoutCode = setTimeout("hideInfoLayer()", 4000);

}


var helpWindow = null;
function openHelp(helpDocument, helpTopic) { //open form help window
	pageHelp = helpDocument + "#" + helpTopic;
	helpWindow = window.open(pageHelp, 'help', "height="+window.screen.availHeight+",width=240, top=0, left="+(window.screen.availWidth-240)+",toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,resizable=yes,fullscreen=no,titlebar=no");
	helpWindow.focus();
}
function closeHelp(){ //close form help window
	if (helpWindow && helpWindow.open && !helpWindow.closed) {
		helpWindow.close(); 
	}
}

function addToList(targetList, thePrompt) {
	//Prompt user for a value
	theValue = prompt(thePrompt);
	//Add value to target list
	if (theValue != null) {
		 //Create the item to be added
		 addedItem = new Option(theValue, theValue);
		 //Add the new item
		 document.getElementById(targetList).options[ document.getElementById(targetList).options.length] = addedItem;
	}
	//Delete the "None Specified" indicator if it is present
	
	if (document.getElementById(targetList).options[0].value == "none") {
		document.getElementById(targetList).options[0] = null;
	}
}

function removeFromList(targetList, noneSpecifiedText) {

  	//If the remove button is pressed without any item selected in the list
	if ( document.getElementById(targetList).options.selectedIndex == -1 || document.getElementById(targetList).options[0].value == "none" || document.getElementById(targetList).options[document.getElementById(targetList).options.selectedIndex] == null) {
	    alert("Please select the Filer ID to remove");
		return;
	}

	//If the "None Specified" indicator is not selected
	if (document.getElementById(targetList).options[0].value != "none") {
		//Delete the selected item
 		document.getElementById(targetList).options[document.getElementById(targetList).options.selectedIndex] = null;
		//If the last item in the list has just been deleted put back the "None Specified" indicator
		if (document.getElementById(targetList).options.length == 0) {
			noneSpecifiedItem = new Option(noneSpecifiedText, "none");
			document.getElementById(targetList).options[document.getElementById(targetList).options.length] = noneSpecifiedItem;
		}
	}
}


function moveBetweenLists(sourceList, targetList, noneSpecifiedText) {
	//If the "None Specified" indicator is not selected
	if (document.getElementById(sourceList).options[0].value != "none") {
		// Check if an item was selected
		if(document.getElementById(sourceList).options.selectedIndex != -1) {
			// Get the selected item
			var selectedItem = document.getElementById(sourceList).options[document.getElementById(sourceList).options.selectedIndex].value;
			//Add value to target list
			if (selectedItem != null) {
				 //Create the item to be added
				 addedItem = new Option(selectedItem, selectedItem);
				 //Add the new item
				 document.getElementById(targetList).options[ document.getElementById(targetList).options.length] = addedItem;
			}
			//Delete the "None Specified" indicator if it is present in the target list
			if (document.getElementById(targetList).options[0].value == "none") {
				document.getElementById(targetList).options[0] = null;
			}

			// Remove the value from the source list
			document.getElementById(sourceList).options[document.getElementById(sourceList).options.selectedIndex] = null;
			//If the last item in the source list has just been deleted put back the "None Specified" indicator
			if (document.getElementById(sourceList).options.length == 0) {
				noneSpecifiedItem = new Option(noneSpecifiedText, "none");
				document.getElementById(sourceList).options[document.getElementById(sourceList).options.length] = noneSpecifiedItem;
			}
		}
	}
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('content').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
			}
			else {
				footerElement.style.top = '0px';
			}
		}
	}
}

window.onload = function() {
	// Causing problems, commenting out for now
//	setFooter();
}

window.onresize = function() {
	// Causing problems, commenting out for now
//	setFooter();
}

// Check the name and version of the browser
// Returns an array with the first elements as the browser name
// and the second element as the browser version
function checkBrowser(){
	var browserInfo = new Array();
	var useragent = navigator.userAgent; 
	 var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName; 
	 var pos = useragent.indexOf('MSIE'); 
	 if (pos > -1) { 
	   bVer = useragent.substring(pos + 5); 
	   var pos = bVer.indexOf(';'); 
	   var bVer = bVer.substring(0,pos); 
	 } 
	 var pos = useragent.indexOf('Opera'); 
	 if (pos > -1)    { 
	   bVer = useragent.substring(pos + 6); 
	   var pos = bVer.indexOf(' '); 
	   var bVer = bVer.substring(0, pos); 
	 } 
	 if (bName == "Netscape") { 
	   var bVer = useragent.substring(8); 
	   var pos = bVer.indexOf(' '); 
	   var bVer = bVer.substring(0, pos); 
	 } 
	 if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) { 
	   var pos = useragent.lastIndexOf('/'); 
	   var bVer = useragent.substring(pos + 1); 
	 } 
	browserInfo[0]=bName;
	browserInfo[1]=bVer;
	return browserInfo;
}

function checkIt(string, detect){
	place = detect.indexOf(string) + 1;
//	thestring = string;
	return place;
}
