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;
	var new_image_height = new_image_width * (480/640);
	var new_image_height = myHeight;
	var left = 0;
	var right = 0;
/*
	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 videoplayer = document.getElementById('videoplayer');
	
	videoplayer.style.height = new_image_height + "px";
	videoplayer.style.width = new_image_width + "px";
	//videoplayer.style.top = (((myHeight) / 2) - (new_image_height / 2 )) + "px";
	//videoplayer.style.left = left + "px";
	/*
	var countdown = document.getElementById('countdown');
	countdown.style.left = (left+20) + "px";
	
	var continuelink = document.getElementById('continue');
	continuelink.style.right = (right) + "px";
	
	var days = document.getElementById('days');
	days.style.right = (right) + "px";*/
}

function toggleMore() {
	var container = document.getElementById('container');
	var morelink = document.getElementById('morelink');
	
	if(container.style.marginTop != '-440px') {
		container.style.marginTop = '-440px';
		morelink.innerHTML = 'Less';
		
	} else {
		container.style.marginTop = '0px';
		morelink.innerHTML = 'More';
	}
}

function toggleDownload() {
	var download = document.getElementById('download');
	
	if(download.style.marginTop != '-150px') {
		download.style.marginTop = '-150px';
		
	} else {
		download.style.marginTop = '-2000px';
	}
	
	var morelink = document.getElementById('morelink');
	if(morelink.innerHTML == 'Less') {
		toggleMore();
	}
}

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

function muteTracker(obj) {
	alert('the new mute state is: '+obj.state);
}

function timeTracker(obj) {
	//alert('the new TIME state is: '+obj.position);
	var time = obj.position;

	var trackname = document.getElementById('trackname');
	
	if(trackname.getAttribute('class') == 'singletrack') {
		return;
	}
	
	if(time < 53) {
		// track 1
		trackname.innerHTML = "&#8216;A.M.&#8217;";
		//alert(obj.position);
	} else if(time < 125) {
		// track 2
		trackname.innerHTML = "&#8216;I&#8217;m New Here&#8217;";
	} else if(time < 203) {
		// track 3
		trackname.innerHTML = "&#8216;Me And The Devil&#8217;";
	} else {
		trackname.innerHTML = "&#8216;I&#8217;ll Take Care Of You&#8217;";
	}
	
};

var player = null; 
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
	player.addModelListener("TIME","timeTracker");
}