function isNumeric(str){
  var re = /[\D]/g
  if (re.test(str)) return false;
  return true;
}
function fncheckall(frm)
{
    if(frm.chkall!='undefined')
	{
	    var MAXCHKS = parseInt(frm.chk_id.length);
	   if(isNaN(MAXCHKS))
	    MAXCHKS = 0;
	  if(frm.chkall.checked == true)
	  {	
		  for(i=0; i<MAXCHKS; i++)
		  {
			  frm.chk_id[i].checked = true;
		  }
		  if(MAXCHKS == 0)
		    frm.chk_id.checked = true;
	  }	
	   else if(frm.chkall.checked == false)
	   {
	      for(i=0; i<MAXCHKS; i++)
		   frm.chk_id[i].checked = false;
		  if(MAXCHKS == 0)
		   frm.chk_id.checked = false; 
	   }
	}
}

function fndeleteall(frm)
{
   var found = "";
   var chks = parseInt(frm.chk_id.length);
   if(isNaN(chks))
     chks = 0;
   for(i=0; i<chks; i++)
   {
      if(frm.chk_id[i].checked == true)
	   found = frm.chk_id[i].value;    
   }
   if(chks==0)
   {
      if(frm.chk_id.checked == true)
	   found = frm.chk_id.value;    
   }
   if(found=="")
   {
      alert("Please select atleast one checkbox.");
	  return false;
   }
   else
   {
   		var p = confirm("Are you sure to delete this image?");
   		frm.submit();
	}	
}

function fndeletesingle(frm)
{
	var p = confirm("Are you sure to delete this image?");
	frm.submit();
}

function fnPopupImg(imgPath)
{
   window.open(imgPath, "ImageView", "width=400 height=400 scrollbars=yes resizable=1");
}
function fnPopupCert(imgPath)
{
   window.open(imgPath, "ImageView", "width=800 height=800 scrollbars=1 resizable=1");
}
function fnPopupDetails(url)
{
   window.open(url, "ImageView", "width=600 height=450 scrollbars=yes");
}

function isEmpty(str){
  return (str == null) || (str.length == 0);
}
// returns true if the string is a valid email
function isEmail(str){
  if(isEmpty(str)) return false;
  var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
  return re.test(str);
}
// returns true if the string only contains characters A-Z or a-z
function isAlpha(str){
  var re = /[^a-zA-Z]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string only contains characters 0-9
function isNumeric(str){
  var re = /[\D]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string only contains characters A-Z, a-z or 0-9
function isAlphaNumeric(str){
  var re = /[^a-zA-Z0-9]/g
  if (re.test(str)) return false;
  return true;
}
// returns true if the string's length equals "len"
function isLength(str, len)
{
  return str.length >= len;
}
// returns true if the string's length is between "min" and "max"
function isLengthBetween(str, min, max){
  return (str.length >= min)&&(str.length <= max);
}
// returns true if the string is a US phone number formatted as...
// (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000
function isPhoneNumber(str){
  var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/
  return re.test(str);
}
// returns true if the string is a valid date formatted as...
// mm dd yyyy, mm/dd/yyyy, mm.dd.yyyy, mm-dd-yyyy
function isDate(str){
  var re = /^(\d{1,2})[\s\.\/-](\d{1,2})[\s\.\/-](\d{4})$/
  if (!re.test(str)) return false;
  var result = str.match(re);
  var m = parseInt(result[1]);
  var d = parseInt(result[2]);
  var y = parseInt(result[3]);
  if(m < 1 || m > 12 || y < 1900 || y > 2100) return false;
  if(m == 2){
          var days = ((y % 4) == 0) ? 29 : 28;
  }else if(m == 4 || m == 6 || m == 9 || m == 11){
          var days = 30;
  }else{
          var days = 31;
  }
  return (d >= 1 && d <= days);
}
// returns true if "str1" is the same as the "str2"
function isMatch(str1, str2){
  return str1 == str2;
}
// returns true if the string contains only whitespace
// cannot check a password type input for whitespace
function isWhitespace(str){ // NOT USED IN FORM VALIDATION
  var re = /[\S]/g
  if (re.test(str)) return false;
  return true;
}
// removes any whitespace from the string and returns the result
// the value of "replacement" will be used to replace the whitespace (optional)
function stripWhitespace(str, replacement){// NOT USED IN FORM VALIDATION
  if (replacement == null) replacement = '';
  var result = str;
  var re = /\s/g
  if(str.search(re) != -1){
    result = str.replace(re, replacement);
  }
  return result;
}
// validate the form

function validateForm(f)
{
   
  if(isEmpty(f.username.value))
  {
     alert("Please enter Username.");
	 f.username.focus();
	 return false;
  }
  
  if(isEmpty(f.passwd.value))
  {
     alert("Please enter Password.");
	 f.passwd.focus();
	 return false;
  }
  
  return true;
}

function fnlanguage(p, loc, t)
{
  var url;
   if(p==1)
     url = loc + 'french/index/task/'+t;
//   else if(p==0 && loc=='http://www.pragyanet.com/pntuser/sunrise/french/')
//     url = 'http://www.pragyanet.com/pntuser/sunrise/' + 'index/task/'+t;
   else if(p==0 && loc=='http://localhost/sunrise/french/')
       url = 'http://localhost/sunrise/' + 'index/task/'+t;
	//alert(url);
	window.location.href = url;	 
}

function validateLoginForm(f)
{
   if(isEmpty(f.txtemail.value))
	{
	  alert("Please enter Email Address.");
	  f.txtemail.focus();
	  return false;
	}
	if(f.txtemail.value!="")
   {
      var x = f.txtemail.value;
	   if(!isEmail(x))
	   {
		  alert("Please enter valid Email Address.");
		  f.txtemail.focus();
		  return false;
	   }
   }
   if(isEmpty(f.txtpwd.value))
	{
	  alert("Please enter Password.");
	  f.txtpwd.focus();
	  return false;
	}
	if(f.txtpwd.value!="")
	{
	  var x = f.txtpwd.value;
	  if(!isLength(x, 6))
	  {
	     alert("Password should be minimum 6 characters.");
		 f.txtpwd.focus();
		 return false;
	  }
	}
	return true;
}
function validRegisterForm(f)
{
    if(isEmpty(f.txtfname.value))
	{
	  alert("Please enter First Name.");
	  f.txtfname.focus();
	  return false;
	}
	if(isEmpty(f.txtlname.value))
	{
	  alert("Please enter Last Name.");
	  f.txtlname.focus();
	  return false;
	}
	if(isEmpty(f.txtemail.value))
	{
	  alert("Please enter Email Address.");
	  f.txtemail.focus();
	  return false;
	}
	if(f.txtemail.value!="")
   {
      var x = f.txtemail.value;
	   if(!isEmail(x))
	   {
		  alert("Please enter valid Email Address.");
		  f.txtemail.focus();
		  return false;
	   }
   }
   if(isEmpty(f.txtpwd.value))
	{
	  alert("Please enter Password.");
	  f.txtpwd.focus();
	  return false;
	}
	if(f.txtpwd.value!="")
	{
	  var x = f.txtpwd.value;
	  if(!isLength(x, 6))
	  {
	     alert("Password should be minimum 6 characters.");
		 f.txtpwd.focus();
		 return false;
	  }
	}
   if(isEmpty(f.txtconfirm.value))
	{
	  alert("Please enter Password for Confirmation.");
	  f.txtconfirm.focus();
	  return false;
	}
	if(f.txtpwd.value != f.txtconfirm.value)
   {
      alert("Please enter same Password for confirmation.");
	  f.txtconfirm.focus();
	  return false;
   }
   if(isEmpty(f.txtaddress.value))
	{
	  alert("Please enter Address.");
	  f.txtaddress.focus();
	  return false;
	}
  if(isEmpty(f.txttown.value))
	{
	  alert("Please enter Town.");
	  f.txttown.focus();
	  return false;
	}
   if(isEmpty(f.txtzipcode.value))
	{
	  alert("Please enter Postal Code.");
	  f.txtzipcode.focus();
	  return false;
	}
   if(isEmpty(f.txtcountry.value))
	{
	  alert("Please enter Country.");
	  f.txtcountry.focus();
	  return false;
	}
	if(isEmpty(f.ph1.value))
	{
	  alert("Please enter Country Code.");
	  f.ph1.focus();
	  return false;
	}	
    if(isEmpty(f.ph2.value))
	{
	  alert("Please enter Area Code.");
	  f.ph2.focus();
	  return false;
	}
    if(isEmpty(f.ph3.value))
	{
	  alert("Please enter Phone Number.");
	  f.ph3.focus();
	  return false;
	}		
	if(!isEmpty(f.ph1.value))
	{
	   if(!isNumeric(f.ph1.value))
      {
		alert("Please enter Only Numeric Values.");
	  	f.ph1.focus();
	  	return false;
	  }
	}
   if(!isEmpty(f.ph2.value))
	{
	   if(!isNumeric(f.ph2.value))
      {
		alert("Please enter Only Numeric Values.");
	  	f.ph2.focus();
	  	return false;
	  }
	}
   if(!isEmpty(f.ph3.value))
	{
	   if(!isNumeric(f.ph3.value))
      {
		alert("Please enter Only Numeric Values.");
	  	f.ph3.focus();
	  	return false;
	  }
	}
 /*  if(f.ph1.value!="" && f.ph2.value!="" && f.ph3.value!="")
   {
       /*var x = f.txtdayphone.value;
	   if(!isPhoneNumber(x))
	   {
	     alert("Please enter valid Phone Format. Valid Formats are (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000");
		 f.txtdayphone.focus();
		 return false;
	   }
   }*/
   if(f.chkPolicy.checked==false)
   {
      alert("Please accept Terms & Conditions to proceed further.");
	  f.chkPolicy.focus();
	  return false;
   }
  return true; 
}

function validPersonalForm(f)
{
   
   if(isEmpty(f.txtfname.value))
	{
	  alert("Please enter First Name.");
	  f.txtfname.focus();
	  return false;
	}
	if(isEmpty(f.txtlname.value))
	{
	  alert("Please enter Last Name.");
	  f.txtlname.focus();
	  return false;
	}
   return true;
}

function validAddressForm(f)
{
   if(isEmpty(f.txtaddress.value))
	{
	  alert("Please enter Address.");
	  f.txtaddress.focus();
	  return false;
	}
  if(isEmpty(f.txttown.value))
	{
	  alert("Please enter Town.");
	  f.txttown.focus();
	  return false;
	}
   if(isEmpty(f.txtzipcode.value))
	{
	  alert("Please enter Postal Code.");
	  f.txtzipcode.focus();
	  return false;
	}
   if(isEmpty(f.txtcountry.value))
	{
	  alert("Please enter Country.");
	  f.txtcountry.focus();
	  return false;
	}
	if(isEmpty(f.txtdayphone.value))
	{
	  alert("Please enter Day Phone.");
	  f.txtdayphone.focus();
	  return false;
	}		
   if(f.txtdayphone.value!="")
   {
       var x = f.txtdayphone.value;
	   if(!isPhoneNumber(x))
	   {
	     alert("Please enter valid Phone Format. Valid Formats are (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000");
		 f.txtdayphone.focus();
		 return false;
	   }
   }
   return true;
}


function validAccountForm(f)
{
   if(isEmpty(f.txtpwd.value))
	{
	  alert("Please enter New Password.");
	  f.txtpwd.focus();
	  return false;
	}
	if(f.txtpwd.value!="")
	{
	  var x = f.txtpwd.value;
	  if(!isLength(x, 6))
	  {
	     alert("Password should be minimum 6 characters.");
		 f.txtpwd.focus();
		 return false;
	  }
	}
   if(isEmpty(f.txtconfirm.value))
	{
	  alert("Please enter Password for Confirmation.");
	  f.txtconfirm.focus();
	  return false;
	}
	if(f.txtpwd.value != f.txtconfirm.value)
   {
      alert("Please enter same Password for confirmation.");
	  f.txtconfirm.focus();
	  return false;
   }
   return true;  
}

function validateEmailForm(f)
{
   if(isEmpty(f.txtemail.value))
	{
	  alert("Please enter Email Address.");
	  f.txtemail.focus();
	  return false;
	}
	if(f.txtemail.value!="")
   {
      var x = f.txtemail.value;
	   if(!isEmail(x))
	   {
		  alert("Please enter valid Email Address.");
		  f.txtemail.focus();
		  return false;
	   }
   }
   return true;
}
function fnkeypress(obj)
{
   var txtObj;
   txtObj = obj.name;
   for(z=0;z<document.frmCart.length;z++)
			{
				if(document.frmCart.elements[z].name==txtObj)
				{
				   if((event.keyCode>=48 && event.keyCode<=57) || event.keyCode==46)
				   {
					  event.returnValue = true;
					}  
				   else
					   {
						 alert("Please enter only numeric values.");
						 document.frmCart.elements[z].value = "";
						 obj.focus();
						 event.returnValue =  false;
					   }	
				}
			}	
  }
function funcDel()
{
	var fnd = "";
	for(var i=0; i<document.frmCart.length; i++)
	{
       if(document.frmCart.elements[i].type == 'checkbox' && document.frmCart.elements[i].checked== true)
	   {
			fnd = document.frmCart.elements[i].value;
	   }	
    }
    if(fnd=="")
	{
		alert("Please select atleast one checkbox.");
		return false;
	}
    else
	 {
        document.frmCart.action1.value = "DeletefromCart";
        document.frmCart.submit();
     }
}
function checkout()
{
	document.frmCart.action1.value = "Checkout";
	document.frmCart.submit()
}
function fnupdate()
{
  document.frmCart.action1.value = "UpdateCart";
  document.frmCart.submit();  
}

function fncheckout()
{
  document.frmCart.action1.value = "Checkout";
  document.frmCart.submit();  
}

function fnaddtocart(pid, pcode, r, s, cname)
{
  
  document.frmList.prodid.value = pid;
  document.frmList.prodcode.value = pcode;
  document.frmList.rate.value = r;
  document.frmList.cursymbol.value = s;
  document.frmList.catname.value = cname;
}
function fnaddtocart1(pid, pcode, r, s, cname)
{
  document.frmList.prodid.value = pid;
  document.frmList.prodcode.value = pcode;
  document.frmList.rate.value = r;
  document.frmList.cursymbol.value = s;
  document.frmList.catname.value = cname;
  document.frmList.submit();
}

function validDeliveryForm(f)
{
   if(isEmpty(f.txtaddress.value))
	{
	  alert("Please enter Address.");
	  f.txtaddress.focus();
	  return false;
	}
  if(isEmpty(f.txttown.value))
	{
	  alert("Please enter Town.");
	  f.txttown.focus();
	  return false;
	}
   if(isEmpty(f.txtzipcode.value))
	{
	  alert("Please enter Postal Code.");
	  f.txtzipcode.focus();
	  return false;
	}
   if(isEmpty(f.txtcountry.value))
	{
	  alert("Please enter Country.");
	  f.txtcountry.focus();
	  return false;
	}
	if(isEmpty(f.ph1.value))
	{
	  alert("Please enter Country Code.");
	  f.ph1.focus();
	  return false;
	}	
    if(isEmpty(f.ph2.value))
	{
	  alert("Please enter Area Code.");
	  f.ph2.focus();
	  return false;
	}
    if(isEmpty(f.ph3.value))
	{
	  alert("Please enter Phone Number.");
	  f.ph3.focus();
	  return false;
	}		
	if(!isEmpty(f.ph1.value))
	{
	   if(!isNumeric(f.ph1.value))
      {
		alert("Please enter Only Numeric Values.");
	  	f.ph1.focus();
	  	return false;
	  }
	}
   if(!isEmpty(f.ph2.value))
	{
	   if(!isNumeric(f.ph2.value))
      {
		alert("Please enter Only Numeric Values.");
	  	f.ph2.focus();
	  	return false;
	  }
	}
   if(!isEmpty(f.ph3.value))
	{
	   if(!isNumeric(f.ph3.value))
      {
		alert("Please enter Only Numeric Values.");
	  	f.ph3.focus();
	  	return false;
	  }
	}
 if(document.frmDelivery.optdelshipping[0].checked == false && document.frmDelivery.optdelshipping[1].checked == false
	&& document.frmDelivery.optdelshipping[2].checked == false)
  {
     alert("Please choose one Shipping option.");
     document.frmDelivery.optdelshipping[0].focus();
     return false;
  }
   f.action1.value = "Adddeliverydetails";
   return true;
}


function fnconfirm()
{
  if(document.frmDelivery.optaddress[0].checked == false && document.frmDelivery.optaddress[1].checked == false)
  {
     alert("Please choose one option.");
     document.frmDelivery.optaddress[0].focus();
     return false;
  }
  if(document.frmDelivery.optshipping[0].checked == false && document.frmDelivery.optshipping[1].checked == false
	&& document.frmDelivery.optshipping[2].checked == false)
  {
     alert("Please choose one Shipping option.");
     document.frmDelivery.optshipping[0].focus();
     return false;
  }
  document.frmDelivery.action1.value = "Confirm";
  document.frmDelivery.submit();  
}

function y2k(number) 
{
	return (number < 1000) ? number + 1900 : number;
}
function isDate (month,day,year) 
{
	var today = new Date();
	var test = new Date(year,month,day);
	if ( (test.getYear() == year) && (month == test.getMonth()) && (day == test.getDate()))
		return true;
	else
		return false;
}

function validCardForm(f)
{
 	/*if(f.ccType.value=="0")
	{
	  alert("Please select Card Type.");
		f.ccType.focus();
		return false;
	}
	if(f.x_card_num.value=="")
	{
		alert("Please enter a value for the 'Credit Card Number'.");
		f.x_card_num.focus();
		return false;
	}
	
	 if(f.x_card_num.value!="")
	   {
	       if(isNaN(f.x_card_num.value))
		   {
		       alert("please enter valid Card Number.");
			   f.x_card_num.focus();
			   return false;
		   }
	   }
	    if(f.x_card_name.value=="")
	   { 
	   		alert("please enter your Card Name.");
	  		f.x_card_name.focus();
	   		return false;
	   }
	   if(f.expmn.value=="-1")
	   { 
	   alert("please select Card Expiry  Month.");
	   f.expmn.focus();
	   return false;
	   }
	   
	   if(f.expyr.value=="-1")
	   { 
	   alert("please select Card Expiry  Year.");
	   f.expyr.focus();
	   return false;
	   }  
	   if(f.expmn.value!="-1" && f.expyr.value!="-1")
	   {
	      var dat = new Date();
		  var expmn = parseInt(f.expmn.value);
		  var expyr = parseInt(f.expyr.value);
		 	  if(expyr<dat.getFullYear())
			  {
				 alert("please select Valid Card Expiry Duration.");
				 f.expyr.focus();
				 return false;
			  }
			  if(expyr==dat.getFullYear()) 
			  {
				   if(expmn-1 < dat.getMonth()) 
				  {
					 alert("please select Valid Card Expiry Duration.");
					 f.expmn.focus();
					 return false;
				  }
			  }
	   }
	   if(f.CVV2.value=="")
	   { 
		   alert("please enter Security Code.");
		   f.CVV2.focus();
		   return false;
	   }  
	   if(f.CVV2.value!="")
	   {
	      var st = f.CVV2.value;
		  if(isNaN(f.CVV2.value))
		  {
		       alert("Please enter 3 or 4 Digit Security Code.");
			   f.CVV2.focus();
			   return false;
		  }
		  
		  if(!(st.length==3 || st.length==4))
		  {
		       alert("please enter 3 or 4 Digit Security Code.");
			   f.CVV2.focus();
			   return false;
		  }
	   }*/
	return true;
}

function validateContactForm(f)
{
   if(isEmpty(f.fname.value))
	{
	  alert("Please enter First Name.");
	  f.fname.focus();
	  return false;
	}
	if(isEmpty(f.lname.value))
	{
	  alert("Please enter Last Name.");
	  f.lname.focus();
	  return false;
	}
	if(isEmpty(f.phone.value))
	{
	  alert("Please enter Phone.");
	  f.phone.focus();
	  return false;
	}		
   if(f.phone.value!="")
   {
       var x = f.phone.value;
	   if(isNaN(x))
	   {
	     alert("Please enter valid Phone Format.");
		 f.phone.focus();
		 return false;
	   }
   }
	if(isEmpty(f.email.value))
	{
	  alert("Please enter Email Address.");
	  f.email.focus();
	  return false;
	}
	if(f.email.value!="")
   {
      var x = f.email.value;
	   if(!isEmail(x))
	   {
		  alert("Please enter valid Email Address.");
		  f.email.focus();
		  return false;
	   }
   }
   if(isEmpty(f.subject.value))
	{
	  alert("Please enter Subject.");
	  f.subject.focus();
	  return false;
	}
	if(isEmpty(f.message.value))
	{
	  alert("Please enter Message.");
	  f.message.focus();
	  return false;
	}
   return true;
}

function validMemberContactForm(f)
{
	if(isEmpty(f.phone.value))
	{
	  alert("Please enter Phone.");
	  f.phone.focus();
	  return false;
	}		
   if(f.phone.value!="")
   {
       var x = f.phone.value;
	   if(isNaN(x))
	   {
	     alert("Please enter valid Phone Format.");
		 f.phone.focus();
		 return false;
	   }
   }
	
   if(isEmpty(f.subject.value))
	{
	  alert("Please enter Subject.");
	  f.subject.focus();
	  return false;
	}
	if(isEmpty(f.message.value))
	{
	  alert("Please enter Message.");
	  f.message.focus();
	  return false;
	}
   return true;
}
function IsPhone(strString)	
{
   //alert("IsNumeric");
   var strValidChars = "+-()1234567890 ";
   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("Invalid Phone Number.");
         	blnResult = false;
         }
      }
   return blnResult;
}
function validateEnquiryForm(f)
{
     if(isEmpty(f.txtname.value))
	{
	  alert("Please enter  Name.");
	  f.txtname.focus();
	  return false;
	}
	
	if(isEmpty(f.txtphone.value))
	{
	  alert("Please enter Phone.");
	  f.txtphone.focus();
	  return false;
	}		
   if(f.txtphone.value!="")
   {
       var x = f.txtphone.value;
	   if(!IsPhone(x))
	   {
	     f.txtphone.value = "";
		 f.txtphone.focus();
		 return false;
	   }
   }
   if(f.txtfax.value!="")
   {
       var x = f.txtfax.value;
	   if(!IsPhone(x))
	   {
	     f.txtfax.value = "";
		 f.txtfax.focus();
		 return false;
	   }
   }
	if(isEmpty(f.txtemail.value))
	{
	  alert("Please enter Email Address.");
	  f.txtemail.focus();
	  return false;
	}
	if(f.txtemail.value!="")
   {
      var x = f.txtemail.value;
	   if(!isEmail(x))
	   {
		  alert("Please enter valid Email Address.");
		  f.txtemail.focus();
		  return false;
	   }
   }
   if(isEmpty(f.txtsubject.value))
	{
	  alert("Please enter Subject.");
	  f.txtsubject.focus();
	  return false;
	}
	if(isEmpty(f.txtcontent.value))
	{
	  alert("Please enter Contents.");
	  f.txtcontent.focus();
	  return false;
	}
   return true;
}
function fndeliverycontinue()
{
  if(document.frmDelivery.optaddress[0].checked == false && document.frmDelivery.optaddress[1].checked == false)
  {
     alert("Please choose one option.");
     document.frmDelivery.optaddress[0].focus();
     return false;
  }
}
function fndelivery()
{
   if(document.frmDelivery.optaddress[0].checked == true)
	{
		divshipping.style.display = 'block';
		divdelivery.style.display = 'none';
		divdeliveryshipping.style.display = 'none';
		trcontinue1.style.display = 'none';
	}
   else if(document.frmDelivery.optaddress[1].checked == true)
	{
		divdelivery.style.display = 'block';
		divdeliveryshipping.style.display = 'block';
		divshipping.style.display = 'none';
		trcontinue1.style.display = 'none';
	}
}

function validateQuoteForm(f)
{
   if(isEmpty(f.lstbusiness.value))
	{
	  alert("Please select Organisation.");
	  f.lstbusiness.focus();
	  return false;
	}
   if(isEmpty(f.txtbusiness.value))
	{
	  alert("Please enter Buiseness Name.");
	  f.txtbusiness.focus();
	  return false;
	}
   if(isEmpty(f.txtcontact.value))
	{
	  alert("Please enter Contact Name.");
	  f.txtcontact.focus();
	  return false;
	}
   if(isEmpty(f.txtphone.value))
	{
	  alert("Please enter Phone Number.");
	  f.txtphone.focus();
	  return false;
	}
   if(f.txtphone.value != "")
   {
		var valid= "+-()1234567890 ";
		if (f.txtphone.value !="")
		{
			var string = f.txtphone.value
			var length = string.length;
			for(var i=0;i<=length;i++)
			{
				var substring = string.substr(i,1);
				if(valid.indexOf(substring)== -1)
				{
					alert("Invalid Phone No.");
					f.txtphone.select();
					return(false);
				}
			}
		}
   }
   if(isEmpty(f.txtemail.value))
	{
	  alert("Please enter Email Address.");
	  f.txtemail.focus();
	  return false;
	}
	if(f.txtemail.value!="")
   {
      var x = f.txtemail.value;
	   if(!isEmail(x))
	   {
		  alert("Please enter valid Email Address.");
		  f.txtemail.focus();
		  return false;
	   }
   }
    if(isEmpty(f.txtpname.value) && isEmpty(f.txtpcode.value))
	{
	  alert("Please enter either Product Name/ Product Code.");
	  f.txtpname.focus();
	  return false;
	}
  if(isEmpty(f.txtitem.value))
	{
	  alert("Please enter No. of Items.");
	  f.txtitem.focus();
	  return false;
	}
  if(f.txtitem.value!="")
	{
	   if(!isNumeric(f.txtitem.value))
       {
	     alert("Please enter only Numeric values.");
	  	 f.txtitem.focus();
	     return false;
	  }
	}
  return true;
}

function validateReferForm(f)
{
    if(isEmpty(f.txtname1.value))
	{
	  alert("Please enter Your Name.");
	  f.txtname1.focus();
	  return false;
	}
	if(isEmpty(f.txtemail1.value))
	{
	  alert("Please enter Your Email Address.");
	  f.txtemail1.focus();
	  return false;
	}
	if(f.txtemail1.value!="")
   {
      var x = f.txtemail1.value;
	   if(!isEmail(x))
	   {
		  alert("Please enter valid Email Address.");
		  f.txtemail1.focus();
		  return false;
	   }
   }
  if(isEmpty(f.txtname2.value))
	{
	  alert("Please enter Your Friend's Name.");
	  f.txtname2.focus();
	  return false;
	}
	if(isEmpty(f.txtemail2.value))
	{
	  alert("Please enter Your Friend's Email Address.");
	  f.txtemail2.focus();
	  return false;
	}
	if(f.txtemail2.value!="")
   {
      var x = f.txtemail2.value;
	   if(!isEmail(x))
	   {
		  alert("Please enter valid Email Address.");
		  f.txtemail2.focus();
		  return false;
	   }
   }
   return true;
}