// JavaScript Document

function isEmail(val)
{
        // Return false if e-mail field does not contain a '@' and '.' .
        if (val.indexOf ('@',0) == -1 || val.indexOf ('.',0) == -1)
        {
                return 1;
        }
        else
        {
                return 0;
        }
}

function isNum(str)
{
        // Return false if characters are not '0-9' or '.' .
        for (var i = 0; i < str.length; i++)
        {
                var ch = str.substring(i, i + 1);
                if ((ch < "0" || "9" < ch) && ch != '.' && ch != '-')
                {
                        return 1;
                }
        }
        return 0;
}
function isSTR(val){
        var str = val;
        // Return false if characters are not a-z, A-Z, or a space.
        for (var i = 0; i < str.length; i++){
                var ch = str.substring(i, i + 1);
                if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && ch != ' '){
                return 1;
                }
        }
        return 0;
}

function employer(){	

var checkform_username=document.checkform.careerdice_employer_username.value;
var checkform_password=document.checkform.careerdice_employer_password.value;
var checkform_repassword=document.checkform.careerdice_employer_repassword.value;
var checkform_email=document.checkform.careerdice_employer_email.value;
var checkform_comp=document.checkform.careerdice_employer_company.value;
var checkform_indu=document.checkform.careerdice_employer_industry_id.value;
//var checkform_cont_person=document.checkform.careerdice_employer_contact_person.value;
//var checkform_cont_personemail=document.checkform.careerdice_employer_contact_person_email.value;
var checkform_zip=document.checkform.careerdice_employer_zip.value;
var checkform_country=document.checkform.careerdice_employer_country_id.value;
var terms=document.checkform.terms;

 var error=0;
	var error_message="There are following errors while processing the Form:\n";	
//Validation for User Name
		if (checkform_username== "" || (checkform_username.length<3)) {
                error_message = error_message + "User name is required and not should be less then 3 characters long\n";
                error = 1;	
	    }
// Validation for passwordword
        if (checkform_password == "" || (checkform_password.length < 6)) {
                error_message = error_message + "Password must be atleast 6 characters long\n";
               error = 1;
        }
// Validation for repassword
        if (checkform_repassword!= checkform_password) {
                error_message = error_message + "Password mismatch. Please retype the correct password\n";
               error = 1;
        }
// Validation for email
        if (checkform_email== "" || isEmail(checkform_email)) {
                error_message = error_message + "Enter the correct Email address\n";
                error = 1;
        }		
//Validation for Company name
		if (checkform_comp == "" || (checkform_comp.length < 3)) {
                error_message = error_message + "Company Name is required \n"; 
                error = 1;
				}		
//Validation for  Industry type
		if (checkform_indu == "-1") {
                error_message = error_message + "Select any one of the Industry Type \n"; 
                error = 1;
				}
			
//Validation for Contact Person
//		if (checkform_cont_person == "") {
    //            error_message = error_message + "Name of Contact Person is required\n"; 
  //              error = 1;
				//}
				
// Validation for email of the contact person
      //  if (checkform_cont_personemail== "" ||  isEmail(checkform_cont_personemail)) {
       //         error_message = error_message + "Enter the correct Email address of contact Person\n";
        //        error = 1;
        //}
	
//Validation for ZipCode
		if (checkform_zip == "" || (checkform_zip.length >8)){
                error_message = error_message + "Zip Code is required and must be in standard format\n"; 
                error = 1;
		}
// Validation for email of the contact person
        if (checkform_country== "-1") {
                error_message = error_message + "Please select country\n";
                error = 1;
        }		
		// check box for validation
if (!(terms.checked)) {
                error_message = error_message + "Please check the agreement box if you have \n  read the terms and conditions\n";
                error = 1;
        }
			
	if (error == 1) {
                alert(error_message);
                return false;
        } 
		else {
                return true;
        }
}




