//animation
function ygAnim(_1,_2,_3){if(_1){this.init(_1,_2,_3);}}ygAnim.prototype={oDomRef:null,iTotalFrames:0,iCurrentFrame:0,animate:function(){ygAnimMgr.registerElement(this);},stop:function(){ygAnimMgr.stop(this);},isAnimated:function(){return this._isAnimated;},setFrameBased:function(_4){if(_4===false){this._isFrameBased=false;this.iTotalFrames=ygAnimMgr.fps*this._units;}else{this._isFrameBased=true;this.iTotalFrames=this._units;}if(this.aTween){this.cacheTween();}},handleOptions:function(){},createTween:function(){},cacheTween:function(){},doTween:function(){},onStart:function(){},onTween:function(){},onComplete:function(){},init:function(el,_6,_7){if(el){this.oDomRef=el;}if(_6){this._units=_6;}if(_7){this.handleOptions(_7);}if(_6===null){this.iTotalFrames=null;}else{this.iTotalFrames=ygAnimMgr.fps*_6;}},getStyle:function(_8){var dv=document.defaultView;if(this.oDomRef.style[_8]){return this.oDomRef.style[_8];}else{if(this.oDomRef.currentStyle){if(_8.indexOf("-")!=-1){_8=_8.split("-");for(var i=1;i<_8.length;++i){_8[i]=_8[i].toUpperCase().charAt(0)+_8[i].substr(1);}_8=_8.join("");}if(this.oDomRef.currentStyle[_8]){return this.oDomRef.currentStyle[_8];}}else{if(dv&&dv.getComputedStyle&&dv.getComputedStyle(this.oDomRef,"").getPropertyValue(_8)){return dv.getComputedStyle&&dv.getComputedStyle(this.oDomRef,"").getPropertyValue(_8);}}}},_isAnimated:false,_isFrameBased:false};ygAnimMgr=new function(){this.fps=200;this.iDelay=1;var _11=null;var _12=[];var _13=0;var _14=this;this.registerElement=function(o){if(o._isAnimated){return false;}_12[_12.length]=o;_13+=1;o._isAnimated=true;o.onStart();o._startTime=new Date();this.start();};this.start=function(){if(_11===null){_11=setInterval(this.run,this.iDelay);}};this.stop=function(o){if(!o){clearInterval(_11);for(var i=0,len=_12.length;i<len;++i){_12[i]._isAnimated=false;}_12=[];_11=null;_13=0;}else{o._isAnimated=false;o.iCurrentFrame=0;o.onComplete();_13-=1;if(_13<=0){_14.stop();}}};this.run=function(){for(var i=_12.length-1;i>=0;--i){var o=_12[i];if(!o||!o._isAnimated){continue;}if(o.iCurrentFrame<o.iTotalFrames||o.iTotalFrames===null){var _16=(new Date()-o._startTime);var _17=(o.iCurrentFrame*o._units*1000/o.iTotalFrames);var _18=0;if(_16<o._units*1000){_18=Math.round((_16/_17-1)*o.iCurrentFrame);}else{_18=o.iTotalFrames-(o.iCurrentFrame+1);}if(_18>0&&isFinite(_18)){if(o.iCurrentFrame+_18>=o.iTotalFrames){_18=o.iTotalFrames-(o.iCurrentFrame+1);}o.iCurrentFrame+=_18;if(o._t){o._t+=_18*(1/(o.iTotalFrames-1));}}o.doTween();o.onTween();o.iCurrentFrame+=1;}else{ygAnimMgr.stop(o);}}};};ygBezier=new function(){this.getPosition=function(_19,t){var _21=[];var n=_19.length;for(var i=0;i<n;++i){_21[i]=[_19[i][0],_19[i][1]];}for(var j=1;j<n;++j){for(i=0;i<n-j;++i){_21[i][0]=(1-t)*_21[i][0]+t*_21[parseInt(i+1)][0];_21[i][1]=(1-t)*_21[i][1]+t*_21[parseInt(i+1)][1];}}return{x:_21[0][0],y:_21[0][1]};};};ygAnim_Move.prototype=new ygAnim();function ygAnim_Move(el,_24,_25){if(el){this.init(el,_24,_25);}}ygAnim_Move.prototype.doTween=function(){var p={};if(!this.oDomRef){ygAnimMgr.stop(this);return false;}if(!this.aTween||!this.aTween[this.iCurrentFrame]){if(this.iCurrentFrame===0){this._t=0;}p=this._getPoint(this._t);this._t+=1/(this.iTotalFrames-1);}else{p=this.aTween[this.iCurrentFrame];}this.oDomRef.style.left=p.x+"px";this.oDomRef.style.top=p.y+"px";};ygAnim_Move.prototype.createTween=function(_27){var t=0;var _28=[];if(_27){for(var i=0;i<this.iTotalFrames;++i){_28[i]={};var p=this._getPoint(t);_28[i].x=p.x;_28[i].y=p.y;t+=1/(this.iTotalFrames-1);}}return _28;};ygAnim_Move.prototype.cacheTween=function(){this.aTween=this.createTween(this._points,this.iTotalFrames);};ygAnim_Move.prototype.handleOptions=function(_29){this.setPoints(_29);};ygAnim_Move.prototype.setPoints=function(_30){if(_30.length==2){if(typeof _30[0]=="number"){_30=[_30];}}var _31=this._getPos();_30.unshift(_31);this._points=_30;if(this.aTween){this.cacheTween();}};ygAnim_Move.prototype.setStart=function(_32){this._points[0]=_32;if(this.aTween){this.cacheTween();}};ygAnim_Move.prototype._getPoint=function(t){var _33={};var _34=null;if(this.getStyle("position")!="relative"&&this.oDomRef.offsetWidth){_34=this.oDomRef.offsetParent;}var _35={x:0,y:0};while(_34&&_34.tagName!="HTML"&&_34.tagName!="BODY"){_35.x+=_34.offsetLeft;_35.y+=_34.offsetTop;_34=_34.offsetParent;}var pos=ygBezier.getPosition(this._points,t);_33.x=Math.round(pos.x)-_35.x;_33.y=Math.round(pos.y)-_35.y;return _33;};ygAnim_Move.prototype._getPos=function(){var pos=[0,0];if(this.getStyle("position")&&this.getStyle("position")=="relative"){if(this.getStyle("left").indexOf("px")!=-1){pos[0]=parseInt(this.getStyle("left"));}else{pos[0]=0;}if(this.getStyle("top").indexOf("px")!=-1){pos[1]=parseInt(this.getStyle("top"));}else{pos[1]=0;}}else{if(typeof ygPos!="undefined"){pos=ygPos.getPos(this.oDomRef);}else{if(this.oDomRef.offsetWidth){pos=[this.oDomRef.offsetLeft,this.oDomRef.offsetTop];var _37=this.oDomRef.offsetParent;if(_37!=this.oDomRef){while(_37){pos[0]+=_37.offsetLeft;pos[1]+=_37.offsetTop;_37=_37.offsetParent;}}}}}return pos;};ygAnim_Size.prototype=new ygAnim();function ygAnim_Size(el,_38,_39){if(el){this.init(el,_38,_39);}}ygAnim_Size.prototype.doTween=function(){var p={};if(!this.oDomRef){ygAnimMgr.stop(this);return false;}if(!this.aTween||!this.aTween[this.iCurrentFrame]){if(this.iCurrentFrame===0){this._t=0;}p=ygBezier.getPosition(this._sizes,this._t);this._t+=1/(this.iTotalFrames-1);}else{p=this.aTween[this.iCurrentFrame];}this.oDomRef.style.width=Math.round(p.x)+"px";this.oDomRef.style.height=Math.round(p.y)+"px";};ygAnim_Size.prototype.createTween=function(_40){var t=0;var _41=[];if(_40){for(var i=0;i<this.iTotalFrames;++i){_41[i]=ygBezier.getPosition(_40,t);t+=1/(this.iTotalFrames-1);}}return _41;};ygAnim_Size.prototype.cacheTween=function(){this.aTween=this.createTween(this._sizes,this.iTotalFrames);};ygAnim_Size.prototype.handleOptions=function(_42){this.setSizes(_42);};ygAnim_Size.prototype.setSizes=function(_43){if(_43.length==2){if(typeof _43[0]=="number"){_43=[_43];}}var _44=this._getSize();_43.unshift(_44);this._sizes=_43;if(this.aTween){this.cacheTween();}};ygAnim_Size.prototype.setStart=function(_45){this._sizes[0]=_45;if(this.aTween){this.cacheTween();}};ygAnim_Size.prototype._getSize=function(){var _46=[0,0];if(this.getStyle("width")&&this.getStyle("width").indexOf("px")!=-1){_46[0]=parseInt(this.getStyle("width"));}else{if(this.oDomRef.offsetWidth){_46[0]=this.oDomRef.offsetWidth;}}if(this.getStyle("height")&&this.getStyle("height").indexOf("px")!=-1){_46[1]=parseInt(this.getStyle("height"));}else{if(this.oDomRef.offsetHeight){_46[1]=this.oDomRef.offsetHeight;}}return _46;};ygAnim_Fade.prototype=new ygAnim();function ygAnim_Fade(el,_47,_48){if(el){if(_48===0){_48=0.01;}this.init(el,_47,_48);this.iTotalFrames=50*_47;}}ygAnim_Fade.prototype.doTween=function(){var p={};if(!this.oDomRef){ygAnimMgr.stop(this);return false;}if(!this.aTween||!this.aTween[this.iCurrentFrame]){if(this.iCurrentFrame===0){this._t=0;}p=ygBezier.getPosition(this._opac,this._t);this._t+=1/(this.iTotalFrames-1);}else{p=this.aTween[this.iCurrentFrame];}p.x=Math.round(p.x*100)/100;this.oDomRef.style.filter="alpha(opacity="+p.x*100+")";this.oDomRef.style.opacity=p.x;this.oDomRef.style["-moz-opacity"]=p.x;this.oDomRef.style["-khtml-opacity"]=p.x;};ygAnim_Fade.prototype.createTween=function(_49){var t=0;var _50=[];for(var i=0;i<this.iTotalFrames;++i){_50[i]=ygBezier.getPosition(this._opac,t);t+=1/(this.iTotalFrames-1);}return _50;};ygAnim_Fade.prototype.cacheTween=function(){this.aTween=this.createTween(this._opac,this.iTotalFrames);};ygAnim_Fade.prototype.handleOptions=function(_51){this.setOpac(_51);};ygAnim_Fade.prototype.setOpac=function(_52){if(typeof _52=="number"){_52=[[_52,1]];}else{for(var i=0;i<_52.length;++i){_52[i]=[_52[i],1];}}var _53=[this._getOpac(),1];_52.unshift(_53);this._opac=_52;if(this.aTween){this.cacheTween();}};ygAnim_Fade.prototype.setStart=function(_54){if(_54==="0"){_54=0.01;}else{if(_54=="1"){_54=0.99;this.oDomRef.style.opacity=_54;}}this._opac[0]=[_54,1];if(this.aTween){this.cacheTween();}};ygAnim_Fade.prototype._getOpac=function(){var _55;if(this.getStyle("opacity")){_55=this.getStyle("opacity");}else{if(this.getStyle("-moz-opacity")){_55=this.getStyle("-moz-opacity");}else{_55=0.99;}}if(_55=="0"){_55=0.01;}else{if(_55=="1"){_55=0.99;this.oDomRef.style.opacity=_55;}}return _55;};ygAnim_Scroll.prototype=new ygAnim();function ygAnim_Scroll(el,_56,_57){if(el){this.init(el,_56,_57);}}ygAnim_Scroll.prototype.doTween=function(){var p={};if(!this.oDomRef){ygAnimMgr.stop(this);return false;}if(!this.aTween||!this.aTween[this.iCurrentFrame]){if(this.iCurrentFrame===0){this._t=0;}p=ygBezier.getPosition(this._points,this._t);this._t+=1/(this.iTotalFrames-1);}else{p=this.aTween[this.iCurrentFrame];}this.oDomRef.scrollLeft=p.x;this.oDomRef.scrollTop=p.y;};ygAnim_Scroll.prototype.createTween=function(_58){var t=0;var _59=[];if(_58){for(var i=0;i<this.iTotalFrames;++i){_59[i]={};var p=this._getPoint(t);_59[i].x=p.x;_59[i].y=p.y;t+=1/(this.iTotalFrames-1);}}return _59;};ygAnim_Scroll.prototype.cacheTween=function(){this.aTween=this.createTween(this._points,this.iTotalFrames);};ygAnim_Scroll.prototype.handleOptions=function(_60){this.setPoints(_60);};ygAnim_Scroll.prototype.setPoints=function(_61){if(_61.length==2){if(typeof _61[0]=="number"){_61=[_61];}}var _62=[this.oDomRef.scrollLeft,this.oDomRef.scrollTop];_61.unshift(_62);this._points=_61;if(this.aTween){this.cacheTween();}};ygAnim_Scroll.prototype.setStart=function(_63){this._points[0]=_63;if(this.aTween){this.cacheTween();}};


//connect
function ygConnect(){}
ygConnect.prototype={_msxml_progid:['MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'],_async_response:{},_http_header:[],_isFormPost:false,_sFormData:null,getConnObject:function(objectId,transactionId)
{var obj,http;try
{http=new XMLHttpRequest();obj={conn:http,oId:objectId,tId:transactionId};}
catch(e)
{for(var i=0;i<this._msxml_progid.length;++i){try
{http=new ActiveXObject(this._msxml_progid[i]);obj={conn:http,oId:objectId,tId:transactionId};}
catch(e){}}}
finally
{if(http!=undefined||obj!=undefined){var connObj=arguments.length>0?obj:http;return connObj;}
else{return null;}}},setProgId:function(id)
{this.msxml_progid.unshift(id);},syncRequest:function(o,sMethod,sUri,bXml,oPostData)
{if(!o){return;}
o.conn.open(sMethod,sUri,false);if(this._http_header.length>0)
this.setHeader(o.conn);if(this._isFormPost){oPostData=this._sFormData;this._isFormPost=false;}
oPostData?o.conn.send(oPostData):o.conn.send(null);try
{if(o.conn.status==200){response=(bXml?o.conn.responseXML:o.conn.responseText);}
else{response=this.connectException(o);}}
catch(e)
{response=this.connectException(e,o.tId);}
finally
{ygConnect.superclass.releaseObject(o);return response;}},asyncRequest:function(o,sMethod,sUri,bXml,oCallback,oCallbackArgs,oPostData)
{if(!o){var queueObject={method:sMethod,uri:sUri,isXml:bXml,callback:oCallback,argument:oCallbackArgs,data:oPostData}
ygConnect.superclass.queueRequest(queueObject);}
else{var self=this;o.conn.open(sMethod,sUri,true);if(oCallback){o.conn.onreadystatechange=function()
{if(o.conn.readyState==4){try
{if(o.conn.status==200){oCallback(o.conn,o.tId,oCallbackArgs);}
else{var errorObj=self.connectException(o);oCallback(errorObj,oCallbackArgs);}}
catch(e)
{var errorObj=self.connectException(e,o.tId);oCallback(errorObj,oCallbackArgs);}
finally
{ygConnect.superclass.releaseObject(o);}}}}
else{o.conn.onreadystatechange=function(){self.stateChange(o,bXml)}}
if(this._http_header.length>0){this.setHeader(o);}
if(this._isFormPost){oPostData=this._sFormData;this._isFormPost=false;}
oPostData?o.conn.send(oPostData):o.conn.send(null);}},stateChange:function(o,bXml)
{var oResponse;switch(o.conn.readyState){case 4:try
{if(o.conn.status==200){oResponse={tId:o.tId,status:o.conn.status,message:(bXml?o.conn.responseXML:o.conn.responseText)}}
else
oResponse=this.connectException(o);}
catch(e)
{oResponse=this.connectException(e,o.tId);}
finally
{this.setResponse(oResponse);ygConnect.superclass.releaseObject(o);}
break;}},setResponse:function(o)
{this._async_response[o.tId]=o;},getResponse:function(tId)
{var oResponse=this._async_response[tId];if(oResponse){delete this._async_response[tId];return oResponse;}},initHeader:function(label,value)
{var oHeader=[label,value];this._http_header.push(oHeader);},setHeader:function(o)
{var oHeader=this._http_header;for(var i=0;i<oHeader.length;i++)
o.conn.setRequestHeader(oHeader[i][0],oHeader[i][1]);oHeader.splice(0,oHeader.length);},getHeader:function(o,label)
{return o.conn.getResponseHeader(label);},getAllHeaders:function(o)
{return o.conn.getAllResponseHeaders();},setForm:function(formName)
{this._sFormData='';var prevElName;var oForm=document.forms[formName];for(var i=0;i<oForm.elements.length;i++){oElement=oForm.elements[i];elName=oForm.elements[i].name;elValue=oForm.elements[i].value;switch(oElement.type)
{case'select-multiple':for(var j=0;j<oElement.options.length;j++){if(oElement.options[j].selected)
this._sFormData+=elName+'='+encodeURIComponent(oElement.options[j].value)+'&';}
break;case'radio':if(oElement.checked)
this._sFormData+=elName+'='+encodeURIComponent(elValue)+'&';break;case'checkbox':if(oElement.checked){if(elName==prevElName){if(this._sFormData.lastIndexOf('&')==sFormData.length-1)
this._sFormData=this._sFormData.substr(0,this._sFormData.length-1);this._sFormData+=','+encodeURIComponent(elValue);}
else
this._sFormData+=elName+'='+encodeURIComponent(elValue)+'&';prevElName=elName;}
break;case'file':break;default:this._sFormData+=elName+'='+encodeURIComponent(elValue)+'&';break;}}
this._sFormData=this._sFormData.substr(0,this._sFormData.length-1);this._isFormPost=true;this.initHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');},abort:function(o)
{if(this.isCallInProgress(o)){o.conn.abort();ygConnect.superclass.releaseObject(o);}},isCallInProgress:function(o)
{if(o)
return o.conn.readyState!=4&&o.conn.readyState!=0;},connectException:function(o,transactionId)
{if(o.conn){return{tId:o.tId,status:o.conn.status,message:o.conn.statusText}}
else{return{tId:transactionId,status:o.name,message:o.message}}}}
var ygConnManager=function(){}
ygConnManager.prototype={_object_count:0,_available_pool:[],_request_queue:[],_enable_pool:true,_max_pool_size:2,_transaction_id:0,http:new ygConnect()}
var ygConn=ygConnManager.prototype;ygConnect.superclass=ygConnManager.prototype;ygConnManager.prototype.setPoolSize=function(i)
{this._max_pool_size=2;}
ygConnManager.prototype.disablePooling=function()
{this._enable_pool=false;}
ygConnManager.prototype.enablePooling=function()
{this._enable_pool=true;}
ygConnManager.prototype.getTransactionId=function()
{return this._transaction_id;}
ygConnManager.prototype.incrObjCount=function()
{this._object_count++;}
ygConnManager.prototype.incrTransactionId=function()
{this._transaction_id++;}
ygConnManager.prototype.getObject=function()
{var o;var oId;var tId=this.getTransactionId();try
{if(window.XMLHttpRequest){oId=this._object_count;o=this.http.getConnObject(oId,tId);if(o){this.incrTransactionId();}
return o;}
else if(window.ActiveXObject){return this.getActiveXObject();}}
catch(e)
{return this.getActiveXObject();}}
ygConnManager.prototype.getActiveXObject=function()
{var o;var oId;var tId=this.getTransactionId();if(this._object_count<this._max_pool_size&&this._available_pool.length==0){oId=this._object_count;o=this.http.getConnObject(oId,tId);if(o){this.incrObjCount();this.incrTransactionId();}}
else if(this._available_pool.length>0){o=this.getAvailableObject();if(o){o.tId=tId;this.incrTransactionId();}}
return o;}
ygConnManager.prototype.getAvailableObject=function()
{return this._available_pool.shift();}
ygConnManager.prototype.releaseObject=function(o)
{try
{if(window.XMLHttpRequest){o=null;}
else{o.conn.onreadystatechange=this.detachStateListener;o.conn.abort();this._available_pool.push(o);}}
catch(e)
{o.conn.onreadystatechange=this.detachStateListener;o.conn.abort();this._available_pool.push(o);}
finally
{this.checkRequestQueue();}}
ygConnManager.prototype.checkRequestQueue=function()
{if(this._request_queue.length>0){var o=this.getObject();var q=this._request_queue.shift();this.http.asyncRequest(o,q.method,q.uri,q.isXml,q.callback,q.argument,q.data);}}
ygConnManager.prototype.queueRequest=function(o)
{this._request_queue.push(o);}
ygConnManager.prototype.detachStateListener=function(){}


//common
function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else 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] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}
	
var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();
addEvent(window,'unload',EventCache.flush);

/* window 'load' attachment */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/* grab Elements from the DOM by className */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/* toggle an element's display */
function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

/* insert an element after a particular node */
function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

/* Array prototype, matches value in array: returns bool */
Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

/* get, set, and delete cookies */
function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
	
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+"="+escape( value ) +
		( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}
	
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

/* quick getElement reference */
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

/* Element Object for quick manipulation */
Object.extend = function(destination, source) {
	for (property in source) {
		destination[property] = source[property];
	}
	return destination;
}
if (!window.Element) {
	var Element = new Object();
}
Object.extend(Element, {
	visible: function(element) {
		return $(element).style.display != 'none';
	},
	toggle: function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			Element[Element.visible(element) ? 'hide' : 'show'](element);
		}
	},
	hide: function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			element.style.display = 'none';
		}
	},
	show: function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			element.style.display = '';
		}
	},
	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},
	getHeight: function(element) {
		element = $(element);
		return element.offsetHeight;
	},
	classNames: function(element) {
		return new Element.ClassNames(element);
	},
	hasClassName: function(element, className) {
		if (!(element = $(element))) return;
		return Element.classNames(element).include(className);
	},
	addClassName: function(element, className) {
		if (!(element = $(element))) return;
		return Element.classNames(element).add(className);
	},
	removeClassName: function(element, className) {
		if (!(element = $(element))) return;
		return Element.classNames(element).remove(className);
	},
	cleanWhitespace: function(element) {
		element = $(element);
		for (var i = 0; i < element.childNodes.length; i++) {
			var node = element.childNodes[i];
			if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
				Element.remove(node);
		}
	}
});
	/* glossary.js */
var glossTitles = {
	// glossTerm
	xCord : null,
	yCord : null,
	terms : Object,
	defBox : Object,
	isOpen : false,
	curItem : Object,
	ajax : null,
	contentFile : "/includes/glossary.php",
	init : function() {
		if ( !document.getElementById ||
			!document.createElement ||
			!document.getElementsByTagName ) {
			return;
		}
		addEvent(document,'mousemove',this.updateXY);
		if ( document.captureEvents ) {
			document.captureEvents(Event.MOUSEMOVE);
		}
		var el = document.createElement('div');
		document.body.appendChild(el);
		el.style.position = 'absolute';
		var i;
		this.terms = getElementsByClass('glossTerm',null,'a');
		var termsLen = this.terms.length;
		this.createDefBox();
		addEvent(document,'click',this.closeDef);
		addEvent($('closeDef'),'click',this.closeDef);
		for ( i=0; i<termsLen; i++ ) {
			addEvent(this.terms[i],'click',this.toggleDef);
		}
	},
	createDefBox : function() {
		this.defBox = document.createElement('div');
			var dl = document.createElement('dl');
				var dt = document.createElement('dt');
					var span = document.createElement('span');
				var dd = document.createElement('dd');
		document.getElementsByTagName('body')[0].appendChild(this.defBox);
		this.defBox.appendChild(dl);
		dl.appendChild(dt);
		dl.appendChild(dd);
		this.defBox.id = 'glossDef';
		this.defBox.style.display = 'none';
			dt.id = 'glossTitle';
				dt.innerHTML = '<strong id="defTerm"></strong><span><a href="#close" id="closeDef" title="Close This Information">Close</a></span>';
			dd.id = 'glossInfo';
		addEvent(this.defBox,'click',this.preventBubble);
	},
	preventBubble : function(e) {
		if ( window.event ) {
			window.event.cancelBubble = true;
		} else if( e.stopPropagation ) {
			e.stopPropagation();
		}
	},
	updateXY : function(e) {
		if ( document.captureEvents ) {
			glossTitles.xCord = e.pageX;
			glossTitles.yCord = e.pageY;
		} else if ( window.event.clientX ) {
			glossTitles.xCord = event.clientX+document.body.scrollLeft;
			glossTitles.yCord = event.clientY+document.body.scrollTop;
		}
	},
	toggleDef : function(e) {
		if ( this === glossTitles.curItem ) {
			if ( glossTitles.isOpen == true ) {
				glossTitles.closeDef();
			} else {
				glossTitles.openDef(this);
			}
		} else {
			glossTitles.openDef(this);
		}
		glossTitles.curItem = this;
		if ( window.event ) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		} else if( e.stopPropagation ) {
			e.stopPropagation();
			e.preventDefault();
		}
		return false;
	},
	openDef : function(obj) {
		var requester = obj.href.split('#')[1];
		var params = '?ajax=true&requester='+requester;
		this.ajax = ygConn.getObject();
		ygConn.http.asyncRequest(this.ajax,'GET',this.contentFile+params,false,null);
		this.updateStatus(1);
	},
	closeDef : function() {
		Element.hide(glossTitles.defBox);
		glossTitles.isOpen = false;
	},
	displayDef : function() {
		var lt = glossTitles.xCord;
		var tp = glossTitles.yCord;
		glossTitles.defBox.style.opacity = '0';
		glossTitles.defBox.style.filter = "alpha(opacity=0)";
		glossTitles.defBox.style.display = 'block';
		if ( parseInt(document.body.clientWidth+document.body.scrollLeft) < parseInt(glossTitles.defBox.offsetWidth+lt) ) {
			glossTitles.defBox.style.left = parseInt(lt-(glossTitles.defBox.offsetWidth))+'px';
		} else {
			glossTitles.defBox.style.left = lt+'px';
		}
		if ( parseInt(document.body.clientHeight+document.body.scrollTop) < parseInt(glossTitles.defBox.offsetHeight+tp) ) {
			glossTitles.defBox.style.top = parseInt(tp-(glossTitles.defBox.offsetHeight))+'px';
		} else {
			glossTitles.defBox.style.top = tp+'px';
		}
		glossTitles.defBox.style.opacity = '0';
		glossTitles.defBox.style.filter = "alpha(opacity=0)";
		Element.show(glossTitles.defBox);
		glossTitles.isOpen = true;
		var a = [ 0, 0.99 ];
		var oAnim = new ygAnim_Fade(glossTitles.defBox, 0.3, a);
		oAnim.setStart(0);
		oAnim.animate();
	},
	updateStatus : function(called) {
		if ( ygConn.http.isCallInProgress(this.ajax) ) {
			if ( called > 50 ) {
				this.cnxError();
			}
			else {
				called++;
				window.setTimeout("glossTitles.updateStatus("+called+")",50);
			}
		}
		else {
			this.handleResponse();
		}
	},
	handleResponse : function() {
		var response = ygConn.http.getResponse(this.ajax.tId).message;
		if ( response == '' ) {
			this.cnxError();
			this.closeDef();
			return;
		}
		var res = response.split('||');
		var term = res[0];
		var definition = res[1];
		$('defTerm').innerHTML = term;
		$('glossInfo').innerHTML = definition;
		this.displayDef();
	},
	cnxError : function() {
		alert('Sorry, we could not look up the help information you were looking for.\nPlease try back in a few minutes');
	}
};
function glossListen() {
	glossTitles.init();
}
addEvent(window,'load',glossListen);