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]+$/;

// function to chk valid file extension
/*function isValidExt(strPath)
{
	var strExt, intPos
	intPos = strPath.lastIndexOf(".")
	strExt = strPath.substr(intPos+1,strPath.length)
	strExt = strExt.toUpperCase()
	switch(strExt)
	{
		case "DOC" : 
			return true;
			break;
		case "TXT" : 
			return true;
			break;
		case "PDF" : 
			return true;
			break;
		default :
			return false;
			break;
	}
}*/


// function to chk valid file extensions---
//prototype- isValidExt(FilePath,ValidExtensions(comma separated values))
//e.g isValidExt('c://mydocuments/test.doc','doc,pdf,txt')
function isValidExt(strFile,strValid)
{
	intPos = strFile.lastIndexOf(".")
	strFType = strFile.substr(intPos+1,strFile.length)
	strFType = strFType.toUpperCase()
	
	strValid = strValid.toUpperCase()
	strValid = strValid.split(",")
	
	for(i=0;i<strValid.length;i++)
		{
			switch(strFType)
			 {
				case strValid[i] : 
						return true;
						break;
			 }
		}
} 

//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;
}
// only english	
function checkEnglish(object_value)	{
	var check_char;	
	for (var i = 0; i < object_value.length; i++) {		
			check_char = object_value.charCodeAt(i);
			
			if (check_char > 300)
				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
}
	
//member Reg Form validation
//---------------------------	
function memregValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.Prefix[document.ASTFForm.Prefix.selectedIndex].value){
		err_msg=err_msg+"Title\n"; x=1;
		}
	if(!document.ASTFForm.fname.value){
		err_msg=err_msg+"First Name\n"; x=1;
		}
	else {
		fname = document.ASTFForm.fname.value;
		if(!checkEnglish(fname)){
		   	err_msg=err_msg+"First Name - Invalid English Characters\n"; x=1;
			}
		}
	
	if(!document.ASTFForm.mname.value){
		err_msg=err_msg+"Middle Name\n"; x=1;
		}
	else {
		mname = document.ASTFForm.mname.value;
		if(!checkEnglish(mname)){
		   	err_msg=err_msg+"Middle Name - Invalid English Characters\n"; x=1;
			}
		}
	if(!document.ASTFForm.lname.value){
		err_msg=err_msg+"Last Name\n"; x=1;
		}
		else {
		lname = document.ASTFForm.lname.value;
		if(!checkEnglish(lname)){
		   	err_msg=err_msg+"Last Name - Invalid English Characters\n"; x=1;
			}
		}
	if(!document.ASTFForm.placeofwork.value){
		err_msg=err_msg+"Place of Work\n"; x=1;
		}
	else {
		placeofwork = document.ASTFForm.placeofwork.value;
		if(!checkEnglish(placeofwork)){
		   	err_msg=err_msg+"Place of Work- Invalid English Characters\n"; x=1;
			}
		}
	if(!document.ASTFForm.department.value){
		err_msg=err_msg+"Department\n"; x=1;
		}
	else {
		department = document.ASTFForm.department.value;
		if(!checkEnglish(department)){
		   	err_msg=err_msg+"Department- Invalid English Characters\n"; x=1;
			}
		}
	if(!document.ASTFForm.designation.value){
		err_msg=err_msg+"Designation\n"; x=1;
		}
		else {
		designation = document.ASTFForm.designation.value;
		if(!checkEnglish(designation)){
		   	err_msg=err_msg+"Job Title - Invalid English Characters\n"; x=1;
			}
		}
	if(!document.ASTFForm.nationality[document.ASTFForm.nationality.selectedIndex].value){
		err_msg=err_msg+"Nationality\n"; x=1;
		}		
	if(!document.ASTFForm.email.value){
		err_msg=err_msg+"Email\n"; x=1;
		}
	else {
		email = document.ASTFForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}
	if(!document.ASTFForm.tel_off.value){
		err_msg=err_msg+"Office Telephone\n"; x=1;
		}
	if(!document.ASTFForm.fax.value){
		err_msg=err_msg+"Fax\n"; x=1;
		}
	if(!document.ASTFForm.paddress.value){
		err_msg=err_msg+"Postal Address\n"; x=1;
		}
	if(!document.ASTFForm.cntry_res[document.ASTFForm.cntry_res.selectedIndex].value){
		err_msg=err_msg+"Country of Residence\n"; x=1;
		}	
	if(!document.ASTFForm.speciality_gen.value){
		err_msg=err_msg+"General Speciality\n"; x=1;
		}
	if(!document.ASTFForm.speciality.value){
		err_msg=err_msg+"Speciality\n"; x=1;
		}
	if(!document.ASTFForm.usrname.value){
		err_msg=err_msg+"User Name\n"; x=1;
		}
	if(!document.ASTFForm.pswd.value){
		err_msg=err_msg+"Password\n"; x=1;
		}
	if(!document.ASTFForm.pswd1.value){
		err_msg=err_msg+"Retype Password\n"; x=1;
		}
	if(document.ASTFForm.pswd.value != document.ASTFForm.pswd1.value){
		err_msg=err_msg+"Password Mismatch. Re-enter new passwords\n"; x=1;
		}	
		
	return msg(err_msg,x)
	}
//---------------------------	
	
//member Reg Form validation
//---------------------------	
function memregNValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.Prefix[document.ASTFForm.Prefix.selectedIndex].value){
		err_msg=err_msg+"Prefix\n"; x=1;
		}
	if(!document.ASTFForm.fname.value){
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.ASTFForm.lname.value){
		err_msg=err_msg+"Last Name\n"; x=1;
		}
		if(!document.ASTFForm.mname.value){
		err_msg=err_msg+"Middle Name\n"; x=1;
		}
	if(!document.ASTFForm.placeofwork.value){
		err_msg=err_msg+"Place of Work\n"; x=1;
		}
	if(!document.ASTFForm.department.value){
		err_msg=err_msg+"Department\n"; x=1;
		}
	if(!document.ASTFForm.designation.value){
		err_msg=err_msg+"Designation\n"; x=1;
		}
	if(!document.ASTFForm.nationality[document.ASTFForm.nationality.selectedIndex].value){
		err_msg=err_msg+"Nationality\n"; x=1;
		}		
	if(!document.ASTFForm.email.value){
		err_msg=err_msg+"Email\n"; x=1;
		}
	else {
		email = document.ASTFForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}
	if(!document.ASTFForm.tel_off.value){
		err_msg=err_msg+"Office Telephone\n"; x=1;
		}
	if(!document.ASTFForm.paddress.value){
		err_msg=err_msg+"Postal Address\n"; x=1;
		}
	if(!document.ASTFForm.cntry_res[document.ASTFForm.cntry_res.selectedIndex].value){
		err_msg=err_msg+"Country of Residence\n"; x=1;
		}	
	if(!document.ASTFForm.speciality_gen.value){
		err_msg=err_msg+"General Speciality\n"; x=1;
		}
	if(!document.ASTFForm.speciality.value){
		err_msg=err_msg+"Speciality\n"; x=1;
		}		
	return msg(err_msg,x)
	}
//---------------------------	
	
//Login Form validation
//---------------------------	
function loginValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	
	if(!document.ASTFForm.usrname.value){
		err_msg=err_msg+"User Name\n"; x=1;
		}
	if(!document.ASTFForm.pswd.value) {
		err_msg=err_msg+"Password\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------	
	
//Forgot password Form validation
//---------------------------	
function fgtloginValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.email.value && !document.ASTFForm.usrname.value){
		err_msg=err_msg+"Enter Email Address or User Name\n"; x=1;
		}
	if(document.ASTFForm.email.value) {
		email = document.ASTFForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}
	return msg(err_msg,x)
	}
//---------------------------		


//member Reg Form validation
//---------------------------	
function memeduValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.degree[document.ASTFForm.degree.selectedIndex].value){
		err_msg=err_msg+"Degree\n"; x=1;
		}
	if(!document.ASTFForm.institution.value){
		err_msg=err_msg+"Institution\n"; x=1;
		}
	if(!document.ASTFForm.cntry[document.ASTFForm.cntry.selectedIndex].value){
		err_msg=err_msg+"Country\n"; x=1;
		}
	if(!document.ASTFForm.cyear.value){
		err_msg=err_msg+"Year\n"; x=1;
		}
		
	return msg(err_msg,x)
	}
//---------------------------	


//Mailing List Form validation
//---------------------------	
function mlValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.Prefix[document.ASTFForm.Prefix.selectedIndex].value){
		err_msg=err_msg+"Prefix\n"; x=1;
		}
	if(!document.ASTFForm.fname.value){
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.ASTFForm.lname.value){
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(!document.ASTFForm.email.value){
		err_msg=err_msg+"Email\n"; x=1;
		}
	else {
		email = document.ASTFForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}
		
	return msg(err_msg,x)
	}
//---------------------------	





//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;
	}	
//---------------------------	

	
//Enquiry Form validation
//---------------------------	
function enqValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.enquiry.value){
		err_msg=err_msg+"Enquiry/Comment\n"; x=1;
		}	
	if(!document.ASTFForm.Prefix[document.ASTFForm.Prefix.selectedIndex].value){
		err_msg=err_msg+"Prefix\n"; x=1;
		}
	if(!document.ASTFForm.fname.value){
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.ASTFForm.lname.value){
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(!document.ASTFForm.email.value){
		err_msg=err_msg+"Email\n"; x=1;
		}
	else {
		email = document.ASTFForm.email.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Email - Invalid Characters\n"; x=1;
			}
		}
	if(!document.ASTFForm.Hear_About_Us[document.ASTFForm.Hear_About_Us.selectedIndex].value){
		err_msg=err_msg+"How  did you hear about us?\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------	


// system administration validation requests

//product update Form validation
//---------------------------	
function prdValidate(){
//alert("3")
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.catid[document.ASTFForm.catid.selectedIndex].value){
		err_msg=err_msg+"Product Category\n"; x=1;
		}	
	if(!document.ASTFForm.prdcode.value){
		err_msg=err_msg+"Product Code\n"; x=1;
		}		
	if(!document.ASTFForm.prddesc.value){
		err_msg=err_msg+"Description\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------	
	
//product Delete Record check
function prdDelCheck() {
	var conf = confirm("The product will be permanently deleted from the database.\nAre you sure?")
	if(!conf) 
		return false;
	else
		return true;
	}	
//---------------------------	

//distributor update Form validation
//---------------------------	
function dstrValidate(){
//alert("3")
	var x=0;
	var err_msg=""	
	var tmp = 0;
	if(!document.ASTFForm.dis_name.value){
		err_msg=err_msg+"Company Name\n"; x=1;
		}
	if(!document.ASTFForm.dis_city.value){
		err_msg=err_msg+"City\n"; x=1;
		}
	if(!document.ASTFForm.dis_cntry[document.ASTFForm.dis_cntry.selectedIndex].value){
		err_msg=err_msg+"Country\n"; x=1;
		}
	if(!document.ASTFForm.dis_telsales.value){
		err_msg=err_msg+"Phone (Sales)\n"; x=1;
		}		
	if (document.ASTFForm.catids.length>0){
		for (i=0;i<document.ASTFForm.catids.length;i++)
 			{
			if (document.ASTFForm.catids[i].checked){
				tmp = 1;
				}
			}
		}
	else {
		if (document.ASTFForm.catids.checked) {
			tmp = 1;
			}
		}
	if (tmp == 0){
		err_msg=err_msg+"Select product category\n"; x=1;
		}		
	return msg(err_msg,x)
	}
//---------------------------	
	
//distributor Delete Record check
function dstrDelCheck() {
	var conf = confirm("The distributor information will be permanently deleted from the database.\nAre you sure?")
	if(!conf) 
		return false;
	else
		return true;
	}	
//---------------------------	


//category update Form validation
//---------------------------	
function catmnValidate(){
//alert("3")
	var x=0;
	var err_msg=""	
	if(!document.ASTFForm.cat_name.value){
		err_msg=err_msg+"Category Name\n"; x=1;
		}
	if(!document.ASTFForm.cat_desc.value){
		err_msg=err_msg+"Description\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------	

//category Delete Record check
function catmnDelCheck() {
	var conf = confirm("The category will be permanently deleted from the database.\nAre you sure?")
	if(!conf) 
		return false;
	else
		return true;
	}	
//---------------------------	


//category update Form validation
//---------------------------	
function catsbValidate(){
//alert("3")
	var x=0;
	var err_msg=""	
	if(!document.ASTFForm.cat_parent[document.ASTFForm.cat_parent.selectedIndex].value){
		err_msg=err_msg+"Parent Category\n"; x=1;
		}
	if(!document.ASTFForm.cat_name.value){
		err_msg=err_msg+"Category Name\n"; x=1;
		}
	if(!document.ASTFForm.cat_desc.value){
		err_msg=err_msg+"Description\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------	

//category Delete Record check
function catsbDelCheck() {
	var conf = confirm("The category will be permanently deleted from the database.\nAre you sure?")
	if(!conf) 
		return false;
	else
		return true;
	}	
//---------------------------	

//Change Password Form validation
//---------------------------	
function passValidate(){
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.Pass1.value){
		err_msg=err_msg+"Old Password\n"; x=1;
		}	
	else {
		if(!checkIlleg(document.ASTFForm.Pass1.value)){
			err_msg=err_msg+"Old Password - Invalid Characters\n"; x=1;
			}
		 }
	if(!document.ASTFForm.Pass2.value){
		err_msg=err_msg+"New Password\n"; x=1;
		}	
	else {
		if(!checkIlleg(document.ASTFForm.Pass2.value)){
			err_msg=err_msg+"New Password - Invalid Characters\n"; x=1;
			}
		 }
	if(!document.ASTFForm.Pass3.value){
		err_msg=err_msg+"Retype Password\n"; x=1;
		}	
	else {
		if(!checkIlleg(document.ASTFForm.Pass3.value)){
			err_msg=err_msg+"Retype Password - Invalid Characters\n"; x=1;
			}
		 }
	if(document.ASTFForm.Pass2.value != document.ASTFForm.Pass3.value){
		err_msg=err_msg+"Password Mismatch. Re-enter new passwords\n"; x=1;
		}	
	return msg(err_msg,x)
	}	
//---------------------------		

	
//Poll Validation
//Uses function msg() defined at top
function pollValidate(){
	var x=0;
	var err_msg=""
	var tmp = 0;
	if (document.PollForm.PollAns.length>0){
		for (i=0;i<document.PollForm.PollAns.length;i++)
 			{
			if (document.PollForm.PollAns[i].checked){
				tmp = 1;
				}
			}
		}
	else {
		if (document.PollForm.PollAns.checked) {
			tmp = 1;
			}
		}
	if (tmp == 0){
		err_msg=err_msg+"Select an Answer\n"; x=1;
		}
	return msg(err_msg,x)
	}	
	

//Discussion Forum - Post Message validation
function Val_DisForm(){
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.subject.value){
		err_msg=err_msg+"Message Subject\n"; x=1;
		}
	if(!document.ASTFForm.msgbody.value){
		err_msg=err_msg+"Message\n"; x=1;
		}
	return msg(err_msg,x)
	}
//---------------------------

//Submit Materials - Post Material validation
function Val_MatForm(){
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.mat_title.value){
		err_msg=err_msg+"Material Title\n"; x=1;
		}
	if(!document.ASTFForm.mat_desc.value){
		err_msg=err_msg+"Description\n"; x=1;
		}
	if(!document.ASTFForm.photo1.value){
		err_msg=err_msg+"Material to be Submitted\n"; x=1;
		}
	return msg(err_msg,x)
	}
//-------------------------

//Shared Docs - Submit Docs validation
function Val_DocForm(){
	var x=0;
	var err_msg=""
	if(!document.ASTFForm.doc_title.value){
		err_msg=err_msg+"Document Title\n"; x=1;
		}
	if(!document.ASTFForm.doc_desc.value){
		err_msg=err_msg+"Description\n"; x=1;
		}
	if(!document.ASTFForm.photo1.value){
		err_msg=err_msg+"Document to be Submitted\n"; x=1;
		}
		
	if(document.ASTFForm.photo1.value!="")
		{
			if(!isValidExt(document.ASTFForm.photo1.value,"doc,pdf,txt,zip"))
				{
				alert("Invalid File Extension")
				document.ASTFForm.photo1.select();
				return false;
				} 
		}
		
	return msg(err_msg,x)
	}
//-------------------------

// validation for Registration Form----First Page  
function validatefrmReg()
{
	//alert(1)     
	var x=0;
	var err_msg=""
	if(!document.frmReg.txtname.value)
		{
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.frmReg.txtlname.value)
		{
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(document.frmReg.cboCountry[document.frmReg.cboCountry.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Country\n"; x=1;
	 }
	if(!document.frmReg.txtEmail.value)
	 {
		err_msg=err_msg+"Email Id\n"; x=1;
	 }
	else 
	 {
		email = document.frmReg.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	}
	if(!document.frmReg.txtUserName.value)
	 {
		err_msg=err_msg+"User Name\n"; x=1;
	 }
	if(!document.frmReg.txtPassword.value)
	 {
		err_msg=err_msg+"Password\n"; x=1;
	 }
	 if(!document.frmReg.txtConfirm.value)
	 {
		err_msg=err_msg+"Confirm Password\n"; x=1;
	 }
	 if((document.frmReg.txtConfirm.value!="") && (document.frmReg.txtPassword.value!=""))
	 {
	 	if(document.frmReg.txtConfirm.value!=document.frmReg.txtPassword.value)
		{err_msg=err_msg+"Password And Confirm Password do not match\n"; x=1;}
	 }
	 
	return msg(err_msg,x)
}

function validatefrmRegU()
{
	var x=0;
	var err_msg=""
	if(!document.frmRegU.txtname.value)
		{
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.frmRegU.txtlname.value)
		{
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(document.frmRegU.cboCountry[document.frmRegU.cboCountry.selectedIndex].value=="")
	 {
		err_msg=err_msg+"Country\n"; x=1;
	 }
	if(!document.frmRegU.txtEmail.value)
	 {
		err_msg=err_msg+"Email Id\n"; x=1;
	 }
	else 
	 {
		email = document.frmRegU.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	}
	return msg(err_msg,x)
}
// function for Registration form second page (proposal summary)
function validatefrmRegS()
{
	//alert(1);
	//alert(document.frmRegS.txtTTitle.value) ;
	var x=0;
	var err_msg=""
	if(!document.frmRegS.txtTTitle.value)
		{
		err_msg=err_msg+"Track Title\n"; x=1;
		}
	if(!document.frmRegS.txtPInv.value)
		{
		err_msg=err_msg+"Principal Investigator\n"; x=1;
		}
	if(!document.frmRegS.txtTopical.value)
		{
		err_msg=err_msg+"Topical Area\n"; x=1;     
		}
	if(!document.frmRegS.txtTitle.value)
		{
		err_msg=err_msg+"Title\n"; x=1;
		}
	return msg(err_msg,x)
}


// function for Registration form second page (TEAM DETAILS)
function validatefrmRegT()
{
	//alert(1)     
	var x=0;
	var err_msg=""
	
	if(!document.frmRegT.cboPrefix[document.frmRegT.cboPrefix.selectedIndex].value){
		err_msg=err_msg+"Prefix\n"; x=1;
		}
	if(!document.frmRegT.txtname.value)
		{
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.frmRegT.txtlname.value)
		{
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(document.frmRegT.cboCountry[document.frmRegT.cboCountry.selectedIndex].value=="") 
	 {
		err_msg=err_msg+"Country\n"; x=1;
	 }
	if(!document.frmRegT.txtEmail.value)
	 {
		err_msg=err_msg+"Email Id\n"; x=1;
	 }
	else 
	 {
		email = document.frmRegT.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	}
	return msg(err_msg,x)
}

//function for Attaching File by the memeber (Attach File)
function validatefrmRegA()
{
	var x=0;
	var err_msg=""
	if(document.frmRegA.txtAtt.value=="")
		{
		err_msg=err_msg+"Attach File\n"; 
		x=1;
		}  
		
	if(document.frmRegA.txtAtt.value!="")
		{
			if(!isValidExt(document.frmRegA.txtAtt.value,"doc,pdf,txt,zip"))
				{
				alert("Invalid File Extension")
				document.frmRegA.txtAtt.select();
				return false;
				} 
		}
	return msg(err_msg,x)
}

	
//AFF Prog Reg Form Validation
//Uses function msg() defined at top
function tafValidate(){
	//alert("test2")
	var x=0;
	var err_msg=""
	if(!document.TAFForm.SndName.value){
		err_msg=err_msg+"Your Name\n"; x=1;
		}
	else {
		if (!checkIlleg(document.TAFForm.SndName.value)){
			err_msg=err_msg+"Your Name - Invalid Characters\n"; x=1;
			}
		}		
	if(!document.TAFForm.SndEmail.value){
		err_msg=err_msg+"Your Email\n"; x=1;
		}
	else {
		email = document.TAFForm.SndEmail.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Your Email - Invalid Characters\n"; x=1;
			}
		 }
	if(!document.TAFForm.RcpName1.value){
		err_msg=err_msg+"Friend's Name\n"; x=1;
		}
	else {
		if(!checkIlleg(document.TAFForm.RcpName1.value)){
			err_msg=err_msg+"Friend's Name - Invalid Characters\n"; x=1;
			}
		 }	
	if(!document.TAFForm.RcpEmail1.value){
		err_msg=err_msg+"Friend's Email\n"; x=1;
		}
	else {
		email = document.TAFForm.RcpEmail1.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"Friend's Email - Invalid Characters\n"; x=1;
			}
		 }
	if(document.TAFForm.RcpName2.value){
		if(!checkIlleg(document.TAFForm.RcpName2.value)){
			err_msg=err_msg+"2nd Friend's Name - Invalid Characters\n"; x=1;
			}
		}
	if(document.TAFForm.RcpEmail2.value){
		email = document.TAFForm.RcpEmail2.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"2nd Friend's Email - Invalid Characters\n"; x=1;
			}
		}
	if(document.TAFForm.RcpName3.value){
		if(!checkIlleg(document.TAFForm.RcpName3.value)){
			err_msg=err_msg+"3rd Friend's Name - Invalid Characters\n"; x=1;
			}
		}
	if(document.TAFForm.RcpEmail3.value){
		email = document.TAFForm.RcpEmail3.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"3rd Friend's Email - Invalid Characters\n"; x=1;
			}
		}		
	if(document.TAFForm.RcpName4.value){
		if(!checkIlleg(document.TAFForm.RcpName4.value)){
			err_msg=err_msg+"4th Friend's Name - Invalid Characters\n"; x=1;
			}
		}
	if(document.TAFForm.RcpEmail4.value){
		email = document.TAFForm.RcpEmail4.value;
		if(email.search(regexp) == -1){
		   	err_msg=err_msg+"4th Friend's Email - Invalid Characters\n"; x=1;
			}
		}		
	return msg(err_msg,x)
	}		


// validation function for job seeking form

function validatefrmSeek()
{
	var x=0;
	var err_msg=""
	if(document.frmSeek.txtLogin.value=="")
		{
		err_msg=err_msg+"Login Name\n"; 
		x=1;
		}  

	if(document.frmSeek.txtPass.value=="")
		{
		err_msg=err_msg+"Password\n"; 
		x=1;
		}  
	if(document.frmSeek.txtConfirm.value=="")
		{
		err_msg=err_msg+"Confirm Password\n"; 
		x=1;
		}  

	 if((document.frmSeek.txtConfirm.value!="") && (document.frmSeek.txtPass.value!=""))
	 {
	 	if(document.frmSeek.txtConfirm.value!=document.frmSeek.txtPass.value)
		{err_msg=err_msg+"Password And Confirm Password do not match\n"; x=1;}
	 }

	if(document.frmSeek.txtFName.value=="")
		{
		err_msg=err_msg+"First Name\n"; 
		x=1;
		}  

	if(document.frmSeek.txtLName.value=="")
		{
		err_msg=err_msg+"Last Name\n"; 
		x=1;
		}  

	if(document.frmSeek.txtBDate.value=="")
		{
		err_msg=err_msg+"Birth Date\n"; 
		x=1;
		}  

	if(document.frmSeek.cboIndustry[document.frmSeek.cboIndustry.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Industry\n"; x=1;
	 }

	if(document.frmSeek.cboExperience[document.frmSeek.cboExperience.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Experience\n"; x=1;
	 }

	if(document.frmSeek.cboLocation[document.frmSeek.cboLocation.selectedIndex].value=="-1")
	 {
		err_msg=err_msg+"Preferred Location\n"; x=1;
	 }
	
	if(document.frmSeek.cboResident[document.frmSeek.cboResident.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Resident Country\n"; x=1;
	 }
	 
	 if(!document.frmSeek.txtEmail.value)
	 {
		err_msg=err_msg+"Email Id\n"; x=1;
	 }
	else 
	 {
		email = document.frmSeek.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	}
 
	if(document.frmSeek.txtCV.value!="")
		{
			if(!isValidExt(document.frmSeek.txtCV.value,"doc,pdf,txt,zip"))
				{
				alert("Invalid File Extension")
				document.frmSeek.txtCV.select();
				return false;
				} 
		}
	return msg(err_msg,x)
}

// FUNCTION TO VALIDATE EMPLOYER REG FORM
function validatefrmEmp()
{
	var x=0;
	var err_msg=""
	if(document.frmEmp.txtLogin.value=="")
		{
		err_msg=err_msg+"Login Name\n"; 
		x=1;
		}  

	if(document.frmEmp.txtPass.value=="")
		{
		err_msg=err_msg+"Password\n"; 
		x=1;
		}  
	if(document.frmEmp.txtConfirm.value=="")
		{
		err_msg=err_msg+"Confirm Password\n"; 
		x=1;
		}  

	 if((document.frmEmp.txtConfirm.value!="") && (document.frmEmp.txtPass.value!=""))
	 {
	 	if(document.frmEmp.txtConfirm.value!=document.frmEmp.txtPass.value)
		{err_msg=err_msg+"Password And Confirm Password do not match\n"; x=1;}
	 }

	if(document.frmEmp.txtCompName.value=="")
		{
		err_msg=err_msg+"Company Name\n"; 
		x=1;
		}  
	
	if(document.frmEmp.cboIndustry[document.frmEmp.cboIndustry.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Industry\n"; x=1;
	 }
	 
	if(document.frmEmp.txtFName.value=="")
		{
		err_msg=err_msg+"Contact First Name\n"; 
		x=1;
		}  

	if(document.frmEmp.txtLName.value=="")
		{
		err_msg=err_msg+"Contact Last Name\n"; 
		x=1;
		}  
	
	
	if(document.frmEmp.txtDesig.value=="")
		{
		err_msg=err_msg+"Contact Designation\n"; 
		x=1;
		}  

	if(document.frmEmp.cboCountry[document.frmEmp.cboCountry.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Country\n"; x=1;
	 }
	 
	 if(document.frmEmp.txtTel.value=="")
		{
		err_msg=err_msg+"Telephone\n"; 
		x=1;
		}  

	 if(!document.frmEmp.txtEmail.value)
	 {
		err_msg=err_msg+"Email Id\n"; x=1;
	 }
	else 
	 {
		email = document.frmEmp.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	}
	
	if(document.frmEmp.txtLogo.value!="")
		{
			if(!isValidExt(document.frmEmp.txtLogo.value,"jpg,gif"))
				{
				alert("Invalid File Extension")
				document.frmEmp.txtLogo.select();
				return false;
				} 
		}
 	return msg(err_msg,x)
}

// function for login for for career network

function validatefrmLogin()
{
	var x=0;
	var err_msg=""
	if(document.frmLogin.txtLogin.value=="")
		{
		err_msg=err_msg+"Login Name\n"; 
		x=1;
		}  
	if(document.frmLogin.txtPass.value=="")
		{
		err_msg=err_msg+"Password\n"; 
		x=1;
		}  
	return msg(err_msg,x)
}

function validatefrmPostjob()
{
	var x=0;
	var err_msg=""
	if(document.frmPostjob.txtJobTitle.value=="")
		{
		err_msg=err_msg+"Job Title\n"; 
		x=1;
		}  
	
	/*if(document.frmPostjob.cboIndustry[document.frmPostjob.cboIndustry.selectedIndex].value=="0")
		{
		err_msg=err_msg+"Industry\n"; 
		x=1;
		}  

	if(document.frmPostjob.cboExperience[document.frmPostjob.cboExperience.selectedIndex].value=="0")
		{
		err_msg=err_msg+"Experience\n"; 
		x=1;
		}  
	*/
	
	if(document.frmPostjob.txtOrgName.value=="")
		{
		err_msg=err_msg+"Organisation Name\n"; 
		x=1;
		}  
	if(document.frmPostjob.txtEmail.value=="")
		{
		err_msg=err_msg+"Email Id\n"; 
		x=1;
		} 
	else 
	 {
		email = document.frmPostjob.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	} 
	
	if(document.frmPostjob.txtCity.value=="")
		{
		err_msg=err_msg+"City\n"; 
		x=1;
		}  
		
	if(document.frmPostjob.cboCountry[document.frmPostjob.cboCountry.selectedIndex].value=="0")
		{
		err_msg=err_msg+"Country\n"; 
		x=1;
		}  
	if(document.frmPostjob.txtEndDate.value=="")
		{
		err_msg=err_msg+"End Date\n"; 
		x=1;
		}  
	return msg(err_msg,x)
}

function validatefrmSeekUpdate()
{
	var x=0;
	var err_msg=""
	
	if(document.frmSeekUpdate.txtFName.value=="")
		{
		err_msg=err_msg+"First Name\n"; 
		x=1;
		}  

	if(document.frmSeekUpdate.txtLName.value=="")
		{
		err_msg=err_msg+"Last Name\n"; 
		x=1;
		}  

	if(document.frmSeek.txtBDate.value=="")
		{
		err_msg=err_msg+"Birth Date\n"; 
		x=1;
		}  

	if(document.frmSeekUpdate.cboIndustry[document.frmSeekUpdate.cboIndustry.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Industry\n"; x=1;
	 }

	if(document.frmSeekUpdate.cboExperience[document.frmSeekUpdate.cboExperience.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Experience\n"; x=1;
	 }

	if(document.frmSeekUpdate.cboLocation[document.frmSeekUpdate.cboLocation.selectedIndex].value=="-1")
	 {
		err_msg=err_msg+"Preferred Location\n"; x=1;
	 }
	
	if(document.frmSeekUpdate.cboResident[document.frmSeekUpdate.cboResident.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Resident Country\n"; x=1;
	 }
	 
	 if(!document.frmSeekUpdate.txtEmail.value)
	 {
		err_msg=err_msg+"Email Id\n"; x=1;
	 }
	else 
	 {
		email = document.frmSeekUpdate.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	}
 
	if(document.frmSeekUpdate.txtCV.value!="")
		{
			if(!isValidExt(document.frmSeekUpdate.txtCV.value,"doc,pdf,txt,zip"))
				{
				alert("Invalid File Extension")
				document.frmSeekUpdate.txtCV.select();
				return false;
				} 
		}
	return msg(err_msg,x)
}

// functin for update of mem profile
function validatefrmMemUpdate()
{
	var x=0;
	var err_msg=""
	if(!document.frmMemUpdate.txtname.value)
		{
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.frmMemUpdate.txtlname.value)
		{
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(document.frmMemUpdate.cboCountry[document.frmMemUpdate.cboCountry.selectedIndex].value=="")
	 {
		err_msg=err_msg+"Country\n"; x=1;
	 }
	if(!document.frmMemUpdate.txtEmail.value)
	 {
		err_msg=err_msg+"Email Id\n"; x=1;
	 }
	else 
	 {
		email = document.frmMemUpdate.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	}
	
	
	if(document.frmMemUpdate.txtPassword.value!="")
	 {
	 	if((document.frmMemUpdate.txtConfirm.value=="") || (document.frmMemUpdate.txtNewPassword.value==""))
			{err_msg=err_msg+"Fill New Password And Confirm New Password\n"; x=1;}
	 	if((document.frmMemUpdate.txtConfirm.value!="") && (document.frmMemUpdate.txtNewPassword.value!=""))
	 		{
	 		if(document.frmMemUpdate.txtConfirm.value!=document.frmMemUpdate.txtNewPassword.value)
				{err_msg=err_msg+"New Password And Confirm New Password do not match\n"; x=1;}
			 }	
	 }
	return msg(err_msg,x)
}

// function for member registration 

function validatefrmRegMem()
{
	var x=0;
	var err_msg=""
	if(!document.frmRegMem.txtname.value)
		{
		err_msg=err_msg+"First Name\n"; x=1;
		}
	if(!document.frmRegMem.txtlname.value)
		{
		err_msg=err_msg+"Last Name\n"; x=1;
		}
	if(document.frmRegMem.cboCountry[document.frmRegMem.cboCountry.selectedIndex].value=="")
	 {
		err_msg=err_msg+"Country\n"; x=1;
	 }
	if(!document.frmRegMem.txtEmail.value)
	 {
		err_msg=err_msg+"Email Id\n"; x=1;
	 }
	else 
	 {
		email = document.frmRegMem.txtEmail.value;
		if(email.search(regexp) == -1)
	     {
		   	err_msg=err_msg+"Email Id-Invalid Characters\n"; x=1;
		 }
	}
	if(!document.frmRegMem.txtUserName.value)
	 {
		err_msg=err_msg+"User Name\n"; x=1;
	 }
	if(!document.frmRegMem.txtPassword.value)
	 {
		err_msg=err_msg+"Password\n"; x=1;
	 }
	 if(!document.frmRegMem.txtConfirm.value)
		 {
			err_msg=err_msg+"Confirm Password\n"; x=1;
		 }
	 if((document.frmRegMem.txtConfirm.value!="") && (document.frmRegMem.txtPassword.value!=""))
		 {
		if(document.frmRegMem.txtConfirm.value!=document.frmRegMem.txtPassword.value) 
			{err_msg=err_msg+"Password And Confirm Password do not match\n"; x=1;}
	 }
	 
	return msg(err_msg,x)
	
}



function validatepub()
{
	var x=0;
	var err_msg=""
	if(!document.pub.title.value)
		{
		err_msg=err_msg+"Title\n"; x=1;
		}
	if(document.pub.ptyp[document.pub.ptyp.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Type\n"; x=1;
	 }
	 
	 if(document.pub.pcat[document.pub.pcat.selectedIndex].value=="0")
	 {
		err_msg=err_msg+"Category\n"; x=1;
	 }
	 
	//the field was deactivated due to an issue with Arabic data
	//if(document.pub.i_file.value)
		//{
			//if(!isValidExt(document.pub.i_file.value,"gif,jpg"))
				//{
				//alert("Invalid Image File Extension")
				//document.pub.i_file.select()
				//return false;
				//err_msg=err_msg+"Invalid Image File Extension\n"; x=1;
				//}
		//} 
		
	if(document.pub.p_file.value!="")
		{
			if(!isValidExt(document.pub.p_file.value,"pdf"))
				{
				//alert("Invalid PDF File Extension")
				//document.pub.p_file.select()
				//return false;
				err_msg=err_msg+"Invalid PDF File Extension"; x=1;
				}
		} 
	if(!document.pub.pubdt.value)
		{
		err_msg=err_msg+"Date\n"; x=1;
		}
	return msg(err_msg,x)
}
