var highlightcolor="#cccccc"
	
		var ns6=document.getElementById&&!document.all
		var previous=''
		var eventobj

		//Regular expression to highlight only form elements
		var intended=/INPUT|TEXTAREA|SELECT|OPTION/

		//Function to check whether element clicked is form element
		function checkel(which){
		if (which.style&&intended.test(which.tagName)){
		if (ns6&&eventobj.nodeType==3)
		eventobj=eventobj.parentNode.parentNode
		return true
		}
		else
		return false
		}

		//Function to highlight form element
		function highlight(e){
		eventobj=ns6? e.target : event.srcElement
		if (previous!=''){
		if (checkel(previous))
		previous.style.backgroundColor=''
		previous=eventobj
		if (checkel(eventobj))
		eventobj.style.backgroundColor=highlightcolor
		}
		else{
		if (checkel(eventobj))
		eventobj.style.backgroundColor=highlightcolor
		previous=eventobj
		}
		}
		

function showRemoteImage() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=725,height=600";
OpenWindow = window.open("", "remote", windowprops); 
}



function showRemoteUpload() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=525,height=150";
OpenWindow = window.open("", "remoteUpload", windowprops); 
}

function showRemoteEmail() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=725,height=650";
OpenWindow = window.open("", "remote_email", windowprops); 
}

function showRemoteErrors() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=850,height=500";
OpenWindow = window.open("", "remote_error", windowprops); 
}

function showRemoteGalleryImage() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=200,height=200";
OpenWindow = window.open("", "remote_gallery_image", windowprops); 
}


function showRemoteProduct() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=200,height=200";
OpenWindow = window.open("", "remote_product", windowprops); 
}

function showRemoteSizeChart() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=800,height=650";
OpenWindow = window.open("", "remote_size_chart", windowprops); 
}


function showRemoteInvoice() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=600,height=700";
OpenWindow = window.open("", "remote_invoice", windowprops); 
}

function showRemoteTerms() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=675,height=800";
OpenWindow = window.open("", "remote_terms", windowprops); 
}

function showRemotePalette() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=200,height=200";
OpenWindow = window.open("", "remote_palette", windowprops); 
}
//--

function closeRemote() {
timer = setTimeout('window.close();', 10);
}

function clearUserText() {
  document.login.du_user_name.value= "";
}

/*
function showRemoteEmail() {
var windowprops = "toolbar=0,location=0,directories=0,status=1, " +
"menubar=0,scrollbars=yes,resizable=yes,width=600,height=700";
OpenWindow = window.open("", "remote_email", windowprops); 
}
*/


function validateNumber(field){
	var val = field.value;
	var okNumber = true;
	var RefString = "-1234567890";
	for (i=0; i< val.length; i++)
		{
			TempChar = val.substring ( i, i+1 );
			if (  TempChar == "." ) { okNumber = false; } /* Can only have zero or one decimal points in a number */
			if (( TempChar == "-" ) && ( i != 0 )) { okNumber = false; } /* Minus Sign must be first character */
			/* Check if current character is valid */
			if ( RefString.indexOf (TempChar,0) == -1)
			{
			/* character not found in RefString */
			okNumber = false;
			}
		}
		if ( okNumber == false ) 
		{
		      alert("Please enter a valid number");
		      field.focus();
		      field.select();
		}
}







var cust_shipping_name_first = "";
var cust_shipping_name_last = "";
var cust_shipping_company = "";
var cust_shipping_street_1 = "";
var cust_shipping_street_2 = "";
var cust_shipping_city = "";
var cust_shipping_state = "";
var cust_shipping_zip = "";
var cust_shipping_phone = "";


function InitSaveVariables(form) {
cust_shipping_name_first = form.cust_shipping_name_first.value;
cust_shipping_name_last = form.cust_shipping_name_last.value;
cust_shipping_phone = form.cust_shipping_phone.value;
cust_shipping_company = form.cust_shipping_company.value;
cust_shipping_street_1 = form.cust_shipping_street_1.value;
cust_shipping_street_2 = form.cust_shipping_street_2.value;
cust_shipping_city = form.cust_shipping_city.value;
cust_shipping_zip = form.cust_shipping_zip.value;
ShipStateIndex = form.cust_shipping_state.selectedIndex;

}

function ShipToBillPerson(form) {
if (form.copy.checked) {
	InitSaveVariables(form);
	form.cust_shipping_name_first.value = form.cust_billing_name_first.value;
	form.cust_shipping_name_last.value = form.cust_billing_name_last.value;
	form.cust_shipping_phone.value = form.cust_billing_phone.value;
	form.cust_shipping_company.value = form.cust_billing_company.value;
	form.cust_shipping_street_1.value = form.cust_billing_street_1.value;
	form.cust_shipping_street_2.value = form.cust_billing_street_2.value;
	form.cust_shipping_city.value = form.cust_billing_city.value;
	form.cust_shipping_zip.value = form.cust_billing_zip.value;
	form.cust_shipping_state.selectedIndex = form.cust_billing_state.selectedIndex;
}
else {
	form.cust_shipping_name_first.value = cust_shipping_name_first;
	form.cust_shipping_name_last.value = cust_shipping_name_last;
	form.cust_shipping_phone.value = cust_shipping_phone;
	form.cust_shipping_company.value = cust_shipping_company;
	form.cust_shipping_street_1.value = cust_shipping_street_1;
	form.cust_shipping_street_2.value = cust_shipping_street_2;
	form.cust_shipping_city.value = cust_shipping_city;
	form.cust_shipping_zip.value = cust_shipping_zip;       
	form.cust_shipping_state.selectedIndex = ShipStateIndex;

   }
}








function reloadImage()
{
	theDate = new Date();
	document["ver_code"].src = "/utils/inc_func_image_verify.asp?" + theDate.getTime();
}


function printPage() {
	javascript:window.print();
  }
  
  
  
  

  
//***************************************************************  
//CHARACTER COUNT DOWN
//***************************************************************
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters remaining on your input limit'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}

function rebuildEvent( finalText, r1, r2, r3, r4 ) {
	var rText = "";
	var finalEvent = "";
	
	finalEvent = document.getElementById('keycode_event_text_final');
	
	if( finalText ) {
		rText += document.getElementById(finalText).value + "\n";
	}
	
	if( r1 ) {
		rText += "Enter xx for " + document.getElementById(r1).value + "\n";
	}
	
	if( r2 ) {
		rText += "Enter xx for " + document.getElementById(r2).value + "\n";
	}
	
	if( r3 ) {
		rText += "Enter xx for " + document.getElementById(r3).value + "\n";
	}
	
	if( r4 ) {
		rText += "Enter xx for " + document.getElementById(r4).value + "\n";
	}
	
	finalEvent.value = rText;
}
