﻿// Run the following method as soon as the page loads (like the old onload)
$(document).ready(function() {
    //alert($("body").attr("id"));
    $("#playerDiv").empty();
    $("#playerDiv").prepend(insertPlayer());
});

/**
* render the flash player
*/
function insertPlayer() {

    var playerPath = 'flash/singleMp3Player.swf';
    var fileName = 'sounds/';
    var pageName = $("body").attr("id");

    // home (default.html)
    if ((pageName == null) || (pageName == "") || (pageName == "home"))
        fileName += "kitten3.mp3";

    else if (pageName == "whoWeAre")
        fileName += "dog4.mp3";

    else if (pageName == "dogWalking")
        fileName += "woof3.mp3";

    else if (pageName == "petSitting")
        fileName += "dog_bark.mp3";

    else if (pageName == "contactUs")
        fileName += "meow1.mp3";

    else
        fileName += "kitten3.mp3";

    //alert(fileName);

    var mp3html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
    mp3html += 'width="1" height="1" ';
    mp3html += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">';
    mp3html += '<param name="movie" value="' + playerPath + '?';
    mp3html += 'showDownload=false&file=' + fileName + '&autoStart=true';
    mp3html += '&backColor=ffffff&frontColor=ffffff';
    mp3html += '&repeatPlay=false&songVolume=50" />';
    mp3html += '<param name="wmode" value="transparent" />';
    mp3html += '<embed wmode="transparent" width="1" height="1" ';
    mp3html += 'src="' + playerPath + '?'
    mp3html += 'showDownload=false&file=' + fileName + '&autoStart=true';
    mp3html += '&backColor=ffffff&frontColor=ffffff';
    mp3html += '&repeatPlay=false&songVolume=50" ';
    mp3html += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
    mp3html += '</object>';
    return mp3html;

}