var popupWin;

// 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')">
function openFPWindow(URL,name,attrib) {
  if (popupWin) {
	if (!popupWin.closed) {
		popupWin.close();
	}
   }
	popupWin = window.open(URL,name,attrib);
	popupWin.focus();
}

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

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 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 doubleSwap(location1, image1, location2, image2) {
        doSwap(location1, image1)
        doSwap(location2, image2)
}

function prodlink(wpid,cat,target) {
	var strURL = "/browse/product/" + String(wpid).substring(0,3) + "/product_" + wpid + ".htm?cs_category=" + cat;
	if (target == null) {
		window.location.href = strURL;
	}
	else {
		target.location.href = strURL;
	}
}

function miplink(wpid,cat,target) {
	var strURL = "/browse/product/" + String(wpid).substring(0,3) + "/mip_" + wpid + ".htm?cs_category=" + cat + "&cs_id=" + wpid;
	if (target == null) {
		window.location.href = strURL;
	}
	else {
		target.location.href = strURL;
	}
}

