
/* susuarios registrados */

function returnJoostLink() {
  document.getElementById('playnow_start').style.display='block';
  document.getElementById('playnow_opening').style.display='none';
}


function clickJoostLink() {
  document.getElementById('playnow_start').style.display='none';
  document.getElementById('playnow_opening').style.display='block';
}

function findJoost() {

	//if browser is any other	
	try{
	  if(navigator.mimeTypes["application/x-joost-spoon"].enabledPlugin != null )  {	
	    joostFound = true;
	  }
	} catch(e) {}
	return joostFound;
}

function sniffJoost() {
	var joostFound = findJoost();
	 if (tinyUrl!="") {
		 
	  //create text if joost is  found
	  if(joostFound) {
	    document.getElementById('playnow_start').style.display = 'block';     
	    var buttonLink = document.getElementById('button-watchit-link');
	    if (buttonLink) {
	      buttonLink.setAttribute("href","joost://" + tinyUrl + location.hash);
	      buttonLink.onclick = clickJoostLink;
	    }
	    var programLink = document.getElementById('program-title-link');
	    if (programLink) {
	      programLink.setAttribute("href","joost://" + tinyUrl + location.hash);
	      programLink.onclick = clickJoostLink;
	    }
	    // include the Facebook code
	    facebookInclude('http://facebook.com/beacon/beacon.js.php?source=5586658845');
	  } else {
	      document.getElementById('playnow').style.display = 'none';     
    }
	}
	// launch client immediately if #play=now
	var hash=location.hash+'';
	if (hash && hash.match(/(?:#|,)(?:play=now)/gim)) {
	  var buttonLink = document.getElementById('button-watchit-link');
	  if (joostFound && buttonLink && buttonLink.onclick) {
	    buttonLink.onclick();
	  }
	}
}
	
function showhide(layer_ref) {
	obj		= document.getElementById(layer_ref);
	if (obj.style.display != "none") {
		obj.style.display	= "none";
	} else {
		obj.style.display	= "block";
	}
    return false;
}


function doLoginFromFlash(username,password) {
	document.getElementById('username').value = username;
	document.getElementById('password').value = password;
	document.getElementById('jsaction').value = 'signin';
	document.getElementById('loginform').submit();
}

function doForgotFromFlash (username) {
	document.getElementById('username').value = username;
	document.getElementById('jsaction').value = 'lostpassword';
	document.getElementById('loginform').submit();
}
function doForgotFromHTML () {
	document.getElementById('jsaction').value = 'lostpassword';
	document.getElementById('loginform').submit();
}

function doLogoutFromFlash() {
	document.getElementById('jsaction').value = 'signout';
	document.getElementById('loginform').submit();
}


function showLogin() {
	if (document.getElementById('login_form') != undefined) {
		document.getElementById('login_form').style.display = "block";
		document.getElementById('login_signin').style.display = "none";
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	var c = readCookie(name);
	createCookie(name,"",-1);
	return c;
}