if(typeof (PG)==="undefined"){
	PG={};
}
PG.Detector={
	getAgent:function(){
		return navigator.userAgent.toLowerCase();
	}
	,isMac:function(M){
		var U=M||this.getAgent();
		return !!U.match(/mac/i);
	}
	,isWin:function(M){
		var U=M||this.getAgent();
		return !!U.match(/win/i);
	}
	,isWin2k:function(M){
		var U=M||this.getAgent();
		return this.isWin(U)&&(U.match(/nt\s*5/i));
	}
	,isWinVista:function(M){
		var U=M||this.getAgent();
		return this.isWin(U)&&(U.match(/nt\s*6/i));
	}
	,isOpera:function(M){
		var U=M||this.getAgent();
		return !!U.match(/opera/i);
	}
	,isIE:function(M){
		var U=M||this.getAgent();
		return !!U.match(/msie/i);
	}
	,isIEStrict:function(M){
		var U=M||this.getAgent();
		return U.match(/msie/i)&&!this.isOpera(U);
	}
	,isFirefox:function(M){
		var U=M||this.getAgent();
		return !!U.match(/firefox/i);
	}
	,isFirefox3:function(M){
		var U=M||this.getAgent();
		return !!U.match(/firefox/i);
	}
	,isSafari31:function(M){
		var U=M||this.getAgent();
		return U.match(/3.1 safari/i)||U.match(/3.1.1 safari/i)||U.match(/3.1.2 safari/i)||U.match(/3.2 safari/i)||U.match(/3.2.1 safari/i)||U.match(/3.2.2 safari/i)||U.match(/3.2.3 safari/i)||U.match(/4.0 safari/i)||U.match(/4.0.2 safari/i)||U.match(/4.0.3 safari/i)||U.match(/4.0.4 safari/i)||U.match(/4.0.5 safari/i)||U.match(/5.0 safari/i)||U.match(/5.0.1 safari/i)||U.match(/5.0.2 safari/i)||U.match(/5.0.3 safari/i)||U.match(/5.0.4 safari/i)||U.match(/5.0.5 safari/i)||U.match(/5.0.6 safari/i)||U.match(/5.1 safari/i)||U.match(/5.1.1 safari/i)||U.match(/5.1.2 safari/i)||U.match(/5.2 safari/i)||U.match(/5.3 safari/i);
	}
};


//  

if(typeof (PG)=="undefined"){PG={}}
PG.Central=Class.create();
Object.extend(PG.Central.prototype,Event.Listener);
Object.extend(PG.Central.prototype,{
	drawers:null,
	container:null,
	triggerTimeout:null,
	initialize:function(A){
		this.drawers=[];
		this.container=$(A)},addDrawer:function(A){},getDrawerCount:function(){
			return this.drawers.length
		}
		,hasDrawers:function(){
			return(this.drawers.length>0)
		}
		,getFirstDrawer:function(){
			return this.drawers[0]||null
		}
		,getLastDrawer:function(){
			return this.drawers[this.drawers.length-1]||null
		}
		,scheduleTrigger:function(B,A){
			this.triggerTimeout=setTimeout(B,A)
		}
		,clearTrigger:function(){
			clearTimeout(this.triggerTimeout)
		}
	}
);

PG.Drawer=Class.create();
Object.extend(PG.Drawer.prototype,Event.Publisher);
Object.extend(PG.Drawer.prototype,{
	bureau:null,
	contentElement:null,
	handle:null,
	indicator:null,
	isOpen:true,
	beforeOpen:null,
	afterOpen:null,
	beforeClose:null,
	afterClose:null,
	transitionDuration:0.3,
	triggerDelay:0,
	initialize:function(F,D,B,C){
		this.contentElement=$(F);
		this.handle=$(D);
		this.bureau=B;
		var E="click";
		if(C!==null&&typeof (C)!="undefined"){
			this.beforeOpen=C.beforeOpen;
			this.afterOpen=C.afterOpen;
			this.beforeClose=C.beforeClose;
			this.afterClose=C.afterClose;
			if(typeof (C.triggerEvent)!="undefined"){
				E=C.triggerEvent
			}
			if(typeof (C.triggerDelay)!="undefined"){
				this.triggerDelay=C.triggerDelay
			}if(typeof (C.transitionDuration)!="undefined"){
				this.transitionDuration=C.transitionDuration
			}
		}
		Element.addClassName(this.contentElement,"last");
		var A=function(G){
			Event.stop(G);
			if(this.triggerDelay>0){
				var H=this.trigger.bind(this);
				B.scheduleTrigger(H,this.triggerDelay)
			}
			else{
				this.trigger()
			}
		};
		Event.observe(this.handle,E,A.bind(this),false);
		Event.observe(this.handle,"mouseout",B.clearTrigger.bind(B),false)
	}
	,toggle:function(){},open:function(){},close:function(){}
}
);

PG.accel=Class.create();
Object.extend(Object.extend(PG.accel.prototype,PG.Central.prototype),{
	drawerDuration:0.5,
	addDrawer:function(B){
		if(this.hasDrawers()){
			var A=this.getLastDrawer();
			A.setNextDrawer(B);
			B.setPreviousDrawer(A);
			B.closedOffset=A.closedOffset+A.getHandleHeight()+3;
		}
		else {
			Element.addClassName(B.contentElement,"first");
			B.closedOffset=0-B.getHeight()+B.getHandleHeight()+3;
			B.indicateVisible()}this.drawers.push(B);
		}
		,getWidth:function(){
			return Element.getWidth(this.container);
		}
		,getHeight:function(){
			return Element.getHeight(this.container);
		}
		,moveDrawer:function(C,A,D){
			var B=new Effect.Move(C,{x:A,y:D,mode:"absolute",transition:Effect.Transitions.sinoidal,duration:this.drawerDuration})
		}
	}
);

PG.bannerDrawer=Class.create();
Object.extend(Object.extend(PG.bannerDrawer.prototype,PG.Drawer.prototype),{
	openedOffset:0,
	closedOffset:0,
	previousDrawer:null,
	nextDrawer:null,
	isVisible:false,
	trigger:function(){
		if(!this.isVisible){
			this.open(true);
			this.indicateVisible();
		}
	},
	toggle:function(){
		if(!this.isOpen){
			this.open();
			this.indicateVisible();
		}else{
			this.close();
		}
	},
	open:function(A){
		if(this.isOpen&&!A){
			return;
		}
		if(this.previousDrawer!==null){
			this.previousDrawer.close();
			this.previousDrawer.indicateObscured();
		}
		if(this.nextDrawer!==null){
			this.nextDrawer.open();
			this.nextDrawer.indicateObscured()
		}
		this.indicateVisible();
		this.isOpen=true;
		this.bureau.moveDrawer(this.contentElement,0,this.openedOffset);
	},
	close:function(A){
		if(!this.isOpen){
			return;
		}
		if(this==this.bureau.getLastDrawer()){
			return;
		}
		if(this.previousDrawer!==null){
			this.previousDrawer.close();
		}
		this.bureau.moveDrawer(this.contentElement,0,this.closedOffset);
		this.indicateObscured();
		this.isOpen=false;
	},
	setPreviousDrawer:function(A){
		this.previousDrawer=A;
		this.indicateObscured();
		this.openedOffset=this.previousDrawer.openedOffset+this.previousDrawer.getHandleHeight()+0;
		Element.setStyle(this.contentElement,{top:this.openedOffset+"px"})},setNextDrawer:function(A){this.nextDrawer=A;Element.removeClassName(this.contentElement,"last");
		if(this.previousDrawer!==null){
			this.previousDrawer.setNextDrawer(this);
		}
		zIndex=parseInt(Element.getStyle(this.contentElement,"zIndex"),0);
		Element.setStyle(this.contentElement,{"zIndex":zIndex+1})},indicateObscured:function(){Element.addClassName(this.contentElement,"obscured");
		this.isVisible=false;
	}
	,indicateVisible:function(){
		this.isVisible=true;
		Element.removeClassName(this.contentElement,"obscured");
	},
	getHandleWidth:function(){
		return Element.getWidth(this.handle);
	},
	getHandleHeight:function(){
		return Element.getHeight(this.handle);
	},
	getWidth:function(){
		return Element.getWidth(this.contentElement);
	},
	getHeight:function(){
		return Element.getHeight(this.contentElement);
	}
});
