
function emailvalidation(target, alertbox)
{
    var targetobj=document.getElementById(target);
    
    apos=targetobj.value.indexOf("@"); 
     
    dotpos=targetobj.value.lastIndexOf(".");
        
    lastpos=targetobj.value.length-1;
        
    if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
    {
        if (alertbox)
        {
            alert(alertbox);
        }
        return false;
    }
    else
    {
        return true;
    }
}
   
    
function emailvalidationConditional(target, alertbox)
{
    var targetobj=document.getElementById(target);
    
    apos=targetobj.value.indexOf("@"); 
     
    dotpos=targetobj.value.lastIndexOf(".");
        
    lastpos=targetobj.value.length-1;
     if( targetobj.value=="") 
     {
     return true;
     }
     else
     { 
    if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
    {
        if (alertbox)
        {
            alert(alertbox);
        }
        return false;
    }
    else
    {
        return true;
    }
    }
}




function emptyvalidation(target, alertbox)
{
    var targetobj=document.getElementById(target);
   
//    alert(targetobj);
    if (targetobj.value==null || targetobj.value=="")
    {
    //alert(target);
        if (alertbox!="")
        {
            alert(alertbox);
        }
        return false;
    }
    else
    {
        return true;
    }
}
//to check textboxes
function customvalidation(target, alertbox1,numbers,alertbox2,flag)
{
    var targetobj=document.getElementById(target);
    var flg=flag;
//    alert(target);
//    alert(targetobj);

    if (targetobj.value==null || (targetobj.value > numbers && flg==0))
    {
        if (alertbox1!="")
        {
            alert(alertbox1);
        }
        return false;
    }
    else if(targetobj.value==null || (targetobj.value=="" && flg==1))
    {
        if (alertbox2!="")
        {
            alert(alertbox2);
        }
        return false;
    }
    else
    {
        return true;
    }
}
function CameraValidation(target1,target2,alertbox)
{
   var selected1 = document.getElementById(target1);
   var selected2=  document.getElementById(target2);

if (selected1.value ==0 && selected2.value =="") 
{
      if (alertbox!="")
        {
            alert(alertbox);
        }
       return false;
}

 else
 {
 return true;
 }

}
function emptyvalidationPASSWORD(target, lbl, alertbox)
{
    var targetlbl=document.getElementById(lbl);
    var targetobj=document.getElementById(target);
    
    if(targetobj.value==null || targetobj.value=="")
    {
        if(targetlbl.value==null || targetlbl.value=="")
        {        
            if (alertbox!="")
            {
                alert(alertbox);
            }
            return false;
        }
        else
        {
            return true;
        }
    }
    else
        return true;
}

//DropDownList Validation
function DropDownValidation()
{

if (document.getelementbyid("forum__ctl0_category").value == 0)
{
alert('Plese select value for dropdown')
return false;
}
return true;
}


 

function valuevalidation(entered, min, max, alertbox, datatype)
{
    with (entered)
    {
        checkvalue=parseFloat(value);
        if (datatype)
        {
            smalldatatype=datatype.toLowerCase();
            if (smalldatatype.charAt(0)=="i")
            {
                checkvalue=parseInt(value)
            };
        }
        if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
        {
            if (alertbox!="")
            {
                alert(alertbox);
            }
            return false;
        }
        else
        {
            return true;
        }
    }
}

function setfocus(a_field_id)
{
    $(a_field_id).focus()
}



 function isInteger (s)
   {
      var i;

//      if (isInteger.arguments.length == 1)
//        return 0;
//      else
//        return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
   }
    /*Numeric Validation*/
  function IsNumeric(sText,target)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
      if(IsNumber==false)
      alert(target);
   return IsNumber;
   
   }

 function ValidateNumber(sText,target)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
      if(IsNumber==false)
      alert(target);
   return IsNumber;
   
   }






//    function validateNumbers(obj,target)
//    {
//        alert('validateNumbers');
//      if (!IsNumeric(obj.value)) 
//      {
//      
//      alert('Please enter only numbers or decimal points in the account field'); 
//      //form.account_number.focus(); 
//      return false; 
//      } 
//        return true;
//    } 
  /*--------------------------------------------*/
    
	



 /*
 function isEmpty(s)
   {
      return ((s == null) || (s.length == 0))
   }
*/
   function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }

 function validateInt(target, alertbox)
   {
     var o = document.getElementById(target);
     if (!isInteger(o.value)) 
        { 
         alert(alertbox);
         return false;
         }
         else
         {
         return true;
      }
   }
   
   function comparevalidation(first, second, alertbox)
{
    var firstobj=document.getElementById(first);
    var secondobj=document.getElementById(second);
    
    if(firstobj.value==secondobj.value)
        return true;
    else
    {
        if (alertbox!="")
        {
            alert(alertbox);
        }
        return false
    }
}

function CheckValidation(AffiliateID)
{
   return (emptyvalidation(AffiliateID,'AffiliateID Can\'t be blank') && validateAffNo(AffiliateID,'AffiliateID must be 6 digits no'));
   
}

    function RPISettingValidation(FoodMinWage,Barallocation,Waiterspoints,BusboyPoints,RunnerPoints)
    {
        //alert(FoodMinWage);
       // emptyvalidation(Barallocation,'Barallocation Is Blanck!!') 
         
        return(validateInt(FoodMinWage,'FoodMinWage Must be numbers') && emptyvalidation(FoodMinWage,'FoodMinWage Is Blanck') && validateInt(Barallocation,'Barallocation Must be numbers')  && emptyvalidation(Barallocation,'Barallocation Is Blanck!!')  && emptyvalidation(Waiterspoints,'Waiterspoints Is  Blanck !!!')  && validateInt(Waiterspoints,'Waiterspoints Must be numbers') && validateInt(BusboyPoints,'BusboyPoints Must be numbers')  &&  emptyvalidation(BusboyPoints,'BusboyPoints Is Blanck!!')   && emptyvalidation(RunnerPoints,'RunnerPoints Is Blanck!!')  && validateInt(RunnerPoints,'RunnerPoints Must be numbers'));
        //return (IsNumeric(FoodMinWage) && IsNumeric(Barallocation) &&  IsNumeric(Waiterspoints) &&  IsNumeric(BusboyPoints) &&  IsNumeric(RunnerPoints));
    }

function login_validation(user, pass)
{
    
    return (emptyvalidation(user, 'Empty user name!') && emptyvalidation(pass, 'Empty password!'));
}
//function Insert_Category_validation(Catname)
//{
//  return (emptyvalidation(Catname, 'Empty Category name!'));
//}
function Insert_Category_validation(type,Catname)
{
   
  return (valDropDownList(type,'You must select a Type') && emptyvalidation(Catname, 'Empty Category name!'));
}
function  Create_Product(productname,WeekRate,wkRate,DayRate,hrRate,Type)
{
 return (valDropDownList(Type,'You must select a Type') && emptyvalidation(productname, 'Empty Product name!') && emptyvalidation(WeekRate, 'Empty Week Rate!') && emptyvalidation(wkRate, 'Empty Four Week Rate!')  && emptyvalidation(DayRate, 'Empty Day Rate!') && emptyvalidation(hrRate, 'Empty Hour Rate!'));
}

function Reserpassword_validation(user)
{
        return (emptyvalidation(user, 'Empty User ID!'));
}
//===========================================================================
function createuser_validation(fname,lname,Chkpay,Tax,hph1,hph2,hph3,wp1,wp2,wp3,address,city,country,statecanada,state, zip,Broughtuby,useremial,ConfEmail,pass,connpass, re_pass,captcha,url,opt1,opt2,opt3,opt4)
{
    return (emptyvalidation(fname, 'First Name cannot be empty!') && emptyvalidation(lname, 'Last Name cannot be empty!') && emptyvalidation(Chkpay, 'Please Enter Checks Payble Info!') && emptyvalidation(Tax, 'Field Empty.Please Enter The SS#/TaxID#!') && validateTax(Tax, 'Tax number must 9 digits') && validatePhonenew(hph1, hph2, hph3) && emptyvalidation(hph3, 'Home telephone number Can\'t be blank') && validatePhonenew(wp1, wp2, wp3) && emptyvalidation(address, 'Address cannot be empty!') && CheckAllLenght(address, 300) && emptyvalidation(city, 'City cannot be empty!') && valCountryStates(country, statecanada, state) && emptyvalidation(zip, 'Zip cannot be empty!') && validateZip(zip, 'Zip should be 5 digit!') && emptyvalidation(Broughtuby, 'Brought You By Field  cannot be empty!') && emptyvalidation(useremial, 'Email Address/Username cannot be empty!') && emailvalidation(useremial, 'Invalid Email Id!') && comparevalidation(useremial, ConfEmail, 'Email-Address  Mismatch!') && emptyvalidation(pass, 'Password cannot be empty!') && comparevalidation(pass, connpass, 'Password   Mismatch!') && isURL(url) && emptyvalidation(captcha, 'Please Enter Captcha!') && chk_arg(opt1, 'Please read and aceept the Agreement of option 1 before continuing.') && chk_arg(opt2, 'Please read and aceept the Agreement of option 2 before continuing.') && chk_arg(opt3, 'Please read and aceept the Agreement of option 3 before continuing.') && chk_arg(opt4, 'Please read and aceept the Agreement of option 4 before continuing.') && emptyvalidation(name, 'Name cannot be empty!') && emptyvalidation(phone, 'Phone cannot be empty!') && validatePhone(phone, 'Invalid Phone no!') && emptyvalidation(email, 'E-Mail cannot be empty!') && emailvalidation(email, 'Invalid Email Id!'));
}

function valCountryStates(country,statecanada,state)
{
//alert('1111');
//var a=document.getElementById(country);
//alert(a);
 if(document.getElementById(country).selectedIndex==0)
    {
          alert('Please Select Country');
           return false;
    }
    if(document.getElementById(country).selectedIndex==1)
    {
        if(document.getElementById(statecanada).selectedIndex==0)
        {
             alert('Please Select State');
             return false;
        }
        else
        {
            return true;
        }
    }
    if(document.getElementById(country).selectedIndex==2)
    {
         if(document.getElementById(state).selectedIndex==0)
        {
             alert('Please Select state');
             return false;
        }
         else
        {
            return true;
        }
    }
}

function updateuser_validation(fname,lname,Chkpay,Tax,hph1,hph2,hph3,wp1,wp2,wp3,address,city,country,statecanada,state, zip,Broughtuby,useremial,ConfEmail,pass,connpass, re_pass,url,opt1,opt2,opt3,opt4,opt5,name,  phone, email)
{
    return (emptyvalidation(fname, 'First Name cannot be empty!') && emptyvalidation(lname, 'Last Name cannot be empty!') && emptyvalidation(Chkpay, 'Field empty. Please Enter The Payble!') && emptyvalidation(Tax, 'Field Empty.Please Enter The SS#/TaxID#!') && validateTax(Tax, 'Tax number must 9 digits') && validatePhonenew(hph1, hph2, hph3) && emptyvalidation(hph3, 'Home telephone number Can\'t be blank') && validatePhonenew(wp1, wp2, wp3) && emptyvalidation(address, 'Address cannot be empty!') && CheckAllLenght(address, 300) && emptyvalidation(city, 'City cannot be empty!') && valCountryStates(country, statecanada, state) && emptyvalidation(zip, 'Zip cannot be empty!') && validateZip(zip, 'Zip should be 5 digit!') && emptyvalidation(Broughtuby, 'Brought you By Field  cannot be empty!') && emptyvalidation(useremial, 'Email Address/Username cannot be empty!') && emailvalidation(useremial, 'Invalid Email Id!') && comparevalidation(useremial, ConfEmail, 'Email-Address  Mismatch!') && comparevalidation(pass, connpass, 'Password   Mismatch!') && isURL(url) && chk_arg(opt1, 'Please read and aceept the Agreement of option 1 before continuing.') && chk_arg(opt2, 'Please read and aceept the Agreement of option 2 before continuing.') && chk_arg(opt3, 'Please read and aceept the Agreement of option 3 before continuing.') && chk_arg(opt4, 'Please read and aceept the Agreement of option 4 before continuing.') && emptyvalidation(name, 'Name cannot be empty!') && emptyvalidation(phone, 'Phone cannot be empty!') && validatePhone(phone, 'Invalid Phone no!') && emptyvalidation(email, 'E-Mail cannot be empty!') && emailvalidation(email, 'Invalid Email Id!'));
}
function updateuser_validationbyAdmin(fname,lname,Chkpay,Tax,hph1,hph2,hph3,address,city,country,statecanada,state, zip,Broughtuby,useremial,ConfEmail,pass,connpass, re_pass,url,comm)
{
   return (emptyvalidation(fname,'First Name cannot be empty!') && emptyvalidation(lname,'Last Name cannot be empty!') && emptyvalidation(Chkpay,'Field empty. Please Enter The Payble!') && emptyvalidation(Tax,'Field Empty.Please Enter The SS#/TaxID#!') && validateTax(Tax,'Tax number must 9 digits') && validatePhonenew(hph1,hph2,hph3)&& emptyvalidation(hph3,'Home telephone number Can\'t be blank') &&  emptyvalidation(address, 'Address cannot be empty!') && CheckAllLenght(address,300) && emptyvalidation(city, 'City cannot be empty!') && valCountryStates(country,statecanada,state) && emptyvalidation(zip, 'Zip cannot be empty!') && validateZip(zip, 'Zip should be 5 digit!') && emptyvalidation(Broughtuby,'Brought you By Field  cannot be empty!') && emptyvalidation(useremial,'Email Address/Username cannot be empty!')&& emailvalidation(useremial, 'Invalid Email Id!') && comparevalidation(useremial, ConfEmail, 'Email-Address  Mismatch!') && comparevalidation(pass, connpass, 'Password   Mismatch!')   &&  isURL(url) && emptyvalidation(comm,'Field empty. Please Enter The Commission!') && validateInt(comm, 'Please enter a valid data!') );
}
function CustomerInfoValidation(FirstName,LastName,hph1,hph2,hph3,wph,wph1,wph2,Email,Address,City,State,Zip)
{
     return (emptyvalidation(FirstName,'First name Can\'t be blank') && emptyvalidation(LastName,'Last name Can\'t be blank') && emptyvalidation(hph1,'Home telephone number Can\'t be blank') && emptyvalidation(hph2,'Home telephone number Can\'t be blank')&& emptyvalidation(hph3,'Home telephone number Can\'t be blank') && validatePhonenew(hph1,hph2,hph3) && emptyvalidation(wph,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph1,'Cellular phone/work phone can\'t be blank ') && emptyvalidation(wph2,'Cellular phone/work phone Can\'t be blank ') && validatePhonenew(wph,wph1,wph2) && emptyvalidation(Email,'Email Can\'t be blank') && emailvalidation(Email,'Please check email') && emptyvalidation(Address,'Address Can\'t be blank') && emptyvalidation(City,'City Can\'t be blank') && valDropDownList(State,'Please select any state') && emptyvalidation(Zip,'Zip Can\'t be blank'));
}

//function OrderValidation(FirstName,LastName,Phone,Zip,Email,Question)
//{
//    return(emptyvalidation(FirstName,'First name Can\'t be blank') && emptyvalidation(LastName,'Last name Can\'t be blank') && emptyvalidation(Phone,'Phone Can\'t be blank') && validatePhone(Phone,'Phone no must be 10 digits') && emptyvalidation(Zip,'Zip code Can\'t be blank') && validateZip(Zip,'Zip code must be 5 digits') && emailvalidationConditional(Email,'Please check your email') && CheckAllLenght(Question,2000,'Enter question within'));
//}

function OrderValidation(FirstName, LastName, Phone, Zip, Email, Question) 
{    
    return (emptyvalidation(FirstName, 'First name Can\'t be blank') && emptyvalidation(LastName, 'Last name Can\'t be blank') && emptyvalidation(Phone, 'Phone Can\'t be blank') && validatePhone(Phone, 'Phone no must be 10 digits') && emptyvalidation(Zip, 'Zip code Can\'t be blank') && validateZip(Zip, 'Zip code must be 5 digits') && emailvalidationConditional(Email, 'Please check your email') && CheckAllLenght(Question, 2000, 'Enter question within'));
}
function SetCaptchaValue(FirstName, LastName, Phone, Zip, Email, Question, Captcha) {
    //alert('SetCaptcha');
    if (OrderValidation(FirstName, LastName, Phone, Zip, Email, Question, Captcha) == true) {
        
        var Captcha = document.getElementById(Captcha).value = '1234';
        return true;
    }
    else {
        return false;
    }
}
function PolishOrderValidation(FirstName,LastName,Phone,Zip,Email,Question)
{
    return(emptyvalidation(FirstName,'Imię nie może być puste') && emptyvalidation(LastName,'Nazwisko nie może być puste') && emptyvalidation(Phone,'Telefon nie może być puste') && validatePhone(Phone,'Telefon nie musi być 10 cyfr') && emptyvalidation(Zip,'Kod nie może być puste') && validateZip(Zip,'Kod musi być 5 cyfr') && emailvalidationConditional(Email,'Sprawdź swoją pocztę') && CheckAllLenghtPolish(Question,2000,'Wpisz pytanie w 2000 znaków'));
}

function SetPolishCaptchaValue(FirstName, LastName, Phone, Zip, Email, Question, Captcha) {
    //alert('SetPolishCaptchaValue');
    if (PolishOrderValidation(FirstName, LastName, Phone, Zip, Email, Question, Captcha) == true) {

        var Captcha = document.getElementById(Captcha).value = '1234';
        return true;
    }
    else {
        return false;
    }
 
}

function ValidateNext(ID,Name)
{
    return(emptyvalidation(ID,'ID Can\'t be blank') && emptyvalidation(Name,'Name Can\'t be blank'));
}

function ValidateUploadFlyer(BannerName,Description,UploadFile)
{
     return(emptyvalidation(BannerName,'Banner name can\'t be blank') && CheckAllLenght(Description,300,'Enter description within 300 Character  ') && FlyerUploadValidation(UploadFile));
}

 function HelpDocumentValidation(DocName,Description,uploadHelpDoc)
 {
    return (emptyvalidation(DocName,'Document name can\'t be blank') && CheckAllLenght(Description,300,'Enter description within') && UploadValidation(uploadHelpDoc,'Please upload file'));
 }


   
function ValidateEditCustomer(FirstName,LastName,hph1,hph2,hph3,wph,Email,Address,City,State,Zip,Notes)
{
   return (emptyvalidation(FirstName,'First name Can\'t be blank') && emptyvalidation(LastName,'Last name Can\'t be blank') && validatePhonenew(hph1,hph2,hph3) && emptyvalidation(wph,'Cellular phone/work phone Can\'t be blank ') && validatePhone(wph,'Enter correct Phone number') && emptyvalidation(Email,'Email Can\'t be blank') && emailvalidation(Email,'Please check email') && emptyvalidation(Address,'Address Can\'t be blank') && emptyvalidation(City,'City Can\'t be blank') && emptyvalidation(State,'State Can\'t be blank') && emptyvalidation(Zip,'Zip Can\'t be blank') && CheckLenght(Notes)) ;
}

//function ValidateAdminEditCustomer(FirstName,LastName,hph1,hph2,hph3,wph1,wph2,wph3,Email,Address,City,State,Zip,TaxID,SS1,SS2,SS3,DOB,RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV,Phone1,Phone2,Phone3)
//{
//    return (emptyvalidation(FirstName,'First name Can\'t be blank') && emptyvalidation(LastName,'Last name Can\'t be blank') && validatePhonenew(hph1,hph2,hph3) && emptyvalidation(wph1,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph2,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph3,'Cellular phone/work phone Can\'t be blank ') && validatePhonenew(wph1,wph2,wph3) && emptyvalidation(Email,'Email Can\'t be blank') && emailvalidation(Email,'Please check email') && emptyvalidation(Address,'Address Can\'t be blank') && emptyvalidation(City,'City Can\'t be blank') && emptyvalidation(State,'State Can\'t be blank') && emptyvalidation(Zip,'Zip Can\'t be blank') && emptyvalidation(TaxID,'TaxID Can\'t be blank') && validateTax(TaxID,'TaxID number must 9 digits') && emptyvalidation(SS1,'SS number Can\'t be blank') && emptyvalidation(SS2,'SS number Can\'t be blank') && emptyvalidation(SS3,'SS number Can\'t be blank') && validateSS(SS1,SS2,SS3) && emptyvalidation(DOB,'date of birth Can\'t be blank') && checkRadioButton() && CheckPaymentInfo(RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV) && validatePhone(Phone1,'Phone number must be 10 digits') && validatePhone(Phone2,'Phone number must be 10 digits') && validatePhone(Phone3,'Phone number must be 10 digits')) ;
//}
function ValidateAdminEditCustomer(FirstName,LastName,hph1,hph2,hph3,wph1,wph2,wph3,Email,Address,City,State,Zip,Package,TaxID,SS1,SS2,SS3,DOB,RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV,Phone1,Phone2,Phone3)
{
    return (emptyvalidation(FirstName,'First name Can\'t be blank') && emptyvalidation(LastName,'Last name Can\'t be blank') && validatePhonenew(hph1,hph2,hph3) && emptyvalidation(wph1,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph2,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph3,'Cellular phone/work phone Can\'t be blank ') && validatePhonenew(wph1,wph2,wph3) && emptyvalidation(Email,'Email Can\'t be blank') && emailvalidation(Email,'Please check email') && emptyvalidation(Address,'Address Can\'t be blank') && emptyvalidation(City,'City Can\'t be blank') && emptyvalidation(State,'State Can\'t be blank') && emptyvalidation(Zip,'Zip Can\'t be blank') && valDropDownList(Package,'Please select any package') && validateTax(TaxID,'TaxID number must 9 digits') && validateSS(SS1,SS2,SS3)   && CheckPaymentInfo(RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV) && validatePhone(Phone1,'Phone number must be 10 digits') && validatePhone(Phone2,'Phone number must be 10 digits') && validatePhone(Phone3,'Phone number must be 10 digits')) ;
}

function ValidateAdminInsertCustomer(FirstName,LastName,hph1,hph2,hph3,wph1,wph2,wph3,Email,Address,City,State,Zip,TaxID,SS1,SS2,SS3,DOB,RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV,Phone1,Phone2,Phone3)
{
    return (emptyvalidation(FirstName,'First name Can\'t be blank') && emptyvalidation(LastName,'Last name Can\'t be blank') && validatePhonenew(hph1,hph2,hph3) && emptyvalidation(wph1,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph2,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph3,'Cellular phone/work phone Can\'t be blank ') && validatePhonenew(wph1,wph2,wph3) && emptyvalidation(Email,'Email Can\'t be blank') && emailvalidation(Email,'Please check email') && emptyvalidation(Address,'Address Can\'t be blank') && emptyvalidation(City,'City Can\'t be blank') && emptyvalidation(State,'State Can\'t be blank') && emptyvalidation(Zip,'Zip Can\'t be blank')  && validateTax(TaxID,'TaxID number must 9 digits') && validateSS(SS1,SS2,SS3)   && CheckPaymentInfo1(RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV) && validatePhone(Phone1,'Phone number must be 10 digits') && validatePhone(Phone2,'Phone number must be 10 digits') && validatePhone(Phone3,'Phone number must be 10 digits')) ;
}
//function ValidateAdminInsertCustomer(FirstName,LastName,hph1,hph2,hph3,wph1,wph2,wph3,Email,Address,City,State,Zip,TaxID,SS1,SS2,SS3,DOB,RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV,Phone1,Phone2,Phone3)
//{
//    return (emptyvalidation(FirstName,'First name Can\'t be blank') && emptyvalidation(LastName,'Last name Can\'t be blank') && validatePhonenew(hph1,hph2,hph3) && emptyvalidation(wph1,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph2,'Cellular phone/work phone Can\'t be blank ') && emptyvalidation(wph3,'Cellular phone/work phone Can\'t be blank ') && validatePhonenew(wph1,wph2,wph3) && emptyvalidation(Email,'Email Can\'t be blank') && emailvalidation(Email,'Please check email') && emptyvalidation(Address,'Address Can\'t be blank') && emptyvalidation(City,'City Can\'t be blank') && emptyvalidation(State,'State Can\'t be blank') && emptyvalidation(Zip,'Zip Can\'t be blank') && emptyvalidation(TaxID,'TaxID Can\'t be blank') && validateTax(TaxID,'TaxID number must 9 digits') && emptyvalidation(SS1,'SS number Can\'t be blank') && emptyvalidation(SS2,'SS number Can\'t be blank') && emptyvalidation(SS3,'SS number Can\'t be blank') && validateSS(SS1,SS2,SS3) && emptyvalidation(DOB,'date of birth Can\'t be blank') && checkRadioButton() && CheckPaymentInfo1(RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV) && validatePhone(Phone1,'Phone number must be 10 digits') && validatePhone(Phone2,'Phone number must be 10 digits') && validatePhone(Phone3,'Phone number must be 10 digits')) ;
//}
function CheckPaymentInfo(RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV)
{
    //alert('Hi');
   var radio=document.getElementsByName('RbtnPayment');
   
//   if (radio[0].checked)
//   {
////      return (emptyvalidation(BankName,'Bank name Can\'t be blank') && emptyvalidation(RoutingNo,'Routing no Can\'t be blank') && IsNumeric(RoutingNo) && emptyvalidation(AccountNo,'Account no Can\'t be blank') && IsNumeric(AccountNo));
//   }
    if(radio[1].checked)
    {
       //alert('1');
       return (emptyvalidation(BankName,'Bank name Can\'t be blank') && emptyvalidation(RoutingNo,'Routing no Can\'t be blank') && IsNumeric(RoutingNo) && emptyvalidation(AccountNo,'Account no Can\'t be blank'));
    }
  else if(radio[2].checked)
    {
       //alert('2');
       return (emptyvalidation(CC,'CC Can\'t be blank') && validateCC(CC,'CC must be 16 digits') && valDropDownList(Month,'Select Month') && valDropDownList(Year,'Select year') && emptyvalidation(CVV,'CVV Can\'t be blank') && validateCVV(CVV,'CVV must be 4 digits number'));
       
    }
    else
    {
    return true;
    }
}

function CheckPaymentInfo1(RbtnPayment,BankName,RoutingNo,AccountNo,CC,Month,Year,CVV)
{
    //alert('Hi');
   var radio=document.getElementsByName('ctl00$ContentPlaceHolder1$rbtnPayment');
   
//   if (radio[0].checked)
//   {
////      return (emptyvalidation(BankName,'Bank name Can\'t be blank') && emptyvalidation(RoutingNo,'Routing no Can\'t be blank') && IsNumeric(RoutingNo) && emptyvalidation(AccountNo,'Account no Can\'t be blank') && IsNumeric(AccountNo));
//   }
//alert(radio);
    if(radio[0].checked)
    {
       //alert('1');
       return (emptyvalidation(BankName,'Bank name Can\'t be blank') && emptyvalidation(RoutingNo,'Routing no Can\'t be blank') && IsNumeric(RoutingNo) && emptyvalidation(AccountNo,'Account no Can\'t be blank'));
    }
   if(radio[1].checked)
    {
       //alert('2');
       return (emptyvalidation(CC,'CC Can\'t be blank') && validateCC(CC,'CC must be 16 digits') && valDropDownList(Month,'Select Month') && valDropDownList(Year,'Select year') && emptyvalidation(CVV,'CVV Can\'t be blank') && validateCVV(CVV,'CVV must be 4 digits number'));
       
    }
    else
    return true;
}

function AdminCustomerInfoValidation(FirstName,LastName,hph1,hph2,hph3,wph,Email,Address,City,State,Zip,AffiliateID,Agreement)
{
     return (emptyvalidation(FirstName,'First name Can\'t be blank') && emptyvalidation(LastName,'Last name Can\'t be blank') && emptyvalidation(hph1,'Home telephone number Can\'t be blank') && emptyvalidation(hph2,'Home telephone number Can\'t be blank')&& emptyvalidation(hph3,'Home telephone number Can\'t be blank') && validatePhonenew(hph1,hph2,hph3) && emptyvalidation(wph,'Cellular phone/work phone Can\'t be blank ') && validatePhone(wph,'Enter correct Phone number') && emptyvalidation(Email,'Email Can\'t be blank') && emailvalidation(Email,'Please check email') && emptyvalidation(Address,'Address Can\'t be blank') && emptyvalidation(City,'City Can\'t be blank') && emptyvalidation(State,'State Can\'t be blank') && emptyvalidation(Zip,'Zip Can\'t be blank') && emptyvalidation(AffiliateID,'AffiliateID Can\'t be blank') && validatePhone(AffiliateID,'AffiliateID must be 10 digits no') && chk_arg(Agreement,'Please read and aceept the Agreement'));
}

function AdminCustomerTelephoneValidation(hph1,hph2,hph3,wtn1,wtn2,wtn3)
{
     return (validatePhonenew(hph1,hph2,hph3) && validatePhonenew(wtn1,wtn2,wtn3));
}

function BankInfoValidation(bnkname,accno,bnkroughtno,bnkaddress)
{
return (emptyvalidation(bnkname,'Bank name Can\'t be blank') && emptyvalidation(accno,'Account No Cannot Be Blank! ') && emptyvalidation(bnkroughtno,'Bank Routing Number  Can\'t be blank') && emptyvalidation(bnkaddress,'Bank Address  Can\'t be blank'))
}
function ValidateGetAffiliate(AffiliateID)
{
    return (emptyvalidation(AffiliateID,'AffiliateID name Can\'t be blank') && validatePhone(AffiliateID,'AffiliateID must be 10 digits no'));
}




function createAdminuser_validation(pswd,cpswd,name,Role, email,phone)
{
   return (  emptyvalidation(pswd,'Password cannot be empty!')   && comparevalidation(pswd, cpswd, 'Password  Mismatch!')  && emptyvalidation(name,'Name cannot be empty!') && valDropDownList(Role, 'Please choose a Role!')  && emptyvalidation(email,'Email Address cannot be empty!')&& emailvalidation(email, 'Invalid Email Id!')    && emptyvalidation(phone, 'Phone cannot be empty!') && validatePhone(phone, 'Invalid Phone no!'));
}

function updateAdminuser_validation(pswd,cpswd,name,Role, email,phone)
{
   return (  comparevalidation(pswd, cpswd, 'Password  Mismatch!') && emptyvalidation(name,'Name cannot be empty!') && valDropDownList(Role, 'Please choose a Role!')  && emptyvalidation(email,'Email Address cannot be empty!')&& emailvalidation(email, 'Invalid Email Id!')    && emptyvalidation(phone, 'Phone cannot be empty!') && validatePhone(phone, 'Invalid Phone no!'));
}

//function createuser_validation(name, pass,lblpass, re_pass, address, city, state, country, zip, phone, email)
//{
//   return (emptyvalidation(name, 'Name cannot be empty!') && emptyvalidation(pass,lblpass, 'Password cannot be empty!') && comparevalidation(pass, re_pass, 'Password Mismatch!') && emptyvalidation(address, 'Address cannot be empty!') && emptyvalidation(city, 'City cannot be empty!') && emptyvalidation(state, 'State cannot be empty!') && emptyvalidation(country, 'Country cannot be empty!') && emptyvalidation(zip, 'Zip cannot be empty!') && emptyvalidation(phone, 'Phone cannot be empty!') && emptyvalidation(email, 'E-Mail cannot be empty!') && emailvalidation(email, 'Invalid Email Id!'));
//}

//=====================================================================================================

function createrestaurant_validation(REST_Name,REST_DESC,REST_Address,REST_City, State, Zip,Phone,REST_FAX, Email, REST_LOCATION,REST_HOUR,REST_FOOD_DELIVERY)
{
   return (emptyvalidation(REST_Name, 'Empty Restaurant Name!') && emptyvalidation(REST_DESC, 'Empty Restaurant Description!') && emptyvalidation(REST_Address, 'Empty Restaurant Address!') && valDropDownList(REST_City, 'Please Select City!') && emptyvalidation(State, 'Empty State value!') && emptyvalidation(Zip, 'Empty Zip Code!') && validateZip(zip, 'Zip should be 5 digit!') && emptyvalidation(Phone, 'Empty Phone No!') && validatePhone(Phone,'Check Phone No!') && emptyvalidation(REST_FAX, 'Empty Fax!') && emailvalidation(Email, 'Invalid Email Id!') && emptyvalidation(Email, 'Empty Email Id!') && emptyvalidation(REST_LOCATION, 'Empty Restaurant Location!') && emptyvalidation(REST_HOUR, 'Empty Restaurant Hour Operation!') && emptyvalidation(REST_FOOD_DELIVERY, 'Empty Delivery!'))
}



function createmenu_validation(menu_Name,menu_desc,price, restaurant, category)
{
   return (emptyvalidation(menu_Name, 'Empty Menu Name!') && emptyvalidation(menu_desc, 'Empty Menu Description!') && emptyvalidation(price, 'Empty Menu Price!') && formatNum(price, 'Price Should be 2 digit decimal!') && valDropDownList(restaurant, 'Select Restaurant!')&& valDropDownList(category, 'Select Category!'))
}
function createremployee_validation1(Emp_FName,Emp_LName)
{
   return (emptyvalidation(Emp_FName, 'Empty Employee First Name!') && emptyvalidation(Emp_LName, 'Empty Employee First Name!') )
}



function createremployee_validation(Emp_FName,Emp_LName,Emp_SSN,Emp_Email,Emp_Phno,State,Emp_Zip)
{
   
   return (emptyvalidation(Emp_FName, 'Empty Employee First Name!') && emptyvalidation(Emp_LName, 'Empty Employee Last Name!') && emptyvalidation(Emp_SSN, 'Empty Employee SSN!') && validateSSn(Emp_SSN,'SSN Must be 9 digit no') && emailvalidationConditional(Emp_Email,'Check Email') && valDropDownList(State,'Empty State') && validateZip(Emp_Zip, 'Zip should be 5 digit!') && emptyvalidation(Emp_Phno,'Empty Phone no') && validatePhone(Emp_Phno,'Check Phone No!'))
}



//================================================================================================
//function createUser_validation(U_Name,PAass,RePass, Address, City, State, Country,Zip,Phone,Email)
//{
//   return (emptyvalidation(U_Name, 'Empty User Name!') && emptyvalidation(PAass, 'Enter Password!') && emptyvalidation(RePass, 'Enter Re-Password!') && emptyvalidation(Address, 'Empty Address') && emptyvalidation(City, 'Empty City value!') && emptyvalidation(State, 'Empty State value!') && emptyvalidation(Country, 'Empty Country Value!') && emptyvalidation(Zip, 'Empty Zip Code!') && emptyvalidation(Phone, 'Empty Phone No!') && emailvalidation(Email, 'Invalid Email Id!') && emptyvalidation(Email, 'Empty Email Id!'))
//}


//validate Image Inputs
function ValidateInputs(ImgTitle,ImgDescription,ImgCamera,txtImgLens,ImgShotSettings,ImgBackColor,ImgFontColor,Camera,Lens)
{
    return(customvalidation(ImgTitle,'Image title may not be more than 50 characters',50,'Image Title cannot be blank',1) && customvalidation(ImgDescription,'Image description may not be more than 1000 characters',1000,'Image Description cannot be blank',1) && customvalidation(ImgBackColor,'',250,'Image forecolor cannot be blank',1)&& customvalidation(ImgFontColor,'',250,'Image backcolor cannot be blank',1) && CameraValidation(Camera,ImgCamera,'Please specify Camera') && CameraValidation(Lens,txtImgLens,'Please Specify Lens') && customvalidation(ImgShotSettings,'Image shot setting may not be more than 250 characters',250,'Image shot setting cannot be blank',0) )
}

//Validate User Info
  function UserValidation(Password,ConfirmPassword,Fname,Lname,Ssn,Permission,PhoneNo,State,Zip,Email)
  {
       
       return(emptyvalidation(Password,'Enter Password') && comparevalidation(Password,ConfirmPassword,'Password does not match! Try Again..') && emptyvalidation(Fname,'Enter First name') && emptyvalidation(Lname,'Enter Last name') && emptyvalidation(Ssn,'Enter SSN') && validateSSn(Ssn,'SSN Must be 9 digit no') && valDropDownList(Permission,'Select any Permission') && validatePhone(PhoneNo,'Phone no must be 10 digit no') && valDropDownList(State,'Select State') && validateZip(Zip,'Zip Code must be 5 digit no') && emailvalidationConditional(Email,'Check email'))
  }

  function UserUpdateValidation(Password,ConfirmPassword,Fname,Lname,Ssn,Permission,PhoneNo,State,Zip,Email)
  {
       
       return(comparevalidation(Password,ConfirmPassword,'Password does not match! Try Again..') && emptyvalidation(Fname,'Enter First name') && emptyvalidation(Lname,'Enter Last name') && emptyvalidation(Ssn,'Enter SSN') && validateSSn(Ssn,'SSN Must be 9 digit no') && valDropDownList(Permission,'Select any Permission') && validatePhone(PhoneNo,'Phone no must be 10 digit no') && valDropDownList(State,'Select State') && validateZip(Zip,'Zip Code must be 5 digit no') && emailvalidationConditional(Email,'Check email'))
  }  

   function AvailableValidation(UserID)
   {
      return (emptyvalidation(UserID,'Enter USerID'))
   }


function Upload_Validation(txtTitle,txtdescription,category)
{
  return(emptyvalidation(txtTitle, 'Image title cannot be blank!') && emptyvalidation(txtdescription, 'Image description cannot be blank!') && valDropDownList(category,'You must select a category'))
}
function alert1()
{
   //alert('abcd');
   alert(isInteger('1'));
}

function UploadBannerValidation(BannerName,BannerSize,uploadBanner)
{
   return (emptyvalidation(BannerName,'Please enter banner name') && ValidateImageDimension(BannerSize,'X','Please check banner dimension') && FileUploadValidation(uploadBanner)); 
}

    function CreateRestaurantValidation(RestaurantName,Fax,Phone,State,Zip)
    {
      return(emptyvalidation(RestaurantName,'Restaurant name cannot be blank') && validatePhone(Fax,'Fax must be 10 digit no') && validatePhone(Phone,'Phone must be 10 digit no') && valDropDownList(State,'Select State') && validateZip(Zip,'Zip Code must be 5 digit no'))
    }
//function validatePhone(obj,alertbox)
//{
//var o = document.getElementById(obj);
//var validNum =(/^[0-5]\d{2}-\d{8}$/);
//if (validNum.test(o.value) == false)
// {
// alert(alertbox);
//return false;
// }
//else
//  {
//  return true;
//  }
//}

 function isURL ( txtId )
{ 
  
                  var string = document.getElementById(txtId).value;     
  
//                  if ( string.search(/^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$/) != -1 ){ 
//                            //alert('Valid URL'); 
//                        return true; 
//                  } 
  
                if(string !="")
                {
                  if ( string.search(/^[www.]+[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$/) != -1 )
                  { 
                            //alert('valid URL'); 
                        return true; 
                  } 
  
                  alert('Not a valid URL'); 
                  document.getElementById(txtId).select(); 
                  document.getElementById(txtId).focus();         
                  return false; 
                  }
                  else
                  {
                  return true; 
                  }
  
            } 
            
            function chk_arg(trgt,alertbox)
    {
    var targetobj=document.getElementById(trgt);
    //alert(targetobj.value)
    //alert("asdsad");
   // alert(targetobj)
    if(targetobj.checked)
    {
    return true;
    }
    else
    {
    alert(alertbox);
    return false;
    }
    }
function validatePhone(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{9}$/);
if(o.value=="")
{
   return true;  
}
else
{
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
 }
} 

function validateMobile(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{9}$/);
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
}
function validateAffNo(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{5}$/);
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
}

    function validateCC(obj,alertbox)
    {
    var o = document.getElementById(obj);
    var validNum =(/^[0-9]\d{15}$/);
    if (validNum.test(o.value) == false)
     {
     alert(alertbox);
    return false;
     }
    else
      {
      return true;
      }
    }

    function validateCVV(obj,alertbox)
    {
    var o = document.getElementById(obj);
    var validNum =(/^[0-9]\d{3}$/);
    if (validNum.test(o.value) == false)
     {
     alert(alertbox);
    return false;
     }
    else
      {
      return true;
      }
    }


function valDropDownList(target, alertbox)
 {
var selected = document.getElementById(target);
//alert(selected.value);
//alert(selected.value);
if (selected.value ==0) 
{
alert(alertbox);
return false;
}
 else
 { 
 return true;
 }
} 


function validatePhonenew(areaCode,prefix,extension)
{
 
  var phoneNum = new String(document.getElementById(areaCode).value + "-" +document.getElementById(prefix).value + "-" + document.getElementById(extension).value);
 
   if(phoneNum!='--')
   {
      var regExpObj = /(\d\d\d)-\d\d\d-\d\d\d\d/;
       
      if(regExpObj.exec(phoneNum) == null)
      {
        //alert('Please enter valid phone no');
        alert(phoneNum + " does not contain a valid Phone no!");
        return false;

      }
      else
      {
      return true;
       // alert("Thank you for your order!");
      }
  }
  else
  {   
  return true
  }
}


function validateTax(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{8}$/);
if(o.value=="")
{
   return true;  
}
else
{
if (validNum.test(o.value) == false)
 {
 o.focus();
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
 }
} 

function validateZip(obj,alertbox)
{ 
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{4}$/);
//alert(o.value);
if(o.value=="")
{
   return true;  
}
else
{
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 } 
else
  {
  return true;
  }
 }
 
}

function validateSSn(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{8}$/);
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
}

function IsMatchFloat(target,alertbox)
{
var mystring=document.getElementById(target);
//    mystring = str;
    if (mystring.match(/^\d+$|^\d+\.\d{2}$/ ) ) 
    {
     
        return true;
    }
    else
    {
       if (alertbox!="")
        {
            alert(alertbox);
        }
        return false;
    }
}

function formatNum(target,alertbox) 
{
var con = document.getElementById(target);
var s=con.value;
//alert(target);
//alert(s);
var OK = /^\d{1,9}(\.\d\d?)?$/.test(s);
if (OK) 
{
s = s.replace(/(\.\d)$/, "$10").replace(/^(\d+)$/, "$1.00")
return true;
} 
else 
{
//alert(s);
//      if (alertbox!="")
//        {
            alert(alertbox);
            return false;
//        }
        
}

}

///^(0|[1-9]\d{0,3})(\.\d\d?)?$/




function isInteger(digit)
{
    var i;
    
    for (i = 0; i < digit.length; i++)
    {
        var c = digit.charAt(i);

        if (!isDigit(c))
            return false;
    }

    return true;
}

function isDigit (c)
{
    return ((c >= "0") && (c <= "9"));
}

function validateInt(target, alertbox)
{
    var o = document.getElementById(target);
    var v = o.value;
    
    var where_is=v.indexOf('.');
        
    if(where_is > -1)
    {
        var first = v.split(".");
        
        if (!isInteger(first[0])) 
        { 
            alert(alertbox);
            setfocus(target);
            return false;
        }
        else
        {
            if (!isInteger(first[1])) 
            { 
                alert(alertbox);
                setfocus(target);
                return false;
            }
            else
            {
                if(first[1].length > 2)
                {
                    alert('Decimal part Can\'t be more than 2 digits!');
                    setfocus(target);
                    return false;
                }
                else
                    return true;
            }
        }
   }
   else
   {
        if (!isInteger(v)) 
        { 
            alert(alertbox);
            setfocus(target);
            return false;
        }
        else
            return true;
   }
}


 function validatePhoneEmpty(obj,alertbox)
{
var o = document.getElementById(obj);
var validNum =(/^[0-9]\d{9}$/);
if (validNum.test(o.value) == false)
 {
 alert(alertbox);
return false;
 }
else
  {
  return true;
  }
 
}

//// Sets Dirty Flag
function setDirtyFlag()
  {
  
    objDF = document.getElementById('dirtyflag');
    //alert(objDF);
    objDF.value = '1';
      
  }
  
  
 //// Check Dirty Flag
 function checkDirtyFlag()
 {
 
    objDF = document.getElementById('dirtyflag');
    //alert(objDF);
    if(objDF.value == '1')
    {
        res=confirm('There is unsaved data in the screen. Do you really want to continue? ');
    }
    //alert(res);
    
    if(res == true)
     return true;
    else
     return false;
 
 
 }
  
    function ConfirmDelete()
 {
    res=confirm('Are you sure you want to delete the selected items ? All data will be lost. Please click on OK to delete the selected items or CANCEL to return to the page');
    if(res==true)
    return true;
    else
    return false;
 } 
 
   function ConfirmSubmit()
 {
    res=confirm('Are you sure You Want to Confirm Payment?  Please click on OK to Pay the items or CANCEL to return to the page');
    if(res==true)
    {
    alert("Payment Data Updated Successfully  !");
    return true;
    }
    
    else
    {
    return false;
    }
 } 
 
 
 function CheckLenght(obj)
  {
     //alert(document.getElementById(obj.id).value);
     var TextValue=document.getElementById(obj).value;
     var TextLenght=TextValue.length;
     //alert(TextLenght);
     if(TextLenght>2000)
     {
         alert('Enter comments within 300 characters');
         //obj.id.focus();          
         return false;
         obj.focus();
     }
     else
     {
        return true;
     }
 }
 
  function CheckAllLenght(obj,TotalLenght,Message)
  {
     //alert(document.getElementById(obj.id).value);
     var TextValue=document.getElementById(obj).value;
     var TextLenght=TextValue.length;
     //alert(TextLenght);
     if(TextLenght>TotalLenght)
     {
         //alert('Enter address within '+ TotalLenght + ' characters');
         alert(Message+' '+ TotalLenght + ' characters');
         
         //obj.id.focus();          
         return false;
         obj.focus();
     }
     else
     {
        return true;
     }
 }
 
  function CheckAllLenghtPolish(obj,TotalLenght,Message)
  {
     //alert(document.getElementById(obj.id).value);
     var TextValue=document.getElementById(obj).value;
     var TextLenght=TextValue.length;
     //alert(TextLenght);
     if(TextLenght>TotalLenght)
     {
         //alert('Enter address within '+ TotalLenght + ' characters');
         alert(Message);
         
         //obj.id.focus();          
         return false;
         obj.focus();
     }
     else
     {
        return true;
     }
 }
 
 function ValidateImageDimension(obj,Delemeter,Message)
 {
      var TextValue=document.getElementById(obj).value.toUpperCase();
      if(TextValue!=null && TextValue!='')
          {
          var Lenght=TextValue.lenght;
          var Seperator= TextValue.indexOf(Delemeter.toUpperCase());
          //Seperator=Seperator.toUpperCase() ;
          if(Seperator==-1)
          {
            alert('Please enter seperator between height and width');
            return false;
          }
          else
          {
            var txt1=TextValue.substring(0,Seperator);
            var txt2=TextValue.substring(Seperator+1);
            
            if(!IsNumeric(txt1,'Width is not a number'))
            {
                //alert('Width is not a number');
                return false;             
            }
            if(!IsNumeric(txt2,'Height is not a number'))
            {
                //alert('Width is not a number');
                return false;             
            }
           else
           {
                return true;
           } 
            
          }
      }
      else
      {
      return true;
      
      }
      
 }
 
 
 function FileUploadValidation(obj)
     {
        //alert(obj);
        var Target= document.getElementById(obj);
        //alert(Target);
        var FileName=Target.value;
        var ext = FileName.substring(FileName.lastIndexOf('.') + 1);        
        if(FileName=='')
        {
        alert('Please upload file');
        return false;
        }
        else
        {
        //alert(FileName);
        //alert(FileName.lastIndexOf('.')!=-1);
          if(FileName.lastIndexOf('.')!=-1)
          { 
              if(ext.toUpperCase() == 'JPG' || ext.toUpperCase() == 'GIF' || ext.toUpperCase() == 'JPEG')
                {
                return true;
                } 
                else
                {
                alert("Only .jpg,.gif can be uploaded");
                Target.focus();
                return false;
                }
           }
           else
           {
                alert('Please provide a proper filename');
                return false;
           }

        }
     }
     
     function UploadValidation(obj,Message)
     {
          //alert(obj);
        var Target= document.getElementById(obj);
        //alert(Target);
        var FileName=Target.value;
        var check=parseInt(FileName.indexOf(':'));
        //alert(check);
        var ext = FileName.substring(FileName.lastIndexOf('.') + 1); 
            
        if(FileName=='')
        {
        alert(Message);
        return false;
        }
        else
         {
            return true;
         }
     }
     
     
     function FlyerUploadValidation(obj)
     {
        //alert(obj);
        var Target= document.getElementById(obj);
        //alert(Target);
        var FileName=Target.value;
        var ext = FileName.substring(FileName.lastIndexOf('.') + 1);        
        if(FileName=='')
        {
        alert('Please upload file');
        return false;
        }
        else
        {
        //alert(FileName);
        //alert(FileName.lastIndexOf('.')!=-1);
          if(FileName.lastIndexOf('.')!=-1)
          { 
              if(ext.toUpperCase() == 'JPG' || ext.toUpperCase() == 'PDF' || ext.toUpperCase() == 'JPEG' || ext.toUpperCase() == 'DOC')
                {
                return true;
                } 
                else
                {
                alert("Only .jpg,.pdf,.doc can be uploaded");
                Target.focus();
                return false;
                }
           }
           else
           {
                alert('Please provide a proper filename');
                return false;
           }

        }
     }
     
     
      function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   //alert( document.getElementById(strString).value);
   if(document.getElementById(strString)!=null)
   {
       var Number=(document.getElementById(strString)).value;
       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 < Number.length && blnResult == true; i++)
          {
          strChar = Number.charAt(i);
          if (strValidChars.indexOf(strChar) == -1)
             {
             blnResult = false;
             alert('Enter only numbers');
             break;
             }
          }
       return blnResult;
   }
   else
   {
       return true;
   }
  }
  
  
  
  function validateSS(areaCode,prefix,extension)
{
  var phoneNum = new String(document.getElementById(areaCode).value + "-" +document.getElementById(prefix).value + "-" + document.getElementById(extension).value);
  //alert(phoneNum);
   if(phoneNum!='--')
   {
      var regExpObj = /(\d\d\d)-\d\d-\d\d\d\d/;
       
      if(regExpObj.exec(phoneNum) == null)
      {
        //alert('Please enter valid phone no');
        alert(phoneNum + " does not contain a valid SS no!");
        return false;

      }
      else
      {
      return true;
       // alert("Thank you for your order!");
      }
  }
  else
  {   
  return true
  }
}