
/**
 * Convenience method, shorthand for YAHOO.util.Dom.get(id)
 */
function get(id)
{
    return YAHOO.util.Dom.get(id);
}

/**
 *
 */
function writeSwf(swf, attributes, params, target)
{
    var atts = "";
    var target = target ? YAHOO.util.Dom.get(target) : null;
    
    for(var i=0; i<attributes.length; i++)
    {
        atts += attributes[i].name + "='" + attributes[i].value + "' ";
    }
    
    var paramAtts = "src='" + swf + "' ";
    var paramElems = "\n<param name='movie' value='" + swf + "' />";
    for(var i=0; i<params.length; i++)
    {
        paramAtts += params[i].name + "='" + params[i].value + "' ";
        paramElems += "\n<param name='" + params[i].name + "' value='" + params[i].value + "' />";
    }
    
    
    var html = "";
    html += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ";
    html += "codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ";
    html += atts + ">";
    html += paramElems;
	html += "<embed " + paramAtts + " " + atts + " type='application/x-shockwave-flash'";
	html += "pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	html += "</object>";
    
    if(target)
    {
        target.innerHTML = html;
    }
    else
    {
        document.write(html);
    }
}

/**
 *
 */
function initMenus()
{
    var menuImgs = [ "imgHome",  "imgHistory", "imgHonorGod", 
        "imgHelpPeople", "imgStore"];
    
    var fnOver = function() { this.src = this.srcOver; };
    var fnOut = function() { this.src = this.srcOut; };
    
    for(var i=0; i<menuImgs.length; i++)
    {
       var img = get(menuImgs[i]);
       
       img.srcOut = img.src;
       img.srcOver = img.src.replace(/.gif/, "_hover.gif?");
       
       img.onmouseover = fnOver;
       img.onmouseout = fnOut;
    }
}

/**
 *
 */
function launchPlayer()
{
    window.open("/sermon_playback.swf", "_blank", "top=200,left=300,location=no,toolbar=no,menu=no,menubar=no,status=no,resizable=no,scrollbars=no,titlebar=no,width=257,height=250");
}

/**
 *
 */
function writePodcast()
{
    var title = "Anytime. Anywhere. Pastor Jeff Perry's Teachings 24/7.";
    writeSwf("/podcast.swf", 
        [
            {name: "id", value: "podcast"},
            {name: "width", value: "263"},
            {name: "height", value: "128"},
            {name: "align", value: "middle"},
            {name: "title", value: title},
            {name: "alt", value: title}
        ], 
        [
            {name: "allowScriptAccess", value: "sameDomain"},
            {name: "quality", value: "high"},
            {name: "bgcolor", value: "#ffffff"}
        ]);
}

/**
 *
 */
function writePlayer()
{
    var title = "Listen to one of Pastor Jeff Perry's latest teachings online.";
    writeSwf("/sermon_playback.swf", 
        [
            {name: "id", value: "sermon_playback"},
            {name: "width", value: "257"},
            {name: "height", value: "250"},
            {name: "align", value: "middle"},
            {name: "title", value: title},
            {name: "alt", value: title}
        ], 
        [
            {name: "allowScriptAccess", value: "sameDomain"},
            {name: "quality", value: "high"},
            {name: "bgcolor", value: "#ffffff"}
        ]);
}

YAHOO.util.Event.on(window, "load", initMenus);
