﻿// JScript File

function setLinkCookie(linkID) 
{
  if (getCookie("auxiliary")==null || getCookie("auxiliary")=="") 
  {
    document.cookie = "auxiliary=" + escape(linkID) + ";path=/;domain=batanga.com";
  }
  
  return true;
 }
 
function resetLinkCookie() 
{
   document.cookie = "auxiliary=;path=/;domain=batanga.com;expires=Thu, 01-Jan-1970 00:00:01 GMT";
   return true;
 }
  
function addFavorites() {
	var title = "Batanga: Videos y Radio";
	var url = "http://www.batanga.com";  
	if (window.sidebar) { // Mozilla Firefox Bookmark		
		window.sidebar.addPanel(title, url,"");	
	} else if( window.external ) { // IE Favorite		
		window.external.AddFavorite( url, title); 
	}	else if(window.opera && window.print) { // Opera Hotlist		
		return true; 
	} 
}

function OpenMyRadioURL(URL)
{
 window.open(URL,'LaunchPlayerAndPlaylist','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,width=430,height=745');        
}

function OpenMyRadio(PlaylistID)
{
    OpenMyRadioURL('./Player/player.aspx?PlaylistID='+PlaylistID);
}


function ShowDetailError(spanID)
{

    var spanTag  = document.getElementById(spanID);

    if(spanTag.style.display == "")
        spanTag.style.display = "none";
    else
        spanTag.style.display = "";
}


function OpenPlaylistBrowser(PlaylistID)
{    
	window.open('http://music.batanga.com/' +  languageId +  '/MyRadio/PlaylistEditor/GeneratePlayList.asp?PlaylistID='+PlaylistID,'BrowserMain','width=1000,height=700');
}
function OpenHelp()
{   
	window.open('http://myradio.batanga.com/Help.html');
}


function AskBeforeDelete(PlaylistID)
{
    if (confirm('Are you sure you want to delete this radio station?'))
    {        
        document.getElementById("ctl00_theContent_delete1").value = PlaylistID;
        return true;         
       
    } 
    else 
    {    
        document.getElementById("ctl00_theContent_delete1").value =  -1;
        return false; 	        
	}
}

/*function setCookieD(cookieName,cookieValue,nDays,Domain) 
{
    var today = new Date();
    var expire = new Date();
    if (nDays == null || nDays == 0) 
        nDays=1;
        
    expire.setTime(today.getTime() + 3600000*24*nDays);
    var theCookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString() + ";path=/;domain=" + Domain + ";";
    document.cookie = theCookie;
    //window.alert('setting cookie:\n' + theCookie);
}
*/
/*
function changeLanguage(newLanguage)
{   
	if (newLanguage =="EN" || newLanguage == "en" )
		myLanguage = "EN";
	else // default is Español
		myLanguage = "ES";
			
	setCookieD("idioma",myLanguage,10,"batanga.com");
	document.location.reload();
    //document.location.href = document.location.href;
}
*/

function logoutClubSubscriber()
{
    setCookieD("LoggedInClub","0",-1,"batanga.com");
    document.location.reload();
    //document.location.href = document.location.href;
}

// Returns a cookie value, given the name of the cookie:
function getCookie(Name) 
{
    var search = Name + "=" ;
	document.cookie.setDomain="batanga.com"
	//HttpCookie languageCookie = HttpContext.Current.Request.Cookies[Name];
	if (document.cookie.length > 0) 
	{ // if there are any cookies
		offset = document.cookie.indexOf(search)
		if (offset != -1 && offset != null) { // if cookie exists
			offset += search.length;
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
		
	}
	else
	{
		return null;
	}
}


//read idioma cookie to set language
var languageId =getCookie("idioma");
var idioma;
if (languageId !=null) {
    if (languageId.toUpperCase()=="EN") {
         languageId="en";
         idioma="EN";
    }  else {
        languageId="sp";
        idioma="ES";
    } 
} else {
    idioma="ES";
    languageId="sp";
} 
