/* NAME: launchPlayer()
   DEFINITION: Launches the popUp audio players from ReverbNation based on attributes of the embed code.*/    

function launchPlayer() {
    if(document.getElementById("rnInlinePlayer")) {
        var playerID = document.getElementById("rnInlinePlayer").id;
        var playerType = document.getElementById("rnInlinePlayer").type;
        var playerSRC = document.getElementById("rnInlinePlayer").src;
        var playerList = playerSRC.substr(93,15);
          
        var playerHeight = parseInt(document.getElementById("rnInlinePlayer").height);
        var playerWidth = parseInt(document.getElementById("rnInlinePlayer").width);
          
        var windowHeight = (playerHeight * .05) + playerHeight;
        var windowWidth = (playerWidth * .05) + playerWidth;
          
        var playerWinMode = document.getElementById("rnInlinePlayer").wmode;
        var playerScriptAccess = document.getElementById("rnInlinePlayer").allowscriptaccess;
        var playerPluginsPage = document.getElementById("rnInlinePlayer").pluginspage;
          
        var htmlWindowPrefix = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
        	htmlWindowPrefix += "<html><head><title>My New Window<\/title><\/head><body>";
        var omniturePrefix = "<!-- SiteCatalyst code version: H.15.1. Copyright 1997-2008 Omniture, Inc. More info available at http:\/\/www.omniture.com -->\n\n<script language='JavaScript' type='text\/javascript' src='http:\/\/www.philly.com\/includes\/s_code.js'><\/script>\n<script language='JavaScript' type='text\/javascript'>\n<!--\/* You may give each page an identifying name, server, and channel on the next lines. *\/\n\ns.pageName='popup-player: Phrequency Playlist " + playerList +  "';\ns.server='www.phrequency.com';\ns.channel='phrequency';\ns.prop3='Pop-up Player Widget';\ns.prop4 = 'ReverbNation';\ns.prop8=s.getTimeParting('d','-5','2009');  \/\/ set day of week\ns.prop9=s.getTimeParting('h','-5','2009');  \/\/ set hour of day\ns.prop10=s.getTimeParting('w','-5','2009'); \/\/ set weekend\/weekday\ns.prop21=s.getDaysSinceLastVisit();\ns.prop17='Phrequency Playlist " + playerList + "';\n\ns.prop22='www.phrequency.com';\ns.prop23='phrequency:popup-player';\n\n\/* E-commerce Variables *\/\ns.events='event1';\ns.prop27='';\n\n\/* Hierarchy Variables *\/\ns.prop5='phrequency,popup-player,index';\ns.hier1='phrequency,popup-player,index';\ns.hier2='phrequency,phrequency,popup-player,index';\n\n\/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************\/\nvar s_code=s.t();if(s_code)document.write(s_code)\/\/--><\/script>\n<script language='JavaScript' type='text\/javascript'><!-- if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-') \/\/--><\/script><noscript><a href='http:\/\/www.omniture.com' title='Web Analytics'><img src='http:\/\/phillycom.112.2O7.net\/b\/ss\/phillycom\/1\/H.15.1--NS\/0' height='1' width='1' border='0' alt='' \/><\/a><\/noscript><!--\/DO NOT REMOVE\/-->\n<!-- End SiteCatalyst code version: H.15.1. -->";
        var embedCode = "<embed id=\"" + playerID + "\" type=\"" + playerType + "\" src=\"" + playerSRC + "\"	height=\"" + playerHeight + "\" width=\"" + playerWidth + "\" wmode=\"" + playerWinMode + "\" allowscriptaccess=\"" + playerScriptAccess + "\" pluginspage=\"" + playerPluginsPage + "\"/>";
        var htmlWindowSuffix = "<\/body><\/html>";
          
        var windowOptions = "width=" + windowWidth + ",height=" + windowHeight + ",scrollbars=no,resizable=no";
          
        var playerWindow = window.open("","rnPlayer", windowOptions);
        var playerCode = htmlWindowPrefix + omniturePrefix + embedCode + htmlWindowSuffix;
          
        playerWindow.document.open();
        playerWindow.document.write(playerCode);
        playerWindow.document.close();
    }
}


/* NAME: getQueryVariable(name_of_variable)
   DEFINITION: Parses the query string of a GET and returns the value if found.*/   

function getQueryVariable(varName) {
    var urlString = window.location.href;
    var queryString = urlString.substring(urlString.indexOf("?")+1,urlString.length);
    var currentVars = new Array();
    var currentVars = queryString.split("&");
    var currentPair = new Array();
          
    for (var x = 0; x < currentVars.length; x++) {
        currentPair = currentVars[x].split("=");
              
        if(currentPair[0] == varName) {
            return currentPair[1];
        }
    }
}


/* NAME: createDateTimeStamp()
   DEFINITION: Creates the dynamic date stamp in the navigation.*/   
function createDateTimeStamp() {
    var today= new Date();
    var currentWeekDay = today.getDay();
    var currentHour    = today.getHours();
    var currentMinutes = today.getMinutes();
    var currentDate    = today.getDate();
    var currentMonth   = today.getMonth();
    var currentYear    = today.getFullYear();
    var months         = new Array("January","February","March","April","May","June","July","August","September","October","November","December");   
    var weekDays       = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    var dateStamp;
    var timeStamp;
    var completeStamp;
    var myTimeDelay;
    
    if(currentHour < 13) {
        var meridian = "AM";
    }
    else {
        currentHour = currentHour - 12;
        var meridian = "PM";
    }
    
    if(currentMinutes < 10) {
       currentMinutes = "0" + currentMinutes;
    }
    
    switch(currentWeekDay) {
        case 0:
            currentWeekDay = weekDays[0];
            break;
        case 1:
            currentWeekDay = weekDays[1];
            break;
        case 2:
            currentWeekDay = weekDays[2];
            break;
        case 3:
            currentWeekDay = weekDays[3];
            break;
        case 4:
            currentWeekDay = weekDays[4];
            break;
        case 5:
            currentWeekDay = weekDays[5];
            break;
        case 6:
            currentWeekDay = weekDays[6];
            break;
    }
    
    switch(currentMonth) {
        case 0:
            currentMonth = months[0];
            break;
        case 1:
            currentMonth = months[1];
            break;
        case 2:
            currentMonth = months[2];
            break;
        case 3:
            currentMonth = months[3];
            break;
        case 4:
            currentMonth = months[4];
            break;
        case 5:
            currentMonth = months[5];
            break;
        case 6:
            currentMonth = months[6];
            break;
        case 7:
            currentMonth = months[7];
            break;
        case 8:
            currentMonth = months[8];
            break;
        case 9:
            currentMonth = months[9];
            break;
        case 10:
            currentMonth = months[10];
            break;
        case 11:
            currentMonth = months[11];
            break;
    }
    
    dateStamp = currentWeekDay + ", " + currentMonth + " " + currentDate + ", " + currentYear;
    timeStamp = currentHour + ":" + currentMinutes + " " + meridian;
    completeStamp = dateStamp + "&nbsp;&bull;&nbsp;" + timeStamp;
     
    document.getElementById("phreqDateTimeJS").innerHTML = completeStamp;
    // Commenting out the setTimeout to keep the page from jumping.
    //myTimeDelay = setTimeout('createDateTimeStamp()',500);
}
