function validate_project(id)
{

	if(trim(frm_case.title.value)=="")
	{
		alert("Please enter title.");
		document.frm_case.title.focus();		
		return false;
	}
 
	if(trim(frm_case.Flimg.value))
	{
		rest = frm_case.Flimg.value.substr(frm_case.Flimg.value.length-4,frm_case.Flimg.value.length);
		lower=rest.toLowerCase();
		if(lower!=".jpg" && lower!="jpeg" && lower!=".png")
		{
			alert("Please upload only JPG or PNG file");
			return false;
		}
	}

	if(id==0) frm_case.action="db_case.php?a=i&id="+id;
	else frm_case.action="db_case.php?a=u&id="+id;
	frm_case.submit()
	
}





function validate_stra(id){
		
	if(trim(frm_part.title.value)==""){
		alert("Please enter title.")
document.frm_part.title.focus();		
return false;
	}	

	if(frm_part.str_url.value==""){

}
else if(frm_part.str_url.value)
	{	
	
	
	var v = new RegExp();
		v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
		
			{ 	//var form=document.form;
				if (!v.test(frm_part["str_url"].value)) 
				{

				   alert("Please enter a valid url format.\ni.e. http://www.address.com");
document.frm_part.str_url.focus();	
				return false;
				}
			}

	}
   
	

if(id==0) frm_part.action="db_partners.php?a=i&id="+id;
	else frm_part.action="db_partners.php?a=u&id="+id;
	frm_part.submit()
}


function validate_r_gallery(id){
	form = document.frm;
	
	if(trim(form.title.value)==""){
		alert("Please enter title.")
document.frm.title.focus();		
return returnFalse(form.title);
	}	
	
	if(id==0){
		if(trim(form.Flimg.value)==""){
			alert("Please browse for residential image.");
			return returnFalse(form.Flimg);
		}
		else{
		rest = form.Flimg.value.substr(form.Flimg.value.length-4,form.Flimg.value.length);
		lower=rest.toLowerCase();
	
	if(lower!=".jpg" && lower!="jpeg" && lower!=".png")
	{
		alert("Please upload only JPG and PNG file");
		return returnFalse(form.Flimg);
	}
  }
}


	if(id==0) form.action="db_r_gallery.php?a=i&id="+id;
	else form.action="db_r_gallery.php?a=u&id="+id;
	
	form.submit()
}



function validatemenu(){
	form = document.frm_smallGroupCalender;
	// PDF
	if(trim(form.file.value)!=""){
		FileExt =form.file.value.substr(form.file.value.length-3,form.file.value.length)
		if(FileExt.toLowerCase()!="pdf"){
			alert("Please upload menu in PDF format only");
			return false;
		}
	}else{
		alert("Please upload menu in PDF format.");
			return false;
	}
	form.submit();
}
function validateHome(val){

if(val=='add'){
	if(trim(document.frm_announcement.announce_image.value)=="")
	{
		alert("Please Upload Image");
		document.frm_announcement.announce_image.focus();
		return false
	}	
}
	if(trim(document.frm_announcement.announce_title.value)=="")
	{
		alert("Please Enter Title");
		document.frm_announcement.announce_title.focus();
		return false
	}
  
	

	document.frm_announcement.action="db_home.php";
 	document.frm_announcement.submit();	
	return true;
	}
function validateLogin()
{

	form = document.login;
	if(trim(form.userName.value)==""){
		alert("Please enter username");
		form.userName.value='';
		form.userName.focus();
		return false;
		}
	if(trim(form.password.value)=="") {
		alert("Please enter password");
		form.password.value='';
		form.password.focus();
		return false;
		}	
	form.action = "db_login.php";
	form.submit();
	return true;
}

function validateAccountInformation(){
	form = document.frm_accountInformation;
	if(trim(form.admin_email.value)==""){
		alert("Please enter e-mail");
		form.admin_email.focus();
		return false;
	}
	else if(checkEmailAddress(form.admin_email.value)=="")	{
		alert("Please enter valid e-mail");
form.admin_email.value="";		
form.admin_email.focus();
		return false;
	}	
	
	form.action = "db_accountInformation.php";
	form.submit();
	return true;
}

function validateChangePassword(login)
{

	form = document.login;
	if(trim(form.oldPass.value)=='')
	{
		alert("Please enter old password");
		form.oldPass.focus();
		return false;
		}
	if(trim(form.newPass.value)=='')
	{
		alert("Please enter new password");
		form.newPass.focus();
		return false;
		}	
	if(trim(form.cNewPass.value)=='')
	{
		alert("Please enter confirm password");
		form.cNewPass.focus();
		return false;
		}	
	if(form.newPass.value!=form.cNewPass.value)
	{
		alert("New password and confirm password are not matched ");
		form.cNewPass.focus()
		return false;
		}
	form.action = "db_changePassword.php";
	form.submit();
	return true;
}

function showsubmenu(submenu){
	document.getElementById("m1").style.display="none";
	document.getElementById("m2").style.display="none";
	document.getElementById("m3").style.display="none";
	document.getElementById("m4").style.display="none";
	document.getElementById("r1").style.display="none";
	document.getElementById("r2").style.display="none";
	document.getElementById("r3").style.display="none";
	document.getElementById("r4").style.display="none";
	document.getElementById("a1").style.display="none";
	document.getElementById("a2").style.display="none";
	document.getElementById("a3").style.display="none";
	document.getElementById("a4").style.display="none";
	document.getElementById("s1").style.display="none";
	document.getElementById("s2").style.display="none";
	document.getElementById("s3").style.display="none";
	document.getElementById("s4").style.display="none";
	if(submenu=="p")	{
		document.getElementById("m1").style.display="";
		document.getElementById("m2").style.display="";
		document.getElementById("m3").style.display="";
		document.getElementById("m4").style.display="";
		document.getElementById("p1").style.background="#6699CC";
		document.getElementById("p2").style.background="#6699CC";
	}
	if(submenu=="r")	{
		document.getElementById("r1").style.display="";
		document.getElementById("r2").style.display="";
		document.getElementById("r3").style.display="";
		document.getElementById("r4").style.display="";
		document.getElementById("rp1").style.background="#6699CC";
		document.getElementById("rp2").style.background="#6699CC";
	}
	if(submenu=="a")	{
		document.getElementById("a1").style.display="";
		document.getElementById("a2").style.display="";
		document.getElementById("a3").style.display="";
		document.getElementById("a4").style.display="";
		document.getElementById("an1").style.background="#6699CC";
		document.getElementById("an2").style.background="#6699CC";
	}
	if(submenu=="d")
	{
		document.getElementById("s1").style.display="";
		document.getElementById("s2").style.display="";
		document.getElementById("s3").style.display="";
		document.getElementById("s4").style.display="";
		document.getElementById("dp1").style.background="#6699CC";
		document.getElementById("dp2").style.background="#6699CC";
	}
}

function validateEmployee(emp){
	form = document.frm;
	//ACTIVE
	if(form.active[form.active.selectedIndex].value==""){
		alert("Please select active.")	;
		form.active.focus();
		return false;
	}
	
	//FIRST NAME
	if(trim(form.fname.value)==""){
		alert("Please enter the Employee's First Name.")	;
		form.fname.focus();
		return false;
	}else if(!checkname(trim(form.fname.value))){
		alert("Invalid first name.")	;
		form.fname.focus();
		return false;
	}
	
	//LAST NAME
	if(trim(form.lname.value)==""){
		alert("Please enter the Employee's Last Name.")	;
		form.lname.focus();
		return false;
	}else if(!checkname(trim(form.lname.value))){
		alert("Invalid last name.")	;
		form.lname.focus();
		return false;
	}
	
	//POSITION
	if(trim(form.position.value)==""){
		alert("Please enter the Employee's Position.")	;
		form.position.focus();
		return false;
	}
	
	//BRIEF BIO
	if(trim(form.briefbio.value)==""){
		alert("Please enter the Employee's Brief Bio.")	;
		form.briefbio.focus();
		return false;
	}
	
	//BIO
	if(trim(form.bio.value)==""){
		alert("Please enter the Employee's Bio.")	;
		form.bio.focus();
		return false;
	}
	
	//PHOTO JPEG
	if(trim(form.photo.value)!=""){
		FileExt =form.photo.value.substr(form.photo.value.length-3,form.photo.value.length)
		if(((FileExt.toLowerCase()!="jpg")&&(FileExt.toLowerCase()!="jpeg"))	){
			alert("Please upload the Employee's Photo in JPG format only");
			return false;
		}
	}
	
	//BIO PDF
	if(trim(form.biopdf.value)!=""){
		FileExt =form.biopdf.value.substr(form.biopdf.value.length-3,form.biopdf.value.length)
		if(FileExt.toLowerCase()!="pdf"){
			alert("Please upload the Employee's Bio in PDF format only");
			return false;
		}
	}
	
	//RESUME PDF
	if(trim(form.resume.value)!=""){
		FileExt =form.resume.value.substr(form.resume.value.length-3,form.resume.value.length)
		if(FileExt.toLowerCase()!="pdf"){
			alert("Please upload the Employee's Resume in PDF format only");
			return false;
		}
	}
	form.action = "db_employee.php?emp="+emp
	form.submit();
}

function validateResource(res){
	form = document.frm;
	//ACTIVE
	if(form.active[form.active.selectedIndex].value==""){
		alert("Please select Active.")	;
		form.active.focus();
		return false;
	}
	
	//RESOURCE TYPE
	if(form.type[form.type.selectedIndex].value==""){
		alert("Please select Resource Type.")	;
		form.type.focus();
		return false;
	}
	
	//TITLE
	if(trim(form.title.value)==""){
		alert("Please enter Title.")	;
		form.title.focus();
		return false;
	}
	
	//PUBLISH DATE
	if(trim(form.pubdate.value)!=""){
		Arr = form.pubdate.value.split("/");
		if(!Arr[0]) Arr[0]=0;
		if(!Arr[1]) Arr[1]=0;
		if(!Arr[2]) Arr[2]=0;
		if(!checkDate(Arr[1],Arr[0],Arr[2])){
			alert("Please enter valid Publish Date in mm/dd/yyyy Format.")	;
			form.pubdate.focus();
			return false;
		}
	}
	
	//EXCERPT
	if(trim(form.exc.value)==""){
		alert("Please enter Excerpt.")	;
		form.exc.focus();
		return false;
	}
	
	//URL
	if(trim(form.url.value)!=""){
		if((form.url.value.indexOf("https://")<0)&&((form.url.value.indexOf("http://")<0))){
			alert("Please enter valid URL.")	;
			form.url.focus();
			return false;
		}
	}
	
	form.action = "db_resource.php?res="+res
	form.submit();
}

function validateAnnouncement(val){

	if(val=='add'){
		if(trim(document.frm_announcement.announce_image.value)==""){
			alert("Please Upload Announcement Image");
			document.frm_announcement.announce_image.focus();
			return false
		}	
	}
	if(trim(document.frm_announcement.announce_title.value)==""){
			alert("Please Enter Title of Announcement");
			document.frm_announcement.announce_title.focus();
			return false
	}
	/* if(val=='add'){
	if(trim(document.frm_announcement.announce_pdf.value)==""){
			alert("Please Select PDF");
			document.frm_announcement.announce_pdf.focus();
			return false;
	}
	}
	if(trim(document.frm_announcement.announce_pdf.value)!=""){
			val1 = document.frm_announcement.announce_pdf.value
			pdf=val1.substr(val1.length-3,val1.length);
			pdf=pdf.toLowerCase();	
			if(pdf!="pdf") {
			  alert("Please Upload File in PDF Format");
			  document.frm_announcement.announce_pdf.focus();
			  return false;
			}
	} */
	document.frm_announcement.action="db_announcement.php";
	document.frm_announcement.submit();	
	return true;
}
/*function hideTheForms()
{
	var id=document.FunctionalExpertise.funexp.options[document.FunctionalExpertise.funexp.selectedIndex].value;
	if(id=="")
	{
	document.getElementById("Capabilities").style.display="none";
	document.getElementById("RefMaterial").style.display="none";
	document.getElementById("Personal").style.display="none";
	}
}*/
function displayTheForms(){
	var id=document.FunctionalExpertise.funexp.options[document.FunctionalExpertise.funexp.selectedIndex].value;
	if(id==""){
		alert("Please Select Functional Expertise:");
		hideTheForm();
		//document.FunctionalExpertise.action="functionalExpertise.php";
		//document.FunctionalExpertise.submit();
		return false;
	}
	document.FunctionalExpertise.action="functionalExpertise.php";
	document.FunctionalExpertise.submit();
}
function deleteInsertExpCap()
{
	var expertise_id=document.getElementById("funexp").selectedIndex;
	var capability_id="";
	var selected=0;
	for(i=0;i<8;i++) {
		capability_id=document.getElementById("capabilitySelect"+i).selectedIndex;
		
		if (capability_id>0)  {
			selected=1;
		}
	}
	document.Capabilities.action="deleteinsertexpcap.php";
	document.Capabilities.submit();
}

function deleteInsertExpRes()
{
	var expertise_id=document.getElementById("funexp").selectedIndex;
	var refMaterial_id="";
	var selected=0;
	for(i=0;i<4;i++)
	{
		refMaterial_id=document.getElementById("refmaterialSelect"+i).selectedIndex;
		//alert(i+"---sh----"+refMaterial_id)
		if (refMaterial_id>0) 
		{
			selected=1;
		}
	}
	document.RefMaterial.action="deleteinsertexpres.php";
	document.RefMaterial.submit();
}
function addPersonalEmployee()
{
	//personal_id=document.Personal.personalSelect2.options[document.Personal.personalSelect2.selectedIndex].value;
	order_id=document.getElementById("personalSelect1").value;
	personal_id=document.getElementById("personalSelect2").value;
	if((order_id=="") && (personal_id==""))	{
		alert("Please Select an Employee and Order:");
		return false;
	}	else if(order_id=="")	{
		alert("Please Select an Order List:");
		return false;
	}	else if(personal_id=="")	{
		alert("Please Select an Employee:");
		return false;
	}	else	{
		document.Personal.action="insertPersonalEmployees.php";
		document.Personal.submit();
	}
}

//CoreCapabilities functions

function hideTheForm()
{
	var id=document.FunctionalExpertise.funexp.options[document.FunctionalExpertise.funexp.selectedIndex].value;
	if(id=="")
	{
	document.getElementById("Capabilities").style.display="none";
	document.getElementById("RefMaterial").style.display="none";
	document.getElementById("Personal").style.display="none";
	}
}
function displayTheForm()
{
var id=document.coreCapabilities.corecap.options[document.coreCapabilities.corecap.selectedIndex].value;
if(id=="")
{
	alert("Please Select Core Capability:");
	return false;
}
else
{
document.coreCapabilities.action="coreCapabilities.php";
document.coreCapabilities.submit();
}
}
function deleteInsertExpertise()
{
	var expertise_id="";
	var selected=0;
	for(i=0;i<6;i++)
	{
		expertise_id=document.getElementById("funexpertSelect"+i).selectedIndex;
		
		if (expertise_id>0) 
		{
			selected=1;
		}
	}
	document.FunctionalExpertise.action="deleteinsertexpertise.php";
	document.FunctionalExpertise.submit();
}
function deleteInsertrefmaterial()
{
	var refMaterial_id="";
	var selected=0;
	for(i=0;i<4;i++)
	{
		refMaterial_id=document.getElementById("refmaterialSelect"+i).selectedIndex;
		
		if (refMaterial_id>0) 
		{
			selected=1;
		}
	}
	document.RefMaterial.action="deleteinsertrefmaterial.php";
	document.RefMaterial.submit();
}
function addPersonalEmployees()
{
	order_id=document.getElementById("personalSelect1").value;
	personal_id=document.getElementById("personalSelect2").value;
	if(order_id=="" && personal_id=="")
	{
		alert("Please Select an Employee and Order:");
		return false;
	}
	else if(order_id=="")
	{
		alert("Please Select an Order List:");
		return false;
	}
	else if(personal_id=="")
	{
		alert("Please Select an Employee:");
		return false;
	}
		document.Personal.action="insertPersonalEmployee.php";
		document.Personal.submit();
}

//capabilityPhase validation functions

function hideThePhaseForm()
{
	var id1=document.capabilityPhase.capPhase.options[document.capabilityPhase.capPhase.selectedIndex].value;
	var id2=document.capabilityPhase.capPhase1.options[document.capabilityPhase.capPhase1.selectedIndex].value;
}
function displayThePhaseForm()
{
	var id1=document.capabilityPhase.capPhase.options[document.capabilityPhase.capPhase.selectedIndex].value;
	var id2=document.capabilityPhase.capPhase1.options[document.capabilityPhase.capPhase1.selectedIndex].value;
	if(id1=="" && id2=="")
	{
		alert("Please Select Perspective and Phase:");
		return false;
	}
	else if(id1=="")
	{
			alert("Please Select Perspective:");
			return false;
	}
	else if(id2=="")
	{
			alert("Please Select Phase:");
			return false;
	}
	document.capabilityPhase.action="capability_phase.php";
	document.capabilityPhase.submit();
}
function deleteInsertCoreCapability()
{
	var corecap_id="";
	var selected=0;
	for(i=0;i<8;i++)
	{
		corecap_id=document.getElementById("capabilitySelect"+i).selectedIndex;
		
		if (corecap_id>0) 
		{
			selected=1;
		}
	}
	document.Capabilities.action="deleteinsertcorecapability.php";
	document.Capabilities.submit();
}
function deleteInsertReferenceMaterial()
{
	var refMaterial_id="";
	var selected=0;
	for(i=0;i<4;i++)
	{
		refMaterial_id=document.getElementById("refmaterialSelect"+i).selectedIndex;
		if (refMaterial_id>0) 
		{
			selected=1;
		}
	}
	document.RefMaterial.action="deleteinsertreferencematerial.php";
	document.RefMaterial.submit();
}


function validateinnerimages(id){

	form = document.frm;	
	
	if(id==0){
		if(trim(form.innerimage.value)==""){
			alert("Please browse for product inner image.");
			return returnFalse(form.innerimage);
		}
		else{
		rest =form.innerimage.value.substr(form.innerimage.value.length-4,form.innerimage.value.length);
		lower=rest.toLowerCase();
	
	if(lower!=".jpg" && lower!="jpeg" && lower!=".png")
	{
		alert("Please Upload Only JPG and PNG File");
		return returnFalse(form.innerimage);
	}
  }
}
		
	if(trim(form.img_title.value)==""){
		alert("Please enter image title.");
document.frm.img_title.focus();	

		return returnFalse(form.img_title);
	}
	if(id==0) form.action="db_c_gallery_innerimages.php?a=i&e="+id;
	else form.action="db_c_gallery_innerimages.php?a=u&e="+id;
	form.submit()
}


function validateinnerimagesr(id){

	form = document.frm;	
	
	if(id==0){
		if(trim(form.innerimage.value)==""){
			alert("Please browse for product inner image.");
			return returnFalse(form.innerimage);
		}
		else{
		rest =form.innerimage.value.substr(form.innerimage.value.length-4,form.innerimage.value.length);
		lower=rest.toLowerCase();
	
	if(lower!=".jpg" && lower!="jpeg" && lower!=".png")
	{
		alert("Please Upload Only JPG and PNG File");
		return returnFalse(form.innerimage);
	}
  }
}
		
	if(trim(form.img_title.value)==""){
		alert("Please enter image title.");
document.frm.img_title.focus();	

		return returnFalse(form.img_title);
	}
	if(id==0) form.action="db_r_gallery_innerimages.php?a=i&e="+id;
	else form.action="db_r_gallery_innerimages.php?a=u&e="+id;
	form.submit()
}








