<!-- meta http-equiv="cache-control" content="no-cache" -->
<!-- meta http-equiv="pragma" content="no-cache" / -->
/*
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'   File:	                Validate.js
'
'   Description:            Commonly used utility functions for Input Form Validation
'
'   Written by:             Imran khalid
'
'	Language(s) Used:		JavaScript
'
'   Date Written:           Sept 18, 2001
'
'   Date Modify:            Feb 10 2004
'
'   Platform:               Microsoft Internet Explorer
'
'   Copyright:              © 2003 Imran Khalid
'                           All rights reserved
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
*/
function reward_vpoints(){

	if(!isEmpty2(document.forms['reward_system'].reward_points))
	{
		client = document.forms['reward_system'].reward_client_points.value;
		enter = document.forms['reward_system'].reward_points.value;
		client =parseInt(client);
		enter = parseInt(enter);

		
		
		if ((enter <= client)	&& (enter > 0))
		{
			return true
		}	
		else
		{
			alert("Reward points must be less than or equal to "+document.forms['reward_system'].reward_client_points.value);
			//alert("enter ="+enter +" cleint "+ client);
			return false			
		}
	}
	else
	return false




} // function 
//---------------------------------------------------------------------------------

function rsagreed(){
	if(document.frmrs.agree.checked == true){
 		return true;

	} // if 
	else {
	alert ("Please select the terms and conditions");
	 return false;
	}
} // function 
//---------------------------------------------------------------------------------
function ship_add_change() {
	item = document.frmship.ship_id;
	shipid = item.options[item.selectedIndex].value;
	params = 'toolbar=no,location=no,directories=no,status=no,menubar=no,';
	params +='scrollbars=yes,resizable=no,width=500,height=350,left=200,top=120';
	window.open ('edit_customer.php?act=ship_change&shipid='+shipid,'edit_customer', params);
	
}

function confirm_delete_order() {
if (confirm("Do you really want to delete the selected Orders?")) {
     return true;
 }
 else
 return false
}
function password_change(){
	
	if(Length_TextField_Validator(document.forms['form17'].password_old))
	if(Length_TextField_Validator(document.forms['form17'].password_new))
	return true;
	return false;
}
function bill_add(){

	if(!isEmpty2(document.forms['frm11'].ssfirstn))
	if(!isEmpty2(document.forms['frm11'].slastn))	
	if(!isEmpty2(document.forms['frm11'].sorg))
	if(!isEmpty2(document.forms['frm11'].saddress))
	if(!isEmpty2(document.forms['frm11'].scity))	
	if(!isEmpty2(document.forms['frm11'].szip))
	if(!isEmpty2(document.forms['frm11'].scountry))	
	if(!isEmpty2(document.forms['frm11'].phone))
return true;	
	return false;

}
function windowclose()
{
	self.close ();	
	opener.location.href = opener.location.href;
}
function ship_add(){


	if(!isEmpty2(document.forms['frm11'].ship_title))
	if(!isEmpty2(document.forms['frm11'].ssfirstn))
	if(!isEmpty2(document.forms['frm11'].slastn))	
	if(!isEmpty2(document.forms['frm11'].sorg))
	if(!isEmpty2(document.forms['frm11'].saddress))
	if(!isEmpty2(document.forms['frm11'].scity))	
	if(!isEmpty2(document.forms['frm11'].szip))
	if(!isEmpty2(document.forms['frm11'].scountry))	
		return true;	
	return false;

}

function edit_customer(act) {
	params = 'toolbar=no,location=no,directories=no,status=no,menubar=no,';
	params +='scrollbars=yes,resizable=no,width=500,height=350,left=200,top=120';

	window.open ('edit_customer.php?act='+act,'edit_customer', params);
}

function UpdateQty(item)
			{
				itemId = item.name;
				newQty = item.value[item.selectedIndex].text;
				
				document.location.href = 'cart.php?action=update_item&id='+itemId+'&qty='+newQty;
			}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function customerPop(Status)
  {
      winCustomer = window.open(Status,'EmailFriend','height=290,width=230,status=0,toolbar=0,resizable,scrollbars=yes');
}
function openDiscount(part_num)
  {
	  url = "http://www.aztekcomputers.com/popup_discount.php?idbp=897ihfdg874oijg98904j0984jlwjer9872345lkjertl90435kljwert945k345098324jkerg90845jkerw9845j09348jfoi90874j&idpn="+part_num+"&nhj=245657575346546897ihfdg874oijg98904";	
		winDiscount = window.open(url,"DiscountW","status, toolbar, menubar, resizable, location, scrollbars, width=800, height=600,left=0,screenX=0,top=0,screenY=0");
}
function delete_client_listing(str){
if (confirm("Do you really want to delete Part. No #"+str+" ?")) {
     	window.location = "vendor_products.php?action=delete&part_num="+str;
 }
}
function validateCartEmail(){
	if(!isEmpty(document.forms['frmSendProduct'].txtEmailAddressTo))
	if(isEmailValid(document.forms['frmSendProduct'].txtEmailAddressTo))
	if(!isEmpty(document.forms['frmSendProduct'].txtEmailAddressFrom))
	if(isEmailValid(document.forms['frmSendProduct'].txtEmailAddressFrom))
	return true;
	return false;
}
function validateFeedbackEmail(){
	if(!isEmpty(document.forms['frmFeedback'].txtEmailAddressTo))
	if(isEmailValid(document.forms['frmFeedback'].txtEmailAddressTo))
	if(!isEmpty(document.forms['frmFeedback'].txtEmailAddressFrom))
	if(isEmailValid(document.forms['frmFeedback'].txtEmailAddressFrom))
	return true;
	return false;
}
function validateFeedbackEmail2(){
	if(!isEmpty(document.forms['frmFeedback'].txtEmailAddressFrom))
	if(isEmailValid(document.forms['frmFeedback'].txtEmailAddressFrom))
	return true;
	return false;
}
function validateEmail(){
	if(!isEmpty(document.forms['frmSave'].txtEmail))
	if(isEmailValid(document.forms['frmSave'].txtEmail))
	return true;
	return false;
}
function validateEmailCartSave(){
	if(!isEmpty(document.forms['frmSaveCart'].txtEmail))
	if(isEmailValid(document.forms['frmSaveCart'].txtEmail))
	document.forms['frmSaveCart'].submit();
}
function validateEmailCartView(){
	if(!isEmpty(document.forms['frmViewCart'].txtEmail))
	if(isEmailValid(document.forms['frmViewCart'].txtEmail))
	document.forms['frmViewCart'].submit();
}
function validateEmailQuoteView(){
	if(!isEmpty(document.forms['frmViewQuote'].txtEmail))
	if(isEmailValid(document.forms['frmViewQuote'].txtEmail))
	document.forms['frmViewQuote'].submit();
}

function validateCustomer(){

	if(!isEmpty2(document.forms['formupdate'].user_id))	
	if(Length_TextField_Validator(document.forms['formupdate'].passwrd))
	return true;
	return false;
}
function validateVendor(){

	if(!isEmpty2(document.forms['frmVendor'].full_name))
		if(!isEmpty2(document.forms['frmVendor'].address1))
			if(!isEmpty2(document.forms['frmVendor'].city))
				if(!isEmpty2(document.forms['frmVendor'].zip))
					if(!isEmpty2(document.forms['frmVendor'].email))
						if(isEmailValid(document.forms['frmVendor'].email))
							if(Length_TextField_Validator(document.forms['frmVendor'].password))
								return true;
	return false;
}
function validateNewCustomer_reg(){
	
	if(!isEmpty2(document.forms['form5'].firstn))
	if(!isEmpty2(document.forms['form5'].LastN))
	if(!isEmpty2(document.forms['form5'].email))
	if(isEmailValid(document.forms['form5'].email))
	if(!isEmpty2(document.forms['form5'].user_id))
	if(!isEmpty2(document.forms['form5'].Passwrd))
	if(Length_TextField_Validator(document.forms['form5'].Passwrd))
	if(!isEmpty2(document.forms['form5'].address))
	if(!isEmpty2(document.forms['form5'].city))	
	if(!isEmpty2(document.forms['form5'].zip))
	if(!isEmpty2(document.forms['form5'].country))
	if(!isEmpty2(document.forms['form5'].phone))
	if(outside_us_check(document.forms['form5'].country.value))
	return true;
	return false;

}
function outside_us_check(country)
{
	if(country == 'US')
	{
		if(!isEmpty2(document.forms['form5'].state))
		return true;
		return false;
	}
	else
	return true;	
}
function isEmpty2(vField){

	if(vField.value.length!=0)
	{	
		SetHighlight(vField, false);
		return false;
	}
	else
	{

		vField.focus();
		alert(vField.name +" is Required. Please Fill in");
	
		SetHighlight(vField, true);
		return true;
	}
}

function isEmpty(vField){

	if(vField.value.length!=0)
	{	
		SetHighlight(vField, false);
		return false;
	}
	else
	{

		vField.focus();
		alert(vField.name.substring(3)+" is Required. Please Fill in");
	
		SetHighlight(vField, true);
		return true;
	}
}

////////////////////////////////////////////////////////////////////////

function SetHighlight(theElement, Highlight)
{
	if(Highlight)
	{
		theElement.focus();
		if(IsExplorer())
		{
			//theElement.style.borderStyle = "double";
			//theElement.style.borderWidth = 4;
		}
	}
	else
	{
		if(IsExplorer())
		{
			//theElement.style.borderStyle = "inset";
			//theElement.style.borderWidth = 2;
		}
	}
}

////////////////////////////////////////////////////////////////////////
function IsExplorer()
{
	var userAgent = navigator.userAgent;
	
	if(userAgent.indexOf("MSIE") >= 0)
		return true;
	else
		return false;
}
////////////////////////////////////////////////////////////////////////

function isEmailValid(varEMail)
{
	
	if(varEMail.value.indexOf("@")!=0)
		if(varEMail.value.indexOf(".")!=0)
			if(varEMail.value.lastIndexOf("@")!=(varEMail.value.length-1))
				if(varEMail.value.lastIndexOf(".")!=(varEMail.value.length-1))
					if(varEMail.value.lastIndexOf(".")!=-1)
						if(varEMail.value.lastIndexOf("@")!=-1)
							if(varEMail.value.indexOf(" ")<0)
								return true;
	alert("Invalid EMail Address");
	return false;
}
/////////////////////
function Length_TextField_Validator(vField)
{
// Check the length of the value of the element named text_name
// from the form named form_name if it's < 3 and > 10 characters
// display a message asking for different input
s = vField.value;

  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);
  }
if ((s.length < 4) || (s.length > 15))
{
// Build alert box message showing how many characters entered
mesg = "You have entered " + s.length + " character(s)\n"
mesg = mesg + "Valid entries are between 4 and 10 characters.\n"
mesg = mesg + "Please verify your input and submit again."
alert(mesg);
// Place the cursor on the field for revision
vField.focus();
// return false to stop further processing
return (false);
}
// If text_name is not null continue processing
return (true);
}
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;
}
