function LoadCopy(str) {
	$(document).ready(function(){
		var content = $("#ajaxcontainer");
		$.blockUI({ message: '<h1 style=\"padding-top: 20px; font-weight: bold; color: #453c2d; \"><img src="/images/ajax-loader.gif" /> Loading...</h1>' });
		content.slideUp();
		content.load("data.php",{
			page: str,
			complete: function() {
				content.slideDown();
				setTimeout("$.unblockUI();", 2000);
			}
		});
		pageTracker._trackPageview(''+str); 
		setTimeout ( "dbh()", 3000);
	});
}
/*
function LoadCopy(str) {
	$(document).ready(function(){
		$.blockUI({ 
			message: '<h1 style=\"color: #453c2d;\"><img src="/images/ajax-loader.gif" /> Loading...</h1>'
		});
		$.ajax({
			url: "data.php",
			data: "page="+str,
			success: function(data){
				var $ajah = $(data);
				$('div#bodycontainer').replaceWith($('div#bodycontainer',$ajah));
				$('div#sidebarcontainer').replaceWith($('div#sidebarcontainer',$ajah));
				setTimeout ( "dbh()", 1000);
				setTimeout("$.unblockUI();", 2000);
			}
		});
	});
}
*/
/*
function LoadCopy(str) {
	$(document).ready(function(){
		$.blockUI({ 
			message: '<h1 style=\"color: #453c2d;\"><img src="/images/ajax-loader.gif" /> Loading...</h1>'
		});
		$.get(
			'data.php?page='+str,
			function(data){
				var $ajah = $(data);
				$('div#bodycontainer').replaceWith($('div#bodycontainer',$ajah));
				$('div#sidebarcontainer').replaceWith($('div#sidebarcontainer',$ajah));
				setTimeout ( "dbh()", 1000);
				setTimeout("$.unblockUI();", 2000);
			}
		);
	});
}
*/
/*
function LoadCopy(str) {
	$(document).ready(function(){
		$.blockUI({ message: '<h1 style=\"color: #453c2d;\"><img src="/images/ajax-loader.gif" /> Loading...</h1>' });
		$.ajax({
			url: "data.php",
			data: "page="+str,
			success: function(html){
				$("div#bodycontainer").html(html);
				setTimeout ( "dbh()", 1000);
			},
			complete: function() {
				setTimeout("$.unblockUI();", 2000);
			}
		});
	});
}

function LoadSidebar() {
	$.ajax({
		url: "sidebar.php",
		data: "page="+str,
		success: function(html){
			$("div#bodycontainer").html(html);
			setTimeout ( "dbh()", 5000 );
		},
		complete: function() {
			setTimeout("$.unblockUI();", 2000);
		}
	});
}
*/

function LoadEvents(str) {
	$(document).ready(function(){
		var content = $("#ajaxcontainer");
		$.blockUI({ message: '<h1 style=\"padding-top: 20px; font-weight: bold; color: #453c2d; \"><img src="/images/ajax-loader.gif" /> Loading...</h1>' });
		content.slideUp();
		content.load("events.php",{
			page: str,
			complete: function() {
				content.slideDown();
				setTimeout("$.unblockUI();", 2000);
			}
		});
		pageTracker._trackPageview(''+str); 
		setTimeout ( "dbh()", 3000);
	});
}
/*
function LoadEvents(str) {
	$(document).ready(function(){
		$.blockUI({ message: '<h1 style=\"color: #453c2d;\"><img src="/images/ajax-loader.gif" /> Loading...</h1>' });
		$("div#bodycontainer").load("events.php",{
			page: str,
			complete: function() {
				setTimeout("$.unblockUI();", 2000);
			}
		});
	});
	setTimeout ( "dbh()", 5000 );
}

function startLytebox(ref,title,rel) {
  var el   = document.getElementById('lytebox_maker');
  el.href  = ref;
  el.title = title;
  el.rel = rel;
  myLytebox.start(el);
} 
*/
function clearMe(formfield){
	if (formfield.defaultValue==formfield.value) {
		formfield.value = ""
	}
}

function dbh() {
	var divHeight = (document.getElementById('bodycontent').offsetHeight);
	var innerHeight = (document.getElementById('inner').offsetHeight);
	var paddiv = 355 + parseFloat(divHeight);
	var copy = (document.getElementById('bodycontainer').offsetHeight);
	var trimcopy = parseFloat(copy) - 40;
	var sbcopy = document.getElementById('sidebarcontent').style.height = trimcopy + 'px';
	
}

var map;
var geocoder = null;
var addressMarker;

function initialize() {
	if (GBrowserIsCompatible()) {      
		map = new GMap2(document.getElementById("map_canvas"));
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setMapType(G_SATELLITE_MAP);
		gdir = new GDirections(map, document.getElementById("directions"));
		GEvent.addListener(gdir, "load", onGDirectionsLoad);
		GEvent.addListener(gdir, "error", handleErrors);
		setDirections("TAMPA", "7721 W. COURTNEY CAMPBELL CAUSEWAY TAMPA, FL 33607", "en_US");
		var mapTypeControl = new GMapTypeControl();
		var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
		var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
		map.addControl(mapTypeControl, topRight);
		GEvent.addListener(map, "dblclick", function() {
			map.removeControl(mapTypeControl);
			map.addControl(new GMapTypeControl(), bottomRight);
		});
		map.addControl(new GSmallMapControl());
	}
}

function setDirections(fromAddress, toAddress, locale) {
	gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale });
}

function handleErrors(){
	if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
		alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
		alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_BAD_KEY)
		alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
		alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	else alert("An unknown error occurred.");
}

function onGDirectionsLoad(){ 
	// Use this function to access information about the latest load()
	// results.
	// e.g.
	// document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	// and yada yada yada...
	var dh = (document.getElementById('directions').offsetHeight);
	setTimeout ( "dbh()", 5000 );
}

/*
var xmlHttp

function LoadCopy(str) {
	document.getElementById("bodycontainer").innerHTML="<div style='width: 200px; height: 100px; text-align: center; margin-left: auto; margin-right: auto; background-color: transparent;'><img src='/images/ajax-loader.gif' style='margin-top: 30px;'><br /><p style='font-weight: bold;'>LOADING...</p></div>";document.getElementById("bodycontainer").innerHTML="<div style='width: 200px; height: 100px; text-align: center; margin-left: auto; margin-right: auto; background-color: transparent;'><img src='/images/ajax-loader.gif' style='margin-top: 30px;'><br /><p style='font-weight: bold;'>LOADING...</p></div>";
	if (str.length==0) { 
		document.getElementById("bodycontainer").innerHTML="";
		return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="data.php";
	url=url+"?page="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=bodyChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function bodyChanged() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("bodycontainer").innerHTML=eval('xmlHttp.responseText');
	dbh();
	}
}

function mydirections() { 
	document.getElementById("bodycontainer").innerHTML="<div id='copycontainer'><h1>Driving Directions to Whiskey Joe's</h1><div id='map_canvas' style='width: 550px; height: 300px; margin-left: auto; margin-right: auto;'></div><div class='clear'></div><div id='formLayout'><form action='#'><table><tr><th style='text-align: left;'>Enter Starting Address:</th><td><input type='text' class='inputbox' name='from' value='Tampa International Airport'/></td><th style='text-align: right;'>&nbsp;</th><td style='text-align: right;'><input type='hidden' size='25' id='toAddress' name='to' value='7720 W Courtney Campbell Causeway, Tampa, FL 33607' /></td></tr><tr><th>Map it Now!!</th><td colspan='3'><input type='hidden' size='25' id='locale' name='locale' value='en' /><input name='submit' onclick='setDirections(from.value, to.value, locale.value); return false;' class='mapbutton' type='submit' value='Get Directions!' /> <span class='bold'>&laquo; Click Here!</span></td></tr></table></form><div class='clear'></div><div id='directions' style='width: auto; height: auto; min-height: 650px; margin-left: auto; margin-right: auto;'></div></div>";

}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
*/


