function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function Search()
{
	var airport = document.getElementById('query').value;
	location.href ='search-' + escape(airport) + '.html';	
}

function BookmarkLinks()
{
	var url = encodeURI(document.location.href);
	var title = encodeURI(document.title);
	var myArray = new Array();
	
	
	myArray[0] = new Array("/images/digg_small.gif", "ADD TO DIGG", "http://digg.com/submit?phase=2&url="+url+"&title="+title);
	myArray[1] = new Array("/images/delicious_small.gif", "ADD TO DEL.ICIO.US", "http://del.icio.us/post?url="+url+"&title="+title);
	myArray[2] = new Array("/images/netscape_small.gif", "ADD TO NETSCAPE", "http://www.netscape.com/submit/?U="+url+"&T="+title);
	myArray[3] = new Array("/images/reddit_small.gif", "ADD TO REDDIT", "http://reddit.com/submit?url="+url+"&title="+title);
	myArray[4] = new Array("/images/stumbleupon_small.gif", "ADD TO STUMBLEUPON", "http://www.stumbleupon.com/submit?url="+url+"&title="+title);
	myArray[5] = new Array("/images/live_small.gif", "ADD TO WINDOWS LIVE", "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&top=1&url="+url+"&title="+title);
	myArray[6] = new Array("/images/yahoo_small.gif", "ADD TO YAHOO MYWEB", "http://myweb.yahoo.com/myresults/bookmarklet?u="+url+"&t="+title);
	myArray[7] = new Array("/images/google_small.gif", "ADD TO GOOGLE", "http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk="+url+"&title="+title);

	

	var code = "<font id=\"social\">";
	for(i=0;i<myArray.length;i++) 
		code += "<a target=\"_blank\" href=\"" + myArray[i][2] + "\"><img border=\"0\" src=\"" + myArray[i][0] + "\" alt=\"" + myArray[i][1] + "\"/></a>&nbsp;";
	code += "</font>";
	return code;
}

function BookmarkSite()
{
	var url = document.location.href;
	var title = document.title;
	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
}

function Contact()
{
	var url = 'http://x.azjmp.com/0BZg5?sub=dbsites';
	window.open(url,'Contact');

}


    function GoogleMapUnload() 	
	{
		if(document.getElementById("map") == null) return;
		GUnload();
	}
    
    function GoogleMapLoad() 	
	{
		if(document.getElementById("map") == null) return;

		var latitude = document.getElementById("gmap_latitude");
		var longitude = document.getElementById("gmap_longitude");
		var bubbleText = document.getElementById("gmap_bubble");
		var address= document.getElementById("gmap_address");
		var city= document.getElementById("gmap_city");
		var state= document.getElementById("gmap_state");
		var zip= document.getElementById("gmap_zip");
		var country= document.getElementById("gmap_country");
		//var found = document.getElementById("gmap_found");

		if(latitude != null) latitude= latitude.value;
		if(longitude != null) longitude= longitude.value;
		if(bubbleText != null) bubbleText= bubbleText.value;
		if(address != null) address= address.value;
		if(city != null) city= city.value;
		if(state != null) state= state.value;
		if(zip != null) zip= zip.value;
		
		var search = "";
		if(address != null) search += address;
		if(state != null) search += ", " + state;
		if(zip != null) search += ", " + zip;

		if (GBrowserIsCompatible()) 
		{
			
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
		   var geocoder = new GClientGeocoder();

		   function showAddress(search) 
		   {  
				found = false;
				geocoder.getLatLng(
								search,
								function(point)
								{
									if (!point) 
									{       
										//document.getElementById("gmap_found").value = false;
										//alert(address + " not found");
										if((latitude == null && longitude == null) || latitude == "" && longitude == "") 
										{
											latitude = 46.890232;
											longitude = -71.235352;
										}

										map.setCenter(new GLatLng(latitude, longitude), 4);
										document.getElementById('mapmsg').innerText = "(location not found on map)";
										//document.getElementById('warning').style.visibility='visible';
									} 
									else 
									{      
										

										//document.getElementById("gmap_found").value = true;
										//document.getElementById('warning').style.visibility='hidden';
										map.setCenter(point, 14);
										var marker = new GMarker(point);        
										map.addOverlay(marker);        
										marker.openInfoWindowHtml(bubbleText);      
									} 

								}  
							  );

			}

			showAddress(search);

			//setTimeout("alert(document.getElementById(\"gmap_found\").value);", 5000); //We MUSt have a delay to check if the map was found.

			//Creates a marker at the given point with the given label
			//var marker = new GMarker(new GLatLng(latitude, longitude), 13);
			//GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(bubbleText);});
			//map.addOverlay(marker);
	    }
	}
