//initialize variables
var flashInstalled = jQuery.fn.flash.hasFlash(8);
var flashPrompt = true;
var menu_style;
var active_dir;
//initialize shadowbox before DOM is loaded//
//Shadowbox.init({ players: ['img', 'html', 'flv', 'swf', 'qt', 'iframe'] });

$(document).ready(function() {
    if (!flashCheck()) {
        //add the 'noflash' ID to the <html> tag
        $("html").attr("id", "noflash");
        //add the superfish class name to the client_header menu
        if (menu_style == "vertical") {
            $("#nav").attr("class", "sf-menu sf-vertical");
        } else {
            $("#nav").attr("class", "sf-menu");
        }
        //load the remote javascript for the non-flash menu system
        $.getScript("http://common.pbhs.com/Scripts/superfish.js", function() {
            // initialize the superfish menus
            $('ul.sf-menu').superfish();
        });
    }

   

    initImageReplacement();

});
function flashCheck() {
    if (!jQuery.fn.flash.hasFlash(8) || $("html").attr("id") == 'noflash') {
        return false;
    } else {
        return true;

    }
}
function loadTopbar(status) {
    active_dir = getDir();
    if (flashCheck() && status != 'mockup') {

        $('#ctl00_home #header').flash(
					{
					    src: 'templates/pbhs/index.swf',
					    flashvars: { load_page: getDir() + getPage(), active_dir: getDir() }
					},
					{ version: 8, update: false },
					  function(htmlOptions) {
					      if (parent.$('iframe ').length) {
					          htmlOptions.wmode = 'opaque';
					      }
					      htmlOptions.height = '100%';
					      htmlOptions.width = '100%';
					      $(this).append($.fn.flash.transform(htmlOptions));
					  }
					 );

	$('#ctl00_interior #header').flash(
					{
					    src: 'templates/pbhs/_menu/topbar.swf',
					    flashvars: { load_page: getDir() + getPage(), active_dir: getDir() }
					},
					{ version: 8, update: false },
					  function(htmlOptions) {
					      if (parent.$('iframe ').length) {
					          htmlOptions.wmode = 'opaque';
					      }
					      htmlOptions.height = '100%';
					      htmlOptions.width = '100%';
					      $(this).append($.fn.flash.transform(htmlOptions));
					  }
					 );

    }
    if (flashCheck()) {
        //initSwfReplacement();
    }
}
function loadBottombar() {
    if (flashCheck()) {
        $('#footer').flash(
					{
					    src: 'templates/pbhs/_menu/bottombar.swf',
					    width: '100%',
					    height: '100%',
					    flashvars: { load_page: getPage(), active_dir: getDir() }
					},
					{ version: 8, update: false }
					 );
    }
}

////functions
function getPage() {
    //var this_page = unescape(location.href);
    //var this_page_split = this_page.split("/");
    //alert(this_page_split.length);
    //if (this_page.indexOf('?') !== -1)
        //this_page = this_page.substring(0, this_page.indexOf('?'))
    //this_page = this_page.substr(this_page.lastIndexOf('/') + 1)

    //if (this_page == "") {
        //this_page = "index.html";
    //}
    return 'default.aspx';
}

function getDir() {
    /*if ($("body").attr("id") == "home") {
        var active_dir = "";

    } else {
        var active_dir = "";

    }*/

    var active_dir = "templates/pbhs/";
    return active_dir;
}


