//javascript file
//MAPS
var big_error="";
function gmapload(what,lati,loni,name,add1,add2) 
{
	if (GBrowserIsCompatible()) 
	{
		document.getElementById("themap").style.display="";
        var map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());	
		
		var nname=name.replace(/_/,"'");
		if(what=="go")
		{
		var nadd1=add1.replace(/.$/,"");
		var nadd2=add2.replace(/ ,/,", ");
		var local=new GLatLng(lati,loni);      
		map.setCenter(local, 13);
		var mark=new GMarker(local)
		var thehtml="<p style='font-family:verdana;font-size:small;'><strong>"+nname+"</strong><br />"+nadd1+"<br />"+nadd2+"</p>";
		map.openInfoWindowHtml(local,thehtml)
		map.addOverlay(mark);
		GEvent.addListener(mark, "click", function(){map.openInfoWindowHtml(local,thehtml);});
		}
		if(what=="find")
		{
		document.getElementById("thedirections").innerHTML="";
		document.getElementById("gmapStatus").innerHTML="<div style='text-align:center;'>Generating Directions...</div>";
		var theplace=add1+add2;
		var directionsPanel=document.getElementById("thedirections");
		var usergadd=document.getElementById("usergadd").value;
		var locale="english";
		
		var directions = new GDirections(map, directionsPanel);
		directions.getPolyline=true;  
		GEvent.addListener(directions, "load", function (){
	if (directions.getStatus().code == G_GEO_SUCCESS)
	{
document.getElementById("gmapStatus").innerHTML = "<div style='font-weight:bold;font-size:115%;text-align:center;'>Success!!!!!!!!!</div>";
	}});
	GEvent.addListener(directions, "error", function (){
	if (directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	{
document.getElementById("gmapStatus").innerHTML = "<span class='wrgmap'>Error</span><span class='wrgmape'>:No corresponding geographic location could be found for your address. This may be due to the fact that the address is relatively new, or it may be incorrect.</span>";
redomap();
	}
	else if (directions.getStatus().code == G_GEO_SERVER_ERROR)
	{
document.getElementById("gmapStatus").innerHTML = "<span class='wrgmap'>Error</span><span class='wrgmape'>:A server error occured.  Please try agin if the error persists please use <a href='http://maps.google.com/maps'>Google Maps</a> directly.</span>";
redomap();
	}	   
	else if (directions.getStatus().code == G_GEO_MISSING_QUERY)
	{
document.getElementById("gmapStatus").innerHTML = "<span class='wrgmap'>Error</span><span class='wrgmape'>:Please verify that an address was submitted. If an address was submitted please use <a href='http://maps.google.com/maps'>Google Maps</a> directly.</span>";
redomap();
	}
	else if (directions.getStatus().code == G_GEO_BAD_KEY)
	{
document.getElementById("gmapStatus").innerHTML = "<span class='wrgmap'>Error</span><span class='wrgmape'>:A system error has occured please contact <a href='mailto:techsupport@theatre-inc.com'>Tech Support</a></span>";
redomap();
	}
	else if (directions.getStatus().code == G_GEO_BAD_REQUEST)
	{
document.getElementById("gmapStatus").innerHTML = "<span class='wrgmap'>Error</span><span class='wrgmape'>:A system error has occured. Please try agin if the error persists please use <a href='http://maps.google.com/maps'>Google Maps</a> directly.</span>";
redomap();
	}		
	else 
	{
document.getElementById("gmapStatus").innerHTML = "<span class='wrgmap'>Error</span><span class='wrgmape'>:An unknown error occurred.</span>";
redomap();
	}  
});
		directions.load("from: "+ usergadd +" to: "+ theplace,{"locale":locale});

		}	
   }
}
function nomap()
{
document.getElementById("themap").style.display="none";
}

function textshow()
{
var len=document.getElementById('usergadd').value;
document.getElementById('gmapStatus').innerHTML="Current Address:<br />"+len;

}
function redomap()
{
var newmap=document.getElementById('gmapdir4').value;
eval(newmap);
}
