popupWins = new Array();

/******************************* 
the popupWins array stores an object reference for
each separate window that is called, based upon
the name attribute that is supplied as an argument
http://www.codestore.net/store.nsf/unid/DOMM-4PYJ3S?OpenDocument
*******************************/
function windowOpener(url, name, args) {
	if (typeof(popupWins[name]) != "object") {
		popupWins[name] = window.open(url,name,args);
	} 
	else {
		if (!popupWins[name].closed){
			popupWins[name].location.href = url;
		}
		else {
			popupWins[name] = window.open(url, name,args);
		}
	}
	popupWins[name].focus();
}

function windowCloser() {
	a=windowCloser.arguments;
	for(var i=0; i<(a.length); i++) {
		if (popupWins[a[i]]) {
			if (popupWins[a[i]].location && !popupWins[a[i]].closed)
				popupWins[a[i]].close();	
		}
	}
}

function popupHelp(url) {
	windowOpener(url, "help", "width=550,height=450,scrollbars=yes,resizable=yes")
}

function popupReviews(url) {
	windowOpener(url, "reviews", "width=550,height=450,scrollbars=yes,resizable=yes")
}

function popupDownloads(url) {
	windowOpener(url, "downloads", "width=550,height=450,scrollbars=yes,resizable=yes")
}

function popupBrandDownloads(url) {
	windowOpener(url, "brandDownloads", "width=550,height=450,scrollbars=yes,resizable=yes")
}

function popup_linkPicker(retLinkTextField, retLinkURLField) {
	var LinkTextValue =  document.getElementById(retLinkTextField).value;
	var LinkURLValue =  document.getElementById(retLinkURLField).value;
	var url = "popup_linkPicker.asp?";
	url+= "LinkTextValue=" + LinkTextValue;
	url+= "&retLinkTextField=" + retLinkTextField;
	url+= "&retLinkURLField=" + retLinkURLField;
	url+= "&LinkURLValue=" + LinkURLValue;
	
	var winName = "linkPicker";
	var features = "width=550,height=550,scrollbars=yes,resizable=yes";

	windowOpener(url, winName, features);
}

function popupRelatedProds(ProductID) {
	var url = "prd-pu_related.asp?";
	url+= "ProductID=" + ProductID;
	var winName = "relatedProds";
	var features = "width=770,height=600,scrollbars=yes,resizable=yes";

	windowOpener(url, winName, features);
}

function popup_featurePicker(MainCatIDField, retIDField, retTxtField) {
	var IDValues, MainCatIDValue, currentTextValue="", url;
	
	IDValues = document.getElementById(retIDField).value;
	MainCatIDValue = document.getElementById(MainCatIDField).value;
	if (retTxtField!="") {
		currentTextValue = escape(document.getElementById(retTxtField).innerHTML);
	}
	
	url = "prd-pu_featurePicker.asp?";
	url+= "MainCatIDValue=" + MainCatIDValue;
	url+= "&retIDField=" + retIDField;
	url+= "&IDValues=" + IDValues;
	url+= "&retTxtField=" + retTxtField;
	url+= "&currentTextValue=" + currentTextValue;
	var winName = "featurePicker";
	var features = "width=400,height=450,scrollbars=yes,resizable=yes";

	windowOpener(url, winName, features);
}

function popupNewsDownloads(url) {
	windowOpener(url, "newsdownloads", "width=550,height=450,scrollbars=yes,resizable=yes")
}