
function ValidateSignIn() { // validates login form
	var frm = document.signinform;
	uid  = frm.user_id.value;
	pass = frm.password.value;

	if ( uid.length == 0 || pass.length == 0 ) {
		alert('Please fill in both your User ID and Password.');
		if( uid.length == 0 )
			frm.user_id.focus();
		else if( pass.length == 0 )
			frm.password.focus();
		return false;
	}
}

function ValidateCustIdForm() { // validates find cust id form
	var frm = document.custidform;
	acctid  = frm.acct_id.value;
	zip = frm.zipcode.value;
	tn = frm.npa.value + frm.co.value + frm.line.value;

	if ( acctid.length == 0 || ( zip.length == 0 && tn.length == 0 ) ) {
		alert('Please provide your Billing Account ID and either your Zip Code or your Contact Telephone Number.');
		if( acctid.length == 0 )
			frm.acct_id.focus();
		else if( zip.length == 0 )
			frm.zipcode.focus();
	    else 
	        frm.npa.focus();
		return false;
	}
	
	if ( zip.length > 0 && tn.length > 0 ) {
	     alert('Please enter either Zip Code OR Contact Telephone Number, not both');
	     frm.zipcode.focus();
	     return false;
	}
	if ( acctid.length < 12 ) {
	     alert('Billing Account ID must be 12 digits');
	     frm.acct_id.focus();
	     return false;
	} else if ( acctid != parseInt(acctid) ) {
	     alert('Billing Account ID must be numeric');
	     frm.acct_id.focus();
	     return false;
	}
	
	if ( zip.length > 0 && zip.length < 5  ) {
	     alert('Invalid Zip Code');
	     frm.zipcode.focus();
	     return false;
	}
	
	if ( tn.length > 0 && tn.length < 10 ) {
	     alert('Invalid Telephone Number');
	     frm.npa.focus();
	     return false;
	}

}

function CheckAll() { // checks all checkboxes on a form

	for ( i = 0; i < form.elements.length; i++ ){

		var FormField = document.form.elements[i];

        //alert("Form Field = " + FormField); // test

		// do not reset checkbox0
		if( FormField.type == "checkbox" || FormField.name != "checkbox0" ){

			if( document.form.checkbox0.checked == true ){

				FormField.checked = true

			}else{

				FormField.checked = false

			}
		}
	}
}


function ScrollFeaturedProduct(){

	// Adopted from The JavaScript Source!!                           //
    // http://JavaScript.Internet.com/Page-Details/Floating-Link.html //
    // Created By Richard Cleaver - Richard@Cleaver.Org.UK            //

	var FeaturedProductTop = screen.availHeight - 270
	var FeaturedProductLeft = 619

	if(document.all){ // ie

		document.all.FeaturedProduct.style.pixelTop = document.body.scrollTop + FeaturedProductTop;

	}else if(document.getElementById) { // netscape, firefox, safari

		document.getElementById('FeaturedProduct').style.top = window.pageYOffset + FeaturedProductTop + 'px';

	}
}

if(document.all){ // scroll on IE

	//window.onscroll = ScrollFeaturedProduct;

}else{  // scroll on FireFox, Netscape, Safari

	//setInterval ('ScrollFeaturedProduct()', 100);
}

function openW(url, name, width, height, o) {
	// options - menubar,resizable,scrollbars,status,toolbar (there are more)
	// if you want them just list them seperated by commas
   var str = "height=" + height + ",width=" + width;
   if (window.screen) {
     var ah = screen.availHeight - 100;
     var aw = screen.availWidth - 10;

     var xc = (aw - width) / 2;
     var yc = (ah - height) / 2;

     if (xc < 0) xc = 20;
     if (yc < 0) yc = 20;

     str += ",left=" + xc + ",screenX=" + xc;
     str += ",top=" + yc + ",screenY=" + yc;
   }
  if (o != '')
		str = str + "," + o;

	if (typeof(win) == "object" && !win.closed){
     win.close();
	}
	win = window.open(url, name , str);
  win.focus();
}

function LTrim(str)
{
	for (var k=0; k<str.length && str.charAt(k)<=" " ; k++) ;
	  return str.substring(k,str.length);
}
function RTrim(str)
{
	for (var j=str.length-1; j>=0 && str.charAt(j)<=" " ; j--) ;
	  return str.substring(0,j+1);
}
function trim(str)
{
	return LTrim(RTrim(str));
}

	function isValidNum(str)
  {
    var validNum = "0123456789";
		for (var i = 0; i < str.length; i++)
		{
			oneChar = str.charAt(i);
      if (validNum.indexOf(oneChar) == -1) {
         return false;
      }
		}
		return true;
  }