/* BuzzVoice Javascript Functions
 * Documentation for JW Mediaplayer
 * http://www.jeroenwijering.com/extras/readme.html#basic
 */
  
function createPlayer(theFile, autoPlay) 
{
	        var s = new SWFObject('pmnplayer.swf','thePlayerID','320','20','7');
	        
	        s.addVariable("file",theFile);
	        s.addVariable("width","320");
	        s.addVariable("height","20");
	        s.addVariable("backcolor", "0xEAEAFF"); //0xEAEAFF
	        s.addVariable("frontcolor","0x000000"); //0x000000
	        s.addVariable("lightcolor","0x336699");
	        s.addVariable("screencolor","0xFFFF00");  
	        s.addVariable("autostart",autoPlay);
	        s.addVariable("bufferlength","1");
	        s.addVariable("enablejs","false");
		s.addParam("wmode", "transparent");

	        
	        //s.addVariable("javascriptid","thePlayerID"); commented out to keep javascript error from appearing.
	        s.write('placeholder');	        
}

function createWidgetPlayer(theFile, autoPlay) 
{
	        var s = new SWFObject('pmnplayer.swf','thePlayerID','158','20','7');
	        
	        s.addVariable("file",theFile);
	        s.addVariable("width","158");
	        s.addVariable("height","20");
	        s.addVariable("backcolor", "0xEAEAFF"); //0xEAEAFF
	        s.addVariable("frontcolor","0x000000"); //0x000000
	        s.addVariable("lightcolor","0x336699");
	        s.addVariable("screencolor","0xFFFF00");  
	        s.addVariable("autostart",autoPlay);
	        s.addVariable("bufferlength","1");
	        s.addVariable("enablejs","false");
	        
	        //s.addVariable("javascriptid","thePlayerID"); commented out to keep javascript error from appearing.
	        s.write('placeholder');
	        
}

// Used to set cursor on searchbox changed.
function setCaretPosition() 
{
    var elem = $get('ctl00_searchControl_txtSearch');
    
    if(elem != null) 
    {
        elem.focus();
    }
}

function RedrawRatings(intCurrentRating, imgClicked)
{
   /* This function changes the image URLs of the rating stars whenever the user mouses over different images.
        We start for loop with i=2 instead of i=1 because the first image will always have a filled star.
    */
    imgID = new String(imgClicked.id);
    imgID = imgID.substring(0,imgID.length -1);
    
    var i = 2;
    var string;
    for (i=2;i<=5;i++)
    {
        //var thisImg = document.getElementById("ctl00_Content_playerControl_gvwFeedItems_ctl02_imgRating" + i);
        var thisImg = document.getElementById(imgID.concat(i));
        if (i<=intCurrentRating)
        {
            thisImg.src = "/Images/pimpstar_orange.gif";
        }
        else
        {
            thisImg.src = "/Images/pimpstar_grey.gif";
        }
        //alert(thisImg.id);
    }
    //alert(imgID);
}

function popUp(URL)
{
    day = new Date();
    id = day.getTime();
    width = new String("749");    // Used for Terms and Privacy Pages
    height = new String("700");
    windowAttribs = new String("toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,");
    windowAttribs += "width=" + width + "px," +
              "height=" + height + "px," +
              "left='+((screen.width -" + width + ") / 2)+'," +
              "top='+ (screen.height - " + height + ") / 2+'";

    eval("page" + id + " = window.open(URL, '" + id + "', '" + windowAttribs + "');"); 
}

function onUpdating()
{
    
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv'); 
        var updateNowPlayingDiv = $get('updateNowPlayingDiv');
        var lblNowPlaying = $get('ctl00_C_PC_lblNowPlaying');
        
        // change label for user.
        if (lblNowPlaying != null) lblNowPlaying.innerHTML = 'One Moment Please...';
        
        // make table invisible
        if (updateNowPlayingDiv != null) updateNowPlayingDiv.style.display = 'none';
        
        // make it visible
        if (updateProgressDiv != null) updateProgressDiv.style.display = '';      
    }

function onUpdated() 
{
    
    // get the update progress div
    var updateProgressDiv = $get('updateProgressDiv'); 
    var updateNowPlayingDiv = $get('updateNowPlayingDiv');
    
    // make it invisible
    if (updateProgressDiv != null) updateProgressDiv.style.display = 'none';
   
    // make table invisible
    if (updateNowPlayingDiv != null) updateNowPlayingDiv.style.display = '';
    
}
