/* JS for map display
	need to declare a "var iframeID = "...";" variable within the index.php page for the map
	*/
var oldframeurl = "";   
var oldframeurl2 = "";
var essayInterval;
var checkInterval; 
var iframeID2;
var helppage = "help.html"; // was features.html
var helpclick = false; // Was the help button clicked to show the help instructions?

$(document).ready(function () {
	ActivateThlPopups("#content");
	setTimeout("bindFrames();",5000);
});

function bindFrames() {
	$("#" + iframeID).bind("load", function() {doFrameCheck(iframeID);});
	if($("#" + iframeID2).length == 1) {$("#" + iframeID2).bind("load",function() {doFrameCheck(iframeID2);});}
}

function doFrameCheck(fid) {
	if(typeof(window.frames[fid]) == "undefined") {return;}
	var newframeurl = window.frames[fid].document.location.href;
	if($("#thl_popup_0_iframe").length ==0) {$("#maphelplnk").trigger("click");}
	$("#thl_popup_0_iframe").attr("src", newframeurl);
	$(".thl-popup-header a").attr("href", newframeurl);
}

function pause(millis) 
{
	var date = new Date();
	var curDate = null;
	do { curDate = new Date(); } 
	while(curDate-date < millis);
} 

function showEssay() {
	$('.jqmWindow').jqmHide();
	$("body").removeClass("full-width").css("background-color","#96967b");
	essayInterval = setInterval("showMap();",500);
}

function showMap() {
	var myhash = window.location.hash;
	if( typeof(myhash) == "string" && myhash.indexOf("essay=")==-1 ) {
		$("body").addClass("full-width");
		window.clearInterval(essayInterval);
	}
}

