// ========= Validation  For Simple Search ==========

function DoSimpleSearch()
{
	var frm = document.frmEmpOpt;
	if (frm.txtSearch.value=="")
	{
		alert("Please Enter some search value.");
		frm.txtSearch.focus();
		return false;		
	}
	else
	{		
		frm.action = "phy_searchResult.asp";		
		frm.submit();
		//window.location="phy_searchResult.asp";
	}
}

// =========  Validation For Adv. Search ==========


	function DoSearch()
	{
		var m;
		//If user wants keyword search
		/*
			if ((document.frmEmpOpt.hdnSearch.value == "") && (document.frmEmpOpt.txtKeywords.value != ""))
			{
				alert('Please select a [search under] value.');				
				return false;
			}*/
		
		if (document.frmEmpOpt.txtKeywords.value != ''){ 
			document.frmEmpOpt.hdnSearch.value = ' ';
				for (var m = 0; m < document.frmEmpOpt.elements.length ; m++){
				if (document.frmEmpOpt.elements[m].name.substring(0,3) == 'chk'){					
					if (document.frmEmpOpt.elements[m].checked == true){
							switch (document.frmEmpOpt.elements[m].name){
							case 'chkName': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'PHY_NAME +';break;
							case 'chkSpez': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'SPEZ_NAME +';break;							
							case 'chkCity': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'CITY +';break;
							case 'chkState': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'STATE +';break;
							case 'chkZip': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'ZIP +';break;
							case 'chkPhone': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'PHONE +';break;
							case 'chkFax': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'FAX +';break;							
							case 'chkMed': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'MED_EDU +';break;
							case 'chkFac': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'FACILITY +';break;
							case 'chkInter': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'INTERSHIP +';break;
							case 'chkResi': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'RESIDENCY +';break;
							case 'chkBoard': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'BOARD_CERTIFICATE +';break;
							//case 'chkSpezDesc': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'SPEZ_DESC +';break;
							//case 'chkAddress': document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value + 'ADDRESS +';break;
						}	//End of switch						
					}//End of if
				}	//End of if
			}	//End of For

			if (trim(document.frmEmpOpt.hdnSearch.value) == '' & !document.frmEmpOpt.chkSpezDesc.checked & !document.frmEmpOpt.chkAddress.checked){
				alert('Please select a [search under] value.');
				return false;
			}
			
			
/*			if (document.frmEmpOpt.hdnSearch.value == " ")
			{
				alert('Please select a [search under] value.');
				return false;
			}*/

				
			
			document.frmEmpOpt.hdnSearch.value = document.frmEmpOpt.hdnSearch.value.substr(1, document.frmEmpOpt.hdnSearch.value.length - 2);
		}else{
			if ( (document.frmEmpOpt.txtPhyName.value == '') && (document.frmEmpOpt.txtSpez.value == '') && (document.frmEmpOpt.SpezId.value == '0') && (document.frmEmpOpt.txtCity.value == '' ) && (document.frmEmpOpt.txtState.value == '') && (document.frmEmpOpt.txtZip.value == '') && (document.frmEmpOpt.txtPhone.value == '') && (document.frmEmpOpt.txtFax.value == ''))
			{
				alert('Please enter a search value.');
				document.frmEmpOpt.txtPhyName.focus();
				return false;
			}

			if ((document.frmEmpOpt.txtSpez.value != '') && (document.frmEmpOpt.SpezId.value != '0'))
			{
				alert('Eihter enter specilization name Or select one from provided list.');
				return false;
			}
		}		
		//document.frmEmpOpt.action = 'phy_searchResult.asp';
		//document.frmEmpOpt.submit();
		return true;
	}



	function CheckAll(){
		var i;
		for(i = 0; i<document.frmEmpOpt.elements.length; i++){  
			if (document.frmEmpOpt.elements[i].name.substring(0,3) == 'chk'){
				document.frmEmpOpt.elements[i].checked = document.frmEmpOpt.chkAll.checked;
			}
		}
	}


function DispPhy(m)
{
	var frm = document.frmEmpOpt;
	frm.submit();
	if (m == "S") {window.location= "phy_dir_spez.asp";}
	if (m == "N") {window.location= "phy_dir.asp";}
}

function OpenSelected()
{
	var frm = document.frmEmpOpt;
	frm.action = "phy_dir.asp";
	frm.submit();
}

function showDtls(m)
{
	var frm = document.frmEmpOpt;
	frm.phyId.value = m;
	frm.action = "phy_detail.asp";
	frm.submit();	
}


function ExpandOne(m)
{
	var frm = document.frmEmpOpt;
	frm.txtSpezCd.value= m;
	frm.txtMode.value= "";
	frm.submit();
}


function ExpColAll(t)
{
	var frm = document.frmEmpOpt;
	frm.txtSpezCd.value="";
	frm.txtMode.value= t;
	frm.submit();	
}

//============= Funtion for Sort the Specialization Result Set====================
	
	function sortResult()
	{
		var frm = document.frmDisp;
		if(frm.so.value == 'A')
			frm.so.value = 'D';
		else
			frm.so.value = 'A';
		frm.submit();
	}
