// JavaScript Document
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{
			try{
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}

		return xmlhttp;
    }

	function getState(countryId) {

		var strURL="attorney-videos/findState.php?country="+countryId;
		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('statediv').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
			//getCity(countryId,0)
		}
	}
	function getCity(countryId,stateId) {
	    // var strURL="findCity.php?state="+stateId+"$country="+countryId;
		var strURL="attorney-videos/findCity.php?country="+countryId+"&state="+stateId;
              //var strURL="findCity.php?state=Georgia&country=United%20States";
		//alert("findCity.php?country="+countryId+"&state="+stateId);
		var req = getXMLHTTP();

		if (req) {

			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('citydiv').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}

	}

function dosearch()
{
	if(document.getElementById("name").value=="")
	 {
		var country=document.getElementById("country").value;
		if(country=="")
			{
				alert("Please select a Country.");
				return false;
			}	
		
		var state=document.getElementById("state").value;
		var city=document.getElementById("city").value;
		if(state=="" && city=="")
			{
				alert("Please specify State or City");
				return false;
			}	
		
		
		var area_id=document.getElementById("area_id").value;
		if(area_id=="")
			{
				alert("Please select a Practice Area");
				return false;
			}
	}			
}

function LoadCountries() {

		var strURL="loadcountries.php";
		var req = getXMLHTTP();

		if (req) {
			document.getElementById('country2').innerHTML="loading..";
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('country2').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
			//getCity(countryId,0)
		}
	}