function InsertCart(psItemNo){
	window.open('PlaceOrder.aspx?itemno=' + psItemNo, '', 'status=none,toolbar=none,width=650,height=350,scrollbars=1,resizable=1');
}
function CopyAddress(){
	window.document.frmAddress.txtSCompany.value = window.document.frmAddress.txtCompany.value;
	window.document.frmAddress.txtSAddr1.value = window.document.frmAddress.txtBAddr1.value;
	window.document.frmAddress.txtSAddr2.value = window.document.frmAddress.txtBAddr2.value;
	window.document.frmAddress.txtSCity.value = window.document.frmAddress.txtBCity.value;
	window.document.frmAddress.txtSState.value = window.document.frmAddress.txtBState.value;
	window.document.frmAddress.txtSZip.value = window.document.frmAddress.txtBZip.value;
	window.document.frmAddress.txtSPhone1.value = window.document.frmAddress.txtBPhone1.value;
	window.document.frmAddress.txtSPhone2.value = window.document.frmAddress.txtBPhone2.value;
}
function CopyAddress2(){
	window.document.frmAddress.txtSContact.value = window.document.frmAddress.txtBContact.value;
	window.document.frmAddress.txtSCompany.value = window.document.frmAddress.txtBCompany.value;
	window.document.frmAddress.txtSAddr1.value = window.document.frmAddress.txtBAddr1.value;
	window.document.frmAddress.txtSAddr2.value = window.document.frmAddress.txtBAddr2.value;
	window.document.frmAddress.txtSCity.value = window.document.frmAddress.txtBCity.value;
	window.document.frmAddress.txtSState.value = window.document.frmAddress.txtBState.value;
	window.document.frmAddress.txtSZip.value = window.document.frmAddress.txtBZip.value;
	window.document.frmAddress.txtSPhone1.value = window.document.frmAddress.txtBPhone1.value;
	window.document.frmAddress.txtSPhone2.value = window.document.frmAddress.txtBPhone2.value;
}
function gotourl(url,sname,swidth,sheight,sreplace,sclose)
{
	var objNewWin;				
	//if (swidth=="") 
	swidth = "1020";
	//if (sheight=="") 
	sheight = "700";
	if (sreplace=="") sreplace = false;
	if (sclose=="") sclose = false;
	objNewWin = window.open(url,sname,"fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + swidth + ",height=" + sheight + ",top=0,left=0",sreplace);	
	if (sclose) window.close();
	objNewWin.focus();	
}
function MassUpdate(){
	window.open('inventory_mupdate.aspx', '', 'status=none,toolbar=none,width=540,height=320');
}
function MarkAll(plChecked, psCtlID, pnColumn){
	var inputs; 
	var chkinput;
	inputs = document.getElementById("dgItemList").rows;
	for (var i=0; i < inputs.length; i++)
	{
		if ((inputs[i].innerText != "") && (inputs[i].cells[pnColumn].getElementsByTagName("INPUT").length>0))
		{
			chkinput = inputs[i].cells[pnColumn].getElementsByTagName("INPUT")[0];
			if (chkinput.id.indexOf(psCtlID)>-1) {
				chkinput.checked = plChecked;
			}
		}
	}
}

function MarkAllNew(plChecked, psCtlID, pnColumn, psGridName){
	var inputs; 
	var chkinput;
	inputs = document.getElementById(psGridName).rows;
	for (var i=0; i < inputs.length; i++)
	{
		if (inputs[i].cells[pnColumn].getElementsByTagName("INPUT").length>0)
		{
			chkinput = inputs[i].cells[pnColumn].getElementsByTagName("INPUT")[0];
			if (chkinput.id.indexOf(psCtlID)>-1) {
				chkinput.checked = plChecked;
			}
		}
	}
}

function CheckInput(){
	if(event.keyCode<47 || event.keyCode>57)
		event.returnValue=false;
}

function chkInput(oThis) {
	if (oThis.value.length < oThis.maxLength)
		oThis.value = (oThis.value + String.fromCharCode(event.keyCode)).toUpperCase();
	event.returnValue=false;
}

function ApplyOptChanged(source, dest1, dest2, dest3){
	var objOpt0, objOpt1, objOpt2, objSource;
	objSource = document.getElementById(source);
	objOpt0 = document.getElementById(dest1);
	objOpt1 = document.getElementById(dest2);
	objOpt2 = document.getElementById(dest3);
	
	if (objSource.selectedIndex == 0){
		objOpt0.style.display = "";
		objOpt1.style.display = "none";
		objOpt2.style.display = "none";
	}
	else if (objSource.selectedIndex == 1){
		objOpt0.style.display = "none";
		objOpt1.style.display = "";
		objOpt2.style.display = "none";
	}
	else{
		objOpt0.style.display = "none";
		objOpt1.style.display = "none";
		objOpt2.style.display = "";
	}
}

function SelectSOClick(tsPage, tsCtlName)
{
	lcKey = eval("window.document." + tsCtlName + ".value");
	winModalWindow = window.open(tsPage + "?ctlname=" + tsCtlName + "&key=" + lcKey,"ModalChild1","dependent=yes,width=600,height=400,scrollbars=yes")
	winModalWindow.focus();
}
function getEvent(){     
	if(document.all)    return window.event;        
		func=getEvent.caller;            
		while(func!=null){    
			var arg0=func.arguments[0];
			if(arg0){
				if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
					|| (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    
				return arg0;
			}
		}
		func=func.caller;
	}
	return null;
}		
function CheckKeyPress(tnQtyDec){
	var evt=getEvent();
	var keycode=evt.keyCode;
	var charcode=evt.charCode;
	if (evt.keyCode==46 && evt.charCode==0)
		return true;
	if (keycode==0)
		keycode=charcode;	
	if((keycode<48 || keycode>57) && keycode!=13 && keycode!=9 && keycode!=8 && keycode!=46 && keycode!=37 && keycode!=39 && keycode!=35 && keycode!=36)
		return false;
	else
	{
		if (tnQtyDec==0 && keycode==46)
		{
			alert("Order quantity has to be an integer.");
			return false;
		}		 			
	}
}
function CheckSeqPress(){
	var evt=getEvent();
	var keycode=evt.keyCode;
	var charcode=evt.charCode;
	if (evt.keyCode==46 && evt.charCode==0)
		return true;
	if (keycode==0)
		keycode=charcode;	
	if((keycode<48 || keycode>57))
		return false;			
}


