//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') {
		
			$('#home #header').flash(
					{ 
					  src: '_menu/topbar.swf',
					  width: '100%',
					  height: '100%',
					  flashvars: { load_page: getPage(), active_dir: getDir() }
					},
					{ version: 8, update: false }
					 );
			
			$('#interior #header').flash(
					{ 
					  src: '../_menu/topbar.swf',
					  width: '100%',
					  height: '100%',
					  flashvars: { load_page: getPage(), active_dir: getDir() }
					},
					{ version: 8, update: false }
					 );
			
	}
//	if(flashCheck()) {
//			initSwfReplacement();
//	}
}
function loadBottombar(){
	if(flashCheck()) {
			$('#footer').flash(
					{ 
					  src: '../_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 this_page;
}

function getDir(){
	if($("body").attr("id") == "home"){
		var active_dir = "";
		
	}else{
	   var active_dir = "../"; 
	   
	}
	return active_dir;
}


