
/* 
function openFPWindow(URL,name,attrib) {
// example of the openFPWindow Function below:
// <a href="javascript:openFPWindow('URL here','title of window here','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=590,height=420')">
	popupWin = window.open(URL,name,attrib);
	popupWin.focus();
}
*/


function doSwap(location, image) {
        document[location].src=image;
}

function doubleSwap(location1, image1, location2, image2) {
        doSwap(location1, image1)
        doSwap(location2, image2)
}

function go(url, fromframe, dowhat) {
	if (fromframe == "frame") {
		if (dowhat == "focus") {
			if (opener.closed != true) {
				opener.location = url
				opener.focus()
			}
			else {
				window.open(url, "mainwindow",  "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=470");
				window.mainwindow.focus()
			}
		}
		else if (dowhat == "close") {
			if (opener.closed != true) {
				opener.top.location = url
				window.close()
			}
			else {
				window.open(url, "mainwindow", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=470");
				window.mainwindow.focus()
				window.close()
			}
		}
		else if (dowhat == "top") {
			top.document.location = url
		}
	}
	else {
		document.location = url
	}
}

function checkSelected(fromframe, dowhat) {
	// alert("checkSelected() function is running")
	var length, i, j, blnChecked, strWPIDs, strURL;
	var arrWPID = new Array();
	blnChecked=false
	length = document.forms.results.wpid.length
	j=0;
	// alert(document.forms.results.wpid.checked)
	for (i=0;i<length;i++) {
		if ((document.forms.results.wpid[i].checked) || (document.forms.results.wpid.checked)) {
			blnChecked = true;
			currValue = document.forms.results.wpid[i].value;
			if(currValue.indexOf(',') != -1){
				stopped    = false;
				startPoint = 0;
				endPoint   = 0;
				currWpid   = "";
				while(stopped == false){
					endPoint = currValue.indexOf(',', startPoint);
					if(endPoint == -1){
						endPoint = currValue.length;
						stopped    = true;
					}
					currWpid    = currValue.substring(startPoint, endPoint);
					arrWPID[j]=currWpid;
					j++;
					startPoint = currValue.indexOf(',', startPoint)+1;
				}
			}
			else{
				arrWPID[j]=document.forms.results.wpid[i].value;
				j++;
			}
		}
	}
	// following statement to test single result
	if (document.forms.results.wpid.checked) {
		// alert(parent.frames.body.document.forms.results.wpid.checked)
		blnChecked = true;
		// alert(blnChecked)
		arrWPID[j]=document.forms.results.wpid.value;
	}
	if (blnChecked) {
		var length = arrWPID.length
		// capture initial part of the string
		strWPIDs = "?wpid1=" + arrWPID[0]
		var p = 2
		for (i=1;i<length;i++) {
			strWPIDs = strWPIDs + "&wpid" + p + "=" + arrWPID[i]
			p++
		}
		// strWPIDs = arrWPID.join(",");
		strUrl = "/asp/mip.asp"+strWPIDs
		// alert(strUrl);
		go(strUrl, fromframe, dowhat);
		// strUrl is the URL to the mip.asp page | fromframe is if it's from a frame value should be "frame" | dowhat is either "close" or "focus"
	} 
	else {
		alert("Please select a product before continuing.");
		// return false;
	}
}

function getvar(arg) {
	// alert(location.search)
	if (location.search.indexOf(arg) != -1) {
		var x = location.search.indexOf(arg)
		var y = location.search.indexOf("&", x)
		if (y == -1) {
			y = location.search.length
		}
		var stringVariables = location.search.substring(x,y)
		var x = (stringVariables.indexOf("=") + 1)
		var y = stringVariables.length
		var stringVariables = stringVariables.substring(x,y)
		// alert(stringVariables)
	}
	else {
		var stringVariables = ""
	}
	stringVariables = unescape(stringVariables)
	return stringVariables
}

function reloadpage() {
	// alert(navigator.appName)
	if (navigator.appName.indexOf("Netscape") != -1) {
		// alert(navigator.appVersion)
		if (navigator.appVersion.indexOf("4.0") == -1) {
			// alert("reloadpage function is running")
			document.location.reload()
		}
	}
}

var strquote = '"'


/*----auto select functions --autoPopulate(),selector(), and autoSelectHotLink()--*/

function autoPopulate(){	
		for(i=0; i<=autoSelectText.length-1; ++i){
			document.autoSelectForm.autoSelectBox.options[i] = new Option();
		}
		for(i=0; i<=autoSelectText.length-1; ++i){	
			document.autoSelectForm.autoSelectBox.options[i].text = autoSelectText[i];
			document.autoSelectForm.autoSelectBox.options[i].value = autoSelectValue[i];
		}
}

function selector(){
document.autoSelectForm.autoSelectBox.options[0].selected = true;
}

function autoSelectHotLink(fromframe, dowhat){
x=document.autoSelectForm.autoSelectBox.selectedIndex;
y=document.autoSelectForm.autoSelectBox.options[x].value;
go(y, fromframe, dowhat)
}

hideIndicator = "no";
function loadFunction(num, loadStatus){
	if(loadStatus == "isOnLoad"){
		if(hideIndicator == "yes"){
		hide();
		}
	}
	if(loadStatus == "notOnLoad"){
		for(i=0; i<=wdid.length; ++i){
			if(num == wdid[i]){
				currfilename = wdidFileName[i];
				hideIndicator = "yes";
			}
		}
	}
}
/*--------------------------------------------------------------------------*/
platform = 0;
browser = 0;
ie4 = "no";
function browse(){
	plat = navigator.platform;
	str_name = navigator.appName;
	if(str_name == "Netscape"){browser = 1;}
	if(str_name == "Microsoft Internet Explorer") {
		if (navigator.appVersion.indexOf("MSIE 4") == -1) {browser = 2;}
		else {
			browser = 2;
			ie4 = "yes";
		}
	}
	if(plat=="Win32"){platform = 3;}
	else{platform = 4;}	
	//alert(browser);
}

broadcastX = 1;
broadcastY = 1;

function getXYCoords(img){
	browse();
	if (browser == 1){
		broadcastX = document[img].x;
		broadcastY = document[img].y;
		//alert("broadcastX = " + broadcastX)
		//alert("broadcastY = " + broadcastY)
	}
	if (document.all) {
		var x = 0;
		var y = 0;
		imgs = img;
		obj = document[imgs];
		while (obj.offsetParent != null) {
			x += obj.offsetLeft;
			//alert("x += obj.offsetLeft results to: " + x)
			y += obj.offsetTop;
			//alert("y += obj.offsetLeft results to: " + y)
			obj = obj.offsetParent;
			//alert("x: " + x + "\r" + "y: " + y + "\r" + "obj: " + obj + "\r" );
		}
		x += obj.offsetLeft;
		y += obj.offsetLeft;
		broadcastX = x;
		broadcastY = y;
		//if(platform == 4){
		//	broadcastX = broadcastX -10;
		//	broadcastY = broadcastY -96;
		//}
		
	}
	//alert("These are the new X and Y coordinates:" + "\r" + "broadcastX = " + broadcastX + "\r" + "broadcastY = " + broadcastY)
}

function DisplayPrice(sPrice, normal_color, sale_color, isInLayer, layerName) {
	// alert("DisplayPrice function running")
	var nPos = sPrice.indexOf(':')	
	if (nPos > 0) {
		var sRegularPrice = new String(sPrice.substring(0,nPos))
		var nLen = sPrice.length
		var sSalePrice = new String(sPrice.substring(nPos+1,nLen))
		if(isInLayer == true && browser == 1){
			document[layerName].document.write("<strike><span class="+normal_color+">" + sRegularPrice + "</span></strike>" 
				+ "<span class="+sale_color+"> now " 
					+ sSalePrice + "</span>")
		}
		else{
			document.write("<strike><span class="+normal_color+">" + sRegularPrice + "</span></strike>" 
				+ "<span class="+sale_color+"> now " 
					+ sSalePrice + "</span>")
		}
	}
	else {
		if(isInLayer == true && browser == 1){
			document[layerName].document.write("<span class='"+normal_color+"'>" + sPrice + "</span>")
		}
		else{
			document.write("<span class='"+normal_color+"'>" + sPrice + "</span>")
		}
	} 
}

/* DisplayPrice("<onol otype=custom oname=stynbr=102119002>") */