// JavaScript Document

 
function CheckNumericKeyInfnumeric($char, $mozChar) {
 

  if($mozChar != null) { // Look for a Mozilla-compatible browser
    if(($mozChar >= 48 && $mozChar <= 57) || $mozChar == 0 || $char == 8 || $mozChar == 13  ) $RetVal = true;
    else {
      $RetVal = false;
     alert('Please enter a numeric value.');
    }
  }
  else { // Must be an IE-compatible Browser
    if(($char >= 48 && $char <= 57) || ($char == 13) ) $RetVal = true;
    else {
      $RetVal = false;
     alert('Please enter a numeric value.');
    }
  }
  return $RetVal;
}


function CheckNumericKeyInfalpha($char, $mozChar) {
 
  
  if($mozChar != null) { // Look for a Mozilla-compatible browser
//    if(($mozChar >= 48 && $mozChar <= 57) )

    if(($mozChar >= 65 && $mozChar <= 90 ) ||($mozChar >= 97 && $mozChar <= 122 ) ||$mozChar==32 || $mozChar == 8 ||$mozChar == 0 ||$mozChar == 13)
    {    $RetVal = true; 
    
    }
    else {
    $RetVal = false;
    alert('Please enter alphabets.');
      
    }
  }
  else { // Must be an IE-compatible Browser
//    if(($char >= 48 && $char <= 57))

  if(($char >= 65 && $char <= 90 ) ||($char >= 97 && $char <= 122 ) ||$char==32 ||$char == 8 ||$char == 0 ||$char == 13)
    
    { $RetVal = true;
    }
    else {
      $RetVal = false;
    alert('Please enter alphabets.');
   
    }
  }
  return $RetVal;
}

function CheckNumericKeyInfof($char, $mozChar) {
 

  if($mozChar != null) { // Look for a Mozilla-compatible browser
    if(($mozChar >= 48 && $mozChar <= 57) || $mozChar == 0 || $mozChar == 8 || $mozChar == 13  || $mozChar == 45) $RetVal = true;
    else {
      $RetVal = false;
      alert('Please enter a numeric value.');
    }
  }
  else { // Must be an IE-compatible Browser
    if(($char >= 48 && $char <= 57) || ($char == 13)|| ($char == 45)  ) $RetVal = true;
    else {
      $RetVal = false;
      alert('Please enter a numeric value.');
    }
  }
  return $RetVal;
}
 /*function emailvalidationn(entered)
{
    apos=entered.indexOf("@");
    dotpos=entered.lastIndexOf(".");
    lastpos=entered.length-1;
        if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
        {
              return false;
        }
        else 
        {
        }
            return true;
}*/



function IsEmail(VALUE) {
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(VALUE)) {
			return false;
		}
		return true;
	}

function trim(s)
{
	var l=0; var r=s.length -1;
	while(l < s.length && s[l] == ' ')
	{	l++; }
	while(r > l && s[r] == ' ')
	{	r-=1;	}
	return s.substring(l, r+1);
}



function validation()
 {
 
 
	form = document.form1;

	//alertComment = "";
document.form1.txt_name.value=trim(document.form1.txt_name.value);
document.form1.txt_country.value=trim(document.form1.txt_country.value);
document.form1.txt_caseoverview.value=trim(document.form1.txt_caseoverview.value);
document.form1.txt_adress.value=trim(document.form1.txt_adress.value);
document.form1.txt_state.value=trim(document.form1.txt_state.value);
document.form1.txt_city.value=trim(document.form1.txt_city.value);

if (form.txt_name.value=="")
	{ 
	
	form.txt_name.focus();
	 alert("Name field cannot be blank.");
	 return false;
	//alertComment = alertComment + "Name can not be blank";

	}

	//if (form.txt_adress.value=="") {
	//alert("Adress field cannot be blank");
	// return false;
	//alertComment = alertComment + "Blank Feild 2";
	//}
	/*if (form.txt_city.value=="")
	{ 
	
	form.txt_city.focus();
	 alert("City field cannot be blank");
	 return false;
	//alertComment = alertComment + "Name can not be blank";

	}
	if (form.txt_state.value=="")
	{ 
	
	form.txt_state.focus();
	 alert("State cannot be blank");
	 return false;
	//alertComment = alertComment + "Name can not be blank";

	}*/
	if (form.txt_country.value=="")
	{ 
	
	form.txt_country.focus();
	 alert("Country field cannot be blank.");
	 return false;
	//alertComment = alertComment + "Name can not be blank";

	}
	
	//if (form.txt_zip.value=="")
//	{ 
//	
//	form.txt_zip.focus();
//	 alert("Zip Code  cannot be blank");
//	 return false;
//	//alertComment = alertComment + "Name can not be blank";
//
//	}
//	else
 if (isNaN(form.txt_zip.value)==true && form.txt_zip.value!="") 
	{
	form.txt_zip.focus();
	alert( "Zipcode value Should be numeric.");
	 return false;
	}
	
	/*if (form.txt_phonenum.value=="")
	{ 
	
	form.txt_phonenum.focus();
	 alert("Phone Number  cannot be blank");
	 return false;
	//alertComment = alertComment + "Name can not be blank";

	}*/
	if (form.txt_emailadress.value=="")
	{ 
	
	form.txt_emailadress.focus();
	 alert("Email adress cannot be blank.");
	 return false;
	//alertComment = alertComment + "Name can not be blank";

	}
	else if(!IsEmail(form.txt_emailadress.value)) {
	alert("Please enter a valid Email ID.");
	form.txt_emailadress.focus();
	form.txt_emailadress.value="";
	return false;
	}

	if (form.txt_confirmemailadress.value=="")
	{ 
	
	form.txt_confirmemailadress.focus();
	 alert("Confirm Email adress field cannot be blank.");
	 return false;
	//alertComment = alertComment + "Name can not be blank";

	}
	else if(!IsEmail(form.txt_confirmemailadress.value))
	{	form.txt_confirmemailadress.focus();
	 alert('Please enter a valid E-mail ID.'); 
	 return false;
	}
	 if((form.txt_emailadress.value!="")&&(form.txt_confirmemailadress.value!="") )
	 { 
   if(form.txt_emailadress.value != form.txt_confirmemailadress.value)
   { 	form.txt_confirmemailadress.focus();
 alert("E-mail ID missmatch!. Please enter E-mail ID again.");
	  return false;
   }
   
   }
	
	 if (form.txt_caseoverview.value=="")
    {
	    form.txt_caseoverview.focus();
        alert('Please write a message.');
        return false;
    }
	  else if (form.txt_caseoverview.value.length >=200)
    {    form.txt_caseoverview.focus();
        alert('Message cannot be more than 200 characters');
        return false;
    }
	
		if(document.form1.cinput.value=="")
		{
		
		alert("Please enter security code.");
		document.form1.cinput.focus();
		return false;
		}
	 
	return true;
}


function focuss() {
document.form1.txt_name.focus();
//alert ("hedfdf");

}

