var arrOpenProducts = new Array();


function loadCPI() {
	top.location = "./PublicPages/ProductPageDefault.aspx";
}

function loadProduct(redirect, title, id) {

	if (redirect != "") {
		var url = "../launchproduct.aspx?productid=" + id + "&redirect=" + escape(redirect);
		top.location = url;
	}
	else {
		alert("You do not currently have access to this product.  Please contact Carswell Sales using the Contact link to purchase access to: " + title);
	}

}


function loadProductOLD(redirect, title, id) {
	var windowname = "ProductId" + id;
	var prodwin = getProductWindowOpen(windowname);
	
	if (prodwin != null) {
		prodwin.location = url;
		prodwin.focus();
	}
	else {

		if (redirect != "") {
			var url = "./launchproduct.aspx?productid=" + id + "&redirect=" + escape(redirect);
			prodwin = window.open(url, windowname);
			prodwin.resizeTo (screen.availWidth, screen.availHeight);
			prodwin.moveTo (0, 0)
			prodwin.name = windowname;
			arrOpenProducts.push(prodwin);
			prodwin.focus();
		}
		else {
			//var prodpage = "productpages/" + title + ".htm";
			//var cpi = getCPIWindow();
			//cpi.setDivContent(cpi,'BodyContentDiv', prodpage);
			alert("You do not currently have access to this product.  Please contact Carswell Sales using the Contact link to purchase access to: " + title);
		}
	}
}


function getProductWindowOpen(windowname) {

	var thiswin;
	var prodwin = null;
	var i;
	
	for (i = 0; i < arrOpenProducts.length; ++i) {
		thiswin = arrOpenProducts[i];
		try {
			if (thiswin.name == windowname) { prodwin = thiswin; break; }
		}
		catch (e) { ; }
		
	}
	return prodwin;
}


function closeProductWindows(){
	var url = "/ereference/CPI_AC_BOOT.aspx";
	
	for (i = 0; i < arrOpenProducts.length; ++i) {
		thiswin = arrOpenProducts[i];
		try {
			//alert(thiswin.name);
			//thiswin.location = url;
			thiswin.close();
		}
		catch (e) {;}
	}
	return true;
}


function iterateProductWindows(){

	var thiswin;
	var i;
	
	if (arrOpenProducts.length == 0) {
		alert("There are no open child windows.");
		return;
	}
	
	for (i = 0; i < arrOpenProducts.length; ++i) {
		thiswin = arrOpenProducts[i];
		alert(thiswin.name);
	}

}

function getCPIWindow() {
	return top.frames["cpi"];
}