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 - 100);
	//var new_image_height = (myHeight - 100);
	
	var newWidth = (myWidth-50);
	var newHeight = (myHeight-50);
	
	var new_image_width = newWidth;
    var new_image_height = new_image_width*(1196/1596);

     var background = document.getElementById('background');
    
    if(new_image_height < newHeight) { 
        new_image_height = newHeight;
        new_image_width = new_image_height*(1596/1196);
    	background.style.top = "0px";
        
    } else {
    	var top = (newHeight - new_image_height) / 2;
        background.style.top = top + "px";
        background.style.left = "0px";
    }
    
   
    background.style.height = new_image_height + "px";
	background.style.width = new_image_width + "px";
	
	var container = document.getElementById('container');
	
	container.style.height = (myHeight-50) + "px";
    container.style.width = (myWidth-50) + "px";	
    
    // vertically center
    
    var content = document.getElementById('content');
    
    var content_offset = ((myHeight-50)-506) / 2;
    
    if(content_offset < 10) {
    	content_offset = 10;
    }
    
    content.style.marginTop = content_offset  + "px";
    
    
    var release_date = document.getElementById('release_date');
    
    var date_offset = (content_offset / 2) + 14;
    
    release_date.style.bottom = "-" + date_offset  + "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];
}

function checkForm()
{
    emailaddress = document.getElementById('email_input');
    if("your@email.com" == emailaddress.value) {
        alert("Please enter a valid email address");
        return false;
    } else {
        document.subscribeform.submit();
    }
}

function toggleComments() {
	
	var packshot = document.getElementById('comments');
	var comments_toggle = document.getElementById('comments_toggle');
	
	if((packshot.getAttribute('class') == 'hide') || (packshot.getAttribute('className') == 'hide')) {
		packshot.setAttribute('class', '');
		packshot.setAttribute('className', '');
		
		comments_toggle.setAttribute('class', '');
		comments_toggle.setAttribute('className', '');
		comments_toggle.innerHTML = 'Show Comments';
	} else {
		packshot.setAttribute('class', 'hide');
		packshot.setAttribute('className', 'hide');
		
		comments_toggle.setAttribute('class', 'hide');
		comments_toggle.setAttribute('className', 'hide');
		comments_toggle.innerHTML = 'Hide Comments';
	}
	
}

var comments_once = false;

function showComments() {
	
	if(!comments_once) {
		/*
		var packshot = document.getElementById('comments');
		var comments_toggle = document.getElementById('comments_toggle');
		
		packshot.setAttribute('class', 'hide');
		packshot.setAttribute('className', 'hide');
		
		comments_toggle.setAttribute('class', 'hide');
		comments_toggle.setAttribute('className', 'hide');
		comments_toggle.innerHTML = 'Hide Comments';
		*/
		
		var comments_toggle = document.getElementById('comments_toggle');
		comments_toggle.setAttribute('class', 'hint');
		comments_toggle.setAttribute('className', 'hint');
	}
	comments_once = true;
}
