
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
		
function mouseoverlink() {
	if (ie4) {
	linkcolor=window.event.srcElement.style.color;
	window.event.srcElement.style.color = "#99CCFF";
	}

}

function mouseoutlink() {
		if (ie4){
		window.event.srcElement.style.color = linkcolor;
		}
}
function isblank(s){
	for(var i=0; i < s.length; i++){
	var c=s.charAt(i);
	if ((c != ' ') && (c != '\n') && (c != '\t')) return (false);
	}
	return (true);
}

function prodformsubmit(goURL, rp, sidx) {
	// Kevin K for  Incident - #89423 & #89425 ... 26 May 2004
	
		var chkhref=document.location.href;
				
		if (chkhref.indexOf("cabu/billinginfo.asp")==-1)
		{
		chk_add2cart_qty();
		}


		if (rp==1){
			document.ProdForm.submit();
		}
		if (rp==2)
		{
			if (sidx.length>0)
			{
				goURL.value="/scripts/cabu/shopcart.asp?sid="+sidx		
			}
			else
			{
				goURL.value="/scripts/cabu/shopcart.asp"
			}
			document.ProdForm.submit();
		}
}

function quickBuySubmit(goURL, rp, sidx) {
		if (rp==1){
			document.ProdForm.submit();
		}
		if (rp==2)
		{
			document.ProdForm.action=document.ProdForm.txtMaintainCartUrl.value;
			if (sidx.length>0)
			{
				goURL.value="/scripts/cabu/shopcart.asp?sid="+sidx		
			}
			else
			{
				goURL.value="/scripts/cabu/shopcart.asp"
			}
			document.ProdForm.submit();
		}
}



function catalogSubmit(rp,sidx)
{
	// Kevin K for  Incident - #89423 & #89425 ... 26 May 2004
		if (rp==1)
		{
			//document.ProdForm.submit();
		}
		if (rp==2)
		{
			var urlValue = "/scripts/cabu/AddToCatalog.asp?sid="+sidx;
			document.ProdForm.action=urlValue;
			//document.ProdForm.submit();
		}
		if (rp==3)
		{
			var urlValue = "/scripts/cabu/MyCatalogListing.asp?sid="+sidx;
			document.ProdForm.action=urlValue;
			//document.ProdForm.submit();
		}
		chk_add2cart_qty();
		document.ProdForm.submit();
		
}

function CheckSelectedField(rFld,Fld1,Fld2,Fld3,Fld4) {
	rd=document.OrderForm.rdPayment[0].checked;
	if (rd){
		Fld2.value="";
		//Fld3.value="";
		Fld4.value="";
	}	
	else{
	Fld1.value="";
	}
	
																							
}


function selectPOPaymentOption(rdFld)
{	
	txtPurchaseOrder=document.OrderForm.TxtPoNum.value;
	if (txtPurchaseOrder.length==0)
	{
	}
	else
	{
		rdFld.checked=true;
		if(document.OrderForm.rdPayment.length > 1)
		{
			document.OrderForm.TxtCCNum.value="";
			document.OrderForm.TxtCCName.value="";
		}
	}
		
}
function selectCCPaymentOption()
{
	txtCCNumber=document.OrderForm.TxtCCNum.value;
	if (txtCCNumber.length==0)
	{
	}
	else
	{
		document.OrderForm.TxtPoNum.value = "";
		if (document.OrderForm.rdPayment[0].checked)
		{
			document.OrderForm.rdPayment[1].checked=true;
		}
	}
		
}


function orderformsubmit(goURL,rp,ckFld) 
{
	ckTerms=ckFld.checked;
	var payOption = "PO";
	
	for (var i = 0; i < document.OrderForm.rdPayment.length; i++) 
	{      
		if (document.OrderForm.rdPayment[i].checked) 
		{         
			payOption=document.OrderForm.rdPayment[i].value;
		}   
	}
	
	var rdPurchaseOrder = false;
	if (payOption == "PO")
	{
		rdPurchaseOrder = true;
	}
	
	//Check if Invoice Me is selected.
	if(rdPurchaseOrder)
	{
		txtPurchaseOrder=document.OrderForm.TxtPoNum.value;
		if (txtPurchaseOrder.length==0)
		{
			alert("Please enter a purchase order number or credit card information.");
			return;
		}
	}
	else	//User selected credit card
	{
		var txtAccount		=	document.OrderForm.TxtCCNum.value;
		var txtName			=	document.OrderForm.TxtCCName.value;
		var txtMonth		=	-1;
		var txtYear			=	-1;
		
		for (var i = 0; i < document.OrderForm.elements.length; i++) 
		{
		    var fldName = document.OrderForm.elements[i].name;
		    if(fldName == "cc-exp-month")
		    {
				txtMonth	=	document.OrderForm.elements[i].options[document.OrderForm.elements[i].selectedIndex].value;	
		    }
		    
		    if(fldName == "cc-exp-year")
		    {
				txtYear	=	document.OrderForm.elements[i].options[document.OrderForm.elements[i].selectedIndex].value;	
		    }  
		}
		
		if(txtAccount.length == 0)
		{
			alert("Please enter credit card number.");
			return;
		}
		
		if(txtName.length == 0)
		{
			alert("Please enter name as displayed on credit card.");
			return;
		}
		
		if(txtMonth == -1 || txtYear == -1)
		{
			alert("Please provide the credit card expiration date.");
			return;
		}
		
		//Following code ensures correct expiration date
		var curDate		= new Date();
		var curMonth	= curDate.getMonth()+1; //Note: this gives 0 to 11 i.e., April is 3 etc.
		var curYear		= curDate.getFullYear();
		
		if(txtYear.length == 2)
		{
			txtYear = 20 + txtYear;
		}
		expMonth	=	new Number(txtMonth);
		expYear		=	new Number(txtYear);
				
		if(expYear <= curYear)
		{
			if (expMonth < curMonth)
			{
				alert("Please enter a valid credit card expiration date.");
				return;	
			}
		}		
	} 

	
	
	if(ckTerms)
	{
		if (rp==1)
		{
			goURL.value="Print"
			document.OrderForm.submit();
		}
		
		if (rp==2)
		{
			
			if (document.OrderForm.TxtFlg.value=="M")
			{
				if (document.frmValidPurchase.EligibleforPurchase.value=="False" && document.frmValidPurchase.EmailType.value =="APPR")
				{
					alert("This order exceeds the order limit set by your company.  This order will be emailed to the designated approver " + document.frmValidPurchase.ContactEmail.value + " for submission.");	
				}
			}	
			goURL.value="Submit"
			document.OrderForm.submit();
		}
	}
	
	if (!ckTerms) 
	{
		if(confirm("\nClick OK if you agree to terms and conditions. \nIf you would like to review terms and conditions, \nplease click CANCEL and Click on 'Review Terms & Conditions' on this page. \nYour agreement to the terms and conditions is required to complete the sale.")) 
		{			
			ckFld.checked=true;
			if (rp==1)
			{
				goURL.value="Print"
				document.OrderForm.submit();
			}
			if (rp==2)
			{
				if (document.OrderForm.TxtFlg.value=="M")
				{
					if (document.frmValidPurchase.EligibleforPurchase.value =="False" && document.frmValidPurchase.EmailType.value =="APPR")
					{
						alert("This order exceeds the order limit set by your company.  This order will be emailed to the designated approver " + document.frmValidPurchase.ContactEmail.value +" for submission.");	
					}
				}
				goURL.value="Submit"
				document.OrderForm.submit();
			}
		}
	}				
		
}



function CheckIntegerField(Fld1) {
	d1=Fld1.value;
	d2=parseInt(Fld1.value);
	
	if (!isNaN(d1))
	{
		if (!isblank(d1))
		{	
			if (d1==d2){
				return true;	
				}
			else{
				if (eval("d1-d2")>0)
				{
					alert("Only Whole numbers are allowed.");
					Fld1.value=d2+1;	
					return true;
				}	
			}			
		}	
	}
	else
	{
		
			alert("Only Whole numbers are allowed.");	
						Fld1.value='';
			return true;
	}																						
}


function OrdRep(goURL,rp,ckFld) {
	if(ckFld != null){
		x1=ckFld.checked;
		if(x1){
			goURL.value="Submit"
			document.ProdForm.submit();
		}
	
		if (!x1) {
			//if(confirm("\nClick OK if you agree to add the first item. \nIf you would like to add some other items, \nplease click CANCEL and Check the Add box on this page.")) {
				//ckFld.checked=true;
				goURL.value="Submit"
				document.ProdForm.submit();
			//}
		}				
	}
	else {
	alert("There are no items to process");
	history.go(-1);
	}
}
//Browser Detection
var browser = "";
var browsername = navigator.appName;
var browserversion = parseInt(navigator.appVersion);
if (browsername == "Netscape") {
    browser = "ns" + browserversion;
} else {
    if (browsername == "Microsoft Internet Explorer") {
        if (browserversion >= 4) {
            browser = "ie" + browserversion;
        } else {
            browser = "ie3";
        }
    }
}

function popNav(url,name,features) {
	if ((browser == "ns3","ns4") || (browser == "ie4")) {
	popBox = window.open(url,name,features);
	popBox.focus();
	    } else {
	        if (browser == "ie3") {
	        popBox = window.open(url,name,features);
	        }  
	}
}

//Added by Gita Viswanaathan on 10/07/02 to make layout changes
//This function is to open the popup window when verisign logo is clicked

function popUp(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
self.name = "mainWin";
}


		
//function Inst_Window(rp){
//   Frame frame = new Frame("Instruccions");
//   frame.setSize(400, 300);
//   frame.setVisible(true);
//}   


// Michael Kim
function UncheckOvernightDelivery(ckFld, part1) {

ckFld.checked=false;
//alert("\nMaterial " + part1 + " not source from CAG's main warehouse, overnight delivery is not possible Online.\n");
alert("\nMaterial " + part1 + " is not available for overnight delivery via the Online Store. To ensure overnight delivery of this product, please call 1-877-447-7278 to place your order.\n");
		
}


<!--
// Kevin K for  Incident - #89423 & #89425 ... 26 May 2004
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function chk_add2cart_qty()
{
obj = document.ProdForm;
	if (obj.TxtCount!=null)
	{

	empflg= true;

		for (i=1;i<=obj.TxtCount.value;i++)
		{
			if (obj.elements['TxtQty'+i]!=null)
			{
				if (trim(obj.elements['TxtQty'+i].value)!='')
				{
					empflg=false;
					i = obj.TxtCount.value+1;		
				}
			}
			else
			{
				if (trim(obj.TxtQty.value)!='')
				{
				empflg==false;
				i = obj.TxtCount.value+1;
				}
			}
			
			
		}
		if (empflg==true)
		{
			if (obj.TxtURL.value.indexOf('&qtyerr=true')>0)
			{obj.action=obj.TxtURL.value}
			else
			{obj.action=obj.TxtURL.value+'&qtyerr=true'}
		}
	}
}


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid date")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid date")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("The date format should be : mm/dd/yyyy")
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
	return true
}

function ValidateForm(form){

	var dt=form.txtScheduleDate;
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    	return true
 }


function selectShippingDate(form)
{
	
	var dt=form.txtScheduleDate;
	var FldVal = dt.value;
	if (FldVal.length==0)
	{
		return;
	}



	var shipDate = new Date(form.txtScheduleDate.value)
	var sDate = shipDate.getDate();
	var sMon = shipDate.getMonth()+1;
	var sYear = shipDate.getFullYear();
	var sDate = sMon + '/'+ sDate +'/'+ sYear

	if(sDate=="NaN/NaN/NaN")
	{
		alert("Please re-enter valid date.");
		form.txtScheduleDate.value = "";
		form.rdDelivery[0].checked=true;
		return;
	}
	
	if (isDate(dt.value)==false){
		//dt.focus()
		form.txtScheduleDate.value = "";
		form.rdDelivery[0].checked=true;
		return false
	}

	form.txtScheduleDate.value = sDate;
	var curDate = new Date();
	var timeDiff =  parseInt((shipDate - curDate)/(1000*60*60*24));

	var rdCnt
	var sd = "ScheduleDelivery";
	var rdVal

	for (var i = 0; i < form.rdDelivery.length; i++) 
	{
		var rdVal= form.rdDelivery[i].value;
		if (rdVal==sd)
		{
			form.rdDelivery[i].checked=true;
			rdCnt = i;
		}
	}
	

	if (curDate > shipDate)
	{
		alert("Delivery date should be in future. Please re-enter desired Delivery Date.");
		form.txtScheduleDate.value = "";
		form.rdDelivery[rdCnt].checked=false;
		form.rdDelivery[0].checked=true;
		return;
	}
	if (form.m_memtype.value=='IDO' || form.m_memtype.value=='DISTRIBUTO')
	{
		if (timeDiff > 30)
		{
			alert("Delivery date cannot be more than 30 days into future. Please re-enter desired Delivery Date.");
			form.txtScheduleDate.value = "";
			form.rdDelivery[rdCnt].checked=false;
			form.rdDelivery[0].checked=true;
			return;
		}
	}
	else
	{
		if (timeDiff > 180)
		{
			alert("Delivery date cannot be more than 180 days into future. Please re-enter desired Delivery Date.");
			form.txtScheduleDate.value = "";
			form.rdDelivery[rdCnt].checked=false;
			form.rdDelivery[0].checked=true;
			return;
		}
	}
	
}


//-->	