
var gTimer = false;
var gMinH = false;
var gDiv = false;

var swfforceresize = function()
{
	
	return {
		/*
		Public API
		*/
		registerObject: function( swf_id, div_id, minW, minH )
		{
			config = { swf_id:swf_id, div_ref:document.getElementById(div_id), minW:minW, minH:minH };
			swfobject.addDomLoadEvent(initFit);
			//SWFForceSize( objectIdStr, minW, minH );
		}
	};
}();

 
function SWFForceSize( div_ref, minWidth, minHeight )
{
	
 		this.minW = minWidth;
 		this.minH = minHeight;

 		this.div 	= div_ref;
		gDiv = this.div;
		
// 		this.addWindowEvent( 'onload', this, this.onLoadDiv );
// 		this.addWindowEvent( 'onresize', this, this.onResizeDiv );
// 		this.addWindowEvent( 'onscroll', this, this.onScrollWindow );
 		
}


 	
SWFForceSize.prototype = {

	thisMovie: function () {
/*		
    	if (navigator.appName.indexOf("Microsoft") != -1) {
        	return window[ this.so.getAttribute('id') ];
    	}
    	else {
        	return document[ this.so.getAttribute('id') ];
    	}
*/
	},
	
 	addWindowEvent: function( eventName, scope, func )
	{
/*	
 		var oldEvent = window[ eventName ];
		if (typeof window[ eventName ] != 'function') window[ eventName ] = function(){ func.call( scope ); };
		else
		{
			window[ eventName ] = function()
			{ 
				if( oldEvent ) oldEvent();
				func.call( scope );
			}
		}
*/		
	},
	
	getBrowserInfo: function () 
	{
/*		
		var codeName = navigator.appCodeName;
		var appName = navigator.appName;
		var appVers = navigator.appVersion;
		var platform = navigator.platform;
		var userAgent = navigator.userAgent;
		var javaEnabled = navigator.javaEnabled();
		var versionMajor = parseInt(appVersion,10);
		
  		var appVers = navigator.appVersion;
		var pos, versMinor = 0;
		
		if ((pos = appVers.indexOf ("MSIE")) > -1) {
			var versMinor = parseFloat(appVers.substr (pos+5));
		} else {
			var versMinor = parseFloat(appVers);
		}
  
		var userLanguage = "";
		if (navigator.userLanguage == "string") {
			userLanguage = navigator.userLanguage;
    	} else if (navigator.language == "string") {
			userLanguage = navigator.language;
    	}
    	
    	return codeName;
  */
	},
	
	getScrollXY: function () {
		
		var scrOfX = 0, scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		return {x:scrOfX, y:scrOfY };
		
	},

	getWinSize: function()
	{
/*		
		var winH, winW;
		if (parseInt(navigator.appVersion)>3) {
			if ( document.body.offsetWidth ){ // Gecko / WebKit
				winW = document.body.offsetWidth;
				winH = document.body.offsetHeight;
			} else if ( document.body.offsetWidth ){ // MS
				winW = document.body.offsetWidth;
				winH = document.body.offsetHeight;
			}
		}
		return { height: winH, width: winW };
*/
	},
	
	onLoadDiv: function()
	{
/*		
		this.div.style.width = "100%";
		this.div.style.height = "100%";
		this.onResizeDiv();
*/
	},

	onScrollWindow: function() 
	{
/*		
		var scrollOffset = this.getScrollXY();
		
		if (this.targetDoc[ this.so.getAttribute('id') ].externalScrollEvent) {
			this.targetDoc[ this.so.getAttribute('id') ].externalScrollEvent( scrollOffset.x, scrollOffset.y );
		} else if (this.thisMovie().externalScrollEvent) {
			this.thisMovie().externalScrollEvent( scrollOffset.x, scrollOffset.y );
		}
*/		
	},

	onResizeDiv: function()
	{

/*
		var winSize = this.getWinSize();
		var w = winSize.width < this.minW? this.minW+"px" : "100%";
		var h = winSize.height < this.minH? this.minH+"px" : "100%";
		var scrollOffset = this.getScrollXY();
		document.title = ( w + "  " + h + " // " + this.div );

		
		if( document.all ) document.body.scroll = ( w!="100%" || h!="100%" )? "auto" : "no";
		this.div.style.width = w;
		this.div.style.height = h;
		
		if (this.targetDoc[ this.so.getAttribute('id') ].externalResizeEvent) {
			this.targetDoc[ this.so.getAttribute('id') ].externalResizeEvent( winSize.width, winSize.height, (winSize.height < this.minH) ? 1 : 0, scrollOffset.x, scrollOffset.y );
		} else if (this.thisMovie().externalResizeEvent) {
			this.thisMovie().externalResizeEvent( winSize.width, winSize.height, (winSize.height < this.minH) ? 1 : 0, scrollOffset.x, scrollOffset.y );
		}
		this.onScrollWindow();
		window.scrollTo (scrollOffset.x, scrollOffset.y);
		
*/

	},
	
	resize: function( w, h )
	{
		h = Math.round(h);

		$( this.div ).css({'height': h + 'px'});
		
		if (gTimer) clearTimeout( gTimer );
		
		gTimer = setTimeout( function () {
			$( 'object#so' ).attr({'height': gMinH + 'px'});	
		}, 2000 );		
		
		//$( window ).scrollTop( 0 );
		gMinH = h;
		this.minW = w;
 		this.minH = h;
 		//this.onResizeDiv();
	},
	
	setScrollTop: function ( y ) {
		
		/*
		var scrollOffset = this.getScrollXY();
		window.scrollTo ( scrollOffset.x, y );
		*/
	}
}
