var new_window = null
function openAddToQuickList(sku, cypher_id) {

    closeAddToCart()
	var loc = "/catalog/mycp/mycp_quick_lists_save_popup.asp?sku=" + sku + "&RegID=" + cypher_id;
	new_window = window.open(loc,'winAddToCart','width=380,height=480,resizable');
	return;
	}
    
	window.onerror=null;

    
function openOrderWin(loc)
    {
    new_window = window.open(loc,'winAddToCart','width=760,height=600,resizable,scrollbars,menubar,toolbar,status');
    return;
	}
    
    
//***** Call this function from the BODY onfocus event to close any previously opened pop-up windows
function closeAddToCart() 
    {
    if(new_window != null) 
        { 
        if(!new_window.closed) 
            { 
            new_window.close()
            new_window = null
            } 
        else 
            {
            new_window = null
            }
        }
    }           

function openCatalogIndex(cat,view) {
    if (cat==1){
    parent.location = "/catalog/catalog_toc.asp?cat=" + cat + "&view=" + view;
    return;
    }
    if (cat==9){
    parent.location = "/catalog/catalog_welcome_MFlex.asp";
    return;
    }
    if (cat==25){
    parent.location = "/catalog/catalog_welcome_Bar.asp";
    return;
    }
    if (cat==26){
    parent.location = "/catalog/catalog_toc.asp?cat=" + cat + "&view=" + view;
    return;
    }
    if (cat==27){
    parent.location = "/catalog/catalog_toc.asp?cat=" + cat + "&view=" + view;
    return;
    }
    if (cat==24){
    parent.location = "/catalog/catalog_toc.asp?cat=" + cat + "&view=" + view;
    return;
    }
   if (cat==30){
    parent.location = "/catalog/catalog_toc.asp?cat=" + cat + "&view=" + view;
    return;
    }
    var loc = "" + parent.contents.location.href;
    var len = loc.length;
	var url = ""
	var itm = "";
	var cnt = 0;
	var itm = "";
    
	for (var i = loc.indexOf("?"); i < len; i++) {   

		url = url + loc.charAt(i);
		}
    
	cnt = itemCount(url,"&");

	for (var i = 0; i < cnt; i++) {   
			
		itm = getItem(i,url,"&");
		itm = getItem(0,itm,"=");
			
		if (itm == "cat") {
			
			itm = "cat=" + cat;
			url = removeItem(i,url,"&");
			url = addItem(itm,url,"&");
			}
		}

	if (url.indexOf("?") == -1) {
		url = url + "?";
		}

	if (url.indexOf("cat") == -1) {
		url = url + "cat=" + cat;
		}

	if (loc.indexOf("product_sidebar") != -1) {
		parent.main.location = "catalog_toc.asp?cat=" + cat;
		//*** try to avoid bad urls from forming.
		if(url.charAt(0) != "?"){
			parent.contents.location = "product_sidebar.asp?" + url;
			}
		else{
			parent.contents.location = "product_sidebar.asp" + url;
			}
		}
	
	else {
		
		parent.main.location = "catalog_toc.asp?cat=" + cat;
		//*** try to avoid bad urls from forming.
		if(url.charAt(0) != "?"){
			parent.contents.location = "catalog_sidebar.asp?" + url;
			}
		else{
			parent.contents.location = "catalog_sidebar.asp" + url;
			}
			
		}
		
	return;
	} 
	
function openProductIndex(cls,par,cat) {
	
	parent.location = "/catalog/product_index.asp?cls=" + cls + "&par=" + par + "&cat=" + cat;
	return;
	}

function openProductList(cls,par,cat,sch,sku,sel) {
	
	if (cls == "") {
	
		alert("Please select a product category.");
		}
	
	else {
		
		parent.location = "product_list.asp?cls=" + cls + "&par=" + par + "&cat=" + cat + "&sch=" + sch + "&sku=" + sku + "&sel=" + sel;
		}

	return;
	}

function openProductView(sku,cls,par,cat,sch,sel,lstBool) {
	
	//parent.contents.location = "product_sidebar.asp?sku=" + sku + "&cls=" + cls + "&par=" + par + "&cat=" + cat + "&sch=" + sch + "&sel=" + sel;
	
	//if (sel != "" && sel.length >= 7) {
		
		parent.location = "/catalog/product_view.asp?sku=" + sku + "&cls=" + cls + "&par=" + par + "&cat=" + cat + "&sch=" + sch + "&sel=" + sel + "&lstBool=" + lstBool;
	    //}

	return;
	}

function openProductIndexProc(sku,cls,par,cat,sch,sel) {
	
	//parent.contents.location = "product_sidebar.asp?sku=" + sku + "&cls=" + cls + "&par=" + par + "&cat=" + cat + "&sch=" + sch + "&sel=" + sel;
	
	//if (sel != "" && sel.length >= 7) {
		
		parent.location = "/catalog/product_index_proc.asp?sku=" + sku + "&cls=" + cls + "&par=" + par + "&cat=" + cat + "&sch=" + sch + "&sel=" + sel;
	    //}

	return;
	}

function openProductCompare(sku,cls,par,cat,sch,sel,trs) {
	//parent.contents.location = "product_sidebar.asp?sku=" + sku + "&cls=" + cls + "&par=" + par + "&cat=" + cat + "&sch=" + sch + "&sel=" + sch;
	parent.location = "/catalog/product_compare.asp?sku=" + sku + "&cls=" + cls + "&par=" + par + "&cat=" + cat + "&sch=" + sch + "&sel=" + sch + "&trs=" + trs;
	return;
	}






function sizeBrowser(wid,hgt) {

	if (getBrowserVersion() > '2') {

		window.resizeTo(wid,hgt);
		window.focus();
		}

	return;
	}

function getBrowserVersion() {

	var str = "";
	
	str = navigator.appVersion;
	str = str.substring(0,1);
	
	return str;	
	}


	window.onerror=null;
	var popWin = null;
    
function openPopWin(URL,winHeight,winWidth){
		//***** close any previously opened pop-up window
		closePopWin()

		//***** Adjust the following window.open parameters to suit the application requirements
		popWin = window.open(URL, "login", "HEIGHT=" + winHeight + ",WIDTH=" + winWidth)
	}


	//***** Call this function from the BODY onfocus event to close any previously opened pop-up windows
function closePopWin() {
		if(popWin != null) { 
			if(!popWin.closed) { 
				popWin.close()
				popWin = null
			} else {
				popWin = null
			}
		}
	}
    





