﻿var showAtMouseLocation = true;

function closeSharePlayListDialog()
{
    ShowHideObjects("visible");
	    
    var shareID  = document.getElementById("sharePlayList");
    shareID.style.display = "none";
}


function getSharePlayListHtml(playlistID, playlistName, djUserName, djScreenName)
{
    var closePanelText;
    var infoText;
    var share1Text;
    var share2Text;
    var share3Text;
    var mailToSubject;
    var mailToLabel;
    
    playlistName = decode(playlistName);
    
    if(language == "EN")
    {
        infoText = "You can share this radio station in three ways...";
        share1Text = "Copy and paste the link into an email or instant messenger:";
        share2Text = "Copy and paste the html code below to any other site:";            
        share3Text = "Send using your computer's email application:";            
        mailToSubject = escape("Check out this cool Radio Station on Batanga: " + playlistName);
        mailToLabel = "Email link to the station";
        closePanelText = "Close";  
    }
    else
    {
        infoText = "Tu puedes compartir esta estaci&oacute;n de radio en tres formas….";
        share1Text = "Copia y pega este v&iacute;nculo en un email o un instant messenger:";
        share2Text = "Copia y pega el c&oacute;digo de abajo en cualquier otra p&aacute;gina web";    
        share3Text = "Envialo usando tu programa de email:";                            
        mailToSubject = escape("Mira esta buenisima estación de radio en Batanga: " + playlistName);
        mailToLabel = "Email el v&iacute;nculo a la staci&oacute;n";
        closePanelText = "Cerrar";            
    }
    
    
    playlistName = playlistName.replace(/'/g, "&#39;");
    
    var playlistUrl = "http://radio.batanga.com/player/player.aspx?playlistid=" + playlistID;
    var djUrl = "http://my.batanga.com/" + djUserName;
    var djImageUrl = "http://photos1.batanga.com/batanga/" + djUserName + "/batanga/" + djUserName + "thumb.jpg";
    
    var myBatangaUserImage = "<img border=\"0\" width=\"60\" height=\"60\" src=\"" + djImageUrl + "\">";
    var batangaLogoText = "<a target=_blank href=\"http://www.batanga.com\"> <img border=\"0\" src=\"http://www.batanga.com/images/Batanga_small.gif\"></a>";        
    var playListText = playlistName + " <a target=_blank href=\"" + playlistUrl + "\"><img border=\"0\" src=\"http://radio.batanga.com/images/ForwardArrow.gif\">play</a>";
    var myBatangaText = "DJ: <a target=_blank href=\"" + djUrl + "\">" + djScreenName + "<center style=\"padding-top:5px;\">" + myBatangaUserImage + "</center></a>";        
    
    var shareCode;
    shareCode = "<div style=\"border:dotted 1px gray;float:left;text-align:left;padding:6px;\">";
        shareCode = shareCode  + "<table cellpadding=1>";
            shareCode = shareCode  + "<tr>";
                shareCode = shareCode  + "<td>";
                    shareCode = shareCode  + "<a target=_blank href=\"http://myradio.batanga.com\"><img align=\"left\" border=\"0\" src=\"http://myradio.batanga.com/images/myradio.jpg\"></a>";
                shareCode = shareCode  + "</td>";
                shareCode = shareCode  + "<td>";
                    shareCode = shareCode  + playListText
                shareCode = shareCode  + "</td>";
            shareCode = shareCode  + "</tr>";
        shareCode = shareCode  + "</table>";        
    shareCode = shareCode  + "</div>";        
    
    //alert(shareCode);
    
    var text;
	text = "<div class=\"st0bo st0ba sharePlayListContentFrame\" >";        
	text = text + "<a style=\"float:right; font-size:10px; margin-top:-7px;\" href=\"#\" onclick=\"javascript:closeSharePlayListDialog(); return false;\">" + closePanelText + "</a>";
	text = text + "<center><h3>" + infoText  + "</h3></center>";	
	    text = text + "<div class=\"sharePlayListTypes\"  >";                    	
	        text = text + "<center><b>1. " + share1Text + "</b></center>";
	        text = text + "<center>URL:&nbsp;<input style=\"width:375px;margin-top:7px;\" id=\"share1\" onclick=\"javascript:copyToClipboard('share1');\" value=\"" + playlistUrl + "\"></center>";
	    text = text + "</div>";	    
	    text = text + "<div class=\"sharePlayListTypes\"   >";                    	
	        text = text + "<center><b>2. " + share2Text + "</b></center>";
            text = text + "<center>Embed:&nbsp;<input id=\"sharecodeTextArea\" style=\"width:375px;margin-top:7px;\" onclick=\"javascript:copyToClipboard('sharecodeTextArea'); return false;\" value='" + shareCode + "'></center>";                
        text = text + "</div>";        
        text = text + "<div class=\"sharePlayListTypes\"   >";                    	
	        text = text + "<center style=\"margin-bottom:7px;\" ><b>3. " + share3Text + "</b></center>";    	        
            text = text + "<center><a id=\"sharecodeMailTo\" href=\"mailto:?subject=" + mailToSubject + "&amp;body=" + playlistUrl + "\">" + mailToLabel + "</a></center>";                
        text = text + "</div>";
    text = text + "</div>";

    return text;
}


function getSharePlayListOnlyHtml(playlistID, playlistName, djUserName, djScreenName)
{
    var closePanelText;
    var infoText;
    var share1Text;
    var share2Text;
    var share3Text;
    var mailToSubject;
    var mailToLabel;
    
    playlistName = decode(playlistName);
    
    if(language == "EN")
    {
        infoText = "You can share this station in three ways:";
        share1Text = "Copy and paste the link into an email or IM:";
        share2Text = "Copy and paste the html code to any other site:";            
        share3Text = "Send via your computer's email application:";            
        mailToSubject = escape("Check out this cool Radio Station on Batanga: " + playlistName);
        mailToLabel = "Email link to the station";
        closePanelText = "Close";  
    }
    else
    {
        infoText = "Tu puedes compartir esta estaci&oacute;n de radio en tres formas….";
        share1Text = "Copia y pega este v&iacute;nculo en un email o un instant messenger:";
        share2Text = "Copia y pega el c&oacute;digo de abajo en cualquier otra p&aacute;gina web";    
        share3Text = "Envialo usando tu programa de email:";                            
        mailToSubject = escape("Mira esta buenisima estación de radio en Batanga: " + playlistName);
        mailToLabel = "Email el v&iacute;nculo a la staci&oacute;n";
        closePanelText = "Cerrar";            
    }
    
    
    playlistName = playlistName.replace(/'/g, "&#39;");
    var playlistUrl = "";
    if(playlistID.indexOf('http')==0)
    {
     playlistUrl = playlistID;
    } else
    {
     playlistUrl = "http://radio.batanga.com/player/player.aspx?playlistid=" + playlistID;
    }
    var djUrl = "http://my.batanga.com/" + djUserName;
    var djImageUrl = "http://photos1.batanga.com/batanga/" + djUserName + "/batanga/" + djUserName + "thumb.jpg";
    
    var myBatangaUserImage = "<img border=\"0\" width=\"60\" height=\"60\" src=\"" + djImageUrl + "\">";
    var batangaLogoText = "<a target=_blank href=\"http://www.batanga.com\"> <img border=\"0\" src=\"http://www.batanga.com/images/Batanga_small.gif\"></a>";        
    var playListText = playlistName + " <a target=_blank href=\"" + playlistUrl + "\"><img border=\"0\" src=\"http://radio.batanga.com/images/ForwardArrow.gif\">play</a>";
    var myBatangaText = "DJ: <a target=_blank href=\"" + djUrl + "\">" + djScreenName + "<center style=\"padding-top:5px;\">" + myBatangaUserImage + "</center></a>";        
    
    var shareCode;
    shareCode = "<div style=\"border:dotted 1px gray;float:left;text-align:left;padding:6px;\">";
        shareCode = shareCode  + "<table cellpadding=1>";
            shareCode = shareCode  + "<tr>";
                shareCode = shareCode  + "<td>";
                    shareCode = shareCode  + "<a target=_blank href=\"http://myradio.batanga.com\"><img align=\"left\" border=\"0\" src=\"http://myradio.batanga.com/images/myradio.jpg\"></a>";
                shareCode = shareCode  + "</td>";
                shareCode = shareCode  + "<td>";
                    shareCode = shareCode  + playListText
                shareCode = shareCode  + "</td>";
            shareCode = shareCode  + "</tr>";
        shareCode = shareCode  + "</table>";        
    shareCode = shareCode  + "</div>";        
    
    //alert(shareCode);
    
    var text='';
	text = text + "<div style='background:#FFFFFF; width:300px; height:235px; margin-left:17px; margin-top:0px;'>";
	text = text + "<h3>" + infoText  + "</h3>";	
	    text = text + '<div style="width:291px; height:65px; background-color:#EAEAEA; border: 1px solid #000000; overflow:hidden; padding-left:3px; padding-top:3px; margin:2px;">';
	        text = text + "<b>1. " + share1Text + "</b><br>";
	        if(language == "EN") text = text + "<br>"
	        text = text + "URL:&nbsp;<input style='width:247px;' id=\"share1\" onclick=\"javascript:copyToClipboard('share1');\" value=\"" + playlistUrl + "\">";
	    text = text + "</div>";	    
	    text = text + '<div style="width:291px; height:65px; background-color:#EAEAEA; border: 1px solid #000000; overflow:hidden; padding-left:3px; padding-top:3px; margin:2px;">';
	        text = text + "<b>2. " + share2Text + "</b><br>";
	        if(language == "EN") text = text + "<br>"
            text = text + "Embed:&nbsp;<input id=\"sharecodeTextArea\" style='width:232px;' onclick=\"javascript:copyToClipboard('sharecodeTextArea'); return false;\" value='" + shareCode + "'>";
        text = text + "</div>";        
        text = text + '<div style="width:291px; height:65px; background-color:#EAEAEA; border: 1px solid #000000; overflow:hidden; padding-left:3px; padding-top:3px; margin:2px;">';
	        text = text + "<b>3. " + share3Text + "</b><br><br>";
            text = text + "<div style=''><a id=\"sharecodeMailTo\" href=\"mailto:?subject=" + mailToSubject + "&amp;body=" + playlistUrl + "\">" + mailToLabel + "</a></div>";
        text = text + "</div>";
    text = text + "</div>";

    return text;
}


function showSharePlayList(playlistID, playlistName, djUserName, djScreenName)
{

    var sharePlayList  = document.getElementById("sharePlayList");
    if(sharePlayList == null)
    {
        alert("Missing sharePlayList tag");
        return;
    }
    
    ShowHideObjects("hidden");
    
    /*
    var dlgWidth = 600;
    var dlgHeight = 300;
    
    // Get the window width and height
    SetWinWidthHeightValues();
    
    var yPositionValue = 0;
    var xPositionValue = 0;
    
    /////////////////////////////////
    //Determin the X position value
    if ( (mouseX + dlgWidth) > winW - 10 )
        { xPositionValue = winW - dlgWidth - 10; }
    else
        { xPositionValue = mouseX; }
    sharePlayList.style.left = xPositionValue + "px";

    /////////////////////////////////
    //Determin the Y position value   
    if ( (mouseY + dlgHeight) > winH - 10)
        { yPositionValue = winH - dlgHeight - 50; }
    else 
        { yPositionValue = mouseY; }
    sharePlayList.style.top = yPositionValue + "px"; 
    */
    
    if(showAtMouseLocation)
    {
        sharePlayList.style.left = mouseX + "px";
        sharePlayList.style.top = mouseY + "px";
    }
        
    sharePlayList.innerHTML = getSharePlayListHtml(playlistID, playlistName, djUserName, djScreenName);
    sharePlayList.style.display = "";
    
    return false;
}

document.write("<div id=\"sharePlayList\" style=\"position:absolute;display:none;width:475px;height:230px;z-index:50010;\"></div>");