/**
*	swffit v1.0 (03/25/2008) <http://swffit.millermedeiros.com/>
*	Copyright (c) 2008 Miller Medeiros <http://www.millermedeiros.com/>
*	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*
* 	swffit is used to resize flash to 100% wid/hei when the browser window is greater than the swf
*	minimum size and to resize swf to the minimum size when browser window is smaller than the minimum size.
*
*/
<!-- //2008 - MILLERMEDEIROS.COM
	var NS = (navigator.appName=='Netscape')?true:false;
	var ft;
	var mw;
	var mh;
	var xw;
	var xh;
	var xc;
	// set the main vars and start the process
	function swffit(t,w,h,_w,_h,c){
		if (t && w && h) {
			ft = t;
			mw = w;
			mh = h;
			xw = _w;
			xh = _h;
			xc = (c || c == null)?true:false;
			if(swfobject.isDomLoaded){
				startFit();
			}else{
				swfobject.addDomLoadEvent(startFit);
			}
		}
	}
	// return an element
	function gEBI(x){
		return x;
	}
	// set the initial parameters
	function startFit(){
		document.getElementsByTagName('html')[0].style.height = '100%';
		document.body.style.margin = '0';
		document.body.style.padding = '0';
		document.body.style.height = '100%';
		if(swfobject.getObjectById(ft)){
			ft = swfobject.getObjectById(ft);
		}else{
			ft = (NS)?document.getElementById(ft).getElementsByTagName('object')[0]:document.getElementById(ft);
		}
		gEBI(ft).style.position = 'absolute';
		window.onresize = fit;
		fit();
	}
	// reposition and resizes
	function fit(){
		iw = (NS)?window.innerWidth:document.body.clientWidth; 
		ih = (NS)?window.innerHeight:document.body.clientHeight;
		ratio=iw/ih;
		//sets width
		if (iw > xw && xw){
			gEBI(ft).style.width = xw+'px';
			if(xc){
				gEBI(ft).style.left = '50%';
				gEBI(ft).style.marginLeft = -(xw/2)+'px';
			}
		} else {
			if (iw > mw && (iw < xw || !xw)) {
				if (ih > mh && (ih < xh || !xh) && iw>=ih*ratio){
					gEBI(ft).style.width =ih*ratio+'px';
				}
				else{

					gEBI(ft).style.width ='100%';
				}
			} else {
				gEBI(ft).style.width = mw+'px';
			}
			if(xc){
				if (iw > mw && (iw < xw || !xw) && ih > mh && (ih < xh || !xh) && iw>ih*ratio) {
					gEBI(ft).style.left = 'auto';
					gEBI(ft).style.marginLeft = (iw-ih*ratio)/2+'px';

				}
				else{
					gEBI(ft).style.left = 'auto';
					gEBI(ft).style.marginLeft = '0';
				}
			}

		}
		// sets height
		if (ih > xh && xh){
			gEBI(ft).style.height = xh+'px';
			if(xc){
				gEBI(ft).style.top = '50%';
				gEBI(ft).style.marginTop = -(xh/2)+'px';;
			}
		}else{
			if (ih > mh && (ih < xh || !xh)){
				if (iw > mw && (iw < xw || !xw) && ih>iw/ratio){
					gEBI(ft).style.height = iw/ratio+'px';
				}
				else{
					gEBI(ft).style.height = '100%'
				}
			} else {
				gEBI(ft).style.height = mh+'px';
			}
			if(xc){
				if (ih > mh && (ih < xh || !xh) && iw > mw && (iw < xw || !xw) && ih>iw/ratio) {
					gEBI(ft).style.top = 'auto';
					gEBI(ft).style.marginTop = (ih-iw/ratio)/2+'px';

				}
				else{
					gEBI(ft).style.top = 'auto';
					gEBI(ft).style.marginTop = '0';
				}
			}
		}
	};
//-->
