/* 
Methods for resizing the flash stage at runtime.

setFlashWidth(divid, newW)
divid: id of the div containing the flash movie.
newW: new width for flash movie

setFlashWidth(divid, newH)
divid: id of the div containing the flash movie.
newH: new height for flash movie

setFlashSize(divid, newW, newH)
divid: id of the div containing the flash movie.
newW: new width for flash movie
newH: new height for flash movie

canResizeFlash()
returns true if browser supports resizing flash, false if not. 
*/
function setFlashWidth(divid, newW){
	document.getElementById(divid).style.width = newW;
}
function setFlashHeight(divid, newH){
	//alert("newH:"+newH)
	document.getElementById(divid).style.height = newH+"px";		
	
	/*if( document.all ){
		if ( (document.body.scroll = ( w!=”100%” || h!=”100%” )? “auto” : “no”) == “auto”){
			document.body.style.overflow = “auto”;
		}
	}*/
	
	
}
function updateFlashSize(divid){
	
	//alert("updateFlashSize -- size height "+(getWinHeight()+"px"))
	setFlashHeight(divid, getWinHeight()+"px");
}

function setFlashSize(divid, newW, newH){
	setFlashWidth(divid, newW);
	setFlashHeight(divid, newH);
}
function canResizeFlash(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}

function getWinHeight(){
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight+5;
}


function getWinWidth(){
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}
function getWinSize(){
	var winH, winW;
	winW = this.getWinWidth();
	winH = this.getWinHeight();
	return { height: winH, width: winW };
}


/////////////////////////////////////////////////////////////////////
// this function repositions the scroll bar to the top of the page.
// call it from flash by using getURL('javascript:resetToTop()');
/////////////////////////////////////////////////////////////////////
function resetToTop()
{
	$('html, body').animate({scrollTop: '0px'}, 800);
}

function buyModal()
{
	$.modal("<iframe src =\"buy_widget.html\" width=\"300\" height=\"250\" marginwidth=\"0px\" marginheight=\"0px\" scrolling=\"NO\" frameborder=\"0\"><p>Your browser does not support iframes.</p></iframe>");
}