//Slide_banner
//Slide_banner End
//validate Form
function validateFormOnSubmit(theForm) 
{
var reason = "";

  reason += validateuser(theForm.Name);
  reason += validatee_id(theForm.Email);
  reason += validatep_no(theForm.Mobile);  
  reason += validatem_box(theForm.Message);
   if (reason != "") {
    alert("Need Valid Information \n" + reason);
    return false;
  }

  return true;
}


function validateEmpty(fld) 
{
    var error = "";
  
    if (fld.value.length == 0) 
{
        fld.style.background = '#ffd0d0'; 
        error = "The required field has not been filled in.\n"
    } 
else 
{
        fld.style.background = 'white';
    }
    return error;   
}

function validateuser(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == 0) {
        fld.style.background = '#fee8e8'; 
        error = "You didn't enter the Name.\n";
    } else if ((fld.value.length < 4) || (fld.value.length > 40)) {
        fld.style.background = '#fee8e8'; 
        error = "The Name is the wrong length.\n";
    }  else {
        fld.style.background = 'White';
    } 
    return error;
}



function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

    function validatee_id(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = '#fee8e8';
        error = "You didn't enter Email ID.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#fee8e8';
        error = "Please enter a valid Email ID.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#fee8e8';
        error = "The Email ID contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validatep_no(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');     

   if (fld.value == "") {
        error = "You didn't enter Mobile Number.\n";
        fld.style.background = '#fee8e8';
    } else if (isNaN(parseInt(stripped))) {
        error = "The Mobile Number contains illegal characters.\n";
        fld.style.background = 'White';        
    } else if ((stripped.length < 1) || (stripped.length > 20)) {
        fld.style.background = '#fee8e8'; 
        error = "The Mobile Number is wrong length.\n";
    }
    return error;
}

function validatem_box(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == 0) {
        fld.style.background = '#fee8e8'; 
        error = "You didn't enter Message.\n";
    } else if ((fld.value.length < 5) || (fld.value.length > 150)) {
        fld.style.background = '#fee8e8'; 
        error = "The Message is the wrong length.\n";
    }  else {
        fld.style.background = 'White';
    } 
    return error;
}

function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
//Validate Form End


//Scroll

