function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}  


function ClearValue(x)
{ 
	document.getElementById(x).value="";
	clearHTML('xtraCounties');

}
function clearHTML(x)
{ 
	document.getElementById(x).innerHTML="";
}
function keypress(e)
{
	var Ucode=e.keyCode? e.keyCode : e.charCode
    if (Ucode == 13)
    {
     //write the code for submit
		ajax_request();
    }
}
function getHTML(type) //type = 'county.html' if from the map or anything else
	{
		var w;
		var url;
		var path = "./includes/";
		switch (type)
		{
			case 'countyName':{
				w = document.countyList.byCounty.selectedIndex;
				url = path + document.countyList.byCounty.options[w].value;
				document.countyseatList.byCountySeat.selectedIndex = 0;
				document.getElementById("placename").value="Enter a city or town";
				toggleBox('xtraCounties',0); //turn off
				clearHTML('xtraCounties');
				break;
			}
			case 'countySeat':{
				w = document.countyseatList.byCountySeat.selectedIndex;
				url = path + document.countyseatList.byCountySeat.options[w].value;
				document.countyList.byCounty.selectedIndex = 0;
				document.getElementById("placename").value="Enter a city or town";
				toggleBox('xtraCounties',0); //turn off
				clearHTML('xtraCounties');

				break;
			}
			case 'findCounties':{
				w = document.xtraCountiesList.listofCounties.selectedIndex;
				url = path + document.xtraCountiesList.listofCounties.options[w].value;
				document.countyList.byCounty.selectedIndex = 0;
				document.countyseatList.byCountySeat.selectedIndex = 0;
				toggleBox('xtraCounties',1); //turn on

				break;
			}
			default :{
				url= path + type;
				document.countyseatList.byCountySeat.selectedIndex = 0;
				document.countyList.byCounty.selectedIndex = 0;
				break;  // from the map or just pass 'county.html'
			}
		} //end of switch
		if (url != "no")
		{
			var pars = '';
			var myAjax = new Ajax.Updater(
					{success: 'layoutCenterBody'}, 
					url, 
					{
						method: 'get', 
						parameters: pars,
						onFailure: reportError,
						onComplete: imagelist
					});
			var nI = document.getElementsByTagName('iframe').length;
            
            if ( nI > 0 ) {
               for(i=0;i<nI;i++) {
                  var mG = document.getElementsByTagName('iframe')[i];
                  if ( mG.name == "google_ads_frame" ) {
                     var src = mG.src + "&rsnd=" + new Date().getTime();
                     mG.src = src;
                     break;
                  }
               }
            }

		}

	}
  function imagelist()
  {
    myLightbox.updateImageList();
  }
	function reportError(request)
	{
		alert('Sorry. There was an error.');
	}
	function reportStart(request)
	{
		alert('There is a start.');
	}

