// JavaScript Document
// ------------------------------------------------

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value==""||value==" ")
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_password(field,alerttxt)
{
with (field)
{
if (value==null||value==""||value==" ")
  {alert(alerttxt);return false}
else {return true}
}
}



function validate_registration_form(thisform)
{

with (thisform)
{
if (document.completeform.title.value=='0')
  {alert("Please select title"); title.focus();return false}
}


with (thisform)
{
if (validate_required(fullname,"Please fill the required fields marked with *")==false)
  {fullname.focus();return false}
}

with (thisform)
{
if (document.completeform.birthday_mon.value=='0' || document.completeform.birthday_day.value=='0' || document.completeform.birthday_yr.value=='0')
  {alert("Please select your date of birth"); birthday_mon.focus();return false}
}


with (thisform)
{
if (validate_required(mobilephone,"Please fill the required fields marked with *")==false)
  {mobilephone.focus();return false}
}

with (thisform)
{
if (document.completeform.country.value=='0')
  {alert("Please select your country"); country.focus();return false}
}


with (thisform)
{
if (validate_required(jobtitle,"Please fill the required fields marked with *")==false)
  {jobtitle.focus();return false}
}

with (thisform)
{
if (validate_required(skills,"Please fill the required fields marked with *")==false)
  {skills.focus();return false}
}

with (thisform)
{
if (radio_button_checker()==false)
  {fullname.focus();return false}
}

with (thisform)
{
if (checkbox()==false)
  {fullname.focus();return false}
}

with (thisform)
{
if (document.completeform.qualification.value=='0')
  {alert("Please select your qualification"); qualification.focus();return false}
}


}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function signupForm(){
	var emailID=document.signup.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }



function radio_button_checker()
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < completeform.gender.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (completeform.gender[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
// If there were no selections made display an alert box 
alert("Please select gender")
return (false);
}
return (true);
}



function checkbox() { 
// Checking if at least one period button is selected. Or not. 
var total=""
for(var i=0; i < document.completeform.workarea.length; i++){
if(document.completeform.workarea[i].checked)
total +=document.completeform.workarea[i].value + "\n"
}
if(total=="") {
alert("select work area");
} else {
document.getElementById("workareas").innerHTML = total;
return true;
}

return false; 
}





// upload file validation starts here

function ExtensionsOkay() {
var extension = new Array();

// Step 1 of 2:
// Replace MyForm with the name of your form and 
//    replace FieldName with the upload field name.

var fieldvalue = document.cvform.validate.value;


// Step 2 of 2:
// Add the file name extensions that are okay (with 
//    the period), for the variables with their numbers 
//    in sequential order, as many or as few as needed, 
//    starting with 0. (These are case sensitive.)

extension[0] = ".doc";
extension[1] = ".pdf";
extension[2] = ".dox";

// No other customization needed.
var thisext = fieldvalue.substr(fieldvalue.lastIndexOf('.'));
for(var i = 0; i < extension.length; i++) {
	if(thisext == extension[i]) { return true; }
	}
alert("Your upload form contains an unapproved file name or its empty.");
return false;
}


// upload file validation ends here

//passing value of file extension to hidden field

function checkext() {
	var change;
	change = document.getElementById("resume").value;
	document.getElementById("validate").value=change;
	}
	
//passing value of file extension to hidden field ends here
	
// delete cv

function deletecall() {
  return confirm("Are you sure you want to delete your resume?");
	}

// delete cv ends here


// post a job form starts here

function validate_postajob_form(thisform)
{

with (thisform)
{
if (validate_required(jobtitle,"Please enter the Job Title")==false)
  {jobtitle.focus();return false}
}


with (thisform)
{
if (industry()==false)
  {jobtitle.focus();return false}
}


with (thisform)
{
if (validate_required(jobdescription,"Please enter the Job Description")==false)
  {jobdescription.focus();return false}
}

with (thisform)
{
if (validate_required(jobtype,"Please select the Job Type")==false)
  {jobtype.focus();return false}
}

with (thisform)
{
if (validate_required(salary,"Please enter the Salary Description")==false)
  {salary.focus();return false}
}


with (thisform)
{
if (validate_required(country,"Please select the Country")==false)
  {country.focus();return false}
}

with (thisform)
{
if (validate_required(company,"Please enter the Company name")==false)
  {company.focus();return false}
}

with (thisform)
{
if (validate_required(firstname,"Please enter the First Name")==false)
  {firstname.focus();return false}
}

with (thisform)
{
if (validate_required(lastname,"Please enter the Last Name")==false)
  {lastname.focus();return false}
}

with (thisform)
{
if (validate_required(email,"Please enter the Email")==false)
  {email.focus();return false}
}



}


function industry() { 
// Checking if at least one period button is selected. Or not. 

var s = document.postajobform.elements['industry[]'];
var i;
var check;
for (i = 0; i < s.length; i++) {
if (s[i].selected) { check='yes'; return true; } else { check='no'; }
}
if (check=='no'){
alert ("Please select atleast one Industry sector"); return false;
}
}


function postajobEmail(){
	var emailID=document.postajobform.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }


// post a job form ends here
