/*@cc_on @*/
/*@if (@_jscript_version < 5)
// fix Function.apply
if (!Function.apply) Function.prototype.apply = function(thisArg, argArray) {
	// Create a function reference to the calling object
	thisArg.____apply = this;
	// Build a string that will later execute the function 
	var fnApplyString = "thisArg.____apply(";
	
	// Check that the argArray are according to standards. Must be array...
	if (typeof(argArray) == "object" && typeof(argArray.length) != "undefined") {
		var quote, comma;
		for(i = 0; i < argArray.length; i++){
			// Add quotes only for string values
			quote = typeof(argArray[i]) == "string" ? "\"" : "";
			// add a comma as param-separator for all except the last param
			comma = (i+1) < argArray.length ? "," : "";
			// add the param to the string we are building
			fnApplyString += quote + argArray[i] + quote + comma;
		}
	} else if (typeof(argArray) != "undefined") {
		// argArray is not an array, but it is defined, so we notify that the 
		// argArray must be an array when specified (according to ECMAScript specs)
		throw TypeError;
	}
	
	fnApplyString += ")";
	// eval the expression, now using the right object, function and parameters
	var retVal = eval(fnApplyString);
	// clean up our expando property reference
	delete thisArg.____apply;
	// return the value that the function was to return
	return retVal;
};
//some of this is from Dean Edwards's IE7 script, some is from Douglas Crockford 
if (![].push) Array.prototype.push = function() {
	for(var i=0; i<arguments.length; i++)
		this[this.length-1] = arguments[i];
	return this.length;
};
if (![].pop) Array.prototype.pop = function() {
	var $item = this[this.length-1];
	this.length--;
	return $item;
};
if (![].shift) Array.prototype.shift = function () {
	return this.splice(0, 1)[0];
};
if (![].splice) Array.prototype.splice = function (s, d) {
	var max = Math.max,
		min = Math.min,
		a = [], // The return value array
		e,  // element
		i = max(arguments.length - 2, 0),   // insert count
		k = 0,
		l = this.length,
		n,  // new length
		v,  // delta
		x;  // shift count

	s = s || 0;
	if (s < 0) {
		s += l;
	}
	s = max(min(s, l), 0);  // start point
	d = max(min(isNumber(d) ? d : l, l - s), 0);    // delete count
	v = i - d;
	n = l + v;
	while (k < d) {
		e = this[s + k];
		if (!isUndefined(e)) {
			a[k] = e;
		}
		k += 1;
	}
	x = l - s - d;
	if (v < 0) {
		k = s + i;
		while (x) {
			this[k] = this[k - v];
			k += 1;
			x -= 1;
		}
		this.length = n;
	} else if (v > 0) {
		k = 1;
		while (x) {
			this[n - k] = this[l - k];
			k += 1;
			x -= 1;
		}
	}
	for (k = 0; k < i; ++k) {
		this[s + k] = arguments[k + 2];
	}
	return a;
};
if (![].unshift) Array.prototype.unshift = function () {
	this.splice.apply(this,
		[0, 0].concat(Array.prototype.slice.apply(arguments)));
	return this.length;
};
@end @*/

/**
 * unFocus Library
 */
if (typeof unFocus == "undefined") var unFocus = {};
if (!unFocus.Utilities) unFocus.Utilities = {
	preloadImage: (function(src) {
		var _images = [];
		return function(src) {
			var l = _images.length;
			_images.push(new Image());
			_images[l].src = src;
		};
	})()
};

/* Class EventManager
	Provides the interface and functionality to a Subscriber/Subscriber Pattern interface for
	classes to easily inherit or use. Event types are passed in during instantiation. I'm not
	sure that's the best way to do it, but that's how it is for now (comments are welcome). */
unFocus.Utilities.EventManager = function() {
	this._listeners = {};
	for (var i = 0; i < arguments.length; i++)
		this._listeners[arguments[i]] = [];
};

/* Method: addEventListener
	A public method that adds an event listener to be called when the hash changes. */
unFocus.Utilities.EventManager.prototype.addEventListener = function($type, $listener) {
	// check that listener is not in list
	for (var i = 0; i < this._listeners[$type].length; i++)
		if (this._listeners[$type][i] == $listener) return;
	// add listener to appropriate list
	this._listeners[$type].push($listener);
};

/* Method: removeListener
	A public method that removes an event listener. */
unFocus.Utilities.EventManager.prototype.removeEventListener = function($type, $listener) {
	// search for the listener method
	for (var i = 0; i < this._listeners[$type].length; i++) {
		if (this._listeners[$type][i] == $listener) {
			this._listeners.splice(i,1);
			return;
		}
	}
};

/* Method: notifyListeners
	Notifies listeners when an event accurs.*/
unFocus.Utilities.EventManager.prototype.notifyListeners = function($type, $data) {
	for (var i = 0; i < this._listeners[$type].length; i++)
		this._listeners[$type][i]($data);
};

/* 
	QuickLoader speeds up the onload event (it fires when the DOM is ready on browsers that support it)
	Pioneered by Dean Edwards/Matthias Miller/John Resig (if I missed anyone let me know!)
	http://dean.edwards.name/weblog/2006/06/again/
*/
unFocus.Utilities.QuickLoader = (function() {
	var _eventMgr = new unFocus.Utilities.EventManager("_quickLoad", "_quickLoadPriority");
	
	function _quickLoad() {
		// cancel the standard load to prevent double call
		if (document.removeEventListener)
			document.removeEventListener("load", _load, false);
		// prevents double load and cleans up possible memory leak issues in IE
		else if (window.detachEvent) window.detachEvent("onload", _load);
		// call loading script
		_load();
	}
	function _load() {
		// trigger listeners
		_eventMgr.notifyListeners("_quickLoadPriority");
		_eventMgr.notifyListeners("_quickLoad"); // :TODO: send the event object
	}
	
	// the following lines all attempt to set up the early load events.
	if (document.addEventListener) {
		// add the quick load for Mozilla (and Opera 9+)
    	document.addEventListener("DOMContentLoaded", _quickLoad, false);
		// fail safe load method (in case the quicker load method fails)
		document.addEventListener("load", _load, false);
	} else if (window.attachEvent)
		window.attachEvent("onload", _load);
	
	// For Safari
	if (/WebKit/i.test(navigator.userAgent)) { // sniff
		var _timer = setInterval(function() {
			if (/loaded|complete/.test(document.readyState)) {
				clearInterval(_timer);
				delete _timer;
				_quickLoad(); // call the onload handler
			}
		}, 10);
	}
	
	// For IE (conditional comments would have been better, but they break compression techniques)
	if (window.ActiveXObject && window.print && !window.opera) {
		document.write("<script id=__"+"ie_onload defer src=javascript:void(0)><\/script>");
		var _script = document.getElementById("__"+"ie_onload");
		_script.onreadystatechange = function() {
			if (this.readyState == "complete")
				_quickLoad();
		};
	}
	
	// return an object with public interface
	var _QuickLoader = {
		addListenter: function($method, $priority) {
			var $type = (!$priority)?"_quickLoad":"_quickLoadPriority";
			_eventMgr.addEventListener($type, $method);
		},
		removeListener: function($method, $priority) {
			var $type = (!$priority)?"_quickLoad":"_quickLoadPriority";
			_eventMgr.removeEventListener($type, $method);
		}
	};
	return _QuickLoader;
})();

function addEvent(element, type, handler) {
	if (element.addEventListener)
		element.addEventListener(type, handler, false);
	else {
		if (!handler.$$guid) handler.$$guid = addEvent.guid++;
		if (!element.events) element.events = {};
		var handlers = element.events[type];
		if (!handlers) {
			handlers = element.events[type] = {};
			if (element['on' + type]) handlers[0] = element['on' + type];
			element['on' + type] = handleEvent;
		}
	
		handlers[handler.$$guid] = handler;
	}
}
addEvent.guid = 1;

function removeEvent(element, type, handler) {
	if (element.removeEventListener)
		element.removeEventListener(type, handler, false);
	else if (element.events && element.events[type] && handler.$$guid)
		delete element.events[type][handler.$$guid];
}

function handleEvent(event) {
	event = event || fixEvent(window.event);
	var returnValue = true;
	var handlers = this.events[event.type];

	for (var i in handlers) {
		if (!Object.prototype[i]) {
			this.$$handler = handlers[i];
			if (this.$$handler(event) === false) returnValue = false;
		}
	}

	if (this.$$handler) this.$$handler = null;

	return returnValue;
}

function fixEvent(event) {
	event.preventDefault = fixEvent.preventDefault;
	event.stopPropagation = fixEvent.stopPropagation;
	return event;
}
fixEvent.preventDefault = function() {
	this.returnValue = false;
};
fixEvent.stopPropagation = function() {
	this.cancelBubble = true;
};

/**
 * cssQuery
 */
/*document.write('<script type="text/javascript" src="/_'+'scripts/cssQuery/cssQuery-p.js"></script>');*/
/*
	cssQuery, version 2.0.2 (2005-08-19)
	Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
	License: http://creativecommons.org/licenses/LGPL/2.1/
*/
/*
	cssQuery, version 2.0.2 (2005-08-19)
	Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
	License: http://creativecommons.org/licenses/LGPL/2.1/
*/

// the following functions allow querying of the DOM using CSS selectors
var cssQuery = function() {
var version = "2.0.2";

// -----------------------------------------------------------------------
// main query function
// -----------------------------------------------------------------------

var $COMMA = /\s*,\s*/;
var cssQuery = function($selector, $$from) {
try {
	var $match = [];
	var $useCache = arguments.callee.caching && !$$from;
	var $base = ($$from) ? ($$from.constructor == Array) ? $$from : [$$from] : [document];
	// process comma separated selectors
	var $$selectors = parseSelector($selector).split($COMMA), i;
	for (i = 0; i < $$selectors.length; i++) {
		// convert the selector to a stream
		$selector = _toStream($$selectors[i]);
		// faster chop if it starts with id (MSIE only)
		if (isMSIE && $selector.slice(0, 3).join("") == " *#") {
			$selector = $selector.slice(2);
			$$from = _msie_selectById([], $base, $selector[1]);
		} else $$from = $base;
		// process the stream
		var j = 0, $token, $filter, $arguments, $cacheSelector = "";
		while (j < $selector.length) {
			$token = $selector[j++];
			$filter = $selector[j++];
			$cacheSelector += $token + $filter;
			// some pseudo-classes allow arguments to be passed
			//  e.g. nth-child(even)
			$arguments = "";
			if ($selector[j] == "(") {
				while ($selector[j++] != ")" && j < $selector.length) {
					$arguments += $selector[j];
				}
				$arguments = $arguments.slice(0, -1);
				$cacheSelector += "(" + $arguments + ")";
			}
			// process a token/filter pair use cached results if possible
			$$from = ($useCache && cache[$cacheSelector]) ?
				cache[$cacheSelector] : select($$from, $token, $filter, $arguments);
			if ($useCache) cache[$cacheSelector] = $$from;
		}
		$match = $match.concat($$from);
	}
	delete cssQuery.error;
	return $match;
} catch ($error) {
	cssQuery.error = $error;
	return [];
}};

// -----------------------------------------------------------------------
// public interface
// -----------------------------------------------------------------------

cssQuery.toString = function() {
	return "function cssQuery() {\n  [version " + version + "]\n}";
};

// caching
var cache = {};
cssQuery.caching = false;
cssQuery.clearCache = function($selector) {
	if ($selector) {
		$selector = _toStream($selector).join("");
		delete cache[$selector];
	} else cache = {};
};

// allow extensions
var modules = {};
var loaded = false;
cssQuery.addModule = function($name, $script) {
	if (loaded) eval("$script=" + String($script));
	modules[$name] = new $script();;
};

// hackery
cssQuery.valueOf = function($code) {
	return $code ? eval($code) : this;
};

// -----------------------------------------------------------------------
// declarations
// -----------------------------------------------------------------------

var selectors = {};
var pseudoClasses = {};
// a safari bug means that these have to be declared here
var AttributeSelector = {match: /\[([\w-]+(\|[\w-]+)?)\s*(\W?=)?\s*([^\]]*)\]/};
var attributeSelectors = [];

// -----------------------------------------------------------------------
// selectors
// -----------------------------------------------------------------------

// descendant selector
selectors[" "] = function($results, $from, $tagName, $namespace) {
	// loop through current selection
	var $element, i, j;
	for (i = 0; i < $from.length; i++) {
		// get descendants
		var $subset = getElementsByTagName($from[i], $tagName, $namespace);
		// loop through descendants and add to results selection
		for (j = 0; ($element = $subset[j]); j++) {
			if (thisElement($element) && compareNamespace($element, $namespace))
				$results.push($element);
		}
	}
};

// ID selector
selectors["#"] = function($results, $from, $id) {
	// loop through current selection and check ID
	var $element, j;
	for (j = 0; ($element = $from[j]); j++) if ($element.id == $id) $results.push($element);
};

// class selector
selectors["."] = function($results, $from, $className) {
	// create a RegExp version of the class
	$className = new RegExp("(^|\\s)" + $className + "(\\s|$)");
	// loop through current selection and check class
	var $element, i;
	for (i = 0; ($element = $from[i]); i++)
		if ($className.test($element.className)) $results.push($element);
};

// pseudo-class selector
selectors[":"] = function($results, $from, $pseudoClass, $arguments) {
	// retrieve the cssQuery pseudo-class function
	var $test = pseudoClasses[$pseudoClass], $element, i;
	// loop through current selection and apply pseudo-class filter
	if ($test) for (i = 0; ($element = $from[i]); i++)
		// if the cssQuery pseudo-class function returns "true" add the element
		if ($test($element, $arguments)) $results.push($element);
};

// -----------------------------------------------------------------------
// pseudo-classes
// -----------------------------------------------------------------------

pseudoClasses["link"] = function($element) {
	var $document = getDocument($element);
	if ($document.links) for (var i = 0; i < $document.links.length; i++) {
		if ($document.links[i] == $element) return true;
	}
};

pseudoClasses["visited"] = function($element) {
	// can't do this without jiggery-pokery
};

// -----------------------------------------------------------------------
// DOM traversal
// -----------------------------------------------------------------------

// IE5/6 includes comments (LOL) in it's elements collections.
// so we have to check for this. the test is tagName != "!". LOL (again).
var thisElement = function($element) {
	return ($element && $element.nodeType == 1 && $element.tagName != "!") ? $element : null;
};

// return the previous element to the supplied element
//  previousSibling is not good enough as it might return a text or comment node
var previousElementSibling = function($element) {
	while ($element && ($element = $element.previousSibling) && !thisElement($element)) continue;
	return $element;
};

// return the next element to the supplied element
var nextElementSibling = function($element) {
	while ($element && ($element = $element.nextSibling) && !thisElement($element)) continue;
	return $element;
};

// return the first child ELEMENT of an element
//  NOT the first child node (though they may be the same thing)
var firstElementChild = function($element) {
	return thisElement($element.firstChild) || nextElementSibling($element.firstChild);
};

var lastElementChild = function($element) {
	return thisElement($element.lastChild) || previousElementSibling($element.lastChild);
};

// return child elements of an element (not child nodes)
var childElements = function($element) {
	var $childElements = [];
	$element = firstElementChild($element);
	while ($element) {
		$childElements.push($element);
		$element = nextElementSibling($element);
	}
	return $childElements;
};

// -----------------------------------------------------------------------
// browser compatibility
// -----------------------------------------------------------------------

// all of the functions in this section can be overwritten. the default
//  configuration is for IE. The functions below reflect this. standard
//  methods are included in a separate module. It would probably be better
//  the other way round of course but this makes it easier to keep IE7 trim.

var isMSIE = true;

var isXML = function($element) {
	var $document = getDocument($element);
	return (typeof $document.mimeType == "unknown") ?
		/\.xml$/i.test($document.URL) :
		Boolean($document.mimeType == "XML Document");
};

// return the element's containing document
var getDocument = function($element) {
	return $element.ownerDocument || $element.document;
};

var getElementsByTagName = function($element, $tagName) {
	return ($tagName == "*" && $element.all) ? $element.all : $element.getElementsByTagName($tagName);
};

var compareTagName = function($element, $tagName, $namespace) {
	if ($tagName == "*") return thisElement($element);
	if (!compareNamespace($element, $namespace)) return false;
	if (!isXML($element)) $tagName = $tagName.toUpperCase();
	return $element.tagName == $tagName;
};

var compareNamespace = function($element, $namespace) {
	return !$namespace || ($namespace == "*") || ($element.scopeName == $namespace);
};

var getTextContent = function($element) {
	return $element.innerText;
};

function _msie_selectById($results, $from, id) {
	var $match, i, j;
	for (i = 0; i < $from.length; i++) {
		if ($match = $from[i].all.item(id)) {
			if ($match.id == id) $results.push($match);
			else if ($match.length != null) {
				for (j = 0; j < $match.length; j++) {
					if ($match[j].id == id) $results.push($match[j]);
				}
			}
		}
	}
	return $results;
};

// for IE5.0
if (![].push) Array.prototype.push = function() {
	for (var i = 0; i < arguments.length; i++) {
		this[this.length] = arguments[i];
	}
	return this.length;
};

// -----------------------------------------------------------------------
// query support
// -----------------------------------------------------------------------

// select a set of matching elements.
// "from" is an array of elements.
// "token" is a character representing the type of filter
//  e.g. ">" means child selector
// "filter" represents the tag name, id or class name that is being selected
// the function returns an array of matching elements
var $NAMESPACE = /\|/;
function select($$from, $token, $filter, $arguments) {
	if ($NAMESPACE.test($filter)) {
		$filter = $filter.split($NAMESPACE);
		$arguments = $filter[0];
		$filter = $filter[1];
	}
	var $results = [];
	if (selectors[$token]) {
		selectors[$token]($results, $$from, $filter, $arguments);
	}
	return $results;
};

// -----------------------------------------------------------------------
// parsing
// -----------------------------------------------------------------------

// convert css selectors to a stream of tokens and filters
//  it's not a real stream. it's just an array of strings.
var $STANDARD_SELECT = /^[^\s>+~]/;
var $$STREAM = /[\s#.:>+~()@]|[^\s#.:>+~()@]+/g;
function _toStream($selector) {
	if ($STANDARD_SELECT.test($selector)) $selector = " " + $selector;
	return $selector.match($$STREAM) || [];
};

var $WHITESPACE = /\s*([\s>+~(),]|^|$)\s*/g;
var $IMPLIED_ALL = /([\s>+~,]|[^(]\+|^)([#.:@])/g;
var parseSelector = function($selector) {
	return $selector
	// trim whitespace
	.replace($WHITESPACE, "$1")
	// e.g. ".class1" --> "*.class1"
	.replace($IMPLIED_ALL, "$1*$2");
};

var Quote = {
	toString: function() {return "'"},
	match: /^('[^']*')|("[^"]*")$/,
	test: function($string) {
		return this.match.test($string);
	},
	add: function($string) {
		return this.test($string) ? $string : this + $string + this;
	},
	remove: function($string) {
		return this.test($string) ? $string.slice(1, -1) : $string;
	}
};

var getText = function($text) {
	return Quote.remove($text);
};

var $ESCAPE = /([\/()[\]?{}|*+-])/g;
function regEscape($string) {
	return $string.replace($ESCAPE, "\\$1");
};

// -----------------------------------------------------------------------
// modules
// -----------------------------------------------------------------------

// -------- >>      insert modules here for packaging       << -------- \\

/*
	cssQuery, version 2.0.2 (2005-08-19)
	Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
	License: http://creativecommons.org/licenses/LGPL/2.1/
*/

cssQuery.addModule("css-standard", function() { // override IE optimisation

// cssQuery was originally written as the CSS engine for IE7. It is
//  optimised (in terms of size not speed) for IE so this module is
//  provided separately to provide cross-browser support.

// -----------------------------------------------------------------------
// browser compatibility
// -----------------------------------------------------------------------

// sniff for Win32 Explorer
isMSIE = eval("false;/*@cc_on@if(@\x5fwin32)isMSIE=true@end@*/");

if (!isMSIE) {
	getElementsByTagName = function($element, $tagName, $namespace) {
		return $namespace ? $element.getElementsByTagNameNS("*", $tagName) :
			$element.getElementsByTagName($tagName);
	};

	compareNamespace = function($element, $namespace) {
		return !$namespace || ($namespace == "*") || ($element.prefix == $namespace);
	};

	isXML = document.contentType ? function($element) {
		return /xml/i.test(getDocument($element).contentType);
	} : function($element) {
		return getDocument($element).documentElement.tagName != "HTML";
	};

	getTextContent = function($element) {
		// mozilla || opera || other
		return $element.textContent || $element.innerText || _getTextContent($element);
	};

	function _getTextContent($element) {
		var $textContent = "", $node, i;
		for (i = 0; ($node = $element.childNodes[i]); i++) {
			switch ($node.nodeType) {
				case 11: // document fragment
				case 1: $textContent += _getTextContent($node); break;
				case 3: $textContent += $node.nodeValue; break;
			}
		}
		return $textContent;
	};
}
}); // addModule


/*
	cssQuery, version 2.0.2 (2005-08-19)
	Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
	License: http://creativecommons.org/licenses/LGPL/2.1/
*/

cssQuery.addModule("css-level2", function() {

// -----------------------------------------------------------------------
// selectors
// -----------------------------------------------------------------------

// child selector
selectors[">"] = function($results, $from, $tagName, $namespace) {
	var $element, i, j;
	for (i = 0; i < $from.length; i++) {
		var $subset = childElements($from[i]);
		for (j = 0; ($element = $subset[j]); j++)
			if (compareTagName($element, $tagName, $namespace))
				$results.push($element);
	}
};

// sibling selector
selectors["+"] = function($results, $from, $tagName, $namespace) {
	for (var i = 0; i < $from.length; i++) {
		var $element = nextElementSibling($from[i]);
		if ($element && compareTagName($element, $tagName, $namespace))
			$results.push($element);
	}
};

// attribute selector
selectors["@"] = function($results, $from, $attributeSelectorID) {
	var $test = attributeSelectors[$attributeSelectorID].test;
	var $element, i;
	for (i = 0; ($element = $from[i]); i++)
		if ($test($element)) $results.push($element);
};

// -----------------------------------------------------------------------
// pseudo-classes
// -----------------------------------------------------------------------

pseudoClasses["first-child"] = function($element) {
	return !previousElementSibling($element);
};

pseudoClasses["lang"] = function($element, $code) {
	$code = new RegExp("^" + $code, "i");
	while ($element && !$element.getAttribute("lang")) $element = $element.parentNode;
	return $element && $code.test($element.getAttribute("lang"));
};

// -----------------------------------------------------------------------
//  attribute selectors
// -----------------------------------------------------------------------

// constants
AttributeSelector.NS_IE = /\\:/g;
AttributeSelector.PREFIX = "@";
// properties
AttributeSelector.tests = {};
// methods
AttributeSelector.replace = function($match, $attribute, $namespace, $compare, $value) {
	var $key = this.PREFIX + $match;
	if (!attributeSelectors[$key]) {
		$attribute = this.create($attribute, $compare || "", $value || "");
		// store the selector
		attributeSelectors[$key] = $attribute;
		attributeSelectors.push($attribute);
	}
	return attributeSelectors[$key].id;
};
AttributeSelector.parse = function($selector) {
	$selector = $selector.replace(this.NS_IE, "|");
	var $match;
	while ($match = $selector.match(this.match)) {
		var $replace = this.replace($match[0], $match[1], $match[2], $match[3], $match[4]);
		$selector = $selector.replace(this.match, $replace);
	}
	return $selector;
};
AttributeSelector.create = function($propertyName, $test, $value) {
	var $attributeSelector = {};
	$attributeSelector.id = this.PREFIX + attributeSelectors.length;
	$attributeSelector.name = $propertyName;
	$test = this.tests[$test];
	$test = $test ? $test(this.getAttribute($propertyName), getText($value)) : false;
	$attributeSelector.test = new Function("e", "return " + $test);
	return $attributeSelector;
};
AttributeSelector.getAttribute = function($name) {
	switch ($name.toLowerCase()) {
		case "id":
			return "e.id";
		case "class":
			return "e.className";
		case "for":
			return "e.htmlFor";
		case "href":
			if (isMSIE) {
				// IE always returns the full path not the fragment in the href attribute
				//  so we RegExp it out of outerHTML. Opera does the same thing but there
				//  is no way to get the original attribute.
				return "String((e.outerHTML.match(/href=\\x22?([^\\s\\x22]*)\\x22?/)||[])[1]||'')";
			}
	}
	return "e.getAttribute('" + $name.replace($NAMESPACE, ":") + "')";
};

// -----------------------------------------------------------------------
//  attribute selector tests
// -----------------------------------------------------------------------

AttributeSelector.tests[""] = function($attribute) {
	return $attribute;
};

AttributeSelector.tests["="] = function($attribute, $value) {
	return $attribute + "==" + Quote.add($value);
};

AttributeSelector.tests["~="] = function($attribute, $value) {
	return "/(^| )" + regEscape($value) + "( |$)/.test(" + $attribute + ")";
};

AttributeSelector.tests["|="] = function($attribute, $value) {
	return "/^" + regEscape($value) + "(-|$)/.test(" + $attribute + ")";
};

// -----------------------------------------------------------------------
//  parsing
// -----------------------------------------------------------------------

// override parseSelector to parse out attribute selectors
var _parseSelector = parseSelector;
parseSelector = function($selector) {
	return _parseSelector(AttributeSelector.parse($selector));
};

}); // addModule


loaded = true;

// -----------------------------------------------------------------------
// return the query function
// -----------------------------------------------------------------------

return cssQuery;

}(); // cssQuery

/**
 * SCVA Stuff
 */
// Search Form behaviors
unFocus.Utilities.QuickLoader.addListenter(function() {
	function resetTextFieldValueLabel(e) {
		if (this.defaultValue == this.value)
			this.value = "";
		else if (!this.value)
			this.value = this.defaultValue;
	}
	function togglePanel(e) {
		var s = ["opened","closed"];
		with (this.parentNode) {
			if (/closed/.test(className))
				s.reverse();
			className = className.replace(s[0], s[1]);
		}
		cssQuery('input[type="hidden"]:first-child', this)[0].value = s[1];
		if (e) e.stopPropagation();
	}
	var panels = cssQuery(".Filters .panel"),
		panel, panelStateElm;
	for (var i = 0; i < panels.length; i++) {
		// check for hardcoded default
		if (!/closed|opened/.test(panels[i]))
			// set the default
			panels[i].className += " opened";
		// get ref to the strong element (but not the weak one - GAFAH!)
		panel = cssQuery("strong", panels[i])[0];
		if (panel) {
			//panel.addEventListener("click", togglePanel, false);
			addEvent(panel, "click", togglePanel);
			// next check for page reload, or refresh default
			panelStateElm = cssQuery('input[type="hidden"]:first-child', panel)[0];
			if (panelStateElm && panelStateElm.value == "closed")
				// simulate click event, to set panel to appropriate state
				togglePanel.call(panel);
		}
	}
	var sk = document.getElementById("SectionKeywords");
	if (sk) {
		addEvent(sk, "focus", function(e) {
			if (this.value == "Enter Search Terms")
				this.value = "";
			e.stopPropagation();
		});
		addEvent(sk, "blur", function(e) {
			if (this.value == "")
				this.value = "Enter Search Terms";
			e.stopPropagation();
		});
	}
	
	// do some image preloading
	with (unFocus.Utilities) {
		preloadImage("/_images/_widgets/buttons/LoginPlannerPage-on.gif");
		preloadImage("/_images/SiteNav/bg.png");
		preloadImage("/_images/sections/searchArrowClosed.gif");
	}
});

/*@cc_on @*/
/*@if (@_win32)
if (navigator.userAgent.match(/MSIE (\d\.\d)/)[1] < 7.0) {
	unFocus.Utilities.QuickLoader.addListenter(function() {
		var _timeoutID = false;
		function _toggleSelects(y) {
			var s = cssQuery("select");
			for (var i=0; i < s.length; i++)
				s[i].style.visibility=(y)?"":"hidden";
		}
		function _showMenu(e) {
			if (_timeoutID)
				clearTimeout(_timeoutID);
			var $menu = cssQuery("div", this)[0];
			if ($menu.style.display != "block") {
				_hideAllMenus(false);
				$menu.style.display="block";
				_toggleSelects(false);
			}
			
			// to delay mouse clicks on the link
			this._linkDelayer = function() {
				this.opened = true;
			}
			this.opened = false;
			setTimeout("cssQuery('#contentNav ."+this.className+"')[0]._linkDelayer()", 250);
			
			e.stopPropagation();
		}
		function _hideMenuHandler(e) {
			_timeoutID = setTimeout("cssQuery('#contentNav')[0]._hideAllMenus(true)", 250);
			e.stopPropagation();
		}
		function _hideAllMenus($hideSelects) {
			var $elms = cssQuery("#contentNav li > div");
			for (var i = 0; i < $elms.length; i++)
				$elms[i].style.display = "";
			if ($hideSelects) _toggleSelects(true);
		}
		var elm = cssQuery("#contentNav")
		if (elm && elm[0])
			elm[0]._hideAllMenus = _hideAllMenus;
		
		// get a list of the contentNav elmenets that have subments
		var $elms = cssQuery("#contentNav li > div");
		
		// :TODO: check these for memory leaks
		for (var i = 0; i < $elms.length; i++) {
			// add the select hide stuff to the parent nodes (li elms)
			addEvent($elms[i].parentNode, "mouseover", _showMenu);
			addEvent($elms[i].parentNode, "mouseout", _hideMenuHandler);
		}
		
		function _menuLinkDelay(e) {
			if (!this.parentNode.opened) 
				e.preventDefault();
		}
		
		$elms = cssQuery("#contentNav > ul > li > div");
		for (i = 0; i < $elms.length; i++)
			addEvent(
				cssQuery('a', $elms[i].parentNode)[0],
				"click", _menuLinkDelay
			);
		
		function _ieHoverFix() {
			this.className = "ieHoverFix";
		}
		function _ieHoverFixOut() {
			this.className = "";
		}
		$elms = cssQuery("#contentNav .subMenu li");
		for (i = 0; i < $elms.length; i++) {
			addEvent($elms[i], "mouseover", _ieHoverFix);
			addEvent($elms[i], "mouseout", _ieHoverFixOut);
		}
		
		// apply png fixes
		if (navigator.userAgent.match(/MSIE (\d\.\d)/)[1] >= 5.5 && document.body.filters) {
			var _fixedImgs=[],
				_imgElm,
				_filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='%1',sizingMethod='scale')",
				_blankSrc = "http://www.scva.net/_"+"scripts/_"+"pngfix.gif";
			for (var i=0; i<document.images.length; i++) {
				_imgElm = document.images[i];
				if (/-trans.png$/.test(_imgElm.src)) {
					_imgElm.realSrc = _imgElm.src;
					_imgElm.runtimeStyle.filter = _filter.replace(/%1/, _imgElm.src);
					_imgElm.src = _blankSrc;
					_fixedImgs.push(_imgElm);
				}
			}
			window.onbeforeprint = function() {
				for (var i = 0; i < _fixedImgs.length; i++) {
					_fixedImgs[i].src = _fixedImgs[i].realSrc;
					_imgElm.runtimeStyle.filter = "";
				}
			};
			window.onafterprint = function() {
				for (var i = 0; i < _fixedImgs.length; i++) {
					_fixedImgs[i].src = _blankSrc;
					_fixedImgs[i].runtimeStyle.filter = _filter.replace(/%1/, _fixedImgs[i].realSrc);
				}
			};
		}
	});
}
@end @*/
