/* Copyright (c) 2006, Yahoo! Inc. All rights reserved.Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt Version: 0.11.4*/ 
if(typeof YAHOO=="undefined"){
	YAHOO={};
}

YAHOO.namespace=function(ns){
	if(!ns||!ns.length){
		return null;
	}
	
	var _2=ns.split(".");
	var _3=YAHOO;
	for(var i=(_2[0]=="YAHOO")?1:0;i<_2.length;++i){
		_3[_2[i]]=_3[_2[i]]||{};
		_3=_3[_2[i]];
	}
	return _3;
};

YAHOO.log=function(_5,_6,_7){
	var l=YAHOO.widget.Logger;
	if(l&&l.log){
		return l.log(_5,_6,_7);
	}else{
		return false;
	}
};

YAHOO.extend=function(_9,_10){
	var f=function(){};
	f.prototype=_10.prototype;
	_9.prototype=new f();
	_9.prototype.constructor=_9;
	_9.superclass=_10.prototype;
	if(_10.prototype.constructor==Object.prototype.constructor){
		_10.prototype.constructor=_10;
	}
};

YAHOO.namespace("util");
YAHOO.namespace("widget");
YAHOO.namespace("example");

/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License:http://developer.yahoo.net/yui/license.txt Version: 0.11.4*/ 
YAHOO.util.CustomEvent=function(_1,_2,_3){
	this.type=_1;
	this.scope=_2||window;
	this.silent=_3;
	this.subscribers=[];
	if(!this.silent){
	}
};

YAHOO.util.CustomEvent.prototype={
	subscribe:function(fn,_5,_6){
		this.subscribers.push(new YAHOO.util.Subscriber(fn,_5,_6));
	},unsubscribe:function(fn,_7){
		var _8=false;
		for(var i=0,len=this.subscribers.length;i<len;++i){
			var s=this.subscribers[i];
			if(s&&s.contains(fn,_7)){
				this._delete(i);
				_8=true;
			}
		}
		return _8;
	},fire:function(){
		var len=this.subscribers.length;
		if(!len&&this.silent){
			return;
		}
		var _12=[];
		for(var i=0;i<arguments.length;++i){
			_12.push(arguments[i]);
		}
		if(!this.silent){
		}
		for(i=0;i<len;++i){
			var s=this.subscribers[i];
			if(s){
				if(!this.silent){
				}
				var _13=(s.override)?s.obj:this.scope;
				s.fn.call(_13,this.type,_12,s.obj);
			}
		}
	},unsubscribeAll:function(){
		for(var i=0,len=this.subscribers.length;i<len;++i){
			this._delete(len-1-i);
		}
	},_delete:function(_14){
		var s=this.subscribers[_14];
		if(s){
			delete s.fn;
			delete s.obj;
		}
		this.subscribers.splice(_14,1);
	},toString:function(){
		return "CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;
	}
};

YAHOO.util.Subscriber=function(fn,obj,_16){
	this.fn=fn;
	this.obj=obj||null;
	this.override=(_16);
};

YAHOO.util.Subscriber.prototype.contains=function(fn,obj){
	return (this.fn==fn&&this.obj==obj);
};

YAHOO.util.Subscriber.prototype.toString=function(){
	return "Subscriber { obj: "+(this.obj||"")+", override: "+(this.override||"no")+" }";
};

if(!YAHOO.util.Event){
	YAHOO.util.Event=function(){
		var _17=false;
		var _18=[];
		var _19=[];
		var _20=[];
		var _21=[];
		var _22=[];
		var _23=0;
		var _24=[];
		var _25=[];
		var _26=0;
		return {
			POLL_RETRYS:200,POLL_INTERVAL:50,EL:0,TYPE:1,FN:2,WFN:3,SCOPE:3,ADJ_SCOPE:4,isSafari:(/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),isIE:(!this.isSafari&&!navigator.userAgent.match(/opera/gi)&&navigator.userAgent.match(/msie/gi)),addDelayedListener:function(el,_28,fn,_29,_30){
				_19[_19.length]=[el,_28,fn,_29,_30];
				if(_17){
					_23=this.POLL_RETRYS;
					this.startTimeout(0);
				}
			},startTimeout:function(_31){
				var i=(_31||_31===0)?_31:this.POLL_INTERVAL;
				var _32=this;
				var _33=function(){
					_32._tryPreloadAttach();
				};
				this.timeout=setTimeout(_33,i);
			},onAvailable:function(_34,_35,_36,_37){
				_24.push({id:_34,fn:_35,obj:_36,override:_37});
				_23=this.POLL_RETRYS;
				this.startTimeout(0);
			},addListener:function(el,_38,fn,_39,_40){
				if(!fn||!fn.call){
					return false;
				}
				if(this._isValidCollection(el)){
					var ok=true;
					for(var i=0,len=el.length;i<len;++i){
						ok=(this.on(el[i],_38,fn,_39,_40)&&ok);
					}
					return ok;
				}else{
					if(typeof el=="string"){
						var oEl=this.getEl(el);
						if(_17&&oEl){
							el=oEl;
						}else{
							this.addDelayedListener(el,_38,fn,_39,_40);
							return true;
						}
					}
				}
				if(!el){
					return false;
				}
				if("unload"==_38&&_39!==this){
					_20[_20.length]=[el,_38,fn,_39,_40];
					return true;
				}
				var _43=(_40)?_39:el;
				var _44=function(e){
					return fn.call(_43,YAHOO.util.Event.getEvent(e),_39);
				};
				var li=[el,_38,fn,_44,_43];
				var _47=_18.length;
				_18[_47]=li;
				if(this.useLegacyEvent(el,_38)){
					var _48=this.getLegacyIndex(el,_38);
					if(_48==-1||el!=_21[_48][0]){
						_48=_21.length;
						_25[el.id+_38]=_48;
						_21[_48]=[el,_38,el["on"+_38]];
						_22[_48]=[];
						el["on"+_38]=function(e){
							YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(e),_48);
						};
					}_22[_48].push(li);
				}else{
					if(el.addEventListener){
						el.addEventListener(_38,_44,false);
					}else{
						if(el.attachEvent){
							el.attachEvent("on"+_38,_44);
					}
				}
			}
			return true;
		},fireLegacyEvent:function(e,_49){
			var ok=true;
			var le=_22[_49];
			for(var i=0,len=le.length;i<len;++i){
				var li=le[i];
				if(li&&li[this.WFN]){
					var _51=li[this.ADJ_SCOPE];
					var ret=li[this.WFN].call(_51,e);
					ok=(ok&&ret);
				}
			}
			return ok;
		},getLegacyIndex:function(el,_53){
			var key=this.generateId(el)+_53;
			if(typeof _25[key]=="undefined"){
				return -1;
			}else{
				return _25[key];
			}
		},useLegacyEvent:function(el,_55){
			if(!el.addEventListener&&!el.attachEvent){
				return true;
			}else{
				if(this.isSafari){
					if("click"==_55||"dblclick"==_55){
						return true;
					}
				}
			}
			return false;
		},removeListener:function(el,_56,fn,_57){
			if(!fn||!fn.call){
				return false;
			}
			var i,len;
			if(typeof el=="string"){
				el=this.getEl(el);
			}else{
				if(this._isValidCollection(el)){
					var ok=true;
					for(i=0,len=el.length;i<len;++i){
						ok=(this.removeListener(el[i],_56,fn)&&ok);
					}
					return ok;
				}
			}
			if("unload"==_56){
				for(i=0,len=_20.length;i<len;i++){
					var li=_20[i];
					if(li&&li[0]==el&&li[1]==_56&&li[2]==fn){
						_20.splice(i,1);
						return true;
					}
				}
				return false;
			}
			var _58=null;
			if("undefined"==typeof _57){
				_57=this._getCacheIndex(el,_56,fn);
			}
			if(_57>=0){
				_58=_18[_57];
			}
			if(!el||!_58){
				return false;
			}
			if(this.useLegacyEvent(el,_56)){
				var _59=this.getLegacyIndex(el,_56);
				var _60=_22[_59];
				if(_60){
					for(i=0,len=_60.length;i<len;++i){
						li=_60[i];
						if(li&&li[this.EL]==el&&li[this.TYPE]==_56&&li[this.FN]==fn){
							_60.splice(i,1);
						}
					}
				}
			}else{
				if(el.removeEventListener){
					el.removeEventListener(_56,_58[this.WFN],false);
				}else{
					if(el.detachEvent){
						el.detachEvent("on"+_56,_58[this.WFN]);
					}
				}
			}
			delete _18[_57][this.WFN];
			delete _18[_57][this.FN];
			_18.splice(_57,1);
			return true;
		},getTarget:function(ev,_62){
			var t=ev.target||ev.srcElement;
			return this.resolveTextNode(t);
		},resolveTextNode:function(_64){
			if(_64&&_64.nodeName&&"#TEXT"==_64.nodeName.toUpperCase()){
				return _64.parentNode;
			}else{
				return _64;
			}
		},getPageX:function(ev){
			var x=ev.pageX;
			if(!x&&0!==x){
				x=ev.clientX||0;
				if(this.isIE){
					x+=this._getScrollLeft();
				}
			}
			return x;
		},getPageY:function(ev){
			var y=ev.pageY;
			if(!y&&0!==y){
				y=ev.clientY||0;
				if(this.isIE){
					y+=this._getScrollTop();
				}
			}
			return y;
		},getXY:function(ev){
			return [this.getPageX(ev),this.getPageY(ev)];
		},getRelatedTarget:function(ev){
			var t=ev.relatedTarget;
			if(!t){
				if(ev.type=="mouseout"){
					t=ev.toElement;
				}else{
					if(ev.type=="mouseover"){
						t=ev.fromElement;
					}
				}
			}
			return this.resolveTextNode(t);
		},getTime:function(ev){
			if(!ev.time){
				var t=new Date().getTime();
				try{
					ev.time=t;
				}catch(e){
					return t;
				}
			}
			return ev.time;
		},stopEvent:function(ev){
			this.stopPropagation(ev);
			this.preventDefault(ev);
		},stopPropagation:function(ev){
			if(ev.stopPropagation){
				ev.stopPropagation();
			}else{
				ev.cancelBubble=true;
			}
		},preventDefault:function(ev){
			if(ev.preventDefault){
				ev.preventDefault();
			}else{
				ev.returnValue=false;
			}
		},getEvent:function(e){
			var ev=e||window.event;
			if(!ev){
				var c=this.getEvent.caller;
				while(c){
					ev=c.arguments[0];
					if(ev&&Event==ev.constructor){
						break;
					}
					c=c.caller;
				}
			}
			return ev;
		},getCharCode:function(ev){
			return ev.charCode||((ev.type=="keypress")?ev.keyCode:0);
		},_getCacheIndex:function(el,_68,fn){
			for(var i=0,len=_18.length;i<len;++i){
				var li=_18[i];
				if(li&&li[this.FN]==fn&&li[this.EL]==el&&li[this.TYPE]==_68){
					return i;
				}
			}
			return -1;
		},generateId:function(el){
			var id=el.id;
			if(!id){
				id="yuievtautoid-"+_26;
				++_26;
				el.id=id;
			}
			return id;
		},_isValidCollection:function(o){
			return (o&&o.length&&typeof o!="string"&&!o.tagName&&!o.alert&&typeof o[0]!="undefined");
		},elCache:{
		},getEl:function(id){
			return document.getElementById(id);
		},clearCache:function(){
		},_load:function(e){
			_17=true;
			var EU=YAHOO.util.Event;
			EU._simpleRemove(window,"load",EU._load);
		},_tryPreloadAttach:function(){
			if(this.locked){
				return false;
			}
			this.locked=true;
			var _72=!_17;
			if(!_72){
				_72=(_23>0);
			}
			var _73=[];
			for(var i=0,len=_19.length;i<len;++i){
				var d=_19[i];
				if(d){
					var el=this.getEl(d[this.EL]);
					if(el){
						this.on(el,d[this.TYPE],d[this.FN],d[this.SCOPE],d[this.ADJ_SCOPE]);
						delete _19[i];
					}else{
						_73.push(d);
					}
				}
			}
			_19=_73;
			var _75=[];
			for(i=0,len=_24.length;i<len;++i){
				var _76=_24[i];
				if(_76){
					el=this.getEl(_76.id);
					if(el){
						var _77=(_76.override)?_76.obj:el;
						_76.fn.call(_77,_76.obj);
						delete _24[i];
					}else{
						_75.push(_76);
					}
				}
			}
			_23=(_73.length===0&&_75.length===0)?0:_23-1;
			if(_72){
				this.startTimeout();
			}
			this.locked=false;
			return true;
		},purgeElement:function(el,_78,_79){
			var _80=this.getListeners(el,_79);
			if(_80){
				for(var i=0,len=_80.length;i<len;++i){
					var l=_80[i];
					this.removeListener(el,l.type,l.fn);
				}
			}
			if(_78&&el&&el.childNodes){
				for(i=0,len=el.childNodes.length;i<len;++i){
					this.purgeElement(el.childNodes[i],_78,_79);
				}
			}
		},getListeners:function(el,_82){
			var _83=[];
			if(_18&&_18.length>0){
				for(var i=0,len=_18.length;i<len;++i){
					var l=_18[i];
					if(l&&l[this.EL]===el&&(!_82||_82===l[this.TYPE])){
						_83.push({type:l[this.TYPE],fn:l[this.FN],obj:l[this.SCOPE],adjust:l[this.ADJ_SCOPE],index:i});
					}
				}
			}
			return (_83.length)?_83:null;
		},_unload:function(e){
			var EU=YAHOO.util.Event;
			for(var i=0,len=_20.length;i<len;++i){
				var l=_20[i];
				if(l){
					var _84=(l[EU.ADJ_SCOPE])?l[EU.SCOPE]:window;
					l[EU.FN].call(_84,EU.getEvent(e),l[EU.SCOPE]);
					delete _20[i];
					l=null;
				}
			}
			if(_18&&_18.length>0){
				var j=_18.length;
				while(j){
					var _86=j-1;
					l=_18[_86];
					if(l){
						EU.removeListener(l[EU.EL],l[EU.TYPE],l[EU.FN],_86);
					}
					l=null;
					j=j-1;
				}
				EU.clearCache();
			}
			for(i=0,len=_21.length;i<len;++i){
				delete _21[i][0];
				delete _21[i];
			}
			EU._simpleRemove(window,"unload",EU._unload);
		},_getScrollLeft:function(){
			return this._getScroll()[1];
		},_getScrollTop:function(){
			return this._getScroll()[0];
		},_getScroll:function(){
			var dd=document.documentElement,db=document.body;
			if(dd&&(dd.scrollTop||dd.scrollLeft)){
				return [dd.scrollTop,dd.scrollLeft];
			}else{
				if(db){
					return [db.scrollTop,db.scrollLeft];
				}else{
					return [0,0];
				}
			}
		},_simpleAdd:function(el,_88,fn,_89){
			if(el.addEventListener){
				el.addEventListener(_88,fn,(_89));
			}else{
				if(el.attachEvent){
					el.attachEvent("on"+_88,fn);
				}
			}
		},_simpleRemove:function(el,_90,fn,_91){
			if(el.removeEventListener){
				el.removeEventListener(_90,fn,(_91));
			}else{
				if(el.detachEvent){
					el.detachEvent("on"+_90,fn);
				}
			}
		}
	};
}
	();
	YAHOO.util.Event.on=YAHOO.util.Event.addListener;
	if(document&&document.body){
		YAHOO.util.Event._load();
	}else{
		YAHOO.util.Event._simpleAdd(window,"load",YAHOO.util.Event._load);
	}
	YAHOO.util.Event._simpleAdd(window,"unload",YAHOO.util.Event._unload);
	YAHOO.util.Event._tryPreloadAttach();
}

/* Copyright (c) 2006, Yahoo! Inc. All rights reserved.  Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt Version: 0.11.3 */ YAHOO.util.Dom=function(){var ua=navigator.userAgent.toLowerCase();var isOpera=(ua.indexOf('opera')>-1);var isSafari=(ua.indexOf('safari')>-1);var isIE=(window.ActiveXObject);var id_counter=0;var util=YAHOO.util;var property_cache={};var toCamel=function(property){var convert=function(prop){var test=/(-[a-z])/i.exec(prop);return prop.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());};while(property.indexOf('-')>-1){property=convert(property);}return property;};var toHyphen=function(property){if(property.indexOf('-')>-1){return property;}var converted='';for(var i=0,len=property.length;i<len;++i){if(property.charAt(i)==property.charAt(i).toUpperCase()){converted=converted+'-'+property.charAt(i).toLowerCase();}else{converted=converted+property.charAt(i);}}return converted;};var cacheConvertedProperties=function(property){property_cache[property]={camel:toCamel(property),hyphen:toHyphen(property)};};return{get:function(el){if(!el){return null;}if(typeof el!='string'&&!(el instanceof Array)){return el;}if(typeof el=='string'){return document.getElementById(el);}else{var collection=[];for(var i=0,len=el.length;i<len;++i){collection[collection.length]=util.Dom.get(el[i]);}return collection;}return null;},getStyle:function(el,property){var f=function(el){var value=null;var dv=document.defaultView;if(!property_cache[property]){cacheConvertedProperties(property);}var camel=property_cache[property]['camel'];var hyphen=property_cache[property]['hyphen'];if(property=='opacity'&&el.filters){value=1;try{value=el.filters.item('DXImageTransform.Microsoft.Alpha').opacity/100;}catch(e){try{value=el.filters.item('alpha').opacity/100;}catch(e){}}}else if(el.style[camel]){value=el.style[camel];}else if(isIE&&el.currentStyle&&el.currentStyle[camel]){value=el.currentStyle[camel];}else if(dv&&dv.getComputedStyle){var computed=dv.getComputedStyle(el,'');if(computed&&computed.getPropertyValue(hyphen)){value=computed.getPropertyValue(hyphen);}}return value;};return util.Dom.batch(el,f,util.Dom,true);},setStyle:function(el,property,val){if(!property_cache[property]){cacheConvertedProperties(property);}var camel=property_cache[property]['camel'];var f=function(el){switch(property){case'opacity':if(isIE&&typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}}else{el.style.opacity=val;el.style['-moz-opacity']=val;el.style['-khtml-opacity']=val;}break;default:el.style[camel]=val;}};util.Dom.batch(el,f,util.Dom,true);},getXY:function(el){var f=function(el){if(el.offsetParent===null||this.getStyle(el,'display')=='none'){return false;}var parentNode=null;var pos=[];var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var doc=document;if(!this.inDocument(el)&&parent.document!=document){doc=parent.document;if(!this.isAncestor(doc.documentElement,el)){return false;}}var scrollTop=Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);var scrollLeft=Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);return[box.left+scrollLeft,box.top+scrollTop];}else{pos=[el.offsetLeft,el.offsetTop];parentNode=el.offsetParent;if(parentNode!=el){while(parentNode){pos[0]+=parentNode.offsetLeft;pos[1]+=parentNode.offsetTop;parentNode=parentNode.offsetParent;}}if(isSafari&&this.getStyle(el,'position')=='absolute'){pos[0]-=document.body.offsetLeft;pos[1]-=document.body.offsetTop;}}if(el.parentNode){parentNode=el.parentNode;}else{parentNode=null;}while(parentNode&&parentNode.tagName.toUpperCase()!='BODY'&&parentNode.tagName.toUpperCase()!='HTML'){if(util.Dom.getStyle(parentNode,'display')!='inline'){pos[0]-=parentNode.scrollLeft;pos[1]-=parentNode.scrollTop;}if(parentNode.parentNode){parentNode=parentNode.parentNode;}else{parentNode=null;}}return pos;};return util.Dom.batch(el,f,util.Dom,true);},getX:function(el){var f=function(el){return util.Dom.getXY(el)[0];};return util.Dom.batch(el,f,util.Dom,true);},getY:function(el){var f=function(el){return util.Dom.getXY(el)[1];};return util.Dom.batch(el,f,util.Dom,true);},setXY:function(el,pos,noRetry){var f=function(el){var style_pos=this.getStyle(el,'position');if(style_pos=='static'){this.setStyle(el,'position','relative');style_pos='relative';}var pageXY=this.getXY(el);if(pageXY===false){return false;}var delta=[parseInt(this.getStyle(el,'left'),10),parseInt(this.getStyle(el,'top'),10)];if(isNaN(delta[0])){delta[0]=(style_pos=='relative')?0:el.offsetLeft;}if(isNaN(delta[1])){delta[1]=(style_pos=='relative')?0:el.offsetTop;}if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+'px';}if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+'px';}var newXY=this.getXY(el);if(!noRetry&&(newXY[0]!=pos[0]||newXY[1]!=pos[1])){this.setXY(el,pos,true);}};util.Dom.batch(el,f,util.Dom,true);},setX:function(el,x){util.Dom.setXY(el,[x,null]);},setY:function(el,y){util.Dom.setXY(el,[null,y]);},getRegion:function(el){var f=function(el){var region=new YAHOO.util.Region.getRegion(el);return region;};return util.Dom.batch(el,f,util.Dom,true);},getClientWidth:function(){return util.Dom.getViewportWidth();},getClientHeight:function(){return util.Dom.getViewportHeight();},getElementsByClassName:function(className,tag,root){var method=function(el){return util.Dom.hasClass(el,className)};return util.Dom.getElementsBy(method,tag,root);},hasClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');var f=function(el){return re.test(el['className']);};return util.Dom.batch(el,f,util.Dom,true);},addClass:function(el,className){var f=function(el){if(this.hasClass(el,className)){return;}el['className']=[el['className'],className].join(' ');};util.Dom.batch(el,f,util.Dom,true);},removeClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,className)){return;}var c=el['className'];el['className']=c.replace(re,' ');if(this.hasClass(el,className)){this.removeClass(el,className);}};util.Dom.batch(el,f,util.Dom,true);},replaceClass:function(el,oldClassName,newClassName){if(oldClassName===newClassName){return false;};var re=new RegExp('(?:^|\\s+)'+oldClassName+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,oldClassName)){this.addClass(el,newClassName);return;}el['className']=el['className'].replace(re,' '+newClassName+' ');if(this.hasClass(el,oldClassName)){this.replaceClass(el,oldClassName,newClassName);}};util.Dom.batch(el,f,util.Dom,true);},generateId:function(el,prefix){prefix=prefix||'yui-gen';el=el||{};var f=function(el){if(el){el=util.Dom.get(el);}else{el={};}if(!el.id){el.id=prefix+id_counter++;}return el.id;};return util.Dom.batch(el,f,util.Dom,true);},isAncestor:function(haystack,needle){haystack=util.Dom.get(haystack);if(!haystack||!needle){return false;}var f=function(needle){if(haystack.contains&&!isSafari){return haystack.contains(needle);}else if(haystack.compareDocumentPosition){return!!(haystack.compareDocumentPosition(needle)&16);}else{var parent=needle.parentNode;while(parent){if(parent==haystack){return true;}else if(!parent.tagName||parent.tagName.toUpperCase()=='HTML'){return false;}parent=parent.parentNode;}return false;}};return util.Dom.batch(needle,f,util.Dom,true);},inDocument:function(el){var f=function(el){return this.isAncestor(document.documentElement,el);};return util.Dom.batch(el,f,util.Dom,true);},getElementsBy:function(method,tag,root){tag=tag||'*';root=util.Dom.get(root)||document;var nodes=[];var elements=root.getElementsByTagName(tag);if(!elements.length&&(tag=='*'&&root.all)){elements=root.all;}for(var i=0,len=elements.length;i<len;++i){if(method(elements[i])){nodes[nodes.length]=elements[i];}}return nodes;},batch:function(el,method,o,override){var id=el;el=util.Dom.get(el);var scope=(override)?o:window;if(!el||el.tagName||!el.length){if(!el){return false;}return method.call(scope,el,o);}var collection=[];for(var i=0,len=el.length;i<len;++i){if(!el[i]){id=id[i];}collection[collection.length]=method.call(scope,el[i],o);}return collection;},getDocumentHeight:function(){var scrollHeight=-1,windowHeight=-1,bodyHeight=-1;var marginTop=parseInt(util.Dom.getStyle(document.body,'marginTop'),10);var marginBottom=parseInt(util.Dom.getStyle(document.body,'marginBottom'),10);var mode=document.compatMode;if((mode||isIE)&&!isOpera){switch(mode){case'CSS1Compat':scrollHeight=((window.innerHeight&&window.scrollMaxY)?window.innerHeight+window.scrollMaxY:-1);windowHeight=[document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a,b){return(a-b);})[1];bodyHeight=document.body.offsetHeight+marginTop+marginBottom;break;default:scrollHeight=document.body.scrollHeight;bodyHeight=document.body.clientHeight;}}else{scrollHeight=document.documentElement.scrollHeight;windowHeight=self.innerHeight;bodyHeight=document.documentElement.clientHeight;}var h=[scrollHeight,windowHeight,bodyHeight].sort(function(a,b){return(a-b);});return h[2];},getDocumentWidth:function(){var docWidth=-1,bodyWidth=-1,winWidth=-1;var marginRight=parseInt(util.Dom.getStyle(document.body,'marginRight'),10);var marginLeft=parseInt(util.Dom.getStyle(document.body,'marginLeft'),10);var mode=document.compatMode;if(mode||isIE){switch(mode){case'CSS1Compat':docWidth=document.documentElement.clientWidth;bodyWidth=document.body.offsetWidth+marginLeft+marginRight;break;default:bodyWidth=document.body.clientWidth;docWidth=document.body.scrollWidth;break;}}else{docWidth=document.documentElement.clientWidth;bodyWidth=document.body.offsetWidth+marginLeft+marginRight;}var w=Math.max(docWidth,bodyWidth);return w;},getViewportHeight:function(){var height=-1;var mode=document.compatMode;if((mode||isIE)&&!isOpera){switch(mode){case'CSS1Compat':height=document.documentElement.clientHeight;break;default:height=document.body.clientHeight;}}else{height=self.innerHeight;}return height;},getViewportWidth:function(){var width=-1;var mode=document.compatMode;if(mode||isIE){switch(mode){case'CSS1Compat':width=document.documentElement.clientWidth;break;default:width=document.body.clientWidth;}}else{width=self.innerWidth;}return width;}};}();YAHOO.util.Region=function(t,r,b,l){this.top=t;this[1]=t;this.right=r;this.bottom=b;this.left=l;this[0]=l;};YAHOO.util.Region.prototype.contains=function(region){return(region.left>=this.left&&region.right<=this.right&&region.top>=this.top&&region.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];}this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region();

var oImageCaptions = {
   init: function() {
      // get all image elements with class "credit"
      var aImages = YAHOO.util.Dom.getElementsByClassName('credit', 'img');

      // loop through them
      for (var i = 0, j = aImages.length; i < j; i++) {
         // make sure they have caption text set
         if (aImages[i].title != '') {
            // save some stuff for later use
            var oParent = aImages[i].parentNode;
			var oSubParent = aImages[i];
			// if the parent is a link, IE doesn't get it, so we have to keep the a tag with the img
			if( oParent.tagName == "A" ) {
				oSubParent = oParent;
				oParent = oSubParent.parentNode;
			}
            var sTitle = aImages[i].title;
			var sClasses = aImages[i].className;
            
            // clear title and className properties
            aImages[i].title = '';
            aImages[i].className = '';
            
            // create new parent container for image
            var oContainer = document.createElement('div');

			// assign classes from img tag
			oContainer.className = sClasses;
            
            // constrain the width and height of DIV to image dimensions
            oContainer.style.width = aImages[i].getAttribute('width') + 'px';
            oContainer.style.height = aImages[i].getAttribute('height') + 'px';
            
            // swap existing image
//            oParent.replaceChild(oContainer, aImages[i]);
            oParent.replaceChild(oContainer, oSubParent);
//            oContainer.appendChild(aImages[i]);
            oContainer.appendChild(oSubParent);

			// create credit
			var oCaptionContainer = document.createElement('div');
            var oCaption = document.createElement('p');
            oCaption.appendChild(document.createTextNode(sTitle));
			oCaptionContainer.appendChild(oCaption);

			// append strapline to parent container
            oContainer.appendChild(oCaptionContainer);

            oCaptionContainer.style.width = aImages[i].getAttribute('width') + 'px';

			var iImageWidth = aImages[i].getAttribute('width');
			oCaptionContainer.style.width = iImageWidth + 'px';
			if (oCaptionContainer.offsetWidth > iImageWidth) {
				oCaptionContainer.style.width = iImageWidth - (oCaptionContainer.offsetWidth - iImageWidth) + 'px';
			} 
         }
      }
   }
}

YAHOO.util.Event.addListener(window, 'load', oImageCaptions.init);

