/*=================================================
  Title:	Flash Interactive Map JS Augment
  Author:	Lee Hogg
  Created:	2003-12-09
  Updated:	2003-12-21
  -------------------------------------------------*/
var version = 'js: 0-03';
var validNum = true;
var cookieSetCount = 0;
var cookieReadCount = 0;
var valueWaitCount = 0;
var urlToFlashCount = 0;
var bikky = document.cookie;
var receivedUrlCoords = false;
var formCoordCount = 0;
var isIE=document.all?true:false;
var isDOM=document.getElementById?true:false;

function getCookie(name) {
	var index = bikky.indexOf(name + "=");
	if (index == -1) return null;
		index = bikky.indexOf("=", index) + 1;
	var endstr = bikky.indexOf(";", index);
	if (endstr == -1) endstr = bikky.length;
		return unescape(bikky.substring(index, endstr));
}
var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days

function setCookie(name, value) {
	if (value != null && value != "")
	document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
	bikky = document.cookie; // update bikky
}
function flashReady(){
	if(!receivedUrlCoords){
		var xPercent = getCookie("xPercentPb");
		var yPercent = getCookie("yPercentPb");
		var zoom = getCookie("zoomPb");
		if(xPercent){
			window.document.flashMap.SetVariable("newCoords", "true")
			window.document.flashMap.SetVariable("xPercentIn", xPercent);
			window.document.flashMap.SetVariable("yPercentIn", yPercent);
			window.document.flashMap.SetVariable("scaleIn", zoom);
			if(document.info){
				document.info.inputType.value = "cookie input";
				document.info.io.value = 'cookie values->Flash';
				document.info.xPercent.value = Math.round(document.info.xPercent.value*1000)/1000;
				document.info.yPercent.value = Math.round(document.info.yPercent.value*1000)/1000;
				document.info.zoom.value = zoom;
			}
		}
	} else if (receivedUrlCoords) {
		window.document.flashMap.SetVariable("newCoords", "true")
		window.document.flashMap.SetVariable("xPercentIn", xUrl)
		window.document.flashMap.SetVariable("yPercentIn", yUrl)
		window.document.flashMap.SetVariable("scaleIn", zUrl)
	} else {
		valueWaitCount++;
		setTimeout("flashReady()", 1000);
	}
}
function urlCoords(x,y,z,pageTitle){
	receivedUrlCoords = true;
	xUrl = x;
	yUrl = y;
	zUrl = z;
	newTitle = pageTitle;
	if (newTitle == ''){
		newTitle = '[title]';
	}
}

function clearUrl(){
	urlCurrent = document.location.href;
	urlQMark = urlCurrent.indexOf('?');
	urlStrip = urlCurrent.substring(0,urlQMark);
	document.location = urlStrip;
}

function coords(x,y,z){
	xPercentNew = x; yPercentNew = y; zoomNew = z;
	setCookie("xPercentPb", xPercentNew); setCookie("yPercentPb", yPercentNew); setCookie("zoomPb", zoomNew);
}
