/*
 * FullScreenBG 1.0 
 * for MooTools 1.1
 *
 * Copyright (c) 2008 Ryan Quigley (exhibit-E.com)
 * Licensed under the MIT (MIT-LICENSE.txt)
 *
 */
var FullScreenBG={
	bg:null,
	img_src:"",
	ratio:1.615,
	mode:"",
	init:function(A,md){FullScreenBG.img_src=A;
		FullScreenBG.mode=md;
		window.addEvent("domready",function(){
			FullScreenBG.createBackground()})},	
   createBackground:function(){
				if(FullScreenBG.bg===null){
					FullScreenBG.bg=new Element("img",{id:"FullScreenBGImg",styles:{position:"fixed",overflow:"hidden",zIndex:0,visibility:"hidden"},src:this.img_src,events:{load:function(){var A=parseInt(FullScreenBG.bg.getStyle("width"),10);
					var B=parseInt(FullScreenBG.bg.getStyle("height"),10);
					FullScreenBG.ratio=A/B;
					window.addEvent("resize",FullScreenBG.scale);
					FullScreenBG.scale();
					new Fx.Tween(FullScreenBG.bg).start("opacity",0,1)}}});
					FullScreenBG.bg.injectInside($("content"));
					if(window.ie6){FullScreenBG.bg.setStyles({position:"absolute",top:window.getScrollTop()});
					window.addEvent("scroll",function(){FullScreenBG.bg.setStyle("top",window.getScrollTop())})}}},
	changeBG:function(A){if(A===FullScreenBG.bg.getProperty("src")){return }FullScreenBG.bg.setOpacity(0);FullScreenBG.bg.setProperty("src",A)},
	scale:function(){
		var A,C,B,E,D;
		A=window.getWidth();
		C=window.getHeight();
		D=FullScreenBG.ratio;
		if(A/C>D){
			B=A;
			E=Math.round(A/D)
			}else{
				B=Math.round(C*D);
				E=C}	
				if (FullScreenBG.mode=='bottom'){	
					FullScreenBG.bg.setStyles({width:B,height:E,marginLeft:0,marginTop:Math.round(C-E)})
	   		} else if (FullScreenBG.mode=='home'){
					FullScreenBG.bg.setStyles({width:B,height:E,marginLeft:Math.round(A/2-B/2),marginTop:Math.round(C/2-E/2)})
				} 	else {
					FullScreenBG.bg.setStyles({width:B,height:E,marginLeft:0,marginTop:0})
				}
			}
		};
