// JavaScript Document

/*function A()
{
if(document.form.fileatt.value!="")
{var oas = new ActiveXObject("Scripting.FileSystemObject");
var d = document.a.b.value;
var e = oas.getFile(d);
var f = e.size;
alert(f + " bytes");
}
}
*/
function validate_form ( )
{
    valid = true;

    if ( document.form.firstname.value== "" ){alert("Please enter your First Name.");
	document.form.firstname.focus();
	
	return(false);}
	if(document.form.lastname.value==""){ alert("Please enter your Last Name.");
	document.form.lastname.focus();
	return(false);}
	if ( ( document.form.gender[0].checked == false )
    && ( document.form.gender[1].checked == false ) )
    {
        alert ( "Please select your Gender." );
		
       return(false);
	   
    }
	if(document.form.birthdaymonth(document.form.birthdaymonth.selectedIndex).text=="Please Select" || document.form.birthdayday(document.form.birthdayday.selectedIndex).text=="Please Select" || document.form.birthdayyear(document.form.birthdayyear.selectedIndex).text=="Please Select")
	{ 
		alert("Please enter your birthday.");
	if(document.form.birthdaymonth(document.form.birthdaymonth.selectedIndex).text=="Please Select")
			{
				document.form.birthdaymonth.focus()
				return false;
			}
	if(document.form.birthdayday(document.form.birthdayday.selectedIndex).text=="Please Select")
			{
				document.form.birthdayday.focus()
				return false;
			}
	if(document.form.birthdayyear(document.form.birthdayyear.selectedIndex).text=="Please Select")
			{
				document.form.birthdayyear.focus()
				return false;
			}
			
	}
	
	if(document.form.nonumb.value==""){ alert("Please enter the No. for your Home Address.");
	document.form.nonumb.focus();
	return(false);}
	if(document.form.nonumb.value==""){ alert("Please enter the No. for your Home Address.");
	document.form.nonumb.focus();
	return(false);}
	if(document.form.street.value==""){ alert("Please enter the Street for your Home Address.");
	document.form.street.focus();
	return(false);}
	if(document.form.city.value==""){ alert(" Please enter your City.");
	document.form.city.focus();
	return(false);}
	if(document.form.province.value==""){ alert(" Please enter your Province.");
	document.form.province.focus();
	return(false);}
	if(document.form.postalcode.value=="") {alert("Please enter your Postal Code.");
	document.form.postalcode.focus();
	return(false);}
	if(document.form.email.value=="") {alert("Please enter your Email Address.");
	document.form.email.focus();
	return(false);}
	
	//A();
	
	
 if((document.form.email.value.indexOf("@")==-1)||(document.form.email.value.indexOf(".")==-1)||(document.form.email.value.indexOf(
																																   ".")) <(document.form.email.value.indexOf("@"))||(document.form.email.value.indexOf("."))-(document.form.email.value.indexOf("@" ))== 1){alert("Email Address not entered correctly. Please try again.");
 document.form.email.focus();

return(false);}
for(broj=1;broj<10;broj++){
var checkOK = "0123456789";
var checkStr = document.form['phone'+broj].value;
var allValid = true;
var allNum = "";
for (i = 0; i< checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Please enter only digit characters in the 'phones' fields.");
document.form['phone'+broj].focus();
return (false);
}
}

    if(document.form.bestwaytocontact[0].selected==true){ alert("Please select the best way to contact you.");
	document.form.bestwaytocontact.focus();
	return(false);}
	
	if(document.form.fileatt.value!="")
	{
			var lo=document.form.fileatt.value
			var flo=lo.split(".")
			var len=flo.length
			var xt=flo[len-1];
			//alert("file extension is " + xt)
			if(xt=="txt" || xt=="doc" || xt== "pdf")
			{
					
			}
			else
			{
				alert("The format of the resume file is not valid. Only txt,doc and pdf files are allowed!")
				document.form.fileatt.focus();
				return false; 
			}
			document.form.chkfile.value='1';
		}
	

	if(
	   (document.form.location[0].selected==true)||
	   (document.form.position.value=="")||
	   (document.form.availability[0].checked==false&&document.form.availability[1].checked==false&&document.form.availability[2].checked==false&&document.form.availability[3].checked==false)
	   ||(document.form.parttimeaccept[0].checked==false&&document.form.parttimeaccept[1].checked==false)
	   ||(document.form.startwork.value=="")||(document.form.unable.value=="")||(document.form.salary.value==""))
	{alert("You must complete all required fields (*) in Section 2 of the application form!");
	document.form.location.focus();
	return(false);
	}
	
	 return valid;
}

