/**
global jquery code
*/

history.navigationMode = 'compatible'; //not sure why this is here


$(document).ready(function() {
	if(document.hash)
	{
		//alert('doc ready '+document.hash);
		//if(typeof parseHash == 'function' && !$.browser.msie) parseHash(document.hash);
		if(typeof parseHash == 'function') parseHash(document.hash);
	}
});


switch_hash = true;
history_hash = '';
//alert(navigator.userAgent);
var msie = false;

if(navigator.userAgent.indexOf('MSIE') != -1)
{
//var msie = true;	
}
//poll the hash continuously..
//its the only way to catch the back button
setInterval(function()
{
    if (document.location.hash != history_hash)
    {
        //alert("Changed from " + hash + " to " + location.hash);
        history_hash = document.location.hash;
		if(switch_hash)
		{
			//alert('doc interval '+history_hash);
			//if(typeof parseHash == 'function' && !msie) parseHash(history_hash);
			if(typeof parseHash == 'function') parseHash(history_hash);
		}
		else
		{
			switch_hash = true;		
		}
    }
}, 100);

function debug(msg)
{
	str = getTimeNow()+' : '+msg;
	if(!$('div#debug').length)
	{
		//$('body').append('<div id="debug" style="clear:both;color:black;background:white;"></div>');
	}
	//$('div#debug').prepend('<div style="padding:2px;border-bottom:1px solid black;font-size:10px">'+str+'</div>');

}
function getTimeNow()
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	str = '';
	if (minutes < 10)
	{
		minutes = "0" + minutes;
	}
	if (seconds < 10)
	{
		seconds = "0" + seconds;
	}
	str = hours + ":" + minutes + ":" +seconds+" ";
	if(hours > 11)
	{
		str = str + "PM";
	} else {
		str = str + "AM";
	}
	return str;
}
