window.onload = function() {
    setMainImageSize();
}

window.onresize = function() {
    setMainImageSize();
}

var type = "";
if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";
if (document.all) type="IE";
if (document.layers) type="NN";
if (!document.all && document.getElementById) type="MO";

function setMainImageSize() {
	var myWidth = 0, 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;
	}
	
	var new_image_width = (myWidth - 50);
	var new_image_height = (myHeight - 50);

/*
	if(new_image_height > (myHeight-0)) { 
			new_image_height = (myHeight-0);
			new_image_width = new_image_height * (640/302);
			left = ((myWidth / 2) - (new_image_width / 2));
			right = ((myWidth / 2) - (new_image_width / 2));
	}
	*/
	var background = document.getElementById('background');
	
	if(new_image_height > new_image_width) {
        background.style.height = new_image_height + "px";
        background.style.width = new_image_height + "px";
        
        var left = (new_image_width - new_image_height) / 2;
        background.style.left = left + "px";
        background.style.top = "0px";
        
	} else {
	   background.style.height = new_image_width + "px";
        background.style.width = new_image_width + "px";
        
        var top = (new_image_height - new_image_width) / 2;
        background.style.top = top + "px";
        background.style.left = "0px";
	}
	
	var container = document.getElementById('container');
	
	container.style.height = (myHeight-50) + "px";
    container.style.width = (myWidth-50) + "px";

	// text placement
	
	var contra = document.getElementById('cont_img');
	var vw = document.getElementById('vw_img');
	var tracklisting = document.getElementById('tl_img');
	
	var contra_height = contra.offsetHeight;
	var vw_height = vw.offsetHeight;
	var vw_width = vw.offsetWidth;
	var tracklisting_height = tracklisting.offsetHeight;
	
	if( (myHeight-200-100) < (434.4+50+50)) {
		
		var target_height = myHeight - 200 - 0 - contra_height;
		
		var current_height = vw_height + 50 + tracklisting_height;
		
		var new_text_width = (vw_width / current_height) * target_height;
		
		vw.style.width = new_text_width + "px";
		tracklisting.style.width = new_text_width + "px";
		
		
		
	} else {
		vw.style.width = "100%";
		tracklisting.style.width = "100%";
	}
	
	// get again as we may have changed them
	var tracklisting_height = tracklisting.offsetHeight;
	var vw_height = vw.offsetHeight;
	
	var logo_gap = (myHeight - (tracklisting_height+25+25) - (contra_height+25+25) - vw_height) / 2;
	
	var vw_container = document.getElementById('vw');
	vw_container.style.top = (contra_height) + logo_gap + "px";
	
}

function fieldFocus(element, text)
{
	if(text == element.value) {
		element.value = "";
	}
}
function fieldBlur(element, text)
{
	if("" == element.value) {
		element.value = text;
	}
}

var player = null; 
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
}

