//*************************************************************************//
//*************************************************************************//
//* *																	* *//
//* *	Author: Grey Cuunty Brett Lawson								* *//
//* *	Description: Contains and set variables that are used through   * *//
//* *				 out the application		 						* *//
//* *	Date: 01/30/2005												* *//
//* *																	* *//
//*************************************************************************//
//*************************************************************************//


//*********************Variable to track maps current setting*************
var m_hvSelect = '';		// Selection variable. Values: Layer Id and co-ordinates
var m_hvUnits = 'Meters';	// Possible values: "Meters", "Kilometers", "Kilometers", "Miles", "Feet"
var m_hvSelection = 'NewSelection';	// Possible values: "NewSelection", "AddSelection"
var m_hvPopupResults = 'ResultsOn';	// Possible values: "ResultsOn", "ResultsOff"
var m_hvActiveLayer;		
var m_hvStrQuery = '';		//Value: LayeryID and String query
var m_hvIsNewQuery = false;	// Track if it is the first time the query has been preformed
var m_hvBuffer = '';		//Value: LayeryID,buffer distance,buffer units
var m_hvLayersToBuffer = '';//Value: LayeryID of all layers to get attributes from in buffer
var m_hvAddText = '';		//Value: Comma deliminated; x co-ordinate, y co-ordinate, Text, font, font size, style, colour
var m_hvAddGeocodeText = '';		//Value: Comma deliminated; x co-ordinate, y co-ordinate, Text, font, font size, style, colour
var m_hvClear = 'false';		//Flag to indicate to clear map
var	m_hvMinX = 0;//467983.105298291;	//Value: Maps current minx
var	m_hvMinY = 0;//4859837.11172622;	//Value: Maps current miny
var	m_hvMaxX = 0;//571925.598950994;	//Value: Maps current maxx
var	m_hvMaxY = 0;//4973442.17345664;	//Value: Maps current maxy
var m_hvMapHeight = 0;
var m_hvMapWidth = 0;
var m_hvTab = "Layers ";		//Tracks what tab is selected Values: Legend,Queries,Layers
var m_Tree;					//Variable for layer tree object
var m_LayerVisible = '';	//Variable layer visibility


var arrLayVisExt = new Array();		//Track the layers visible extent
var arrLayVisibility = new Array(); //Track what layers are visible
var m_User;							//Variable for Current User
//*********************Variable to track users browser*************
var m_sClientBrowserType;	// Possible values: "IE", "Netscape"
var m_sClientPlatform;		// Possible values: "Windows","Mac"
var m_sClientBrowserVesion;	// Possible values: "Nav4", "Nav5", "IE3", "IE4", "IE5", "IE6"

// Determine browser type and platform.
if (navigator.appName.indexOf("Netscape")>=0) {
	m_sClientBrowserType = 'Netscape';
} else if (navigator.appName.indexOf('Microsoft') >=0) {
	m_sClientBrowserType = 'IE';
} else {
	window.location = "unsupported.htm";
}
if (navigator.userAgent.indexOf("Win") >= 0) {
	m_sClientPlatform = 'Windows';
} else if (navigator.platform.indexOf("Mac") >= 0) {
	m_sClientPlatform = 'Mac';
} else {
	window.location = "unsupported.htm";
}
//Determine browser version
if (m_sClientBrowserType == "Netscape") 
{
	if (parseFloat(navigator.appVersion)<5) 
	{
		m_sClientBrowserVesion = 'Nav4';
	} 
	else 
	{
		m_sClientBrowserVesion = 'Nav5';
	}
}
else if (m_sClientBrowserType == "IE") 
{
	m_sClientBrowserVesion = testIE();

}
//function to check IE Version
function testIE() 
{
	nav = navigator;
	nav.v = 0; 
	pos=0; 
	agt = navigator.userAgent.toLowerCase();

	if ((pos = agt.indexOf('msie')) != -1 ) 
	{
		nav.v = parseFloat('0' + agt.substr(pos+5), 10);
		var pg =(nav.v < 4)? "IE3" :
			(nav.v < 5)? "IE4" :
			(nav.v < 6)? "IE5" :
			(nav.v < 7)? "IE6" : null;
	}
	if (pg) {return pg;}
}

//*********************Variable to track users window sizer*************
var w = screen.availWidth||screen.width;
var h = screen.availHeight||screen.height;

window.moveTo(0 , 0); 
window.moveBy(-4 , -4); 
window.resizeTo(w + 8 , h + 8);

//Get size of main map window
var cwinW = 630;
var cwinH = 460;

function getInternalSize()
{
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName=="Netscape") 
		{
			cwinW = parent.frames[3].window.innerWidth;
			cwinH = parent.frames[3].window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			cwinW = parent.frames[3].document.body.offsetWidth;
			cwinH = parent.frames[3].document.body.offsetHeight;
		}
	}
	m_hvMapHeight = cwinH - 90;
	m_hvMapWidth = cwinW - 145;
	
}

//*********************Variable to track Popup Windows so they can be closed later*************
var winArray = new Array();

//*********************Variable to Detect Pluggins specificly ADOBE*************
//use to detect plugins like Adobe Reader
var m_pluginlist;

if (m_sClientBrowserType == "IE" && m_sClientPlatform == 'Windows') 
{ 
	m_pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.6","Acrobat Reader") + detectIE("PDF.PdfCtrl.5","Acrobat Pro") + detectIE("AcroPDF.PDF.1","Acrobat Reader 7"); 

}
if (m_sClientBrowserType == 'Netscape' || m_sClientPlatform == 'Mac') 
{
	nse = ""; 
	for (var i=0;i<navigator.mimeTypes.length;i++) 
	{
		nse += navigator.mimeTypes[i].type.toLowerCase();
	}
	m_pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
}

function detectIE(ClassID,name) 
{ 
	result = false; 
	document.writeln('<script language="VBscript">');
	document.writeln('on error resume next');
	document.writeln('result = IsObject(CreateObject("' + ClassID + '"))');
	document.writeln('</scr' + 'ipt>');
	//alert(name + " , " + result);
	if (result) 
	{
		return name+',';
	}
	else
	{
		return '';
	}
}

function detectNS(ClassID,name) 
{ 
	n = ""; 
	if (nse.indexOf(ClassID) != -1) 
	{
		if (navigator.mimeTypes[ClassID].enabledPlugin != null) 
		{
			n = name+",";
		}
	}
	return n;
}

m_pluginlist += navigator.javaEnabled() ? "Java," : "";
if (m_pluginlist.length > 0) 
{
	m_pluginlist = m_pluginlist.substring(0,m_pluginlist.length-1);
}

//*********************Variable to Preload images Used in mouse over and out*************

if (document.images) 
{
	var imgmailon = new Image;
	imgmailon.src = "images/mapicons/mail2_on.gif";
	
	var imgmailoff = new Image;
	imgmailoff.src = "images/mapicons/mail2.gif";
	
	imghomeon = new Image;
	imghomeon.src = "images/home_on.gif";
	
	imghomeoff = new Image;
	imghomeoff.src = "images/home.gif";
}
