var new_window = null

function submitNext() {
	
	document.frmCheckout.hdnPageAction.value = "Next";
	document.frmCheckout.submit();
	}


function submitPrevious() {
	
	document.frmCheckout.hdnPageAction.value = "Previous";
	document.frmCheckout.submit();
	}

function submitUpdate() {

	document.frmCheckout.hdnPageAction.value = "Update";
	document.frmCheckout.submit();
	}

function submitJump(loc) {
	
	document.location.href = loc;
	}

function submitCopy() {
	
	document.frmCheckout.hdnPageAction.value = "Copy";
	document.frmCheckout.submit();
	}

function gotoHelp() {
	
	parent.location = "/catalog/help/onewhelp2.asp";
	return;
	} 

function gotoSearch() {
	
	parent.location = "/catalog/search.asp";
	return;
	} 

function gotoLogout() {

	parent.contents.location = "login_sidebar.asp?action=logout";
	return;
	}

function gotoWhyOpenAccount() {

	parent.location = "/catalog/help/registering.asp";
	return;
	}

function gotoReminder() {

	parent.location = "/catalog/reminder.asp";
	return;
	}

function gotoCatalogHome() {

	parent.location = "/catalog/catalog_welcome.asp";
	return;
	}

function gotoCCCOA() {
 
 if (document.frmCCCOA.txtCCCOA.value == "") {
  alert("Please enter a lot number.");
  return;
 }
 else {
  window.open("http://www.columbuschemical.com/CPCofA.aspx?CCN=89200-35&LotID=" + document.frmCCCOA.txtCCCOA.value);
  return;
 }
}


	
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,resesizable,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 openSkuInfo(sku) {

	var loc = "sku_info.asp?sku=" + sku;
	new_window = window.open(loc,'winAddToCart','width=350,height=380');
	return;
	}

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;
		parent.location = "/catalog/product_view.asp?sku=" + sku 
	    //}

	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 openPreviousNext(sku,cls,par,cat,sel,sch,lstBool) {
    openProductView(sku,cls,par,cat,sch,sel,lstBool)
	//parent.contents.location = "product_sidebar.asp?sku=" + sku + "&cls=" + cls + "&par=" + par + "&cat=" + cat + "&sel=" + sel + "&sch=" + sch;
	//parent.location = "/catalog/product_view.asp?sku=" + sku + "&cls=" + cls + "&par=" + par + "&cat=" + cat + "&sch=" + sch + "&sel=" + sel + "&lstBool=true";
	return;
	}

function synchWelcomeSidebar() {
	
	parent.contents.location = "login_sidebar.asp";
	return;
	} 

function synchTOCSidebar(cat) {
	
	parent.contents.location = "catalog_sidebar.asp?cat=" + cat;
	return;
	} 

function synchIndexSidebar(cat) {

	synchTOCSidebar(cat);
	return;
	} 

function synchListSidebar(cat) {
	
	var sid_loc = "" + parent.contents.location.href;

	if (sid_loc.indexOf("product_sidebar.asp") == -1) {
	
		if (sid_loc.indexOf("catalog_sidebar.asp") == -1) {
	
			parent.contents.location = "catalog_sidebar.asp?cat=" + cat;
			}
		}

	return;
	} 

function synchViewSidebar(sku) {

	var sid_loc = "" + parent.contents.location.href;
	var mpg_loc = "" + parent.main.location.href;
	var new_loc = "";
	var len = mpg_loc.length;
	var parms = "";
	var itm = "";
	var parm_count = 0;

	if (sid_loc.indexOf("product_sidebar.asp") == -1) {

		// rebuild frameset
		new_loc = "product_sidebar.asp";

		if (mpg_loc.indexOf("?") != -1) {

			for (var i = mpg_loc.indexOf("?"); i < len; i++) {   
				
				parms = parms + mpg_loc.charAt(i);
				}
			
			if (parms.indexOf("sel") != -1) {
			
				parm_count = itemCount(parms,"&");
			
				for (var i = 0; i < parm_count; i++) {   
					itm = getItem(i,parms,"&");
					itm = getItem(0,itm,"=");
					if (itm == "sel") {
						removeItem(i,parms,"&");
						itm = "sel=" + sku;
						addItem(itm,parms,"&");
						}
					}
				
				parent.contents.location = new_loc + parms;
				}

			else {
				
				parent.contents.location = new_loc + parms + "&sel=" + sku;
				}
			}
			
		else {
			//*** Prevent bad urls from forming
			if(new_loc.charAt(new_loc.length - 1) != "?"){
				parent.contents.location = new_loc + "?sel=" + sku;
				}
			else{
				parent.contents.location = new_loc + "sel=" + sku;
				}
			}
		}

	return;
	} 

function synchCompareSidebar(sch) {

	var sid_loc = "" + parent.contents.location.href;
	var mpg_loc = "" + parent.main.location.href;
	var new_loc = "";
	var len = mpg_loc.length;
	var parms = "";

	if (sid_loc.indexOf("product_sidebar.asp") == -1) {

		// rebuild frameset
		new_loc = "product_sidebar.asp";

		if (mpg_loc.indexOf("?") != -1) {

			for (var i = mpg_loc.indexOf("?"); i < len; i++) {   
				
				parms = parms + mpg_loc.charAt(i);
				}
			
			if (parms.indexOf("sel") != -1) {
			
				parm_count = itemCount(parms,"&");
			
				for (var i = 0; i < parm_count; i++) {   
					itm = getItem(i,parms,"&");
					itm = getItem(0,itm,"=");
					if (itm == "sel") {
						removeItem(i,parms,"&");
						itm = "sel=" + sch;
						addItem(itm,parms,"&");
						}
					}
				parent.contents.location = new_loc + parms;
				}

			else {
			
				parent.contents.location = new_loc + parms + "&sel=" + sch;
				}
			}
		
		else {
			//*** Prevent bad urls from forming
			if(new_loc.charAt(new_loc.length - 1) != "?"){
				parent.contents.location = new_loc + "?sel=" + sch;
				}
			else{
				parent.contents.location = new_loc + "sel=" + sch;
				}
			
			}
		}

	return;
	} 

function synchSearchSidebar(cat) {
	
	synchTOCSidebar(cat);
	return;
	} 

function refreshMainPage() {
	
	parent.main.location.reload();
	return;
	}

function setPageFocus() {
	
	var nam = navigator.appName;
	var ver = navigator.appVersion;
	
	if (!(nam == 'undefined' || ver == 'undefined') && !(nam == '<undefined>' || ver == '<undefined>') && (ver.charAt(0) > '2')) {

		parent.main.focus();
		}

	return;
	}

function setQuickAddFocus() {

	if (document.frmCart.hdnQuickAdd.value == "Yes") {

		document.location.href = "#quickadd";
		//document.frmCart.txtSku.focus();
		}

	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;	
	}

function lablinkup()
{
var number = document.dropdown.ddlinks.selectedIndex;
location.href = document.dropdown.ddlinks.options[number].value;
}


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
			}
		}
	}
    