// JavaScript Document
// Error Reporting Function:
/*var reportStatus = new Array(); 
function report ( msg ) { 
	reportStatus.push ( msg ); 
} 
function showReport ( err ) { 
	alert ( reportStatus.join ( "\n" ) ); 
} 
window.onerror = function ( err, url, line ) { 
	report ( err + " [" + url + " - line " + line + "]" ); showReport(); 
}*/
// Debug:
//Check to see if we are running ie, also make a variable for the doc body, and one for the user placed div.


DocBody = document.getElementsByTagName ("body").item (0);

try {
	WindowRef = window.location.href;
} catch(e) {
	WindowRef = "";
}

IE = document.all?true:false;

if (!IE) {
	document.captureEvents(Event.MOUSEMOVE);
}
document.documentElement.onmousemove = getMousePosition;

//When a new group is created that group is assigned a number between 0 and the MagicNum.
MagicNum = 99999999999999999999;


// Scroll bars use interval functions to run, how many miliseconds between intervals:
// Standard comonly used intervallength:
gIntervalLengh = 66;
// The speed of refresh when the user is dragging the scroll handle:
ScrollFromDivIntervalLengh = 66;
// How often the widget checks to see if the user has scrolled the ResultsDiv by means other than using the scroll bar (Such as selecting and dragging inside it).
gDoubleCheckScrollInterval = 2000;
// There is a function that redraws elements of the widget after the widget has first loaded, this fixs some display problems that occure in fire fox. This is how long it waits before the redraw:
MrFixItIntervalLength = 5000;

gResultsPending = true;
DragReturn = true;

MouseX = 0;
MouseY = 0;

IntervalObj = new Object();
EndIntvalObj = new Object();
// The InteractivityObj holds sub objects named after different div types, as well as diferent event types.
// the handle interactivity object checks the InteractivityObj for a reference to the div type that the event was activated on
// and for the type of event that was activated, then it runs the function whos name is accosiated with that div type or event type.
// ReturnAs is used to flag certain div and event types to return false.
InteractivityObj = new Object();
// This is set to true when more results are being downloaded off the server. This will pause certain elements of interaction.
// This is set to true when the user opperates a scroll bar, it causes the HandleInteractivity function to return false
// so no events get passed to the window while the scroll bars are in use.
// this is what prevents IE from trying to select stuff when you drag the scroll bar.
SuspendOtherInteraction = false;



// These are all the variables used in the scroll bars.
// I put them into a function to make settings them easier. I may take them out of a function
// and distribute them among the scroll bar functions latter, in order to speed performance.
//Core Interval Actions:----------------------------------------------------------------------------------

// What IE5 doesn't have shift?

if(!Array.prototype.shift) { // if this method does not exist..

	Array.prototype.shift = function(){
		firstElement = this[0];
		this.reverse();
		this.length = Math.max(this.length-1,0);
		this.reverse();
		return firstElement;
	}
	
}

if(!Array.prototype.unshift) { // if this method does not exist..
	
	Array.prototype.unshift = function(){
		this.reverse();
		
			for(var i=arguments.length-1;i>=0;i--){
				this[this.length]=arguments[i]
			}
			
		this.reverse();
		return this.length
	}
}




function PXToNum(Value) {
	return parseInt(Value.replace(/[a-zA-Z]+$/, ""));
}


function AddInterval (RootDiv, IntervalAction, EndIntervalAction) {
	//Description: Sets interval to call the function passed in IntervalAction, it passed that function the CallingDiv. IntervalLength is derived from: RootDiv.IntervalLengh. The Interval is assigned to a variable inside the IntervalObj.
	//The Interval Obj is intended to allow multiple intervals to happen at once, but I am not sure this functionality
	//will ever be used.
	var RootDivId;
	var RootDivId = RootDiv.id;
	var RootDiv = document.getElementById(RootDivId);
	if (EndIntervalAction) {
		EndIntvalObj[IntervalAction] = new Object();
		EndIntvalObj[IntervalAction].Action = EndIntervalAction;
		EndIntvalObj[IntervalAction].RootDiv = RootDiv;
	}
	SuspendOtherInteraction = true;
	SystemInteraction = false;
	IntervalObj[IntervalAction] = setInterval(IntervalAction + "("+"\""+ RootDivId +"\""+")", gIntervalLengh);
}

function KillInterval(IntToKill, SpecificInt) {
	// Go through the IntervalObjand clear all the intervals it holds, then go through the EndIntvalObj
	// and activate any corresponding functions stored there. then delete the referance.
	if (SpecificInt != true) {
		// IntervalObj:
		for (IntToKill in IntervalObj) {
			clearInterval(IntervalObj[IntToKill]);
			IntervalObj[IntToKill] = undefined;
			delete IntervalObj[IntToKill];
		}
		//End IntervalObj:
		for (IntToKill in EndIntvalObj) {
			//alert ("End Int " + EndIntvalObj[IntToKill].Action);
			eval(EndIntvalObj[IntToKill].Action)(EndIntvalObj[IntToKill].RootDiv);
			EndIntvalObj[IntToKill] = undefined;
			delete EndIntvalObj[IntToKill];
		}
		
	} else {
		//IntervalObj:
		clearInterval(IntervalObj[IntToKill]);
		IntervalObj[IntToKill] = undefined;
		delete IntervalObj[IntToKill];
		//EndIntervalObj:
		eval(EndIntvalObj[IntToKill].Action)(EndIntvalObj[IntToKill].RootDiv);
		EndIntvalObj[IntToKill] = undefined;
		delete EndIntvalObj[IntToKill];
	}

	SuspendOtherInteraction = false;
	SystemInteraction = false;
}

//Interaction Functions:-----------------------------------------------------------------------------------------------------------------


function HandleInteraction(evt) {
    /* The following is for compatability */
    /* IE does NOT by default pass the event object */
    /* obtain a ref to the event if one was not given */
	// When interaction of some sort occures this function is called and passed the event
	// it looks on the event that was passed to see the div type of the object the event occured on
	// it then checks to see if the InteractivityObj has a variable with correspounds to either the
	// event type, or the div type of the calling div.
	// if so it activates the function stored in that variable and passes it both the calling div and the evt its self.
	// if InteractivityObj.ReturnAs object contains a correspounding refernce it returns false.
	// also if SuspendOtherInteraction is true, it returns false.
	// this is to prevent events from being passed when the user activates the scroll bar.
	
	if (InteractivityObj == undefined){
		InteractivityObj = new Object();
	}
	
    if (!evt) {
		evt = window.event;
		EvtTarget = evt.srcElement;
	} else {
		EvtTarget = evt.target;
	}
	if (EvtTarget.src) {
		EvtTarget = EvtTarget.parentNode;
	}
	EvtDivType = EvtTarget.DivType;
	EvtType = evt.type;

	if (InteractivityObj[EvtType] || InteractivityObj.ReturnAs[EvtType]) {
		if (InteractivityObj[EvtType][EvtDivType]) {
			eval(InteractivityObj[EvtType][EvtDivType])(/*CallingDiv =*/ EvtTarget, /*CallingEvent = */evt);
		} else {
			for (EvtAction in InteractivityObj[EvtType]) {
				eval(InteractivityObj[EvtType][EvtAction])(/*CallingDiv =*/ EvtTarget, /*CallingEvent = */evt);
			}
		}
	}
	
	if (InteractivityObj[EvtDivType]) {
		if (InteractivityObj[EvtDivType][EvtType]) {
			eval(InteractivityObj[EvtDivType][EvtType])(/*CallingDiv =*/ EvtTarget, /*CallingEvent = */evt);
		}
	}
	
	if (InteractivityObj.ReturnAs[EvtType] != undefined){
		return InteractivityObj.ReturnAs[EvtType];
	} else if (InteractivityObj.ReturnAs[EvtDivType] != undefined){
		return InteractivityObj.ReturnAs[EvtDivType];
	} else if (SuspendOtherInteraction == true) {
		return false
	} else {
		return true;
	}
}
//
function CaptureEvents(EventsArray){
	// tell the browser to capture the events stored in the EventsArray;
	for (n=0; n<=EventsArray.length - 1; n++){
		document.documentElement[EventsArray[n]] = HandleInteraction;
	}
}

// Specific Interaction Functions:----------------------------------------------------------------------------------
function getMousePosition(e) {
	// Get and store the position.
	DocBody = document.getElementsByTagName ("body").item (0);

	MouseX = 0;
	MouseY = 0;
	if (DocBody) {
		if (!e) {
			e = window.event;
		}
		if (e.pageX || e.pageY) {
			MouseX = e.pageX;
			MouseY = e.pageY;
		} else if (e.clientX || e.clientY) {
			MouseX = e.clientX + DocBody.scrollLeft;
			MouseY = e.clientY + DocBody.scrollTop;
		}
	}
	
	if (typeof(DragReturn) != "undefined"){
		return DragReturn;
	} else {
		return true;
	}
}

function TrackOtherInteraction() {
	SuspendOtherInteraction = true;
	SystemInteraction = true;
}
//General Functions:---------------------------------------------------------------------------------------------------
//
function MakeDiv (_Target, AssignVar, RootDiv, DivType, ObjPath) {
	//Description: A generic Create Div Function.
	//Makes a new Div and assigns it to the variables whose name is passed in AssignVar;
	var NewDiv = document.createElement ("div");
	NewDiv.RootDiv = RootDiv;
	NewDiv.DivType = DivType;
	NewDiv.ObjPath = ObjPath;
	NewDiv.id = AssignVar;
	_Target.appendChild (NewDiv);
	return NewDiv;
	
}

//
function MakeImg (_Target, AssignVar, Source) {
	//Description: A generic Create Img function
	var NewImg = document.createElement ("img");
	NewImg.src = Source;
	NewImg.id = AssignVar;
	_Target.appendChild (NewImg);
	return NewImg;
	
}
//
function MakeScript (srcPath) {
	//Dunno if this works.
	
	var DocBody = document.getElementsByTagName ("body").item (0);
	var NewScript = document.createElement ("script");
	NewScript.id = srcPath;
	NewScript.src = srcPath;
	DocBody.appendChild (NewScript);
	return NewScript;
	
}
//
function MakeTable (_Target, AssignVar) {
	//Description: A generic Create Table Function.
	//alert ("1");
	var NewTable = document.createElement ("table");
	NewTable.id = AssignVar;
	_Target.appendChild (NewTable);
	return NewTable;
	//alert ("2");
}
//
function MakeRandom(MaxNum) {
	return Math.floor(Math.random()* MaxNum);
}

function AddRow (_Target, Placement) {
	// Makes rows in the table and adds one column for content.
	//alert ("Add Row Target " + _Target);
	if (!Placement) {
		Placement = _Target.rows.length;
	}
	var TR = _Target.insertRow(Placement);
	return TR;

}
//
function AddColumn (_Target, Placement) {
	// Adds Columns to a row.
	//alert (_Target);
	if (!Placement) {
		Placement = _Target.cells.length;
	}
	var TD = _Target.insertCell(Placement);
	return TD;
}
//
function SetPos (_Target, vLeft, vTop, vWidth, vHeight) {
	// Just a convient function used when first building the scroll bar
	// Could be used for other things as well but so far it isn't.
	_Target.style.position ="absolute";
	if (vLeft) {
		_Target.style.left = vLeft + "px";
	}
	
	if (vTop) {
		_Target.style.top = vTop + "px";
	}
	
	if (vWidth) {
		_Target.style.width = vWidth + "px";
	}
	
	if (vHeight) {
		_Target.style.height = vHeight + "px";
	}
}

function GetElemByName(ElemType, ElemName){
	if (!IE) {
		var Elem = document.getElementsByName(ElemName)[0];
	} else {
		var Divs = document.getElementsByTagName(ElemType);
		for (var n=0; n<Divs.length; n++) {
			var CurDiv = Divs[n];
			if (CurDiv.name == ElemName) {
				var Elem = CurDiv;
			}
		}
	}
	return Elem;
}

function GetDomElemSpec(HolderElem, TagType, TagProperty, Identifier, ReturnMany, Debug) {
	var HolderElem = GetDomElem(HolderElem);
	var Subjects = HolderElem.getElementsByTagName(TagType);
	if (Debug) {
		alert ("Found: " + Subjects.length + "\nOf Tag Type: " + TagType);
	}
	var ReturnArray = [];
	for (var n=0; n<Subjects.length; n++) {
		var CurElem = Subjects[n];
		if (Debug) {
			alert ("CurElem: " + CurElem + "\n TagProp: " + TagProperty + "\n Identifier: " + Identifier + "\n Value: " + CurElem[TagProperty]);
		}
		
		if (Identifier) {
			if (typeof(Identifier) == "string") {
				if (CurElem[TagProperty] == Identifier) {
					ReturnArray[ReturnArray.length] = CurElem;
					if (Debug) {
						alert ("Match String");
					}
					if (!ReturnMany) {
						break;	
					}
				}
			} else if (Identifier) {
				if (Identifier.test(CurElem[TagProperty])) {
					ReturnArray[ReturnArray.length] = CurElem;
					if (Debug) {
						alert ("Match Reg Ex");
					}
					if (!ReturnMany) {
						break;	
					}
				}
			}
		} else {
			ReturnArray[ReturnArray.length] = CurElem;
			if (Debug) {
				alert ("Match Default");
			}
			if (!ReturnMany) {
				break;	
			}
		}
	}
	
	if (!ReturnMany) {
		ReturnArray = ReturnArray[0];
	}
	return ReturnArray;
}
	
//
function AlignTo(_Target, AnchorObj, AlignArray, InsideIt, Relative ) {
		var _Target = GetDomElem(_Target);
		// Align Array: SubjectAlignPointH, AnchorAlignPointH, TweakH, SubjectAlignPointV, AnchorAlignPointV, TweakV);
		if (AlignArray) {
			if (!OffsetTweak) {
				OffsetTweak = 0;
			}
			var SubjectAlignPoint = AlignArray[0];
			var AnchorAlignPoint = AlignArray[1];
			var OffsetTweak = AlignArray[2];
			var AnchorPoint;
			if (!Relative) {
				var AnchorLeft = GetLeft(AnchorObj);
				var AnchorTop = GetTop(AnchorObj);
			} else {
				var AnchorLeft = AnchorObj.offsetLeft;
				var AnchorTop = AnchorObj.offersetTop;
			}
			if (AnchorAlignPoint == "left") {
				if (InsideIt) {
					AnchorPoint = 0 + OffsetTweak;
				} else {
					AnchorPoint = AnchorLeft + OffsetTweak;
				}
			} else if (AnchorAlignPoint == "right") {
				if (InsideIt) {
					AnchorPoint = 0 + AnchorObj.offsetWidth + OffsetTweak;
				} else {
					AnchorPoint = AnchorLeft + AnchorObj.offsetWidth + OffsetTweak;
				}
			} else if (AnchorAlignPoint == "center") {
				if (InsideIt) {
					AnchorPoint = 0 + (AnchorObj.offsetWidth / 2) + OffsetTweak;
				} else {
					AnchorPoint = AnchorLeft + (AnchorObj.offsetWidth / 2) + OffsetTweak;
				}
				
			}
			//Subject Left To Anchor Left:
			if (SubjectAlignPoint == "left") {
				_Target.style.left = AnchorPoint + "px";
			//Subject Right To Anchor Left:
			} else if (SubjectAlignPoint == "right") {
				_Target.style.left = AnchorPoint - _Target.offsetWidth + "px";
			//Subject Center To Anchor Left:
			} else if (SubjectAlignPoint == "center") {
				//alert ("AP"+AnchorPoint);
				//alert (_Target.offsetWidth / 2);
				_Target.style.left = AnchorPoint - (_Target.offsetWidth / 2) + "px";
			}
			
			var SubjectAlignPoint = AlignArray[3];
			var AnchorAlignPoint = AlignArray[4];
			var OffsetTweak = AlignArray[5];
			
			if (AnchorAlignPoint == "top") {
				if (InsideIt) {
					AnchorPoint = 0 + OffsetTweak;
				} else {
					AnchorPoint = AnchorTop + OffsetTweak;
				}
			} else if (AnchorAlignPoint == "bottom") {
				if (InsideIt) {
					AnchorPoint = 0 + AnchorObj.offsetHeight + OffsetTweak;
				} else {
					AnchorPoint = AnchorTop + AnchorObj.offsetHeight + OffsetTweak;
				}
			} else if (AnchorAlignPoint == "center") {
				if (InsideIt) {
					AnchorPoint = 0 + (AnchorObj.offsetHeight / 2) + OffsetTweak;
				} else {
					AnchorPoint = AnchorTop + (AnchorObj.offsetHeight / 2) + OffsetTweak;
				}
			}
			//Subject Left To Anchor Left:
			if (SubjectAlignPoint == "top") {
				_Target.style.top = AnchorPoint + "px";
			//Subject Right To Anchor Left:
			} else if (SubjectAlignPoint == "bottom") {
				_Target.style.top = AnchorPoint - _Target.offsetHeight + "px";
			//Subject Center To Anchor Left:
			} else if (SubjectAlignPoint == "center") {
				_Target.style.top = AnchorPoint - (_Target.offsetHeight / 2) + "px";
			}
		}
}
//
function GetPercent(MinRange, MaxRange, PlaceInRange, MinVal, MaxVal) {
	var ValWiggleRoom = (MaxVal - MinVal);
	var RangeWiggleRoom = (MaxRange - MinRange)
	var PlaceInRangeWiggleRoom = (PlaceInRange - MinRange);
	var ReturnVal = MinVal + (ValWiggleRoom * (PlaceInRangeWiggleRoom / RangeWiggleRoom));
	if (ReturnVal < 1) {
		ReturnVal = 1;
		// Cuz IE can't display a Zero Height Div
	}
	return ReturnVal;
}
//
function FormatElm (_Target, NewFormating) {
	//Description: A generic Formating Function.
	//Run through the property's passed through NewFormating and apply them to the object passed through _Target. This can also be used to assign mouse actions etc.
	if (typeof(NewFormating) == "object") {
		for (FormatObj in NewFormating) {
			try {
				if (FormatObj == "style"){
					if (!_Target.style) {
						_Target.style = new Object();
					}
					if (typeof(NewFormating.style) == "string"){
						_Target.style = NewFormating.style;
					} else {
						for (StyleObj in NewFormating[FormatObj]){
							_Target.style[StyleObj] = NewFormating.style[StyleObj];
						}
					}
				} else {
					_Target[FormatObj] = NewFormating[FormatObj];
				}
				} catch(e) {
			}
		}
	}
}

//
function ClearTable(_Target) {
	//Description/Actions: 
	//Goes through the table passed to it and removes all its rows – lets a table start from scratch. Called right before populating a table as a sort of fresh slate effect.
	while (_Target.rows.length > 0){
		_Target.deleteRow(0);
	}
	
	//alert ("Table Cleared");
}
//These 2 are deprecated for GetTop and GetLeft
function GetTop(_Target) {
	var TrueVal = _Target.offsetTop;
	BreakIt = false;
	var LastVal = 0;
	while (typeof(_Target.parentNode.offsetLeft) == "number" && !BreakIt){
		_Target = _Target.parentNode;
		
		var CurVal = _Target.offsetTop;
		if (_Target.nodeName != "TD"){
		//if (CurVal != LastVal){
			TrueVal += _Target.offsetTop;
		}
		//alert (_Target + " = " + _Target.offsetTop + " = " + CurVal);
		var LastVal = _Target.offsetTop;
	}
	return TrueVal;
}

function GetLeft(_Target) {
	var TrueVal = _Target.offsetLeft;
	BreakIt = false;
	var LastVal = 0;
	while (typeof(_Target.parentNode.offsetLeft) == "number" && !BreakIt){
		_Target = _Target.parentNode;
		var CurVal = _Target.offsetLeft
		if (CurVal != LastVal){
			TrueVal += _Target.offsetLeft;
		}
		var LastVal = _Target.offsetLeft;
	}
	return TrueVal;
}
//
function DoXMLToObj(XMLObj){
	KillWhiteSpace(XMLObj);
	return XMLToObj(XMLObj);
}
function XMLToObj(XMLObj, TargetObj) {
	if (XMLObj.nodeName == "#document") {
		XMLObj = XMLObj.firstChild;
	}

	var n;
	if (!TargetObj) {
		TargetObj = new Object();
	}

	for (n=0;n<=XMLObj.childNodes.length-1;n++){
		if (XMLObj.childNodes[n].nodeType == 1){
			if (XMLObj.childNodes[n].attributes) {
				for (n2=0;n2<=XMLObj.childNodes[n].attributes.length-1;n2++){
					if (XMLObj.childNodes[n].attributes[n2].specified && XMLObj.childNodes[n].attributes[n2].expando) {
						TargetObj[XMLObj.childNodes[n].attributes[n2].name] = XMLObj.childNodes[n].attributes[n2];
					}
				}
			}

			var ArrayFound = false;
			if (n+1 <= XMLObj.childNodes.length - 1) {
				if (XMLObj.childNodes[n].nodeName == XMLObj.childNodes[n+1].nodeName || !isNaN(XMLObj.childNodes[n].nodeName || XMLObj.childNodes[n].nodeName == "Array")){
					ArrayFound = true;
				}
			} else if (n-1 > 0){
				if (n-1 >= 0 && XMLObj.childNodes[n].nodeName == XMLObj.childNodes[n-1].nodeName || !isNaN(XMLObj.childNodes[n].nodeName || XMLObj.childNodes[n].nodeName == "Array")){
					ArrayFound = true;
				}
			}
			
			if (ArrayFound){
				if (XMLObj.childNodes[n].nodeName == "Array") {
					//alert ("Making New Array in Keywords");
					var NewTarget = TargetObj;
				} else {
					//alert ("Making Fresh Array: " + XMLObj.childNodes[n].nodeName);
					var NewTarget = TargetObj[XMLObj.childNodes[n].nodeName] = new Array();
				}
				var n2=0;
				var BreakIt = false;
				while (!BreakIt){
					/*alert (XMLObj.childNodes[n].nodeName);
					alert (XMLObj.childNodes[n].firstChild);
					alert (XMLObj.childNodes[n].firstChild.nodeName);*/
					//alert (XMLObj.childNodes[n].firstChild.nodeName);
					/*if (XMLObj.childNodes[n].firstChild == null) {
						//XMLObj.childNodes[n].firstChild.nodeValue = "";
						var NewNode = XMLDoc.createNode(1, "#text", "");
						XMLObj.childNodes[n].appendChild(NewNode);
					}*/
					//alert (XMLObj.childNodes[n].nodeName);
					if (XMLObj.childNodes[n].firstChild != null && XMLObj.childNodes[n].firstChild.nodeType != 3){
						//alert ("I am: " + XMLObj.childNodes[n].nodeName);
						//alert ("My First Born is: " + XMLObj.childNodes[n].firstChild.nodeName);
						if (XMLObj.childNodes[n].firstChild.nodeName == "Array"){
							NewTarget[n2] = new Array();
						} else {
							NewTarget[n2] = new Object();
						}
						new XMLToObj(XMLObj.childNodes[n], NewTarget[n2]);
					} else {
						if (XMLObj.childNodes[n].firstChild != null){
							var TheString = EscapeQuotes(XMLObj.childNodes[n].firstChild.nodeValue);
						} else {
							var TheString = "";
						}
						if (TheString.charAt(0) == "[" || TheString.charAt(0) == "{" || TheString == "true" || TheString == "false" || isNaN(TheString) == false) {
							NewTarget[n2] = eval(TheString);																			 
						} else {
							NewTarget[n2] = TheString;
						}
					}
					if (!XMLObj.childNodes[n+1] || XMLObj.childNodes[n].nodeName != XMLObj.childNodes[n+1].nodeName){
						BreakIt = true;
					}
					n2++;
					n++;
				}
			} else {
				if (XMLObj.childNodes[n].firstChild.nodeType != 3){
					var NewTarget = TargetObj[XMLObj.childNodes[n].nodeName] = new Object();
					new XMLToObj(XMLObj.childNodes[n], NewTarget);
					
				} else {
					var TheString = EscapeQuotes(XMLObj.childNodes[n].firstChild.nodeValue);
					if (TheString.charAt(0) == "[" || TheString.charAt(0) == "{" || TheString == 'true' || TheString == 'false' || isNaN(TheString) == false) {
						TheString = eval(TheString);																			 
					}
					if (TargetObj.length != undefined) {
						TargetObj[TargetObj.length] = TheString;
					} else {
						TargetObj[XMLObj.childNodes[n].nodeName] = TheString;
					}
				}
			}
		}
	}
	return TargetObj;
}

function KillWhiteSpace(XMLObj) {
	var RexExIt = /\S/;
	var n;
	//alert (XMLObj.nodeName);
	for (n=0;n<=XMLObj.childNodes.length-1;n++){
		if (XMLObj.childNodes[n].nodeType == 3 && !RexExIt.test(XMLObj.childNodes[n].nodeValue)){
			XMLObj.childNodes[n].parentNode.removeChild(XMLObj.childNodes[n]);
			n--;
		} else if (XMLObj.childNodes[n].childNodes){
			new KillWhiteSpace(XMLObj.childNodes[n]);
		}
	}
}

function BeginObjToString(MyObj, ObjName){
	if (ObjName) {
		MyString = ObjName + " = {"
	} else {
		MyString = "{"
	}
	new ObjToString(MyObj, "\t");
	MyString += "\n" + "};";
	return MyString;
}

function ObjToString(MyObj, Tabs) {
	if (!Tabs) {
		var Tabs = "";
	}
	if (MyString.charAt(MyString.length-1) == ","){
		MyString = MyString.substring(0, MyString.length-1)		   
	} else if (MyString.charAt(MyString.length-1) == "\n" && MyString.charAt(MyString.length-1) == ",") {
		MyString = MyString.substring(0, MyString.length-2);
		MyString += "\n";
	}
	var Obj;
	var FirstChild = true;
	for (Obj in MyObj) {
		if (!FirstChild) {
			MyString += ", ";
		}
		if (isNaN(Obj)){
			MyString += "\n" + Tabs + Obj + " : ";
		}
		if (typeof(MyObj[Obj]) == "object") {
			if (MyObj[Obj].length == undefined){
				MyString += "{";
				new ObjToString(MyObj[Obj], Tabs+"\t");
				MyString += "\n" + Tabs + "}" ;
			} else {
				MyString += "[";
				new ObjToString(MyObj[Obj], Tabs+"\t");
				MyString += "]";
			}
		} else {
			if (typeof(MyObj[Obj]) == "string"){
				MyString +=  "\"" + EscapeQuotes(MyObj[Obj]) + "\"";
			} else {
				MyString += EscapeQuotes(MyObj[Obj]);
			}
		}
		FirstChild = false;
	}
	return MyString;
}

function BeginObjToXML(MyObj, XMLName){
	MyXmlString = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
	MyXmlString += "<TopObject>";
	new ObjToXML(MyObj);
	MyXmlString += "</TopObject>";
	//MyString += "};";
	//alert (MyString);
	return MyXmlString;
}

function ObjToXML(MyObj, PrevName) {
	//alert ("Obj to XML Called");
	var Obj;
	if (PrevName) {
		if (!isNaN(PrevName)) {
			PrevName = "Array";
		}
	}
	for (Obj in MyObj) {
		if (!isNaN(Obj)){
			MyXmlString += "<"+PrevName+">";
		} else if (typeof(MyObj[Obj]) == "object" && MyObj[Obj].length == undefined){
			MyXmlString += "<"+Obj+">";
		}
		if (typeof(MyObj[Obj]) == "object") {
			new ObjToXML(MyObj[Obj], Obj);
		} else {
			if (isNaN(Obj)) {
				MyXmlString += "<"+Obj+">" + EscapeQuotes(MyObj[Obj]) + "</"+Obj+">";
				//MyXmlString += "<"+Obj+"><![CDATA[" + EscapeQuotes(MyObj[Obj]) + "]]></"+Obj+">";
			} else {
				MyXmlString += EscapeQuotes(MyObj[Obj]);
				//MyXmlString += "<![CDATA[" +EscapeQuotes(MyObj[Obj]) + "]]";
			}
		}
		if (!isNaN(Obj)){
			MyXmlString += "</"+PrevName+">" ;
		} else if (typeof(MyObj[Obj]) == "object" && MyObj[Obj].length == undefined){
			MyXmlString += "</"+Obj+">";
		}
		
	}
	//alert ("My String: " + MyString);
	return MyXmlString;
}

function EscapeQuotes(MyString){
	if (MyString && typeof(MyString) == "string" && MyString != ""){
		MyString = MyString.replace(/'|\+\'/g, "\\\'");
		MyString = MyString.replace(/"|\+"/g, "\\\"");
		return MyString;	
	}
	return MyString;
}

function BeginArrayToString (MyArray) {
	MyArrayString = "[";
	new ArrayToString(MyArray);
	MyArrayString += "]";
	return MyArrayString;
}

function ArrayToString(MyArray) {
	var n;
	var FirstChild = true;
	for (n=0;n<=MyArray.length-1;n++){
		if (!FirstChild){
			MyArrayString += ", ";
		}
		if (typeof(MyArray[n]) == "object"){
			MyArrayString += "[";
			new ArrayToString(MyArray);
			MyArrayString += "],";	
		} else {
			if (typeof(MyArray[n]) == "string"){
				MyArrayString += "\"" + MyArray[n] + "\"";
			} else {
				MyArrayString += MyArray[n];
			}
		}
		
		FirstChild = false;
	}
}
//IE = document.all?true:false;
function GetXML (FilePath, HandlerFunction) {
	//var XMLDoc;
	//alert ("GetXmlCalled");
	if (document.all) {
		XMLDoc = new ActiveXObject("Microsoft.XMLDOM"); 
		XMLDoc.onreadystatechange = function () {
			if (XMLDoc.readyState == 4) {
				eval(HandlerFunction)(XMLDoc);
			}
		}
	} else {
		XMLDoc = document.implementation.createDocument("", "", null);
		XMLDoc.onload = function () {
			eval(HandlerFunction)(XMLDoc);
		}
	}
	XMLDoc.load(FilePath);
}

function SendXMLRequest(Script, PostData, HandlerFunction, FailedFunction) {
	if (window.XMLHttpRequest) {
		this.http = new XMLHttpRequest();
		http.onreadystatechange = TestXMLReturn(http, HandlerFunction, FailedFunction);
		http.open('POST', Script);
		http.send(PostData);
	} else if (window.ActiveXObject) {
		this.http = new ActiveXObject("Microsoft.XMLHTTP");
		if (http) {
			http.onreadystatechange = TestXMLReturn(this.http, HandlerFunction, FailedFunction);
			http.open('POST', Script);
			http.send(PostData);
		}
	}
}

function TestXMLReturn (http, HandlerFunction, FailedFunction){
	if (http.readyState == 4 && http.status == 200 && http.responseText.indexOf('invalid') == -1) {             // only if "OK"
		eval(HandlerFunction)(http.responseXML);
	} else {
		eval(FailedFunction)(http.responseXML);
	}
}

// Pass these tree functions the Node we are starting at, and an array containing node names (like TD, TR, TABLE, etc) and or IDs, and or Names,
// Proceeded in the array by a letter telling the script which direction to go: u, d, r, l.
function TreeWalk(Target, RoadSigns, Loose, Debug){
	var Direction = "";
	Target = GetDomElem(Target);
	while (Target && RoadSigns.length > 0){
		if (RoadSigns[0].length == 1) {
			Direction = RoadSigns.shift();
		} else {
			if (Direction.toLowerCase() == "u"){
				Target = Target.parentNode;
			} else if (Direction.toLowerCase() == "d") {
				if (Target.nodeName == "#text") {
					Target = Target.nextSibling;
				} else {
					Target = Target.firstChild;
				}
			} else if (Direction.toLowerCase() == "r") {
				Target = Target.nextSibling;
			} else if (Direction.toLowerCase() == "l") {
				Target = Target.previousSibling;
			}
			
			if (Debug) {
				try {
					if (Target.style) {
						var OldBorder = Target.style.border;
					} else {
						var OldBorder = "";
					}
					Target.style.border = "1px solid #FF0000;";
				} catch(e){
				}
				alert (Target + ": Type = " + Target.nodeName + ", ID = " +  Target.id);
				try {
					Target.style.border = OldBorder;
				} catch(e){
				}
			}
			if (Loose) {
				if (Target && (Target.nodeName.toLowerCase() == RoadSigns[0].toLowerCase() || (Target.id && Target.id.toLowerCase().indexOf(RoadSigns[0].toLowerCase()) > -1) || (Target.name && Target.name.toLowerCase().indexOf(RoadSigns[0].toLowerCase()) > -1))){
					RoadSigns.shift();
				}
			} else {
				if (Target && (Target.nodeName.toLowerCase() == RoadSigns[0].toLowerCase() || (Target.id && Target.id.toLowerCase() == RoadSigns[0].toLowerCase()) || (Target.name && Target.name.toLowerCase() == RoadSigns[0].toLowerCase()))){
					RoadSigns.shift();
				}
			}
		}
	}
	return Target;
}

function createCookie(name,value,expire) {
	if (expire) {
		var date = new Date();
		date.setTime(date.getTime()+expire);
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function WhatBack(Returned){
	alert ("WhatBack:" + Returned.responseText);
}


function AddSessionId(QueryString) {
	QueryString += "&";
	QueryString += "session_id=" + String(MakeRandom(9999999));
	return QueryString;
}

function GetDomElem(_Target) {
		if (typeof(_Target) == "string") {
			_Target = document.getElementById(_Target);
		}
		return _Target;
	}
	
function GetCellPos(_Target) {
	var MyTd = TreeWalk(_Target, ["u", "td"]);
	var MyTr = TreeWalk(_Target, ["u", "tr"]);
	return [MyTd, MyTr];
}

function SortTable(_Target, ColNum, Desc, SortBy, StartAt, EndAt){
		var SortArray = [];
		if (!StartAt) {
			var StartAt = 0;
		}
		if (!EndAt) {
			var EndAt = _Target.rows.length;
		}
		for (var n=StartAt; n<EndAt; n++) {
			var Cells = _Target.rows[n].cells;
			var Value = Cells[ColNum].innerHTML.toLowerCase();
			var ValueAsInt = parseInt(Value);
			if (ValueAsInt == Value) {
				Value = ValueAsInt;
			}
			var ContentArray = [];
			for (var n2=0; n2<Cells.length; n2++) {
				ContentArray[ContentArray.length] = Cells[n2].innerHTML;
			}
			SortArray[SortArray.length] = [Value, ContentArray];
		}
		//alert (SortArray);
		SortArray.sort(function(a,b){ 
		  if (a[0] > b[0]) 
			 return 1 
		  if (a[0] < b[0]) 
			 return -1 
		  return 0; 
		});
		//alert (SortArray);
		for (var n=StartAt; n<_Target.rows.length; n++) {
			if (Desc) {
				SubArray = SortArray.pop();
			} else {
				SubArray = SortArray.shift();
			}
			//alert (Desc);
			//alert(SubArray[1][1]);
			ContentSubArray = SubArray[1];
			//var Cells = _Target.rows[n].cells;
			for (var n2=0; n2<ContentSubArray.length; n2++) {
				_Target.rows[n].cells[n2].innerHTML = ContentSubArray[n2];
			}
		}
	}
	
	
function ShowHideThese(Targets, Show) {
	for (var n=0; n<Targets.length; n++) {
		var _Target = Targets[n];
		if (Show) {
			_Target.style.display = "";
		} else {
			_Target.style.display = "none";
		}
	}
}


function AddIdsFromArray(IDsArray, AddOnArray) {
	for (n=0;n<AddOnArray.length; n++) {
		IDsArray[IDsArray.length] = AddOnArray[n].id;
	}
	return IDsArray;
}

function CollectFields(HolderElem, AddToArray, NoSelects, NoChecks, NoRadios, NoInputs, NoTexts) {
	if (AddToArray) {
		var TargetsArray = AddToArray;
	} else {
		var TargetsArray = [];
	}
	if (!NoSelects) {
		var Selects = HolderElem.getElementsByTagName("select");
		TargetsArray = AddIdsFromArray(TargetsArray, Selects);
	}
	if (!NoChecks) {
		var Checks = HolderElem.getElementsByTagName("checkbox");
		TargetsArray = AddIdsFromArray(TargetsArray, Checks);
	}
	if (!NoRadios) {
		var Radios = HolderElem.getElementsByTagName("radio");
		TargetsArray = AddIdsFromArray(TargetsArray, Radios);
	}
	if (!NoInputs) {
		var Inputs = HolderElem.getElementsByTagName("input");
		TargetsArray = AddIdsFromArray(TargetsArray, Inputs);
	}
	
	if (!NoTexts) {
		var Texts = HolderElem.getElementsByTagName("textarea");
		TargetsArray = AddIdsFromArray(TargetsArray, Texts);
	}
	
	return TargetsArray;
}

function SendRequest(Script, Value, Sync, ContentType, HandlerFunction, FailureFunction, Method, SessionName, Extra) {
	//alert ("Bout to post: " + Value);

	if (!Sync) {
		Sync = false;
	}
	if (!Method) {
		Method = "GET";
	}
	
	if (Value.length > 255) {
		Method = "POST";
	}
	
	if (!ContentType) {
		ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
	}
	
	if (Method == "GET") {
		Script += "?" + Value;
		Value = null;
	}
	var RanID = Math.floor(Math.random()* 9999999999);
	if (!SessionName) {
		SessionName = "http" + RanID;
	}
	if (!this[SessionName]) {
		if (window.XMLHttpRequest) {
			var http = eval(SessionName + " = new XMLHttpRequest()");
		} else if (window.ActiveXObject) {
			var http = eval(SessionName + " = new ActiveXObject('Microsoft.XMLHTTP')");
		}
	
		if (http) {
			var PassToCheck = "'" + HandlerFunction + "','" + FailureFunction + "','" + SessionName + "'";
			if (Extra) {
				PassToCheck += "'" + Extra + "'";
			}
			this[SessionName + "Interval"] = setInterval("CheckSession(" + PassToCheck + ")", 100);
		} else {
			eval(FailureFunction)(http);
		}
		try {
			http.open(Method, Script, Sync);
			if (ContentType){
				http.setRequestHeader("Content-Type", ContentType);
			}
			http.send(Value);
		} catch(e) {
			if (FailureFunction) {
				eval(FailureFunction)(http);
			}
		}
	}
}

function CheckSession(HandlerFunction, FailureFunction, SessionName, Extra) {
	this[SessionName];
	if (this[SessionName].readyState == 4) {
		if (this[SessionName].status == 200) {
			KillInterval(SessionName);
			if (HandlerFunction) {
				eval(HandlerFunction)(this[SessionName], Extra);
			}
			KillSession(SessionName);
		} else {
			KillInterval(SessionName);
			if (FailureFunction) {
				eval(FailureFunction)(this[SessionName], Extra);
			}
			KillSession(SessionName);
		}
	}
}

function KillSession(SessionName) {
	this[SessionName] = undefined;
	try {
		delete this[SessionName];
	} catch(e) {
	}
}

function KillInterval(SessionName) {
	clearInterval(this[SessionName + "Interval"]);
	this[SessionName + "Interval"] = undefined;
	try {
		delete this[SessionName + "Interval"];
	} catch(e) {
	}
}

/*function SendRequest(Script, Value, Sync, ContentType, HandlerFunction, FailureFunction, Method, SessionName, Extra) {
	//alert ("Bout to post: " + Value);

	if (!Sync) {
		Sync = false;
	}
	if (!Method) {
		Method = "GET";
	}
	
	if (Value.length > 255) {
		Method = "POST";
	}
	
	if (!ContentType) {
		ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
	}
	
	if (Method == "GET") {
		Script += "?" + Value;
		Value = null;
	}
	var RanID = Math.floor(Math.random()* 9999999999);
	if (!SessionName) {
		SessionName = "http" + RanID;
	}
	if (!this[SessionName]) {
		if (window.XMLHttpRequest) {
			var http = eval(SessionName + " = new XMLHttpRequest()");
		} else if (window.ActiveXObject) {
			var http = eval(SessionName + " = new ActiveXObject('Microsoft.XMLHTTP')");
		}
	
		if (http) {
			var PassToCheck = "'" + HandlerFunction + "','" + FailureFunction + "','" + SessionName + "'";
			if (Extra) {
				PassToCheck += "'" + Extra + "'";
			}
			this[SessionName + "Interval"] = setInterval("CheckSession(" + PassToCheck + ")", 100);
		} else {
			KillSession(SessionName);
			KillInterval(SessionName);
			eval(FailureFunction)(http);
		}
		try {
			http.open(Method, Script, Sync);
			if (ContentType){
				http.setRequestHeader("Content-Type", ContentType);
			}
			http.send(Value);
		} catch(e) {
			KillSession(SessionName);
			KillInterval(SessionName);
			if (FailureFunction) {
				eval(FailureFunction)(http);
			}
		}
	}
}

function CheckSession(HandlerFunction, FailureFunction, SessionName, Extra) {
	this[SessionName];
	if (this[SessionName].readyState == 4) {
		if (this[SessionName].status == 200) {
			KillInterval(SessionName);
			if (HandlerFunction) {
				eval(HandlerFunction)(this[SessionName], Extra);
			}
			KillSession(SessionName);
		} else {
			KillInterval(SessionName);
			if (FailureFunction) {
				eval(FailureFunction)(this[SessionName], Extra);
			}
			KillSession(SessionName);
		}
	}
}

function KillSession(SessionName) {
	this[SessionName] = undefined;
	try {
		delete this[SessionName];
	} catch(e) {
	}
}

function KillInterval(SessionName) {
	clearInterval(this[SessionName + "Interval"]);
	this[SessionName + "Interval"] = undefined;
	try {
		delete this[SessionName + "Interval"];
	} catch(e) {
	}
}*/



function OpenWindow(URL, Width, Height, Resizable, Scrollable, Extras) {
		if(!Width) {
			var Width = 550;
		}
		if(!Height) {
			var Height = 292;
		}
		if(!Extras) {
			var Extras = "no";
		} else if (Extras==true) {
			var Extras = "yes";
		}
		if(!Resizable) {
			var Resizable = "no";
		} else if (Resizable==true) {
			var Resizable = "yes";
		}
		if(!Scrollable) {
			var Scrollable = "no";
		} else if (Scrollable==true) {
			var Scrollable = "yes";
		}
		

		var ExtraParam = 'width=' + Width + ',height=' + Height + ',menubar='+ Extras +',toolbar='+ Extras +',location='+ Extras +',status='+ Extras +',resizable='+ Resizable +',scrolling='+ Scrollable +',scrollbars='+ Scrollable; 
		var ExitWindow = false;
		try {
			ExitWindow = window.open(URL, "_blank", ExtraParam);
		} catch(e) {
			ExitWindow = false;
		}
		
		try{
			var WindowParent = ExitWindow["parent"];
		} catch (e) {
			var WindowParent = false;
		}
		
		if (!WindowParent) {
			alert ("Your browser appears to have blocked the window you attemped to open. \nHold down control and click this link again to over ride your pop up blocker.");
			return false;
		} else {
			return ExitWindow;
		}
	}
	
	
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

/*function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
	if (IE) {
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])
		if ((version >= 5.5) && (document.body.filters)) 
		{
		  for(var i=0; i<document.images.length; i++)
		  {
			 var img = document.images[i]
			 var imgName = img.src.toUpperCase()
			 if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			 {
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + imgMouseOver + imgMouseOut + imgMouseOnClick
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				alert(strNewHTML);
				img.outerHTML = strNewHTML
				i = i-1
			 }
		  }
		}    
	}
}
*/

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{

	if (document.all) {
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])
		if ((version >= 5.5) && (document.body.filters)) 
		{
		  for(var i=0; i<document.images.length; i++)
		  {
			 var img = document.images[i]
			 var imgName = img.src.toUpperCase()
			 if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			 {	
			 	var imgOuterHTML = img.outerHTML;
				imgOuterHTML = imgOuterHTML.replace(/^<IMG|>$/g, "");
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + /*imgID + imgClass + imgTitle +*/ imgOuterHTML
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML
				//alert(strNewHTML);
				i = i-1
			 }
		  }
		}    
	}
}

function GetWindowSize() {
	try{
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.body && ( document.body.parentNode.clientWidth || document.body.parentNode.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.parentNode.clientWidth;
			myHeight = document.body.parentNode.clientHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		return [myWidth, myHeight];
	} catch(e){
		return [0, 0];
	}
}

function GetWindowScroll() {
	try{
		var scrOfX = 0, scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		return [scrOfY, scrOfX];
	} catch(e) {
		
	}
}