var str;
var langcat;

function submitCCM(){
			if (document.getElementById("Country").value == ""){
				alert ("Country Field Cannot Be Blank");
				document.getElementById("Country").focus(); 
				return false; 
			}
			if (document.getElementById("Role").value == ""){
				alert ("Role Field Cannot Be Blank");
				document.getElementById("Role").focus(); 
				return false; 
			}
                        if (document.getElementById("Name").value == ""){
				alert ("Name Field Cannot Be Blank");
				document.getElementById("Name").focus(); 
				return false; 
                        }
			if (document.getElementById("Sector").value == ""){
				alert ("Sector Field Cannot Be Blank");
				document.getElementById("Sector").focus(); 
				return false; 
			}
			if (document.getElementById("Organization").value == ""){
				alert ("Organization Field Cannot Be Blank");
				document.getElementById("Organization").focus(); 
				return false; 
			}

			if ((document.getElementById("Phone").value == "") || isNaN(document.getElementById("Phone").value)){
				alert ("Phone Field Cannot Be Blank and Must be Digits");
				document.getElementById("phone1").focus(); 
				return false; 
			}
			
			if (document.getElementById("Email").value == ""){
				alert ("Email Field Cannot Be Blank");
				document.getElementById("Email").focus(); 
				return false; 
			}
			if (document.getElementById("Email").value.indexOf('@')<1){
				alert ("Enter valid Email");
				document.getElementById("Email").focus(); 
				return false; 
			}
			
			
			else{
			
				return true;
			}
	 }

function submitNGO(){
			if (document.getElementById("name_organization").value == ""){
				alert ("Organization's Name Field Cannot Be Blank");
				document.getElementById("name_organization").focus(); 
				return false; 
			}
			
			if ((document.getElementById("title").value == "Others") && (document.getElementById("titleothers").value == "")){	
					alert ("Supply Your Title in the Title Field");
					document.getElementById("titleothers").disabled = false;
					document.getElementById("titleothers").focus(); 
					return false;	
			}
			if (document.getElementById("fname").value == ""){
				alert ("Firstname Field Cannot Be Blank");
				document.getElementById("fname").focus(); 
				return false; 
			}
			if (document.getElementById("lname").value == ""){
				alert ("Lastname Field Cannot Be Blank");
				document.getElementById("lname").focus(); 
				return false; 
			}
			if (document.getElementById("area_specialization").value == ""){
				alert ("Specialization's Field Cannot Be Blank");
				document.getElementById("area_specialization").focus(); 
				return false; 
			}
			if ((document.getElementById("type_organization").value == "Others") && (document.getElementById("orgtypeothers").value == "")){
				alert ("Organization's Type Field Cannot Be Blank");
				document.getElementById("orgtypeothers").focus(); 
				return false; 
			}
			if ((document.getElementById("no_staff").value != "") && isNaN(document.getElementById("no_staff").value)){
				alert ("No of Staff Field Must be a Digit");
				document.getElementById("no_staff").focus(); 
				return false; 
			}
			/*
			if ((document.getElementById("experience").value == "") || isNaN(document.getElementById("experience").value)){
				alert ("Years of Experience Field Must be a Digit");
				document.getElementById("experience").focus(); 
				return false; 
			}
			*/
			
			if (document.getElementById("street").value == ""){
				alert ("Street Field Cannot Be Blank");
				document.getElementById("street").focus(); 
				return false; 
			}
			if (document.getElementById("city").value == ""){
				alert ("City Field Cannot Be Blank");
				document.getElementById("city").focus(); 
				return false; 
			}
			
			if (document.getElementById("country").value == ""){
				alert ("Country Field Cannot Be Blank");
				document.getElementById("country").focus(); 
				return false; 
			}
			if ((document.getElementById("zip").value != "") && (isNaN(document.getElementById("zip").value))){
				alert ("Years of zip Field Must be a Digit");
				document.getElementById("zip").focus(); 
				return false; 
			}
			
			if (document.getElementById("email").value == ""){
				alert ("Email Field Cannot Be Blank");
				document.getElementById("email").focus(); 
				return false; 
			}
			if (document.getElementById("email").value.indexOf('@')<1){
				alert ("Enter valid Email");
				document.getElementById("email").focus(); 
				return false; 
			}
			
			if ((document.getElementById("phone1").value == "") || (isNaN(document.getElementById("phone1").value))){
				alert ("Phone 1 Field Cannot Be Blank and Must be Digits");
				document.getElementById("phone1").focus(); 
				return false; 
			}
			if ((document.getElementById("phone2").value != "")){
					if ((isNaN(document.getElementById("phone2").value))){
					alert ("Phone 2 Field Must be Digits");
					document.getElementById("code2").focus(); 
					return false; 
				}
			
			}
			else{
			
				return true;
			}
	 }
	 

function submitConsultant(){
			if ((document.getElementById("title_consultant").value == "Others") && (document.getElementById("titleothers_consultant").value == "")){	
					alert ("Supply Your Title in the Title Field");
					document.getElementById("titleothers").focus(); 
					return false;	
			}
			if (document.getElementById("fname_consultant").value == ""){
				alert ("Firstname Field Cannot Be Blank");
				document.getElementById("fname_consultant").focus(); 
				return false; 
			}
			if (document.getElementById("lname_consultant").value == ""){
				alert ("Lastname Field Cannot Be Blank");
				document.getElementById("lname_consultant").focus(); 
				return false; 
			}
			if (document.getElementById("qualification_consultant").value == ""){
				alert ("Qualification Field Cannot be Blank");
				document.getElementById("qualification_consultant").focus(); 
				return false; 
			}
			/*
			if ((document.getElementById("experience_consultant").value == "") || isNaN(document.getElementById("experience_consultant").value)){
				alert ("Years of Experience Field Must be a Digit");
				document.getElementById("experience_consultant").focus(); 
				return false; 
			}
			*/
			if (document.getElementById("nationality_consultant").value == ""){
				alert ("Nationality Field Cannot Be Blank");
				document.getElementById("nationality_consultant").focus(); 
				return false; 
			}
			if ((document.getElementById("rate").value == "") || isNaN(document.getElementById("rate").value)){
				alert ("Rate Field Must be a Digit");
				document.getElementById("rate").focus(); 
				return false; 
			}
			
			if (document.getElementById("street_consultant").value == ""){
				alert ("Street Field Cannot Be Blank");
				document.getElementById("street_consultant").focus(); 
				return false; 
			}
			/*
			if (document.getElementById("city_consultant").value == ""){
				alert ("City Field Cannot Be Blank");
				document.getElementById("city_consultant").focus(); 
				return false; 
			}
			*/
			if (document.getElementById("country_consultant").value == ""){
				alert ("Country Field Cannot Be Blank");
				document.getElementById("country_consultant").focus(); 
				return false; 
			}
			if ((document.getElementById("zip_consultant").value != "") && isNaN(document.getElementById("zip_consultant").value)){
				alert ("Years of zip Field Must be a Digit");
				document.getElementById("zip_consultant").focus(); 
				return false; 
			}
			
			if (document.getElementById("email_consultant").value == ""){
				alert ("Email Field Cannot Be Blank");
				document.getElementById("email_consultant").focus(); 
				return false; 
			}
			if (document.getElementById("email_consultant").value.indexOf('@')<1){
				alert ("Enter valid Email");
				document.getElementById("email_consultant").focus(); 
				return false; 
			}
			
			if ((document.getElementById("phone1_consultant").value == "") || isNaN(document.getElementById("phone1_consultant").value)){
				alert ("Phone 1 Field Cannot Be Blank and Must be Digits");
				document.getElementById("phone1_consultant").focus(); 
				return false; 
			}
			if ((document.getElementById("phone2_consultant").value != "")){
					if ((isNaN(document.getElementById("phone2_consultant").value))){
					alert ("Phone 2 Field Cannot Be Blank and Must be Digits");
					document.getElementById("phone2_consultant").focus(); 
					return false; 
				}
			
			}
			else{
			
				return true;
			}
}

function submitContact(){
			if ((document.getElementById("title_contact").value == "Others") && (document.getElementById("titleothers_contact").value == "")){	
					alert ("Supply Your Title in the Title Field");
					document.getElementById("titleothers_contact").focus(); 
					return false;	
			}
			
			if (document.getElementById("fname_contact").value == ""){
				alert ("Firstname Field Cannot Be Blank");
				document.getElementById("fname_contact").focus(); 
				return false; 
			}
			if (document.getElementById("lname_contact").value == ""){
				alert ("Lastname Field Cannot Be Blank");
				document.getElementById("lname_contact").focus(); 
				return false; 
			}
			
			/*
			if (document.getElementById("street").value == ""){
				alert ("Street Field Cannot Be Blank");
				document.getElementById("street").focus(); 
				return false; 
			}
			if (document.getElementById("city").value == ""){
				alert ("City Field Cannot Be Blank");
				document.getElementById("city").focus(); 
				return false; 
			}
			if (document.getElementById("state").value == ""){
				alert ("state Field Cannot Be Blank");
				document.getElementById("state").focus(); 
				return false; 
			}
			if (document.getElementById("country").value == ""){
				alert ("Country Field Cannot Be Blank");
				document.getElementById("country").focus(); 
				return false; 
			}
			*/
			if ((document.getElementById("zip_contact").value != "") && isNaN(document.getElementById("zip_contact").value)){
				alert ("Years of zip Field Must be a Digit");
				document.getElementById("zip_contact").focus(); 
				return false; 
			}
			
			if (document.getElementById("email_contact").value == ""){
				alert ("Email Field Cannot Be Blank");
				document.getElementById("email_contact").focus(); 
				return false; 
			}
			if (document.getElementById("email_contact").value.indexOf('@')<1){
				alert ("Enter valid Email");
				document.getElementById("email_contact").focus(); 
				return false; 
			}
			
			if ((document.getElementById("phone1_contact").value == "") || isNaN(document.getElementById("phone1_contact").value)){
				alert ("Phone 1 Field Cannot Be Blank and Must be Digits");
				document.getElementById("phone1_contact").focus(); 
				return false; 
			}
			if ((document.getElementById("phone2_contact").value != "")){
					if ((isNaN(document.getElementById("phone2").value))){
					alert ("Phone 2 Field Must be Digits");
					document.getElementById("phone2_contact").focus(); 
					return false; 
				}
			
			}
			else{
			
				return true;
			}
	 }


function submitIntern(){
			var a;
			if ((document.getElementById("title_intern").value == "Others") && (document.getElementById("titleothers_intern").value == "")){	
					alert ("Supply Your Title in the Title Field");
					document.getElementById("titleothers_intern").focus(); 
					return false;	
			}
			if (document.getElementById("fname_intern").value == ""){
				alert ("Firstname Field Cannot Be Blank");
				document.getElementById("fname_intern").focus(); 
				return false; 
			}
			if (document.getElementById("lname_intern").value == ""){
				alert ("Lastname Field Cannot Be Blank");
				document.getElementById("lname_intern").focus(); 
				return false; 
			}
			/*
			if ((document.getElementById("experience_intern").value != "") || isNaN(document.getElementById("experience_intern").value)){
				alert ("Years of Experience Field Must be a Digit");
				document.getElementById("experience_intern").focus(); 
				return false; 
			}
			*/
			if (document.getElementById("street_intern").value == ""){
				alert ("Street Field Cannot Be Blank");
				document.getElementById("street_intern").focus(); 
				return false; 
			}
			
			if (document.getElementById("country_intern").value == ""){
				alert ("Country Field Cannot Be Blank");
				document.getElementById("country_intern").focus(); 
				return false; 
			}
			if ((document.getElementById("zip_intern").value != "") && isNaN(document.getElementById("zip_intern").value)){
				alert ("Years of zip Field Must be a Digit");
				document.getElementById("zip+intern").focus(); 
				return false; 
			}
			
			if (document.getElementById("email_intern").value == ""){
				alert ("Email Field Cannot Be Blank");
				document.getElementById("email_intern").focus(); 
				return false; 
			}
			if (document.getElementById("email_intern").value.indexOf('@')<1){
				alert ("Enter valid Email");
				document.getElementById("email_intern").focus(); 
				return false; 
			}
			
			if ((document.getElementById("phone1_intern").value == "") || isNaN(document.getElementById("phone1_intern").value)){
				alert ("Phone 1 Field Cannot Be Blank and Must be Digits");
				document.getElementById("phone1_intern").focus(); 
				return false; 
			}
			if ((document.getElementById("phone2_intern").value != "")){
					if ((isNaN(document.getElementById("phone2").value))){
					alert ("Phone 2 Field Cannot Be Blank and Must be Digits");
					document.getElementById("phone2_intern").focus(); 
					return false; 
				}
			
			}
			else{
			
				return true;
			}
	 }




function addLanguage(langcat){

	if(langcat == "ngo"){
		//var cat = document.getElementById("category").value;
		var cat = "NGO";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
		var id = document.getElementById("id").value;
				
		adLanguage(a,b,c,d,id,cat);
		//alert(d);
		return true;
	}
	else if(langcat == "consultant"){
		//var cat = document.getElementById("category").value;
		var cat = "Consultant";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
		var id = document.getElementById("id").value;
				
		adLanguage(a,b,c,d,id,cat);
		return true;
	
	}
	else if(langcat == "contact"){
		//var cat = document.getElementById("category").value;
		var cat = "Contact";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
		var id = document.getElementById("id").value;
				
		adLanguage(a,b,c,d,id,cat);
		//alert("Here");
		return true;
	
	}
	else if(langcat == "intern"){
		//var cat = document.getElementById("category").value;
		var cat = "Intern";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
		var id = document.getElementById("id").value;
				
		adLanguage(a,b,c,d,id,cat);
		return true;
	
	}

}

function addLang(langcat){

	if(langcat == "ngo"){
		//var cat = document.getElementById("category").value;
		var cat = "NGO";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
				
		InsertLang(a,b,c,d,cat);
		return true;
	}
	else if(langcat == "consultant"){
		//var cat = document.getElementById("category").value;
		var cat = "Consultant";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
				
		InsertLang(a,b,c,d,cat);
		return true;
	
	}
	else if(langcat == "contact"){
		//var cat = document.getElementById("category").value;
		var cat = "Contact";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
				
		InsertLang(a,b,c,d,cat);
		return true;
	
	}
	else if(langcat == "intern"){
		//var cat = document.getElementById("category").value;
		var cat = "Intern";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
				
		InsertLang(a,b,c,d,cat);
		return true;
	
	}

}

function addHomeLang(langcat){

	if(langcat == "ngo"){
		//var cat = document.getElementById("category").value;
		var cat = "NGO";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
				
		InsertHomeLang(a,b,c,d,cat);
		return true;
	}
	else if(langcat == "consultant"){
		//var cat = document.getElementById("category").value;
		var cat = "Consultant";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
				
		InsertHomeLang(a,b,c,d,cat);
		return true;
	
	}
	else if(langcat == "contact"){
		//var cat = document.getElementById("category").value;
		var cat = "Contact";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
				
		InsertHomeLang(a,b,c,d,cat);
		return true;
	
	}
	else if(langcat == "intern"){
		//var cat = document.getElementById("category").value;
		var cat = "Intern";
		var a;
		if(document.getElementById("language").value == "Others"){
			a = document.getElementById("otherlang").value;
		}else{
			a = document.getElementById("language").value;
		}
		var b = document.getElementById("speaking").value;
		var c = document.getElementById("reading").value;
		var d = document.getElementById("writing").value;
				
		InsertHomeLang(a,b,c,d,cat);
		return true;
	
	}

}
function changeOrg(type_organization,orgtypeothers){
	if (document.getElementById(type_organization).value == "Others"){
				document.getElementById(orgtypeothers).disabled = false;
				if (document.getElementById(orgtypeothers).value == ""){
					//document.getElementById("qualificationothers").value = "";
					document.getElementById(orgtypeothers).focus(); 
					return false;
				} 
			}
	else{
			document.getElementById(orgtypeothers).value = "";
			document.getElementById(orgtypeothers).disabled = true;
	}
}
function changeOrg_contact(){
	
    
    if (document.getElementById("type_organization").value == "NGO"){
				document.getElementById("type_ngo").disabled = false;
				if (document.getElementById("type_ngo").value == ""){
					document.getElementById("type_ngo").focus(); 
					return false;
				} 
			}
	else{
			document.getElementById("type_ngo").value = "";
			document.getElementById("type_ngo").disabled = true;
	}
    
    if (document.getElementById("type_organization").value == "Private"){
				document.getElementById("type_private").disabled = false;
				if (document.getElementById("type_private").value == ""){
					document.getElementById("type_private").focus(); 
					return false;
				} 
			}
	else{
			document.getElementById("type_private").value = "";
			document.getElementById("type_private").disabled = true;
	}
    if (document.getElementById("type_organization").value == "Others"){
				document.getElementById("orgtypeothers").disabled = false;
				if (document.getElementById("orgtypeothers").value == ""){
					document.getElementById("orgtypeothers").focus(); 
					return false;
				} 
			}
	else{
			document.getElementById("orgtypeothers").value = "";
			document.getElementById("orgtypeothers").disabled = true;
	}
}
function changeSpec(){
	if (document.getElementById("area_specialization").value == "Others"){
				document.getElementById("specothers").disabled = false;
				if (document.getElementById("specothers").value == "Specify others"){
					document.getElementById("specothers").value = "";
					document.getElementById("specothers").focus(); 
					return false;
				} 
			}
	else{
			document.getElementById("specothers").value = "";
			document.getElementById("specothers").disabled = true;
	}
}
function changeTaCat(){
	if (document.getElementById("tacategory").value == "Public Health"){
					document.getElementById("tacategoryothers").disabled = false;
					if (document.getElementById("tacategoryothers").value == ""){
						document.getElementById("tacategoryothers").focus(); 
						return false;
					} 
				}
		else{
				document.getElementById("tacategoryothers").value = "";
				document.getElementById("tacategoryothers").disabled = true;
	}
}
function changeQual(){
	if (document.getElementById("qualification").value == "Others"){
					document.getElementById("qualificationothers").disabled = false;
					if (document.getElementById("qualificationothers").value == ""){
						//document.getElementById("qualificationothers").value = "";
						document.getElementById("qualificationothers").focus(); 
						return false;
					} 
				}
		else{
				document.getElementById("qualificationothers").value = "";
				document.getElementById("qualificationothers").disabled = true;
	}
}
function changeOther(title,titleothers){
	if (document.getElementById(title).value == "Others"){
				document.getElementById(titleothers).disabled = false;
				if (document.getElementById(titleothers).value == ""){
					//alert ("Supply Your Title in the Title Field");
					document.getElementById(titleothers).focus(); 
					return false;
				} 
			}
	else{
			document.getElementById(titleothers).value = "";
			document.getElementById(titleothers).disabled = true;
	}
	
}

function changeLangOther(){
	if (document.getElementById("language").value == "Others"){
				document.getElementById("otherlang").disabled = false;
				//document.getElementById("otherlang").type = "text";
				if (document.getElementById("otherlang").value == ""){
					//alert ("Supply Your Title in the Title Field");
					document.getElementById("otherlang").focus(); 
					//return false;
				} 
			}
	else{
			document.getElementById("otherlang").value = "";
			//document.getElementById("otherlang").type = "hidden";
			document.getElementById("otherlang").disabled = true;
	}
	
}
function mailValidate(){
			
			
			if (document.getElementById("from").value == ""){
				alert ("From Field Cannot Be Blank");
				document.getElementById("from").focus(); 
				return false; 
			}
			if (document.getElementById("from").value.indexOf('@')<1){
				alert ("Enter valid Email");
				document.getElementById("from").focus(); 
				return false; 
			}
			if (document.getElementById("subject").value == ""){
				alert ("Subject Field Cannot Be Blank");
				document.getElementById("subject").focus(); 
				return false; 
			}
			
			
			if (document.getElementById("message").value == ""){
				alert ("Message Field Cannot Be Blank");
				document.getElementById("message").focus(); 
				return false; 
			}
			
			else{
			
				return true;
			}
	 }
	 
function showField() {
		document.getElementById("textspecialization").style.display= "block";
		document.getElementById("textspecialization").style.visibility= "visible";
		
		document.getElementById("selectspecialization").style.display= "none";
		document.getElementById("selectspecialization").style.visibility= "hidden";
}
	
function hideField() {
		document.getElementById("textspecialization").style.display= "none";
		document.getElementById("textspecialization").style.visibility= "hidden";
		
		document.getElementById("selectspecialization").style.display= "block";
		document.getElementById("selectspecialization").style.visibility= "visible";
}
function showNgoSearch() {
		document.getElementById("ngodiv").style.display= "block";
		document.getElementById("ngodiv").style.visibility= "visible";
		
		document.getElementById("tadiv").style.display= "none";
		document.getElementById("tadiv").style.visibility= "hidden";
		
		document.getElementById("condiv").style.display= "none";
		document.getElementById("condiv").style.visibility= "hidden";
}
	
function showTaSearch() {
		document.getElementById("ngodiv").style.display= "none";
		document.getElementById("ngodiv").style.visibility= "hidden";
		
		document.getElementById("tadiv").style.display= "block";
		document.getElementById("tadiv").style.visibility= "visible";
		
		document.getElementById("condiv").style.display= "none";
		document.getElementById("condiv").style.visibility= "hidden";
}

function showContactSearch() {
		document.getElementById("ngodiv").style.display= "none";
		document.getElementById("ngodiv").style.visibility= "hidden";
		
		document.getElementById("tadiv").style.display= "none";
		document.getElementById("tadiv").style.visibility= "hidden";
		
		document.getElementById("condiv").style.display= "block";
		document.getElementById("condiv").style.visibility= "visible";
}
function search_value(){
		var cat = document.getElementById("category").value;
		var str = document.getElementById("search_txt").value;
		search(cat,str);
}