/**************************************************
Ribbit Sizer
By Matt Dunnerstick - http://ribbitflightschool.com
v 2.1 - 12-13-2010
**************************************************/
var minwidth=1024;
var minheight=764;
var thediv = "#theflash";

function getScrollBarWidth () {  
	var inner = document.createElement('p');  
	inner.style.width = "100%";  
	inner.style.height = "200px";  

	var outer = document.createElement('div');  
	outer.style.position = "absolute";  
	outer.style.top = "0px";  
	outer.style.left = "0px";  
  	outer.style.visibility = "hidden";  
	outer.style.width = "200px";  
	outer.style.height = "150px";  
  	outer.style.overflow = "hidden";  
	outer.appendChild (inner);  

	document.body.appendChild (outer);  
	var w1 = inner.offsetWidth;  
  	outer.style.overflow = 'scroll';  
	var w2 = inner.offsetWidth;  
	if (w1 == w2) w2 = outer.clientWidth;  

	document.body.removeChild (outer);  
	return (w1 - w2);  
}
function setSize() {
	var myWidth = 0;
	var myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	//alert(myHeight+":"+myWidth);
	
	//adjust scroll
	var scrollwidth = getScrollBarWidth();
	myWidth = myWidth - scrollwidth;
	
	if (myHeight<minheight) myHeight=minheight;
	if (myWidth<minwidth) myWidth=minwidth;
	
	if (myHeight>minheight) myHeight = "100%";
	if (myWidth>minwidth) myWidth = "100%";
	
	$(thediv).height( myHeight);
	$(thediv).width( myWidth);
	// $("#debug").html("<p>"+myHeight+":"+myWidth+"</p>");
	setTimeout ( "setSize()", 250 );
}
function ribbitSizer(divid,w,h,fillscreen) { 
	minwidth=w;
	minheight=h;
	thediv = divid;
		
	if (fillscreen==true) { 
		window.moveTo(screen.availLeft, screen.availTop);
		window.resizeTo(screen.availWidth, screen.availHeight);
		setSize();
	}
		
	setTimeout ( "setSize()", 250 );
}
