//alert('JS loaded');

GoogleAnalyticsAccountNumber = "";
/**********************************************
***				Global Variables			***
**********************************************/
//alert("here");
//alert(typeof( window[ 'ThisMenuName' ] ));

if ( typeof( window[ 'DebugAlertFlag' ] ) == "undefined" ) {DebugAlertFlag = "off";}
function DebugAlert(t){	if(DebugAlertFlag == "on"){alert(t);}}


if ( typeof( window[ 'ThisMenuName' ] ) == "undefined" ) { //Load once.
	//alert("Load once");
	DevRoot = "";
	ThisMenuName = "sm_index.shtml";
	FourButtonFlag	= "";
	ThisSubMenuId = "";
	
	//Colors for Text Links
	TopNavOnColor = "#bdbda5";
	TopNavSelectedColor = "#000000";
	TopNavOffColor = "#ffffff";
	
	//Colors for Text Background
	TopNavBgOnColor = "#4D4D4D";
	TopNavBgSelectedColor = "#342218";
	TopNavBgOffColor = "";			//Leave Blank if Not in use 
	
	//Colors for Text Links
	SubNavOnColor = "#dddddd";
	SubNavSelectedColor = "#ffffff";
	SubNavOffColor = "#eeeeee";
	
	//Colors for Text Background
	SubNavBgOnColor = "#647486";
	SubNavBgSelectedColor = "#647486";
	SubNavBgOffColor = "#95a2b0";			//Leave Blank if Not in use 
	
	//Read Page Name.
	//oStageFrame = document.getElementById('StageFrame');
	ThisPage = GetFileNameFromPath(location.href);
	IFrameLoaded = false;
	
	Global_aDivContainer = "";
	Global_aURL = "";
	Global_ix = "";
	
	EnumPageTransitionType = {none:0,fade:1,slidein:2,slideout:3,uncover:4};
	PageTransitionType = "none";
	PageTransitionDirection = "";
	PageTransitionSpeed = "";
	
	GrowingFlag = false;
	
	NextIframeId = 765;
	DebugAlert("ThisPage="+ThisPage);
}

DebugAlert("Pass 1");
//DebugAlert("FindObjById('GlobalDiv')="+FindObjById('GlobalDiv'));
//DebugAlert("document.getElementById('GlobalDiv')="+document.getElementById('GlobalDiv'));
if(!FindObjById('GlobalDiv')){
	DebugAlert("Pass 1.1");
	var gDiv = document.createElement('div');
	gDiv.setAttribute("LoadingPages", "");
	gDiv.style.display = 'none';
	gDiv.style.height = '0px';
	gDiv.style.width = '0px';
	var Body = document.getElementsByTagName('body').item(0);
	if(Body){
		/*
		var oBody = this;
		if(top.document.body)
			oBody = top.document.body;
		//alert(oBody);
		*/
		Body.appendChild(gDiv);
	}
	if(document.all.Body)
		document.all.Body.appendChild(gDiv) // IE only
}
DebugAlert("Pass 2");

/*
if(!FindObjById('refreshForm')){
	var gForm = document.createElement('form');
	gForm.setAttribute("name", "refreshForm");
	var gInput = document.createElement('input');
	gInput.type = "hidden";
	gInput.value = "";
	gInput.setAttribute("name", "visited");

	alert("doing it");
	
	var Body = document.getElementsByTagName('body').item(0);
	//var MyForm = Body.getElementsById('refreshForm');
	alert("Body="+Body);

	Body.appendChild(gDiv);
	document.all.Body.appendChild(gDiv) // IE only
	
	gDiv.appendChild(gInput);
	
	alert("done!!");

}
*/

/*******	End of Global Variables		*******/
function tester(){
	alert("made it");
}


//alert("Loading follows from:"+ThisPage);
/**********************************************
***			Javascrit File Loader			***
**********************************************/
//alert("ThisPage="+ThisPage);
//alert('JS loading');
//alert("typeof(km_scripts)="+typeof(km_scripts)+"\nThisPage="+ThisPage);
if (typeof(km_scripts) == 'undefined') var km_scripts = new Object();

km_myclass_import(DevRoot+'/sm_Scripts/BrowserDetect.js');
km_myclass_import(DevRoot+'/sm_Scripts/BrowserLayoutFixes.js');
km_myclass_import(DevRoot+'/sm_Scripts/689Design.js');
km_myclass_import(DevRoot+'/sm_Scripts/AC_RunActiveContent.js');
//km_myclass_import(DevRoot+'/sm_Scripts/FlashLoader.js');
km_myclass_import(DevRoot+'/sm_Scripts/689Nav.js');
km_myclass_import(DevRoot+'/sm_Scripts/PageTransitions.js');
km_myclass_import(DevRoot+'/sm_Scripts/sunset.js');
km_myclass_import(DevRoot+'/sm_Scripts/Calendar.js');
km_myclass_import(DevRoot+'/sm_Scripts/Mouse.js');
if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1)
	km_myclass_import(DevRoot+'/sm_Scripts/FireFox.js');
km_myclass_import(DevRoot+'/sm_Scripts/PngFix.js');

//alert('all scripts loaded');
/*
inc("../sm_Scripts/BrowserDetect.js");
inc("../sm_Scripts/BrowserLayoutFixes.js");
inc("../sm_Scripts/PngFix.js");
inc("../sm_Scripts/689Design.js");
inc("../sm_Scripts/AC_RunActiveContent.js");
inc("../sm_Scripts/689Nav.js");
inc("../sm_Scripts/Sunset.js");
*/

/******	End of Javascrit File Loader	*******/

var HRefFileNameArray = location.href.split("/");
var ThisFileNm = HRefFileNameArray[HRefFileNameArray.length-1];
ThisFileNm = ThisFileNm.split("?")[0];
if((ThisFileNm == "") || (ThisFileNm == "index.html")){
	//alert("Clearing");
	WaitAndLoad('ClearPageLoadList');				//clear Page Load List
	//alert("Page List cleared");
}


//Get the page name.
if(FindObjById('StageFrame'))
	ThisPage = GetFileNameFromPath(FindObjById('StageFrame').src);
//alert(ThisPage);



function inc(filename){
	var body = document.getElementsByTagName('body').item(0);
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	body.appendChild(script)
}


/* several more functions that call functions in the above two files */
function blah (foo)
{
if (isBlank(foo)) return false;
}



function WaitAndLoad(funct,retries){
	if(typeof(retries) == "undefined"){var retries=500;}
	//alert("first: typeof window[ funct ]("+retries+")="+typeof window[ funct ]);
	if(typeof window[ funct ] != "function"){
		retries--;
		if(retries > 0)
			setTimeout('WaitAndLoad("'+funct+'",'+retries+')',10);
		return;
	}else{
		//alert("typeof window[ funct ]="+typeof window[ funct ]+"\nretries="+retries);
		//setTimeout('alert("typeof(funct)="+typeof(ClearPageLoadList));', 3000);
		eval(funct+"();");
	}
	return;
}


function km_myclass_import(jsFile) {
	//alert("km_scripts["+jsFile+"]="+km_scripts[jsFile]);
	if (km_scripts[jsFile] != null) return;
	var scriptElt = document.createElement('script');
	scriptElt.type = 'text/javascript';
	scriptElt.src = jsFile;
	document.getElementsByTagName('head')[0].appendChild(scriptElt);
	km_scripts[jsFile] = jsFile; // or whatever value your prefer
}

function ImportScript(jsFile){
	newJS = document.createElement('script');
	newJS.type='text/javascript';
	newJS.src=jsFile;
	document.getElementsByTagName('head')[0].appendChild(newJS);
}


function GetFileNameFromPath(Path){
	var MyArray = Path.split("/");
	if(MyArray[MyArray.length-1].toLowerCase().split("?")[0].length)
		return MyArray[MyArray.length-1].toLowerCase().split("?")[0];
	return "index.html";
}


function GetObjById(id){
	DebugAlert("Here 1");
	if(document.getElementById(id))
		return document.getElementById(id);
	DebugAlert("Here 2");
	if(parent.document.getElementById(id))
		return parent.document.getElementById(id);
	DebugAlert("Here 3");
	if(parent.parent.document.getElementById(id))
		return parent.parent.document.getElementById(id);
	DebugAlert("Here 4");
	if(top.document.getElementById(id))
		return top.document.getElementById(id);
	try{
		if((window.opener) && (window.opener.document.getElementById(id)))
			return window.opener.document.getElementById(id);
	}catch(err){
		DebugAlert("err="+err);
		return null
	}
	

	return null
}

function FindObjById(id){
	if(GetObjById(id))
		return GetObjById(id);
	//Check IFrames for Object
	if(top.document.getElementsByTagName('iframe')){
		var oMyIframes = top.document.getElementsByTagName('iframe');
		for(var ix=0; ix < oMyIframes.length; ix++){
			//alert("Loop through ix="+ix+"\nof (oMyIframes.length)="+oMyIframes.length+"\nLooking For ID: "+id+"\ntop.eval(oMyIframes[ix].id)="+top.eval(oMyIframes[ix].id));
			if(top.eval(oMyIframes[ix].id).document.getElementById(id))
				return top.eval(oMyIframes[ix].id).document.getElementById(id);
			if(FindChildIframeById(oMyIframes[ix], id) != null)
				return FindChildIframeById(oMyIframes[ix], id);
		}
	}
	return null;
}

function FindChildIframeById(iFrameObj2, id){
	try{
		//alert("test: "+eval(iFrameObj2.id).document.getElementsByTagName('iframe').length);
		var oMyIframes = eval(iFrameObj2.id).document.getElementsByTagName('iframe');
		var ix = oMyIframes.length;
		//alert("ix: "+ix);
		while(ix--){
			//alert("in ix="+ix+" & id = "+id);
			//alert("oMyIframes[ix].id = "+oMyIframes[ix].id);
			//alert("eval(oMyIframes[ix]).document.getElementById(id)="+eval(oMyIframes[ix]).document.getElementById(id));
			if(eval(oMyIframes[ix]).document.getElementById(id)){
				//alert("GOT IT in the child");
				return eval(oMyIframes[ix]).document.getElementById(id);
			}
		}
		//alert("Returning null");
		return null;
	}
	catch(err){
		return null;
	}
}



function GenerateNewIFrameID(){
	if ( typeof( NextIframeId ) == "undefined" ) { NextIframeId=0; }
	while(FindObjById("MyIFrame"+NextIframeId)){ NextIframeId = NextIframeId + 1; }
	return "MyIFrame"+NextIframeId;
}


//Execute on the load of the main page only
function MainPageLoad(){



}

//Execute on the load of the main page only
function EveryPageLoad(){
	addChildFramesToLoadList();
	alert("PageLoadList="+PageLoadList);
}



  // Removes leading whitespaces
  function LTrim( value ) {
  	
  	var re = /\s*((\S+\s*)*)/;
  	return value.replace(re, "$1");
  	
  }
  
  // Removes ending whitespaces
  function RTrim( value ) {
  	
  	var re = /((\s*\S+)*)\s*/;
  	return value.replace(re, "$1");
  	
  }
  
 // Removes leading and ending whitespaces
  function trim( value ) {
  	
  	return LTrim(RTrim(value));
  	
  }

String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};







