if (window.addEventListener)
{
	window.addEventListener("load",
		function()
 		{
			setTimeout(hideAddressbar, 0);
			
			setupPlatform();

			var type = "trailer";

			if (document.location.hash)
			{
				var hash = document.location.hash.substr(1, document.location.hash.length - 1);

				if (hash == "trailer")
				{
					type = "trailer"
				}
				else if (hash == "teaser")
				{
					type = "teaser";
				}
				else if (hash == "trailer12")
				{
					type = "trailer12";
				}
			}	
			
			if (type == "trailer")
			{
				var element = document.getElementById("videoSwitcherTrailer");
				element.className = "selected";			
			}		
			else if (type == "teaser")
			{
				var element = document.getElementById("videoSwitcherTeaser");
				element.className = "selected";				
			}
			else if (type == "trailer12")
			{
				var element = document.getElementById("videoSwitcherTrailer12");
				element.className = "selected";				
			}
		},
		false);
}

function hideAddressbar()
 {
    window.scrollTo(0, 1);
}

function signupFocus()
 {
    var element = document.getElementById("signupEmail");
    if (element.value == signupText)
    {
        element.style.color = "#ccc";
        element.value = '';
    }
}

function signupBlur()
 {
    var element = document.getElementById("signupEmail");
    if (element.value == '')
    {
        element.style.color = "#888";
        element.value = signupText;
    }
}

function posterClick(e)
 {
		var videoType = "trailer";
	
		// a video type was specified explicitly, so set the selection
		if (e)
		{
			if (e == "trailer")
			{
				videoType = "trailer";
				document.getElementById("videoSwitcherTrailer12").className = "";
				document.getElementById("videoSwitcherTrailer").className = "selected";
				document.getElementById("videoSwitcherTeaser").className = "";
			}
			else if (e == "teaser")
			{
				videoType = "teaser";
				document.getElementById("videoSwitcherTrailer12").className = "";
				document.getElementById("videoSwitcherTrailer").className = "";
				document.getElementById("videoSwitcherTeaser").className = "selected";
			}
			else if (e == "trailer12")
			{
				videoType = "trailer12";
				document.getElementById("videoSwitcherTrailer12").className = "selected";
				document.getElementById("videoSwitcherTrailer").className = "";
				document.getElementById("videoSwitcherTeaser").className = "";
			}
		}
		// a video type wasn't specified, so use the hash
		else
		{
			if (document.location.hash)
			{
			
				var hash = document.location.hash.substr(1, document.location.hash.length - 1);
							
				if (hash == "trailer")
				{
					videoType = "trailer";
				}
				else if (hash == "teaser")
				{
					videoType = "teaser";
				}
				else if (hash == "trailer12")
				{
					videoType = "trailer12";
				}
			}
		}
		
    var element = document.getElementById("VideoContainer");

		if (videoType == "trailer")
		{
			element.innerHTML = '<div id="teaserVideoObject"><object width="480" height="346"><param name="movie" value="http://www.youtube.com/v/tUnACVP-4NY&hl=en_US&fs=1&&autoplay=1"></param><param name="allowFullScreen" value="false"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/tUnACVP-4NY&hl=en_US&fs=1&&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="480" height="346"></embed></object></div>';			
		}
		else if (videoType == "teaser")
		{
    	element.innerHTML = '<div id="teaserVideoObject"><object width="480" height="346"><param name="movie" value="http://www.youtube.com/v/arjW9n6m7PQ&hl=en_US&fs=1&&autoplay=1"></param><param name="allowFullScreen" value="false"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/arjW9n6m7PQ&hl=en_US&fs=1&&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="480" height="346"></embed></object></div>';			
		}
		else if (videoType == "trailer12")
		{
    	element.innerHTML = '<div id="teaserVideoObject"><object width="480" height="346"><param name="movie" value="http://www.youtube.com/v/Ro_9tQpPjRQ&hl=en_US&fs=1&&autoplay=1"></param><param name="allowFullScreen" value="false"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Ro_9tQpPjRQ&hl=en_US&fs=1&&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="480" height="346"></embed></object></div>';			
		}
}

function thumbnailOnClick()
 {
    var videoElement = document.getElementById("teaserVideoObject");

    if (videoElement)
    {
        var containerElement = document.getElementById("teaserVideoContainer");

        containerElement.innerHTML = "<div id='teaserVideoPoster' onclick='posterClick()'><div id='teaserFrank'></div></div>";
    }
}

function togglePlatform()
{
	if (document.body.className == 'ios')
		document.body.className = 'mac';
	else
		document.body.className = 'ios';

}

function setupPlatform()
{
	// Browser check
	// Look for Mac
	if (navigator.appVersion.indexOf('Macintosh') > -1)
	{
		document.body.className = 'mac';
	}
	else {
		document.body.className = 'ios';
	}
}




