// JavaScript Document
function validate_quickcontact(thisform)
{
with (thisform)
	{
		
	//	if(fname.value=="Name")fname.value="";	
	if (emptyvalidation(q_name,"Woops! You forgot to fill in your Name")==false) 
		{
		q_name.focus();
		return false;	
		}
		
		
	/*if(email.value=="Email")email.value=""; */	
	if (emptyvalidation(q_email,"Woops! You forgot to fill in your Email Address")==false) 
		{
		q_email.focus();
		return false;	
		}	
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = thisform.q_email.value;
  
	if(reg.test(address) == false) 
	{ 
      alert('Woops! You have entered an invalid Email Address');
	  q_email.focus();
	  q_email.select();
      return false;
   }
  if (emptyvalidation(q_phone,"Woops! You forgot to fill in Phone No")==false) 
		{
		q_phone.focus();
		return false;	
		}
		if(res = IsPhoneNumber(thisform.q_phone.value) == false )
		{
			alert("Enter valid phone number");
			q_phone.focus();
			q_phone.select();
			return false;
		}
	if (emptyvalidation(q_comments,"Woops! You forgot to fill in your Comments")==false) 
		{
		q_comments.focus();
		return false;	
		}
		
		
	}
	thisform.submit();
}
function validate_login(thisform)
{
		thisform.submit();
}
function validate_signup(thisform)
{
	with (thisform)
	{
	/*if(email.value=="Email")email.value=""; */	
	if (emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false) 
		{
		email.focus();
		return false;	
		}	
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = thisform.email.value;
  
	if(reg.test(address) == false) 
	{ 
      alert('Woops! You have entered an invalid Email Address');
	  email.focus();
	  email.select();
      return false;
   }
	}
	thisform.submit();
}
function validate_exchange(thisform)
{
	with (thisform)
	{
	if (emptyvalidation(reason,"Woops! You forgot to fill in Reason for Exchange")==false) 
		{
		reason.focus();
		return false;	
		}
		if (emptyvalidation(wrong_size,"Woops! You forgot to fill in Wrong Size")==false) 
		{
		wrong_size.focus();
		return false;	
		}
		if (emptyvalidation(defective,"Woops! You forgot to fill in Defective")==false) 
		{
		defective.focus();
		return false;	
		}
	}thisform.submit();
}
function validate_search(thisform)
{
	with (thisform)
	{
	if (emptyvalidation(searchtext,"Woops! Please Enter One Value")==false) 
		{
		searchtext.focus();
		return false;	
		}
		else if(searchtext.value == 'Search a Product')
		{
			alert('Woops! Please Enter One Value')
			searchtext.focus();
			return false;
		}
 	
	}
	thisform.submit();
}

function IsNumeric(strString)
{
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;
   //if ((strString.length == 0) || (strString.length > 16) )  return false;

   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) 
	  blnResult = false;
      }
   return blnResult;
}
function IsPhoneNumber(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.- []()";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
		 //alert("Enter a phone number");
         blnResult = false;
         }
      }
   return blnResult;
   }	
function emptyvalidation(entered, alertbox)
{
	with (entered)
	{
		while (value.charAt(0) == ' ')
			value = value.substring(1);
		while (value.charAt(value.length - 1) == ' ')
			value = value.substring(0, value.length - 1);
		if (value==null || value=="")
		{
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}

