function msg(n_msg,x){
var msg="The following fields were found to be blank or incorrect.\nKindly check and correct it before submiting the form \n"
msg=msg+"------------------------------------------------------------------\n\n"
msg=msg+n_msg+"\n\n"
if(x==1){alert(msg); return false;}
}

//for email addresses
var regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;

//illegal characters in fields
var illegalCharStr = '~!@#$%^*()<>{}[]=?/\\\":;';

var illegalCharStrWeb = '~!@#$%^*()<>{}[]=?";';
 	
// Removes all characters which appear in string bag from string s.
function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

//check for illegal characters
function checkIlleg(va)
{
	var stripped = stripCharsInBag (va, illegalCharStr);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}

//check illegal characters for url
function checkIllegweb(va)
{
	var stripped = stripCharsInBag (va, illegalCharStrWeb);
	if(va != '' && stripped.length < va.length)
	{
		return false;
	}
	return true;
}

//check for tel number
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

//Verify TEXTAREA field - general
function VerifyMsg(f_ld,c_nt,cnt_fld) {

	var len = f_ld.value.length
	var cl

	if ((len == 1) && (f_ld.value.substring(0, 1) == " ")) {
		f_ld.value = ""
		len = 0
	}
	if (len > (c_nt-10)) {
		f_ld.value = f_ld.value.substring(0, c_nt)
		cl = 0
	}
	else {
		cl = c_nt - len
	}
	eval(cnt_fld).value = cl
}

//Delete Record check
function rsDelCheck(url) {
	var conf = confirm("The record will be permanently deleted from the database.\nAre you sure?")
	if(!conf) 
		return false;
	else
		window.location=url;
	}	
//---------------------------	

// FAQs
var ns6=document.getElementById&&!document.all?1:0
var head="display:''"
var folder=''
function dropit(curobj){
folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style
if (folder.display=="none")
folder.display=""
else
folder.display="none"
}

//Log-in Form I validation
//---------------------------	
function subValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.HCForm.name.value){
		err_msg=err_msg+"Name\n"; x=1;
		}	
	if(!document.HCForm.postaddr.value){
		err_msg=err_msg+"Postal Address\n"; x=1;
		}	
	if(!document.HCForm.cntry[document.HCForm.cntry.selectedIndex].value){
		err_msg=err_msg+"Country\n"; x=1;
		}
	if(!document.HCForm.email.value){
		err_msg=err_msg+"Email Address\n"; x=1;
		}
	else {
		email = document.HCForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email Address - Invalid\n"; x=1;
			}
		}
	return msg(err_msg,x)
	}
//---------------------------	
	
//Reg Form I validation
//---------------------------	
function regValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.lgnemail.value){
		err_msg=err_msg+"Email Address\n"; x=1;
		}
	else {
		email = document.ISTForm.lgnemail.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email Address - Invalid\n"; x=1;
			}
		}
	if(!document.ISTForm.lgnpswd.value){
		err_msg=err_msg+"Password\n"; x=1;
		}
	else if(!document.ISTForm.lgnpswd1.value){
		err_msg=err_msg+"Re-enter Password\n"; x=1;
		}
	else if(document.ISTForm.lgnpswd.value != document.ISTForm.lgnpswd1.value){
		err_msg=err_msg+"Password Mismatch. Re-enter new passwords\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------	

//Contact us Form validation
//---------------------------	
function vConValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.comments.value){
		err_msg=err_msg+"Comments/Enquiry\n"; x=1;
		}	
	if(!document.ISTForm.titleid[document.ISTForm.titleid.selectedIndex].value){
		err_msg=err_msg+"Title\n"; x=1;
		}
	if(!document.ISTForm.fname.value){
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.ISTForm.lname.value){
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(!document.ISTForm.countryid[document.ISTForm.countryid.selectedIndex].value){
		err_msg=err_msg+"Country\n"; x=1;
		}
		
	if(!document.ISTForm.email.value){
		err_msg=err_msg+"Email Address\n"; x=1;
		}
	else {
		email = document.ISTForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email Address - Invalid\n"; x=1;
			}
		}
	return msg(err_msg,x)
	}
//---------------------------	

//Forgot Log-in validation
//---------------------------	
function frgtemlValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.email.value){
		err_msg=err_msg+"Email Address\n"; x=1;
		}
	else {
		email = document.ISTForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email Address - Invalid\n"; x=1;
			}
		}	
	return msg(err_msg,x)
	}
//---------------------------	

//Change email validation
//---------------------------	
function chgemlValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.lgnemail1.value){
		err_msg=err_msg+"Email Address\n"; x=1;
		}
	else {
		email = document.ISTForm.lgnemail1.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email Address - Invalid\n"; x=1;
			}
		}	
	return msg(err_msg,x)
	}
//---------------------------	

//Change Password validation
//---------------------------	
function chgpwdValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.lgnpswd0.value){
		err_msg=err_msg+"Current Password\n"; x=1;
		}
	if(!document.ISTForm.lgnpswd.value){
		err_msg=err_msg+"New Password\n"; x=1;
		}
	else if(!document.ISTForm.lgnpswd1.value){
		err_msg=err_msg+"Re-enter New Password\n"; x=1;
		}
	else if(document.ISTForm.lgnpswd.value != document.ISTForm.lgnpswd1.value){
		err_msg=err_msg+"Password Mismatch. Re-enter new passwords\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------	
	
//Profile Form validation
//---------------------------	
function proValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.lgnemail1.value){
		err_msg=err_msg+"Email Address\n"; x=1;
		}
	else {
		email = document.ISTForm.lgnemail1.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email Address - Invalid\n"; x=1;
			}
		}	
	if(!document.ISTForm.titleid[document.ISTForm.titleid.selectedIndex].value){
		err_msg=err_msg+"Title\n"; x=1;
		}
	if(!document.ISTForm.fname.value){
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.ISTForm.lname.value){
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(!document.ISTForm.dob.value){
		err_msg=err_msg+"Date of Birth\n"; x=1;
		}
	if(!document.ISTForm.nationalityid[document.ISTForm.nationalityid.selectedIndex].value){
		err_msg=err_msg+"Nationality\n"; x=1;
		}
	if(!document.ISTForm.msid[document.ISTForm.msid.selectedIndex].value){
		err_msg=err_msg+"Marital Status\n"; x=1;
		}
	if(!document.ISTForm.gender[document.ISTForm.gender.selectedIndex].value){
		err_msg=err_msg+"Gender\n"; x=1;
		}
	if(!document.ISTForm.address.value){
		err_msg=err_msg+"Address\n"; x=1;
		}
	if(!document.ISTForm.city.value){
		err_msg=err_msg+"City\n"; x=1;
		}
	if(!document.ISTForm.countryid[document.ISTForm.countryid.selectedIndex].value){
		err_msg=err_msg+"Country\n"; x=1;
		}
	if(!document.ISTForm.telh.value){
		err_msg=err_msg+"Telephone (Home)\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------	


//Education Form validation
//---------------------------	
function eduValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.edu_stdate.value){
		err_msg=err_msg+"From Date\n"; x=1;
		}
	if(!document.ISTForm.edu_endate.value){
		err_msg=err_msg+"To Date\n"; x=1;
		}
	if(!document.ISTForm.edu_lvlid[document.ISTForm.edu_lvlid.selectedIndex].value){
		err_msg=err_msg+"Level\n"; x=1;
		}	
	if(!document.ISTForm.edu_qualification.value){
		err_msg=err_msg+"Qualification\n"; x=1;
		}
	if(!document.ISTForm.edu_institution.value){
		err_msg=err_msg+"Institution\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------	

	
//Technical Skill Form validation
//---------------------------	
function techValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.tec_skill.value){
		err_msg=err_msg+"Technical Skill\n"; x=1;
		}
	if(!document.ISTForm.tec_years.value){
		err_msg=err_msg+"Duration\n"; x=1;
		}
	else {
		if(isNaN(document.ISTForm.tec_years.value)){
			err_msg=err_msg+"Duration - Invalid Characters\n"; x=1;
			}
		 }
	return msg(err_msg,x)
	}
//---------------------------		


//Education Form validation
//---------------------------	
function langValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.lan_name.value){
		err_msg=err_msg+"Language\n"; x=1;
		}
	if(!document.ISTForm.lan_lvlid[document.ISTForm.lan_lvlid.selectedIndex].value){
		err_msg=err_msg+"Ability\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------	

	
//Career Details Form validation
//---------------------------	
function carValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.car_stdate.value){
		err_msg=err_msg+"From Date\n"; x=1;
		}
	if(!document.ISTForm.car_endate.value){
		err_msg=err_msg+"To Date\n"; x=1;
		}
	if(!document.ISTForm.car_company.value){
		err_msg=err_msg+"Company\n"; x=1;
		}
	if(!document.ISTForm.car_position.value){
		err_msg=err_msg+"Position\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------		


//Referee Details Form validation
//---------------------------	
function refValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.ref_name.value){
		err_msg=err_msg+"Name\n"; x=1;
		}
	if(!document.ISTForm.ref_position.value){
		err_msg=err_msg+"Position\n"; x=1;
		}
	if(!document.ISTForm.ref_company.value){
		err_msg=err_msg+"Company\n"; x=1;
		}
	if(!document.ISTForm.ref_tel.value){
		err_msg=err_msg+"Telephone\n"; x=1;
		}
	if(document.ISTForm.ref_email.value){		
		email = document.ISTForm.ref_email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid\n"; x=1;
			}
		}
	return msg(err_msg,x)
	}
//---------------------------	
	
//Referee Details Form validation
//---------------------------	
function addinfoValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.add_info.value){
		err_msg=err_msg+"Additional Information\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------	
	
//Application Form validation
//---------------------------	
function appValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.comments.value){
		err_msg=err_msg+"Comments\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------		



//Administration	



//Log-in Form I validation
//---------------------------	
function lgnValidateS(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.usrname.value){
		err_msg=err_msg+"User Name\n"; x=1;
		}
	if(!document.ISTForm.pswd.value){
		err_msg=err_msg+"Password\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------	
	
	
//Company update Form validation
//---------------------------	
function cmValidateS(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ISTForm.cmname.value){
		err_msg=err_msg+"Name of the Company\n"; x=1;
		}
	if(!document.ISTForm.cmprofile.value){
		err_msg=err_msg+"Profile\n"; x=1;
		}	
	if(document.ISTForm.cmlogo.value){
		FullPath = document.ISTForm.cmlogo.value
		var re = new RegExp('gif|jpg$');
		// Only allow submit if it is an image file allowed 
		if (!FullPath.match(re)) {  
			err_msg=err_msg+"Selected file is not a supported format. (Supported Formats: JPG/GIF)\n"; x=1;
		 }	
		}
	if(document.ISTForm.cmweb.value){
		var url = new RegExp('^http://');
		cmweb = document.ISTForm.cmweb.value;
		if(!cmweb.match(url)){
		   	err_msg=err_msg+"Web Site - URL Invalid (http://)\n"; x=1;
			}
		}
	return msg(err_msg,x)
	}
//---------------------------	
	
//Change Password form Validation
//Uses function msg() defined at top
function passValidateS(){
	var x=0;
	var err_msg=""
	if(!document.ISTForm.pswd.value){
		err_msg=err_msg+"Old Password\n"; x=1;
		}
	if(!document.ISTForm.pswd1.value){
		err_msg=err_msg+"New Password\n"; x=1;
		}
	if(!document.ISTForm.pswd2.value){
		err_msg=err_msg+"Re-enter Password\n"; x=1;
		}
	if(!(document.ISTForm.pswd1.value == document.ISTForm.pswd2.value) ){
		err_msg=err_msg+"Password Mismatch. Re-enter new passwords.\n"; x=1;
		}
	return msg(err_msg,x);
	}
	
//Vacancy update Form validation
//---------------------------	
function vacValidateS(){
//alert("3")
	var x=0;
	var err_msg=""	
	if(!document.ISTForm.vaccmid[document.ISTForm.vaccmid.selectedIndex].value){
		err_msg=err_msg+"Company\n"; x=1;
		}	
	if(!document.ISTForm.vactitle.value){
		err_msg=err_msg+"Job Title\n"; x=1;
		}	
	if(!document.ISTForm.vacdesc.value){
		err_msg=err_msg+"Description\n"; x=1;
		}
	if(!document.ISTForm.vacstdate.value){
		err_msg=err_msg+"Display Start Date\n"; x=1;
		}
	if(!document.ISTForm.vacendate.value){
		err_msg=err_msg+"Display End Date\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------	


//Status value Form validation
//---------------------------	
function stValidateS(){
//alert("3")
	var x=0;
	var err_msg=""	
	if(!document.ISTForm.sttitle.value){
		err_msg=err_msg+"Status Title\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------	


//FAQ's  Form validation
//---------------------------	
function faqValidateS(){
//alert("3")
	var x=0;
	var err_msg=""	
	if(!document.ISTForm.faqqst.value){
		err_msg=err_msg+"Question\n"; x=1;
		}	
	if(!document.ISTForm.faqans.value){
		err_msg=err_msg+"Answer\n"; x=1;
		}	
	return msg(err_msg,x)
	}
//---------------------------	


//Login Activate/Deactivate  check
function rsActCheck(url) {
	var conf = confirm("The candidate login status will be changed.\nAre you sure?")
	if(!conf) 
		return false;
	else
		window.location=url;
	}	
//---------------------------	


//print a page	
function printpage() {
		window.print();
	}			