/**
*	swffit v2.3.1 (08/05/2009) <http://swffit.millermedeiros.com/>
*	Copyright (c) 2009 Miller Medeiros <http://www.millermedeiros.com/>
*	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swffit=function(){
		
	var win=window,doc=document,html=doc.getElementsByTagName("html")[0],AGENT=navigator.userAgent.toLowerCase(),WK=/webkit/.test(AGENT),IE=/msie/.test(AGENT)&&!win.opera,FF=/firefox/.test(AGENT)&&!win.opera,UNDEF="undefined",_ft,_re,_t,_mw,_mh,_xw,_xh,_hc,_vc,_ow,_oh;
	//swfobject.createCSS("object","position:absolute");
	function fit(t,mw,mh,xw,xh,hc,vc){
		var mw=(mw)?mw:_ow,mh=(mh)?mh:_oh,xw=(xw)?xw:null,xh=(xh)?xh:null,hc=false,vc=false;
		configure({target:t,minWid:mw,minHei:mh,maxWid:xw,maxHei:xh,hCenter:hc,vCenter:vc});
	}
	function configure(o){
		var evalNum=function(v,p){
			return(typeof o[p]!=UNDEF)?o[p]:v;
		};
		_mw=evalNum(_mw,"minWid");
		_mh=evalNum(_mh,"minHei");
		_xw=evalNum(_xw,"maxWid");
		_xh=evalNum(_xh,"maxHei");
		var evalBool=function(v,p){
			return(o[p]||(v&&typeof o[p]==UNDEF));
		};
		_hc=false;
		_vc=false;
		
		if(o.target&&(o.target!=_t)){
			_t=o.target;
			swfobject.addDomLoadEvent(initFit);
		if(IE){
			swfobject.addLoadEvent(initFit);
		}}else{
			startFit();
		}
	}
	function initFit(){
		if(!html.style.overflowX){
			controlScroll(0,0);
		}
		if(!html.style.overflowY){
			controlScroll(0,1);
		}
		html.style.height=doc.body.style.height="100%";
		doc.body.style.margin=doc.body.style.padding=0;
		var st="width:100%;height:100%";
		st+=(IE)?";overflow:hidden":"";
		swfobject.createCSS("#"+_t,st);
		_ft=doc.getElementById(_t);
		_ft=(_ft!=UNDEF&&FF&&/object/.test(_ft.innerHTML))?doc.getElementById(_t).getElementsByTagName("object")[0]:_ft;
		_ow=_ft.width;
		_oh=_ft.height;
		_mw=(_mw)?_mw:_ow;
		_mh=(_mh)?_mh:_oh;
		startFit();
	}
	function startFit(){
		setSize();
		if(!_re){
			swffit.addResizeEvent(setSize);
		_re=1;
		}
	}
	function stopFit(w,h){
		if(_re){
			swffit.removeResizeEvent(setSize);
			_re=0;
			setStyle("top","auto");
			setStyle("left","auto");
			setStyle("marginTop",0);
			setStyle("marginLeft",0);
			var w=(w)?w:"100%",h=(h)?h:"100%";
			setWidth(w);
			setHeight(h);
			forceRedraw();
		}
	}
	function forceRedraw(){
		if(WK){
			html.focus();
		}
	}
	function controlResizeEvent(a,fn){
		var p=(a)?["addEventListener","attachEvent"]:["removeEventListener","detachEvent"];
		if(win[p[0]]){
			win[p[0]]("resize",fn,false);
		}else{
			if(win[p[1]]){
			win[p[1]]("onresize",fn);
			}
		}
	}
	function setWidth(w){
		var v=(isNaN(w))?w:w+"px";
		setStyle("width",v);
	}
	function setHeight(h){
		var v=(isNaN(h))?h:h+"px";
	setStyle("height",v);
	}
	function setStyle(p,v){
		_ft.style[p]=v;
	}
	function setSize(){
		var iw=(win.innerWidth)?win.innerWidth:doc.body.clientWidth,ih=(win.innerHeight)?win.innerHeight:doc.body.clientHeight;
		iw-=(!IE&&ih<=_mh)?18:0;
		ih-=(!IE&&iw<=_mw)?18:0;
		if(_xw&&iw>=_xw){
			setWidth(_xw);
			setPosition(0,1);
		}else{
			if(iw>_mw&&(iw<_xw||!_xw)){
				setWidth("100%");
			}else{
				setWidth(_mw);
			}
			setPosition(0,0);
		}
		if(_xh&&ih>=_xh){
			setHeight(_xh);
		setPosition(1,1);
		}else{
			if(ih>_mh&&(ih<_xh||!_xh)){
				setHeight("100%");
			}else{
				setHeight(_mh);
			}
			setPosition(1,0);
		}
		forceRedraw();
	}
	function setPosition(t,x){
		
		var p,m;
		if(t){
			p=(x&&_vc)?"50%":"auto";
			m=(x&&_vc)?-(_xh*0.5)+"px":0;
			setStyle("top",p);
			setStyle("marginTop",m);
		}else{
			p=(x&&_hc)?"50%":"auto";
		m=(x&&_hc)?-(_xw*0.5)+"px":0;
		setStyle("left",p);
		setStyle("marginLeft",m);
		}
	}
	function controlScroll(s,v){
		var p=(v)?"overflowY":"overflowX";
		html.style[p]=(s)?"scroll":"auto";
	}
	function getValueOf(p){
		var o={target:_t,minWid:_mw,minHei:_mh,maxWid:_xw,maxHei:_xh,hCenter:false,vCenter:false};
		return o[p];
	}
	
	return{fit:fit,configure:configure,startFit:startFit,stopFit:stopFit,getValueOf:getValueOf,addResizeEvent:function(fn){controlResizeEvent(1,fn);},removeResizeEvent:function(fn){controlResizeEvent(0,fn);},showScrollH:function(){controlScroll(1,0);},showScrollV:function(){controlScroll(1,1);}};
}();
	