// JavaScript Document


function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
}


function newBkgColor(hex, whichColor){
	thisMovie("myFlash").newBkgColor("0x" + hex);
	thisMovie("myFlash2").newBkgColor(whichColor);
	document.body.style.backgroundColor = 	"#" + hex;
	var sidebarBkg = 	document.getElementById('sidebar_bg');
	sidebarBkg.style.backgroundColor = 		"#" + hex;
}


/*
If window is larger than html content -> 	Flash width/height = 100%
If window is smaller than content -> 		Flash width/height = min width/height
*/

window.onresize = function(){
	resizeFlash();
}

function resizeFlash(){
	//Content size
	if (document.getElementById) {
		var contentElement = document.getElementById('container');
		minWidth = 		contentElement.offsetWidth;
		minHeight = 	contentElement.offsetHeight;
		marginTopBottom = 	44;
	}
	
	//Window size
	var winWidth = 0, winHeight = 0;
	if(typeof(window.innerWidth) == 'number'){
		//Non-IE
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;
	}else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)){
		//IE 6+ in 'standards compliant mode'
		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;
	}else if( document.body && (document.body.clientWidth || document.body.clientHeight)){
		//IE 4 compatible
		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;
	}

	//Flash size
	if(winWidth >= minWidth){
		flashWidth = 	"100%";
	}else{
		flashWidth = minWidth;
	}
	
	if(winHeight >= minHeight){
		flashHeight = 	"100%";
	}else{
		flashHeight = minHeight + marginTopBottom;
	}

	//Set new flash size
	thisMovie('myFlash').width =	flashWidth;
	thisMovie('myFlash').height =	flashHeight;
}