// aliennetwork.js

function newMovie(whatVideoId) {
	thisMovie("myytplayer").newMovieSWF(whatVideoId);
}

function newCue(whatVideoCue) {
	myVideoArray = whatVideoCue.split(',');
	thisMovie("myytplayer").newCueSWF(myVideoArray);
}

function setVolume(whatVolume) {
	thisMovie("myytplayer").setVolumeSWF(whatVolume);
}

function pauseMyMovie(whatVideoCue) {
	thisMovie("myytplayer").pauseMyMovieSWF();
}

function playMyMovie(whatVideoCue) {
	thisMovie("myytplayer").playMyMovieSWF();
}

function currentTimeOfMyMovie() {
	var myCurrentTime = thisMovie("myytplayer").currentTimeOfMyMovieSWF();
	return myCurrentTime;
}

function totalTimeOfMyMovie() {
	var myTotalTime = thisMovie("myytplayer").totalTimeOfMyMovieSWF();
	return myTotalTime;
}

function setMovieTitle(whatTitle) {
	thisMovie("myytplayer").movieTitleSWF(whatTitle);
}

function tellFlashToMakeAlert() {
	thisMovie("myytplayer").makeAlert();
}

// "gup" gets a value from a parameter/name in the URL string
function gup( name ){  
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
	var regexS = "[\\?&]"+name+"=([^&#]*)";  
	var regex = new RegExp( regexS );  
	var results = regex.exec( window.location.href );  
	if( results == null )    
		return "";  
	else    
		return results[1];
}

// Used in SWFObject call in the Flashvars section
function getMovieFromURL() {
	if ( gup('movieId') == '' ) {
		return "none";	
	} else {
		return gup('movieId');
	}
}

// This is an important function to remain in all swfobject externalInterface usage!
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1 || window.attachEvent) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}

function goToPage(whatURL) {
	window.location = whatURL;	
}

// Function to change the display of the side contents.  Uses the jQuery library to do so.
var $j = jQuery.noConflict(); // noConflict mode to be compatible on page with Prototype
function setSideId(whatId) {
	// Hide all Divs.
	$j('#videoDetailsContent .detailsContent').hide('slow');
	$j('#embed_link .embed_input').hide('slow');
	// Display the whatId div.
	var temp = '#' + whatId;
	$j(temp).show('slow');

	var temp2 = '#' + whatId + "_embed";
	$j(temp2).show('slow');
}



// on load, attach function to show specific video details
function show22VideoDetails() {
	//document.getElementById(showThisVideoOnLoad).style.display = "block";
}

if (window.addEventListener) {
	//window.addEventListener('load', show22VideoDetails, false);
} else {
	//window.attachEvent('onload', show22VideoDetails);
}





/* Form Validation Code */
function resetValidation(){
	ToggleErrorMessageVisibility(false);
	document.getElementById("ctl00_ctl00_BodyContent_Main_pageMain_ucAlienNetworkAlertsSignUp_emailAlertTextBox").value = 'Ex. yourname@gmail.com';
	//document.getElementById("ucAlienNetworkAlertsSignUp_emailAlertTextBox").value = 'Ex. yourname@gmail.com';
}

function InitAlertsSignUp()
{
	ToggleErrorMessageVisibility(false);
}

function ToggleErrorMessageVisibility(visible)
{
	document.getElementById("divError").style.display = (visible) ? '' : 'none';
}

function IsValidEmail(eventArgument)
{
	if (!emailCheck(eventArgument)){
		//emailCheck function location: objects/insiderNewsletter.js
		return false;
	}
	return (eventArgument != '' && eventArgument != 'Ex. yourname@gmail.com');
}

function SubmitAlertsSignUp(eventTarget, eventArgument)
{
	//alert(eventArgument);
	if (!eventArgument){
		eventArgument = document.getElementById('ctl00_ctl00_BodyContent_Main_pageMain_ucAlienNetworkAlertsSignUp_emailAlertTextBox').value;
	}
	if (!IsValidEmail(eventArgument))
	{
		ToggleErrorMessageVisibility(true);
		return;
	}
	
	__doPostBack(eventTarget, eventArgument);
}

function getValue(o) {
    var ctrl = document.getElementById(o);
	return ctrl.value;
}

/* AWB - Testing button's onclick event */
//function awb() {
//	alert("Running awb() function");
	
//	var awb_test = document.getElementById("ucAlienNetworkAlertsSignUp_btnSubmit");
	
//	awb_test.onclick = function() {
//		alert("Onclick is working");	
//	};
//}

/* AWB - Adding  above function to */
if (window.attachEvent) { // IE only
//	window.attachEvent("load", awb);
} else if (window.addEventListener) { // DOM only
//	window.addEventListener("onload", awb, false);	
}
