/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| JavaScript Library
| Developed by Bill Brewer
| Copyright (c)2008-2010
| All rights reserved.
| This code is licensed for use on a single server.
| This code is licensed for use by the original purchaser only.
\-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

var ac = {

	$:function(id){

		return document.getElementById(id);

	},


	createModal:function(display){
	/* @ (display) = 
			div [a div to display in the modal window]
			contents [html contents to copy to the modal window]
			opac [opacity of the content window, defaults to 100]
			sphere (boolean) [display with a spherical background] */

		// Create the modal background if needed //
		if (!this.$('modalBackground'))
			this.createElem({node:'div', id:'modalBackground'}, 'body');

		// Close the modal when clicking outside of it //
		this.addEvent(this.$('modalBackground'), 'click', function(){ ac.eraseModal(); });
		
		// Create the contents of this div //
		if (!display.contents && !display.div)
			var nodeContents = '<a href="javascript:ac.eraseModal();">erase</a>';
				else
			var nodeContents = null;

		// Set the ac.modalWindow to the correct div element id //
		if (display.div)
			ac.modalWindow = display.div;	
				else
			ac.modalWindow = 'modalWindow';

		if (display.contents){

			// Create the contents window //
			if (!this.$(ac.modalWindow))
				this.createElem({node:'div', id:ac.modalWindow, content:nodeContents}, 'body');

			this.$(ac.modalWindow).innerHTML = display.contents;
		}

		// Set Opacity to 0 //
		this.changeOpacity(0, ac.modalWindow);
		this.changeOpacity(0, 'modalBackground');


		// Make modal window visible //
		this.$(ac.modalWindow).style.display = 'block';
		this.$('modalBackground').style.display = 'block';

		// Set the correct class for display //
		this.$(ac.modalWindow).className = display.sphere ? 'modalWindowSphere' : 'modalWindow';

		// Special < IE7 -only remove selects //	
		if (ac.IE && window.XMLHttpRequest == null)
			replaceSelectsWithSpans();

			ac.modalWindowResize = function (){

				div = ac.$(ac.modalWindow);

				div.style.left = Math.max(((window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0) + (ac.getWindowWidth() - div.offsetWidth) / 2), 0) + 'px';
				div.style.top = Math.max(((window.XMLHttpRequest == null ? document.documentElement.scrollTop : 0) + (ac.getWindowHeight() - div.offsetHeight) / 2), 0) + 'px';

			};

			ac.modalWindowResize();

			// Attach events for a page resize //
			this.addEvent(window, 'resize', ac.modalWindowResize);

			if (!this.isset(display.opac)) // Default opacity to 100 //
				display.opac = 100;

			// Fade In //
			this.fade('modalBackground', 0, ac.modalWindowOpac, 300);
			this.fade(this.modalWindow, 0, display.opac, 300);

			// Create close button //
			if (!this.isset(display.opac) || !display.hideModalClose)
				setTimeout(function(){ ac.createModalClose(ac.modalWindow, display.sphere ? true : false); }, 1000);

	},


	createModalSphere:function(contents){
	// @ (display) = div [a div to display in the modal window], contents [html contents to copy to the modal window], opac [opacity of the content window, defaults to 100] //
			contents = '<img onclick="ac.eraseModal();" style="cursor:pointer;" src="Source/skin1/images/modal_top.png" width="521" height="35" /><br /><div class="modalSphere">'+contents+'</div><br /><img src="Source/skin1/images/modal_bottom.png" width="521" height="35" />';
	
			this.createModal({contents:contents, sphere:true});

	},


	// Create a button to close the Modal Window //
	createModalClose:function(div, sphere){

		div = this.$(div);
		
		// Create a holder div //
		if (!this.$('modalClose') || !div)
			this.createElem({node:'div', id:'modalClose'}, 'body');

		// Make invisible //
		this.changeOpacity(0, 'modalClose');
		this.$('modalClose').style.display = sphere ? 'none' : '';
		this.$('modalClose').style.zIndex = 99999;
		
		if (sphere)
			return;		

		// Special AJAX Speedbar code //
		if (typeof(unhighlightSpeedbar) == 'function')
			closeLink = "javascript:ac.eraseModal(); unhighlightSpeedbar();";
				else
			closeLink = "javascript:ac.eraseModal();";

		// Contents //
		this.$('modalClose').innerHTML = '<a style="text-decoration:none; border:0;" href="'+closeLink+'">Close <img style="border:0; padding:3px;" height="9" width="9" src="'+ac.ImagesDir+'/modal_close.png"></a>';

		// Move //	
		offsets = this.calculateOffsets(div);

		if (!this.$('modalClose') || offsets.width == 0) // Modal window was deleted //
			return;

		this.$('modalClose').style.width = (offsets.width-6)+'px';
		this.$('modalClose').style.left = offsets.x+'px';
		this.$('modalClose').style.top = (offsets.y-18)+'px';

		this.fade('modalClose', 0, 100, 300);

	},

	
	getStyle:function(obj, property){

	//console.log(obj.className);

	// First find the properties listed in the CSS Files //
	for (var i = 0; i < document.styleSheets.length; i++){

		// Now search the file for the property //
		for (var x=0; x<document.styleSheets[i].cssRules.length; x++){
											 
			rule = document.styleSheets[i].cssRules[x].cssText;

			// Check if this rule applies //
			//if (rule.search(
											 
											 
	 }		
}


	//alert(document.styleSheets[0].cssRules);


	},


	eraseModal:function(){

		// Make sure the modal is completely loaded //
		opacity = this.$(ac.modalWindow).style.opacity ? this.$(ac.modalWindow).style.opacity : this.$(ac.modalWindow).style.MozOpacity;
		
		if (opacity < (ac.modalWindowOpac/100) || !this.$('modalClose') || !this.$(ac.modalWindow))
			return;

		// Make sure the cursor doesn't disappear //
		document.body.focus();

		// Fade Out //
		this.fade('modalBackground', 70, 0, 300);
		this.fade(ac.modalWindow, 100, 0, 300);
		this.fade('modalClose', 100, 0, 300);

		setTimeout(function(){ac.$(ac.modalWindow).style.display = ac.$('modalClose').style.display = ac.$('modalBackground').style.display = 'none'}, 300);

		// Special < IE7 -only processing for windowed elements //
		if (ac.IE && window.XMLHttpRequest == null)
			removeSelectSpans();

		},


	rand:function(maxnum){

		return Math.floor(Math.random()*(maxnum+1));

	},


	// For modal windows in IE //
	removeSelectSpans:function(){

		var selects = document.getElementsByTagName('select');

		for (var i = 0; i < selects.length; i++){
			var select = selects[i];

			if (select.clientWidth == 0 || select.clientHeight == 0 || 
				select.nextSibling == null || select.nextSibling.className != 'selectReplacement')
					continue;

			select.parentNode.removeChild(select.nextSibling);
			select.style.display = select.cachedDisplay;

			}
		},


	// For modal windows in IE //
	replaceSelectsWithSpans:function(){

		var selects = document.getElementsByTagName('select');

		for (var i = 0; i < selects.length; i++){

			var sel = selects[i];

			if (sel.clientWidth == 0 || sel.clientHeight == 0 || 
				sel.nextSibling == null || sel.nextSibling.className == 'selectReplacement')
					continue;

			var span = document.createElement('span');

			span.style.height = (sel.clientHeight - 4) + 'px';
			span.style.width = (sel.clientWidth - 6) + 'px';
			span.style.display = 'inline-block';
			span.style.border = '1px solid rgb(200, 210, 230)';
			span.style.padding = '1px 0 0 4px';
			span.style.fontFamily = 'Arial';
			//span.style.fontSize = 'smaller';
			span.style.position = 'relative';
			span.style.top = '1px';
			span.className = 'selectReplacement';

			span.innerHTML = sel.options[sel.selectedIndex].innerHTML + 
				'<img src="'+ImagesDir+'/select_arrow.gif" alt="drop down" style="position: absolute; right: 1px; top: 1px;" />';

			sel.cachedDisplay = sel.style.display;
			sel.style.display = 'none';
			sel.parentNode.insertBefore(span, sel.nextSibling);

			}
		},


	// Fade //
	changeOpacity:function(opacity, id, time){

		change = function(opacity, id){

			if (!ac.$(id))
				return;

			object = ac.$(id).style;
			object.opacity = (opacity / 100);
			object.MozOpacity = (opacity / 100);
			object.KhtmlOpacity = (opacity / 100);
			object.filter = "alpha(opacity=" + opacity + ")";

		};

		if (typeof(time) == 'undefined')		
			change(opacity, id);
				else
			setTimeout(function(){change(opacity, id)}, time);

		},


	fade:function(id, opacStart, opacEnd, millisec){
		var counter = 1;

		// Frames (25FPS) //
		var frames = millisec/200;

		// If the start opacity is 0 set the initial opacity and display //
		if (opacStart == 0){
			this.changeOpacity(0, id);

			if (this.$(id).style.display == 'none')
				this.$(id).style.display = '';		
		}

		// Fade Out //
		if (opacStart > opacEnd) {

			// Number of setTimeout calls to make //
			var movesToMake = (opacStart-opacEnd)/frames;
			var pixelsPerMove = (opacStart-opacEnd)/movesToMake;
			var miliPerMove = millisec/movesToMake;

			while (opacStart > opacEnd){

				opacStart -= pixelsPerMove;
				if (opacStart < opacEnd) opacStart = opacEnd;
					this.changeOpacity(opacStart, id, (miliPerMove*counter));
					counter++

				}
			}

		// Fade In //
		else if (opacStart < opacEnd){

			// Number of setTimeout calls to make //
			var movesToMake = (opacEnd-opacStart)/frames;
			var pixelsPerMove = (opacEnd-opacStart)/movesToMake;
			var miliPerMove = millisec/movesToMake;

			while (opacStart < opacEnd){

				opacStart += pixelsPerMove;
				if (opacStart > opacEnd) opacStart = opacEnd;
					this.changeOpacity(opacStart, id, (miliPerMove*counter));
					counter++

				}
			}
		},


	// Grow/Shrink an object //
	changeSizeTimeout:function(size, id, xy, time){

		changeS = function(size, id, xy){

			if (typeof(size) != 'undefined' && ac.$(id))
				try{

				if (size > 0)
					ac.$(id).style.display = '';
				else if (size <= 0)
					ac.$(id).style.display = 'none';

				if (xy == 'y' || xy == 'Y')
					ac.$(id).style.height = size+'px';	
				else if (xy == 'x' || xy == 'X')			
					ac.$(id).style.width = size+'px';

				}catch(e){}
					
				if (typeof(ac.realignMask) == 'function')
					ac.realignMask();
			};

		if (typeof(time) == 'undefined')		
			changeS(size, id, xy);
				else
			setTimeout(function(){changeS(size, id, xy)}, time);	
		},

	
	changeSize:function(opt){
	// @ opt [options] = id [the string id of the element], start, end, xy, millisec //	

		var counter = 1;	

		// Frames (25FPS) //
		var frames = opt.millisec/20;

		// Shrink //
		if(opt.start > opt.end){

			// Number of setTimeout calls to make //
			var movesToMake = (opt.start-opt.end)/frames;
			var pixelsPerMove = (opt.start-opt.end)/movesToMake;
			var miliPerMove = opt.millisec/movesToMake;

			while (opt.start > opt.end){

				opt.start -= pixelsPerMove;
				if (opt.start < opt.end) opt.start = opt.end;

					ac.changeSizeTimeout(opt.start, opt.id, opt.xy, miliPerMove*counter);
					counter++;

				};	
			}

		// Grow //
		else if(opt.start < opt.end){

			// Number of setTimeout calls to make //
			var movesToMake = (opt.end-opt.start)/frames;
			var pixelsPerMove = (opt.end-opt.start)/movesToMake;
			var miliPerMove = opt.millisec/movesToMake;

			while (opt.start < opt.end){

				opt.start += pixelsPerMove;
				if (opt.start > opt.end) opt.start = opt.end;

					ac.changeSizeTimeout(opt.start, opt.id, opt.xy, miliPerMove*counter);
					counter++;

				};
			}
		},


	// Change a style value //
	changeStyleTimeout:function(size, id, style_attr){
		if (typeof(size) != 'undefined' && this.$(id))
			try{

				if (style_attr == 'top')			
					this.$(id).style.top = size+'px';
				else if (style_attr == 'left')			
					this.$(id).style.left = size+'px';

			}catch(e){}
		},


	changeStyle:function(opt){	
	// @ opt [options] = id [the string id of the element], start, end, style_attr, millisec //	

		var counter = 1;	

		// Frames (25FPS) //
		var frames = opt.millisec/20;

		// Shrink //
		if(opt.start > opt.end){

			// Number of setTimeout calls to make //
			var movesToMake = (opt.start-opt.end)/frames;
			var pixelsPerMove = (opt.start-opt.end)/movesToMake;
			var miliPerMove = opt.millisec/movesToMake;

			while (opt.start > opt.end){

				opt.start -= pixelsPerMove;
				if (opt.start < opt.end) opt.start = opt.end;

					setTimeout("ac.changeStyleTimeout(" + (opt.start) + ",'" + opt.id + "','" + opt.style_attr + "')",(miliPerMove*counter));
					counter++;

				};
			}

		// Grow //
		else if(opt.start < opt.end){

			// Number of setTimeout calls to make //
			var movesToMake = (opt.end-opt.start)/frames;
			var pixelsPerMove = (opt.end-opt.start)/movesToMake;
			var miliPerMove = opt.millisec/movesToMake;

			while (opt.start < opt.end){

				opt.start += pixelsPerMove;
				if (opt.start > opt.end) opt.start = opt.end;

					setTimeout("ac.changeStyleTimeout(" + (opt.start) + ",'" + opt.id + "','" + opt.style_attr + "')",(miliPerMove*counter));
					counter++;

				};
			}

		},


	// Utiltiy functions //
	getWindowWidth:function(){
		var width =
			document.documentElement && document.documentElement.clientWidth ||
			document.body && document.body.clientWidth ||
			document.body && document.body.parentNode && document.body.parentNode.clientWidth ||
			0;

		return width;

		},


	getWindowHeight:function(){

		if (window.innerHeight)
			return window.innerHeight;
				else
			return document.documentElement.clientHeight;
	},


	// Calculate the X-Y offset of an object and its size //
	calculateOffsets:function(obj, offsets){

		if (!offsets){
			offsets = new Object();
			offsets.x = offsets.y = 0;

			// Size of the obj //
			try{	
				offsets.width = obj.offsetWidth;
				offsets.height = obj.offsetHeight; } catch(e){}
			}

		if (typeof(obj) == 'string')
			obj = this.$(obj);

			offsets.x += obj.offsetLeft;
			offsets.y += obj.offsetTop;

			do{
				obj = obj.offsetParent;

			if (!obj)
				break;
				offsets.x += obj.offsetLeft;
				offsets.y += obj.offsetTop;

				} while(obj.tagName.toUpperCase() != 'BODY');

		return offsets;

		},

	/**
	* Determine the size of a HTML element with a style:display = none
	*
	* @param obj obj/string HTML element to determine size.
	*
	* @retutn int Pixel size of the div once it is displayed
	*/
	offsetHidden:function(obj){

		if (typeof(obj) != 'object')
			obj = this.$(obj);
			
			newSize = {};

			origPosition = obj.style.postition;
			origLeft = obj.style.left;
			origHeight = obj.style.height;

			obj.style.left = '-1000px';				
			obj.style.position = 'absolute'; // Get the size of the selected div //
			obj.style.height = '';
			obj.style.display = '';

			newSize.height = obj.offsetHeight;
			newSize.width = obj.offsetWidth;

			obj.style.display = 'none';
			obj.style.position = origPosition ? origPosition : '';
			obj.style.left = ac.isint(origLeft) ? origLeft+'px' : '';
			obj.style.height = ac.isint(origHeight) ? origHeight+'px' : '';

		return newSize;

	},

	/**
	* Determine the size of a HTML element if the contents are changed
	*
	* @param obj obj/string HTML element to determine size
	* @param html string HTML code to use when calculating new size
	*
	* @retutn int Pixel size of the div once it is displayed
	*/
	offsetChanged:function(obj, html){

		if (typeof(obj) != 'object')
			obj = this.$(obj);

		/*  Clone a node, hide it, change the text, and then use the offsetHidden
			function to determine it's size */
			newNode = obj.cloneNode(true);
			newNode.style.display = 'none';
			newNode.innerHTML = html;
			obj.parentNode.appendChild(newNode);

			newsize = this.offsetHidden(newNode);

			obj.parentNode.removeChild(newNode); // Cleanup //

		return newsize;

	},

	/**
	* Determine if a give value is in an array
	*
	* @param needle string Value to search for
	* @param haystack array Array of data to search through
	*
	* @return boolean
	*/
	in_array:function(needle, haystack){

		for (i=0; i<haystack.length; i++){

			if (typeof(haystack[i]) != 'string')
				continue;

			if (typeof(needle) == 'string' && haystack[i].toLowerCase() == needle.toLowerCase())
				return true;

		}

		return false;

	},


	/**
	* Remove whitespace from the start and end of a string
	*
	* @param str string
	*
	* @return string String with whitespace removed
	*/
	trim:function(str){

		while(str.charAt(0)==' ' || str.charAt(0)== "\n" || str.charAt(0)== "\t"){
			str = str.substring(1);
		}

		while(str.charAt(str.length-1)==' ' || str.charAt(str.length-1)=="\n" || str.charAt(str.length-1)=="\t"){
			str = str.substring(0, str.length-1);
		}

		return str;

	},


	// PHP like isset function //
	isset:function(obj){

		return typeof(obj) != 'undefined' && obj !== null;

	},


	// Check if a value is a valid integer //
	isint:function(num){

		var y = parseInt(num * 1);

		 if (isNaN(y))
			return false;

		return num == y && num.toString() == y.toString(); 

	},


	scrollToElement:function(elem){

		var offsets = ac.calculateOffsets(elem);	
		window.scrollTo(0, offsets.y);

	},


	// Add and Remove Event's //
	addEvent:function(obj, type, fn){
	// @ obj = the object to add, type = change, resize, etc, fn= function to execute //

		// Make sure the object is valid //
		if (!obj)
			return;

		if (obj.attachEvent){
			obj['e'+type+fn] = fn;
			obj[type+fn] = function(){
					obj['e'+type+fn](window.event);
					};

				obj.attachEvent('on'+type, obj[type+fn]);

			} else {

				obj.addEventListener(type, fn, false);			

			}
		},


	removeEvent:function(obj, type, fn){

		if (obj.removeEventListener)
			obj.removeEventListener( type, fn, false );

		else if (obj.detachEvent){
			obj.detachEvent( "on"+type, obj[type+fn] );
			obj[type+fn] = null;
			obj["e"+type+fn] = null;
			}
	},

	/**
	* Dynamically create a new node in the document
	*
	* @param properties object This object will specify the node to be created, options:
	*				node[div, span, etc.]
	*				content[HTML to place inside the created node]
	*				input[for forms]
	*				type[for <input> example: 'button']
	*				size
	*				value
	*				name
	*				id
	*				src[for images]
	*				className
	*				add_br [adds a <br /> tag after the element is created]
	*
	* @param parent str/obj Parent node to attach the newly created node
	*
	* @return string Unique id of the created node
	*/
	createElem:function(properties, parent){

		if (parent == 'body' || !parent)
			parent = document.body;
		else if (typeof(parent) != 'object')
			parent = this.$(parent);

		// Generates a random id if there wasn't one specified //
		if(!properties.id)
			properties.id = 'id'+this.rand(9999999); 

		if (properties.node == 'input' && ac.IE){

				var newElemStr = '';	

				if (properties.type)      newElemStr += 'type="'+properties.type+'" ';
				if (properties.name)      newElemStr += 'name="'+properties.name+'" ';
				if (properties.size)      newElemStr += 'size="'+properties.size+'" ';
				if (properties.value)     newElemStr += 'value="'+properties.value+'" ';
				if (properties.id)        newElemStr += 'id="'+properties.id+'" ';
				if (properties.className) newElemStr += 'class="'+properties.className+'" ';

				var newElem = document.createElement('<input '+newElemStr+'>');
				properties.className = null; // Make sure this isn't loaded later in the function //

				} else {

			var newElem = document.createElement(properties.node);

			if(properties.size) newElem.size = properties.size;
			if(properties.type) newElem.type = properties.type;
			if(properties.value) newElem.value = properties.value;
			if(properties.name) newElem.name = properties.name;
			if(properties.src) newElem.src = properties.src;
			if(properties.className) newElem.className = properties.className;

			// Events //
			if(properties.onclick) newElem.onclick = properties.onclick;

			newElem.id = properties.id;

		}

		parent.appendChild(newElem);

		if (properties.className)
			this.$(properties.id).className = properties.className;

		if (properties.content && properties.node != 'input')
			this.$(properties.id).innerHTML = properties.content;

		// Add a final <br> tag //
		if (properties.add_br){
			var br = document.createElement("br");
			parent.appendChild(br);
		}

		return properties.id;

	},


	// Main AJAX function //
	ajax:function(opt){
	// @ ajax_opt (opt) = url [url to connect to], method [GET or POST], return_func [function to execute when data is returned], return_var [this will return the response from the server to a variable assigned to this function (var foo=ac.ajax(...], parameters [variables to send], returned [type of data - 'xml' || 'text' || 'script'], requestName [this is optional]

	var xmlHttp;

		// Make sure the ajax is not disabled //
		if (!ac.ajaxOn)
			return;

		// Create the obj //		
		if (window.XMLHttpRequest){

			try{ xmlHttp = new XMLHttpRequest(); } catch (e) { xmlHttp = false;	}

			}

		// IE6 //
		else if (!xmlHttp && window.ActiveXObject){

			try{xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {	xmlHttp = false; }

		}

		if (!xmlHttp){

			if (opt.onError)
				opt.onError();	

				return;		
			}

	
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){

			xmlHttp.onreadystatechange = function (){

			// If there isn't anything required with the return data cancel this once it is loaded //
			if (xmlHttp.readyState == 2 && (!ac.ajaxOn || (!ac.isset(opt.return_func) && !ac.isset(opt.return_var)))){
				xmlHttp.abort();
				return;

			} else {

			if (xmlHttp.readyState == 4){
				if (xmlHttp.status == 200){

					if (checkReturnedData(xmlHttp)){

						
						if (opt.returned == 'xml'){
							var xmlResponse = xmlHttp.responseXML;

							if (opt.return_var)
								return xmlResponse;
							else if (opt.return_func)
								opt.return_func(xmlHttp.responseXML);

						}

						else if (opt.returned == 'script'){
							eval(xmlHttp.responseText);

							}

						else {

							if (opt.return_var)
								return xmlHttp.responseText;
							else if (opt.return_func)
								opt.return_func(xmlHttp.responseText);					

							}	

					
					} else {

						if (opt.onError)
							opt.onError();			

						}			

					}
				}
			}
		};

		// Function to make sure the data returned from the server is valid //
		function checkReturnedData(xmlHttp){

		try {

			/*  No server status (requesting a local), any status in the 200 range, 304 if the document has 
				not been modified, or Safari returns an empty status if the file has not been modified  */
			return !xmlHttp.status && location.protocol == "file:" || (xmlHttp.status >= 200 && xmlHttp.status < 300) || xmlHttp.status == 304 || navigatoxmlHttp.userAgent.indexOf('Safari') >= 0 && typeof xmlHttp.status == 'undefined';

			} catch(e){}

			return false;

		}

		xmlHttp.open(opt.method, opt.url, true);
		xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		if (opt.parameters) xmlHttp.setRequestHeader('Content-length', opt.parameters.length);
		xmlHttp.setRequestHeader('Connection', 'close');

		// Make the server request //
		xmlHttp.send(opt.parameters);

			}

			// Error connecting //
			else {}
	},


	// Convert an Basic XML file into two JS arrays //
	XMLToJSArray:function(xmlDoc, parentNode){

		var rawData = xmlDoc.getElementsByTagName(parentNode)[0];
		var returnArr = [];
		returnArr['keys'] = [];
		returnArr['values'] = [];

		for (i=0; i < rawData.childNodes.length; i++){

			// Make sure it isn't the root tag //
			if (rawData.childNodes[i].nodeType == 1){

				oneRecord = rawData.childNodes[i];

				returnArr['keys'][i] = oneRecord.tagName;

				try {
					returnArr['values'][oneRecord.tagName] = oneRecord.childNodes[0].nodeValue;
						}catch(e){
					returnArr['values'][oneRecord.tagName] = '';
						}
					}
				}

			return returnArr;	
	},


	// Get a single value from an xml object //
	valueFromXML:function(xmlDoc, nodeName){

		if (!isset(xmlDoc))
			return;

		return xmlDiv.getElementsByTagName(nodeName)[0].childNodes[0].nodeValue;	

	},


	/**
	* Mask an element 
	*
	* @param string element to cover with a mask
	*
	* @return string id of mask element
	*/
	mask:function(elem){

		obj = this.$(elem);
		id = elem+'_obj';

		if (!this.$(id))
			this.createElem({node:'div', id:id, className:'elementMask'}, 'body');

		offsets = this.calculateOffsets(obj);

		maskObj = this.$(id);

		maskObj.style.height = offsets.height+'px';
		maskObj.style.width = offsets.width+'px';
		maskObj.style.top = offsets.y+'px';
		maskObj.style.left = offsets.x+'px';
		maskObj.style.display = '';
		
		// Helper function to realign when the page changes //
		ac.realignMask = function(){
			
			if (ac.maskElements.length > 0){
			
			for (i=0; i<ac.maskElements.length; i++){
				
				// Object may have been deleted, so first insure it is an object //
				if (ac.$(ac.maskElements[i]))
					ac.mask(ac.maskElements[i]);

				}	
			}
		};

		// Helper function to remove the mask //
		ac.unmask = function(elem){
			if (this.$(elem+'_obj'))	
				this.$(elem+'_obj').style.display = 'none';
			
			// Remove from mask array //
			for (i=0; i<ac.maskElements.length; i++){ 
				if (ac.maskElements[i] == elem)
					ac.maskElements.splice(i, 1);					
			}
		};
		
		if (!this.in_array(elem, ac.maskElements)){

			ac.maskElements.push(elem); // Add element to the array to realign //
		
			// Attach events for a page resize //
			this.addEvent(window, 'scroll', function(){ ac.realignMask(); });
			//this.addEvent(window, 'click', function(){ ac.mask(elem); });
		}
		
		return id;
		
	},


	// Get the mouse cooridinates //
	getMousePos:function(e){

		// Normalize the event object
		e = e || window.event;

		// Check for the non-IE position, then the IE position, and finally return 0
		var x = e.pageX || e.clientX + document.body.scrollLeft || 0;
		var y = e.pageY || e.clientY + document.body.scrollTop || 0;

			// Store the current settings //
			ac.mousePos.x = x;
			ac.mousePos.y = y;

			//ac.$('mousePos').innerHTML = 'X='+ac.mousePos.x+', Y='+ac.mousePos.y;

	},

	
	dragChangeSize:function(e){

		// Normalize the event object
		e = e || window.event;

		var targ;

		if (e.target)
			targ=e.target;
		else if (e.srcElement) 
			targ=e.srcElement;

		// Safari bug //
		if (targ.nodeType==3) 
			targ = targ.parentNode;

		var id = targ.id.substr(5, targ.id.length);

		var obj = ac.$(id);

		ac.mousePos.startx = ac.mousePos.x;
		ac.mousePos.starty = ac.mousePos.y;
		ac.mousePos.id = id;
		ac.mousePos.objOrigHeight = obj.offsetHeight;
		ac.mousePos.objOrigWidth = obj.offsetWidth;

		ac.addEvent(document.body, 'mousemove', ac.dragUpdateSize);

		},


	dragUpdateSize:function(){

		// Amount of X and Y movement of the mouse //
		if (ac.mousePos.startx > ac.mousePos.x)
			var xChange = ac.mousePos.x - ac.mousePos.startx;
		else if (ac.mousePos.x > ac.mousePos.startx)
			var xChange = ac.mousePos.x - ac.mousePos.startx;
		else
			xChange = 0;

		if (ac.mousePos.starty > ac.mousePos.y)
			var yChange = ac.mousePos.y - ac.mousePos.starty;
		else if (ac.mousePos.y > ac.mousePos.starty)
			var yChange = ac.mousePos.y - ac.mousePos.starty;
		else
			var yChange = 0;

		// Amount to change //
		var x = ac.mousePos.objOrigWidth + xChange;
		var y = ac.mousePos.objOrigHeight + yChange;

		// The element can't be smaller than 1px //
		x = x < 1 ? 1 : x;
		y = y < 1 ? 1 : y;

		// Don't allow the textarea to grow larger than its parent element //
		if ((ac.$(ac.mousePos.id).parentNode.offsetWidth - x) < 35)
				return;

		ac.changeSizeTimeout(x, ac.mousePos.id, 'x');
		ac.changeSizeTimeout(y, ac.mousePos.id, 'y');

		//ac.$('mousePos').innerHTML = 'Change X='+xChange+', Y='+yChange;

		},


	cancelChangeTextarea:function(){

		try{ ac.removeEvent(document.body, 'mousemove', ac.dragUpdateSize); } catch (e){}

	},


	addTextareaResizeSpan:function(){

		// Add the needed event handlers for the resize to operate correctly //
		ac.addEvent(document.body, 'mousemove', ac.getMousePos);
		ac.addEvent(document.body, 'mouseup', ac.cancelChangeTextarea);

		var textareas = document.getElementsByTagName('textarea');

		for (var i = 0; i < textareas.length; i++){
			var textarea = textareas[i];

			if (!textarea.id || textarea.nextSibling == null || ac.$('span_'+textarea.id))
				continue;

			var newElem = document.createElement('span');		
			newElem.id = 'span_'+textarea.id;
			newElem.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;';
			newElem.style.backgroundImage="url("+ac.ImagesDir+"/textarea_edit.png)";
			newElem.style.backgroundRepeat = 'no-repeat';
			newElem.style.cursor = 'se-resize';
			newElem.onmousedown = this.dragChangeSize;

			textarea.style.float = 'left';

			textarea.parentNode.insertBefore(newElem, textarea.nextSibling);

			}
		},

	/**
	* Create a new object by inheriting from an existing object and adding to it.
	*
	* @param parent object Object to inherit from 
	* @param child object New object properties and methods
	*
	* @return object with both the parent and childs properties and methods	
	*/
	extend:function(parent, child){

		function F(){}
		F.prototype = parent;
		extendedObj = new F();
		extendedObj.uber = parent;
		
			for (var i in child){
				extendedObj[i] = child[i];
			}
			
		return extendedObj;
		
		},

	/**
	* An onload event handler for an image to trigger a function when the image has fully loaded
	*
	* @param imgObj Reference to the image object to trigger the onload function
	* @param fn Function to execute when the image has been fully loaded
	*/
	onImageLoad:function(imgObj, fn){
		
		if (!ac.interval)
			ac.interval = [];
		
		if (!imgObj.id)
			imgObj.id = 'id'+ac.rand(999999); // Assign an id if this is empty, this will be used for the interval id //
		
		ac.isImgLoaded = function(obj){
		
			if(obj.complete || obj.onload)
				return true;
					else
				return false;
		};
		
		ac.interval[imgObj.id] = setInterval(function(){ if (ac.isImgLoaded(imgObj)){ fn(); window.clearInterval(ac.interval[imgObj.id]); }}, 1000);

		},

	/**
	* Preload an image so that it is available in the browser cashe for smooth transitions
	*
	* @param path string Path to the image, if it doesn't begin with http, the ac.ImagesDir will
	*			be used for the full path to the server.
	*/
	preloadImg:function(path){
		
		if (path.substr(0, 4) != 'http')
			path = ac.ImagesDir+'/'+path;
		
		img = new Image();
		img.src = path;		
		
		}
	}


/*@cc_on @if (@_jscript)
ac.IE = true;	
@else */
ac.IE = false;
/* @end @*/


ac.modalWindow = null;
ac.modalWindowOpac = 80;
ac.ajaxRequests = [];
ac.ajaxRequests.active = 0;
ac.ajaxRequests.current = 0;
ac.ajaxRequests.queue = [];
ac.ajaxOn = true;
ac.mousePos = {};
ac.maskElements = [];