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 ucfirst(str) {
    var firstLetter = str.substr(0, 1);
    return firstLetter.toUpperCase() + str.substr(1);
}
function getHTML(type) // 'county.html' if from the map or anything else
	{
		var w;
		var url;
		var str;
		var anchors = document.getElementsByName('STATE');
		var myAnchor = anchors[0];	
		var st = myAnchor.innerHTML;  // This give you 'STATE' from the menu
		var sta = st.toLowerCase();  // make sure it is lowercase
		var	path = "../genCountyHtml.php?fn=http://barnfield.net/";
		switch (type)
		{
			case 'countyName':{
				w = document.countyList.byCounty.selectedIndex;
				str = 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;			
				str = 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;
				str = document.xtraCountiesList.listofCounties.options[w].value;
				document.countyList.byCounty.selectedIndex = 0;
				document.countyseatList.byCountySeat.selectedIndex = 0;
				toggleBox('xtraCounties',1); //turn on

				break;
			}
			default :{
				str = type;
				document.countyseatList.byCountySeat.selectedIndex = 0;
				document.countyList.byCounty.selectedIndex = 0;
				break;  // from the map or just pass 'county.html'
			}
		} //end of switch
		str = str.replace('html', 'jpg') ;
		url = path + sta + "/images/" + str;
		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.');
	}


