var myDiv = false;
var m1=false;
var m2=false;
var s1=false;
var s2=false;
var mTimeout=false;
var mSticky=.5;
var section="";
function init(){


	// SET THE ROLLOVER OFFSTATE TO HILITE FOR THE SECTION WE ARE ON
	try{
		eval( "nav"+section+"_off.src = nav"+section+"_hilite.src" );
		imgChange('topNavDiv', "nav" + section, "nav" + section + "_off" );
		

		
	gNav_Init();
	}
	catch(er){
	
	}
	
	


	try
	{
		
	
		gNav_Init();
		
			
	}
	catch(er){
	
	}
}

function manualOmnitureFlashTrack(curWindow,inOrOut,trackName,url,newWindow)
{
    var s=s_gi(s_account); 
    s.tl(curWindow,inOrOut,trackName);
    
    if (newWindow)
    {
        window.open(url,'','')
    } 
    else
    {
        document.location = url;
    }
}

function mstate(m,s){
	eval( m +" = "+ s); 
	if (s==0){    
		mTimeout = setTimeout("mhide()",(mSticky*1000)); 
	} else { 
		if (hideForms) hideShowForm(0);
		clearTimeout(mTimeout);
	}
}

function mhide(){  
	if (m1==false){
		 imgChange('topNavDiv', 'navabout', 'navabout_off' );
		 showHide('aboutmenuDiv','','hide'); 
	}  
	if (m2==false && s1==false && s2==false){
		imgChange('topNavDiv', 'navplan', 'navplan_off' );
		 showHide('planmenuDiv','','hide');  
	}
	if (s1==false){  
		showHide('islandssub','','hide'); 
	}
	if (s2==false){ 
		showHide('whattodosub','','hide'); 
	}	
	
	if (m1==false && m2==false && s1==false && s2==false && hideForms==true){
		hideShowForm(1);
	}
}

function manHitboxTrack(url,pageName,pagePath,timeout) {  
    //_hbPageView(pageName,pagePath); 
    setTimeout("manHitboxRedir('" + url + "')",timeout);
}

function manHitboxRedir(url) {
     window.location = url;
}

function trackFlash(code) {
    //if (code == "closePromo") 
        //_hbPageView("amexClosePromo","/bahamas/amexflashpromo");
        
    //if (code == "promoBookClick")
        //_hbPageView("amexPromoClick","/bahamas/amexflashpromo");
        
    //if (code == "slideBookClick")
        //_hbPageView("amexSlideClick","/bahamas/amexflashpromo");
        
    //if (code == "slideLearnClick")
        //_hbPageView("amexSlideLearnClick","/bahamas/amexflashpromo");
}

function trackFlashFma(url, fmaId, popup) {
    var path = window.location.pathname;
    var pageName = path.substring(path.lastIndexOf('/') + 1);
    
    if (pageName == '')
        pageName = 'index.aspx';
    
    pageName = pageName.replace(' ','');
    pageName = pageName.substring(0,pageName.indexOf('.'));
    pageName = pageName.toUpperCase() + 'FMA_' + fmaId;
  
    //_hbPageView(pageName,"/bahamas/fma"); 
    setTimeout("flashFmaRedirect('" + url + "'," + popup + ")",750);
}

function flashFmaRedirect(url,popup) {
     if (popup)
        window.open(url);
    else
        window.location = url; 
}

function soff(i){   
	if (i==1){ 
		showHide('islandssub','','hide'); 
	}
	if (i==2){ 
		showHide('whattodosub','','hide'); 
	}	

}
 
function imgChange(layer,imgName,imgObj) {  
	if (document.images) { 
		if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')
		else document.images[imgName].src = eval(imgObj+".src")
	}
}


var selectsHidden = false;

function toggleAllSelects()
{
    if((typeof document.all != "undefined") && typeof document.body.style.maxHeight == "undefined")
    {   
        for(var f = 0; f < window.frames.length; f++)
            toggleSelects(window.frames[f].document);
            
        toggleSelects(window.document);
        
        selectsHidden = !selectsHidden;
    }
}

function toggleSelects(insideOf)
{
    if((typeof document.all != "undefined") && typeof document.body.style.maxHeight == "undefined")
    {   
        var boxes = insideOf.getElementsByTagName("select");

        for(var s = 0; s < boxes.length; s++) 
            boxes[s].style.visibility = (selectsHidden) ? "" : "hidden";
    }
}

function imgChangeSrc(layer, imgName, imgSrc, uid) {   uid=0; 
	eval( "imgObj"+uid+" = new Image()" );
	eval( "imgObj"+uid+".src = imgSrc" ); 
	imgObj = eval("imgObj"+uid);   
	
	if (document.images) { 
		if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = imgObj.src')
		else document.images[imgName].src = eval("imgObj.src")
	} 
}

 


function findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function showHide() { 
  var i,p,v,obj,args=showHide.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) {v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function offOn(objid, showorhide)
{ 

	var o;
	if (document.layers)
		o=document.layers[0].getElementById( objid );
	else
		o = document.getElementById( objid );
	if ( o !=null)
	{
		if (o.style)
		{ 
			o=o.style;
			var display = "none";
			if ( showorhide == "inline" )
			{
				display = "inline";
			}
			else if ( showorhide == "show" || showorhide == "block" )
			{
				display = "block";
			}
			
			o.display=display;

		}
	}
}
 
function changeThis(i,c) {
	i.className   =  c;
}
 

function changeClass(i,c) { 
	if (document.getElementById) {  
	document.getElementById(i).className =  c;  
	} else {
	document.all[i].className = c;	
	}
}

function changeBg(i,c) {
 try {
		if (c!="transparent"){ c = "#"+c; }
		if (document.getElementById) {
		document.getElementById(i).style.background =  c;
		} else {
		document.all[i].style.background  =  c;	
		}
	} catch(e) {}
}

if (document.images) 
	{ 
	path = "/assets/nav/";  
	navabout_on = new Image(); navabout_on.src = path+"04_about_on.gif"; 	
	navabout_off = new Image(); navabout_off.src = path+"04_about.gif"; 	
	navabout_hilite = new Image(); navabout_hilite.src = path+"04_about_hilite.gif"; 	
 
	navplan_on = new Image(); navplan_on.src = path+"05_plan_on.gif"; 	
	navplan_off = new Image(); navplan_off.src = path+"05_plan.gif"; 	
	navplan_hilite = new Image(); navplan_hilite.src = path+"05_plan_hilite.gif"; 	 
 
	navbook_on = new Image(); navbook_on.src = path+"06_book_on.gif"; 	
	navbook_off = new Image(); navbook_off.src = path+"06_book.gif"; 
	navbook_hilite = new Image(); navbook_hilite.src = path+"06_book_hilite.gif"; 	
 
	navevents_on = new Image(); navevents_on.src = path+"07_events_on.gif"; 	
	navevents_off = new Image(); navevents_off.src = path+"07_events.gif"; 
	navevents_hilite = new Image(); navevents_hilite.src = path+"07_events_hilite.gif"; 	
 
	navweather_on = new Image(); navweather_on.src = path+"08_weather_on.gif"; 	
	navweather_off = new Image(); navweather_off.src = path+"08_weather.gif"; 	
	navweather_hilite = new Image(); navweather_hilite.src = path+"08_weather_hilite.gif"; 		
}	


function getRandNumber(MAX) {
   return Math.ceil((Math.random() * (MAX)));
}




var oWindowsT = new Object();

function viewAccMap( mapid, datarightid, databottomid )
{
	var themap = document.getElementById( mapid );
	var therightdata = document.getElementById( datarightid );
	var thebottomdata = document.getElementById( databottomid );
	
	var mapwindow = window.open( '', '', 'toolbar=0, location=0, directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=650,height=430' );
	mapwindow.focus();
	
	mapwindow.document.write('<html><head>');
	mapwindow.document.write('<LINK href="/library/styles-pos.css" type="text/css" rel="stylesheet">');
	mapwindow.document.write('<LINK href="/library/styles-text.css" type="text/css" rel="stylesheet">');
	mapwindow.document.write('</head><body class="blueBg">');
	mapwindow.document.write('<table border=0 cellspacing=0 cellpadding=0 width="100%"><tr><td width=400><img src="' + themap.src + '" border=0 valign=middle></td><td width=10><img src="/assets/global/shim.gif" width=10 height=1></td>');
	mapwindow.document.write('<td valign=top width=240 align=left><br><br><div class="MediumTxtBlueLnk">' + therightdata.innerHTML + '</div></td><td>&nbsp;</td></tr>');
	mapwindow.document.write('<tr><td colspan=4>' + thebottomdata.innerHTML + '</td></tr></table>');
	mapwindow.document.write('</body></html>');
	mapwindow.document.close();
}


function ihoppopup( url )
{
	ihopwindow = window.open( url, 'ihoppopup', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=600,height=430' );
	ihopwindow.focus();
	return false;
}

function ihop360popup( url )
{
	ihopwindow = window.open( url, 'ihop360popup', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=880,height=430' );
	ihopwindow.focus();
	return false;
}

function openNewWindowSimple(sURL, sTarget,bRefresh) {
	if  (oWindowsT[sTarget]) {
		if(oWindowsT[sTarget].closed || (bRefresh == true)) {
			oWindowsT[sTarget] = window.open(sURL,sTarget);
		}
		oWindowsT[sTarget].focus();
	} else {
		oWindowsT[sTarget] = window.open(sURL,sTarget);
		oWindowsT[sTarget].focus();
	}
}

function openNewWindow(sURL, sTarget, lWidth, lHeight,bScrolling,bRefresh) {
	if (bScrolling) {
		var sScrolling = "yes";
	} else {
		var sScrolling = "no";
	}
	if  ((lWidth ==0) || (lHeight == 0)){
		var sPar = "history=no,location=no,scrollbars=" + sScrolling	
	} else {
		var sPar = "history=no,location=no,scrollbars=" + sScrolling +",width=" + new Number(lWidth) + ",height=" + new Number(lHeight)	
	}
	
	if  (oWindowsT[sTarget]) {
		if(oWindowsT[sTarget].closed || (bRefresh == true)) {
			oWindowsT[sTarget] = window.open(sURL,sTarget,sPar);
		}
		oWindowsT[sTarget].focus();
	} else {
		oWindowsT[sTarget] = window.open(sURL,sTarget,sPar);
		oWindowsT[sTarget].focus();
	}
}				

hideFormsArray = new Array();
hideFormsState=true;
hideForms=false;					
function hideShowForm(flag){
   if (flag!=hideFormsState){
	d=document.forms[0]; 
	
	for (i=0;i<(hideFormsArray.length);i++ ){
		e = d.elements[hideFormsArray[i]];
		//n = hideFormsArray[i] + "Div"; }

		if (flag){
			e.style.display="inline";
			//document.getElementById(n).style.background="url('/assets/global/shim.gif')";  
		} else {
			e.style.display="none";
			//document.getElementById(n).style.background="url('/assets/global/grid.gif')"; 
		}
		
	}
    hideFormsState=flag;
   }
}

function uncheckMyTripSuppliersByExperience( expid )
{
	try
	{
		//search for experience to see if it is checked or not
		var experiences = document.getElementsByName( "keepexperience" );		
		for ( var x=0; x<experiences.length; x++ )
		{
			if ( experiences[x].value == expid )
			{
				if ( experiences[x].checked == true )
				{
					return;
				}
			}
		}
	
		var suppliers = document.getElementsByName( "keepsupplier" );
		for ( var x=0; x<suppliers.length; x++ )
		{
			if ( suppliers[x].value.search( "^" + expid + "-" ) != -1 )
			{
				suppliers[x].checked = false;
			}
		}
	}
	catch ( e )
	{
	}
	
}

function isExperienceChecked( expid )
{
	try
	{
		//search for experience to see if it is checked or not
		var experiences = document.getElementsByName( "keepexperience" );		
		for ( var x=0; x<experiences.length; x++ )
		{
			if ( experiences[x].value == expid )
			{
				if ( experiences[x].checked == true )
				{
					return;
				}
				else
				{
					return false;
				}
			}
		}
	}
	catch ( e )
	{
	}	
	return false;
}


//get Cookies 
function getCookie(Name) 
{
    var search = Name + "="
    if (document.cookie.length > 0) { 
        // if there are any cookies
        offset = document.cookie.indexOf(search)
        if (offset != -1) { 
            // if cookie exists
            offset += search.length

            // set index of beginning of value
            end = document.cookie.indexOf(";", offset)

            // set index of end of cookie value
            if (end == -1)
                end = document.cookie.length
			
            return unescape(document.cookie.substring(offset, end))
        }
    }
}


//getting heading value for item counts
function getMyBahamasHeading(cookiename) {

	var itemcount = getCookie(cookiename);
	if (typeof(itemcount) == "undefined") {
		return "My Bahamas / Sign up to save, share and print your vacation plans.";
	}
	
	if ( new String(itemcount).length == 0) {
		return "My Bahamas / Sign up to save, share and print your vacation plans.";
	}
	
	if (itemcount == 0) {
		return "My Bahamas / My Trip / 0 Items";
	}
	if (itemcount  == 1) {
		return  " My Bahamas / My Trip / 1 Reason To Go";
	} else {
		return  "My Bahamas / My Trip / " + itemcount + " Reasons To Go";
	}
	return "";
}

function getMyBahamasLoginLogout()
{
	var guid = getCookie("__bahamasGUID");
	if ( guid == null || guid == "" )
	{
		return "<a href='/bahamas/mybahamas/login.aspx'>Sign In</a>";
	}
	else
	{
		return "<a href='/bahamas/mybahamas/signout.aspx'>Sign Out</a>";
	}
}

var currentislandid = 0;
var currentexperienceid = 0;
var currentsupplierid = 0;
var currenteventid = 0;
function setMyBahamasLabels()
{
	var guid = getCookie("__bahamasGUID");
	var selectedislands = getCookie("MyBahamasSelectedIslands");
	var selectedexperiences = getCookie("MyBahamasSelectedExperiences");
	var selectedsuppliers = getCookie("MyBahamasSelectedSuppliers");
	var selectedevents = getCookie("MyBahamasSelectedEvents");
	if ( guid == null || guid == "" )
	{
		offOn( "mybahamascopylabel", "block" );
		offOn( "isaddedlink", "hide" );
		offOn( "addtomybahamaslink", "block" );
	}
	else
	{
		offOn( "mybahamascopylabel", "hide" );
		offOn( "isaddedlink", "hide" );
		offOn( "addtomybahamaslink", "block" );

		if ( ( currentislandid > 0 && selectedislands != null && existsInCSVArray( selectedislands, currentislandid ) )
			|| ( currentexperienceid > 0 && selectedexperiences != null && existsInCSVArray( selectedexperiences, currentexperienceid ) )
			|| ( currenteventid > 0 && selectedevents != null && existsInCSVArray( selectedevents, currenteventid ) )
			|| ( currentsupplierid > 0 && selectedsuppliers != null && existsInCSVArray( selectedsuppliers, currentsupplierid ) ) )
		{
			offOn( "isaddedlink", "block" );
			offOn( "addiconimg", "hide" );
			offOn( "addtomybahamaslink", "hide" );
		}
	}

}

function existsInCSVArray( arr, str )
{
	var thearray = arr.split(",");
	for (var x=0; x<thearray.length; x++)
	{
		if ( thearray[x] == str )
			return true;
	}
	return false;
}

function setROITag(sURL) {
	mpt = new Date();
	var sImageURL = '<img src="' + sURL + '&mpuid=' + mpt.getTime() + '-' + mpt.getTimezoneOffset() + '"' + ' width="0" height="0" border="0">'
//	alert(sImageURL);
	
	var sID  = roiIDString(sURL);

	if( new String(getCookie(sID)) == "undefined") {
		//alert(sID);
		setCookie(sID, "viewed");
		document.write(sImageURL);
	} 
}

function setSpotlightTag(src, type, cat, ord) {
	var rnd = Math.round(Math.random()*3141581723+10);
	
	var srcUrl = "http://ad.doubleclick.net/activity;"
	srcUrl += "src=" + src + ";";
	srcUrl += "type=" + type + ";";
	srcUrl += "cat=" + cat + ";";
	srcUrl += "ord=" + ord + ";";
	srcUrl += "num=" + rnd + ";";
	
	var sImageURL = '<img src="' + srcUrl + '" width="0" height="0" border="0">'
	
	var sID  = "spotlight-" + cat;

	if( new String(getCookie(sID)) == "undefined") {
		//alert(sImageURL);
		setCookie(sID, "viewed");
		document.write(sImageURL);
	} 
}

function setBahSpotlightTag(cat) {
	setSpotlightTag('1145976', 'motta751', cat, '1');
}

function getROITag() {

}

function roiIDString(sURL) {
	try {
	 
		var aPieces = new String(sURL).split("/");
		var sID = aPieces[aPieces.length - 1].split("?")[0];
		return sID;
	}
	catch ( e )
	{
		return "";
	}	
}

function setCookie(name, value, expires, domain, secure)
{
	Delete_Cookie(name);
    document.cookie= name + "=" + value +
        ((expires) ? "; expires=" + expires.toGMTString() : "") + "; path=/" +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


function loadNewHomeSplash() { 
	var homemovie = new FlashObject("/assets/swf/AccordionPanel.swf", "homemovie", "468", "229", 9, "transparent");
	            
	homemovie.addParam("allowScriptAccess", "sameDomain");
	homemovie.addVariable("dataURL","/assets/swf/config/AccordianPanel.xml");
	homemovie.write("splash_image");

}

function loadHomeSplashAMEX(){ 
    
		var theform;
		if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
			theform = document.forms["Form1"];
		}
		else {
			theform = document.Form1;
		} 
		
		var splashArray = theform.splashArray.value.split(","); 
		var splashSwf = theform.splashSwf.value; 
		var splashSlideXml = theform.splashSlideXml.value;
		var splashFmaXml = theform.splashFmaXml.value;
		
		
		var n = Get_Cookie("bah_rotate");
		var n = eval(n);
		
		if (!n){ 
			n=0;
		} else if (n>=splashArray.length){
			n=0;
		}
		n=n+1;
		
		Set_Cookie_Extended("bah_rotate",n);
		//imgChangeSrc("mainDiv","splash_image", splashArray[n-1],69);

		var imgtag = "<img src=\"" + splashArray[n-1] + "\" border=0 width=595 height=228>";

		//we have to disable on mac due to dhtml menu problems
		var ismac = false;
		//if ( navigator.userAgent.indexOf('Mac') != -1 )
			//ismac = true;

		//if ( splashSwf != null && splashSwf != "" )
		if ( splashSwf != null && splashSwf != "" && !ismac )
		{
			    cCookie = getCookie("bahamas_country");
                if (typeof cCookie == "undefined") {
    	            makeCountryRequest(); 
    	        }
   
				var homemovie = new FlashObject("/assets/swf/bahLoader.swf", "homemovie", "595", "386", 9, "transparent");
				            
				homemovie.addParam("allowScriptAccess", "sameDomain");
				homemovie.addVariable("slideshowXML", splashSlideXml); 
				homemovie.addVariable("swfFile", splashSwf);
                homemovie.addVariable("fmaXML", splashFmaXml)
				homemovie.altTxt = imgtag;
				homemovie.bypassTxt = "";
				homemovie.write("splash_image");
				//alert( homemovie.getHTML() );
		}
		else
		{
			document.getElementById("splash_image").innerHTML = imgtag;
		} 
}

				
function loadHomeSplash(){ 
		var theform;
		if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
			theform = document.forms["Form1"];
		}
		else {
			theform = document.Form1;
		} 
		
		var splashArray = theform.splashArray.value.split(","); 
		var splashSwf = theform.splashSwf.value; 
		var n = Get_Cookie("bah_rotate");
		var n = eval(n);
		
		if (!n){ 
			n=0;
		} else if (n>=splashArray.length){
			n=0;
		}
		n=n+1;
		
		Set_Cookie_Extended("bah_rotate",n);
		//imgChangeSrc("mainDiv","splash_image", splashArray[n-1],69);

		var imgtag = "<img src=\"" + splashArray[n-1] + "\" border=0 width=595 height=228>";

		//we have to disable on mac due to dhtml menu problems
		var ismac = false;
		//if ( navigator.userAgent.indexOf('Mac') != -1 )
			//ismac = true;

		//if ( splashSwf != null && splashSwf != "" )
		if ( splashSwf != null && splashSwf != "" && !ismac )
		{
				var homemovie = new FlashObject(splashSwf, "homemovie", "595", "228", 7, "transparent");
				homemovie.addParam("allowScriptAccess", "sameDomain");
				homemovie.altTxt = imgtag;
				homemovie.bypassTxt = "";
				homemovie.write("splash_image");
				//alert( homemovie.getHTML() );
		}
		else
		{
			document.getElementById("splash_image").innerHTML = imgtag;
		} 
    
}
    
 
// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
 
function Set_Cookie_Extended( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}   



FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver || 6; // default to 6
	this.align = "middle"; // default to middle
	this.codebase = this.version +",0,0,0"; // fix cab download
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "Please <a href='http://www.macromedia.com/go/getflashplayer'>upgrade your Flash Player</a>.";
	this.bypassTxt = "<p>Already have Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
	this.params = new Object();
	this.variables = new Object();
	if ( c == "transparent" )
	{
		this.wmode = this.addParam('wmode','transparent');	
	}
	else if (c)
	{
		this.color = this.addParam('bgcolor', c);
	}	
	this.addParam('quality', 'high'); // default to high
	this.doDetect = getQueryParamValue('detectflash');
}

FlashObject.prototype.addParam = function(name, value) {
	this.params[name] = value;
}

FlashObject.prototype.getParams = function() {
    return this.params;
}

FlashObject.prototype.getParam = function(name) {
    return this.params[name];
}

FlashObject.prototype.addVariable = function(name, value) {
	this.variables[name] = value;
}

FlashObject.prototype.getVariable = function(name) {
    return this.variables[name];
}

FlashObject.prototype.getVariables = function() {
    return this.variables;
}

FlashObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

FlashObject.prototype.getHTML = function() {
    var flashHTML = "";
    var pre = "";
    
    
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
    
        if(window.parent.document.location.protocol.indexOf("https") >= 0)
        {
            pre = "s";
        }


        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http' + pre + '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ this.codebase +'" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';

        if (this.getParamTags() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    else { // Everyone else
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs() != null) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    }
    return flashHTML;	
}


FlashObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}

FlashObject.prototype.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		}
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
		} else {
			document.write(this.altTxt +""+ this.bypassTxt);
		}
	}		
}

function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x){
			if (x.description) {
				var y = x.description;
	   			flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
//document.write( 'version: ' + flashversion + '<br>\n' );
	return flashversion;
}

function detectFlash(ver) {	
	if (getFlashVersion() >= ver) {
		return true;
	} else {
		return false;
	}
}


function getQueryStringValue(variable)
{
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        }
        return "";
}

// get value of querystring param
function getQueryParamValue(param) {
	var q = document.location.search;
	var detectIndex = q.indexOf(param);
	if(q.length > 1 && detectIndex != -1) {
		return q.substring(q.indexOf("=", detectIndex)+1, q.indexOf("&", detectIndex));
	} else {
		return true;
	}
}

// Editor

function popEditor(url, w, h)
{
	editor = window.open(url, 'bahamasEditor', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + w + ',height=' + h);
	editor.focus();	
}

function popPlainWindow(url)
{
	var now = new Date();
	plain = window.open(url, now.getTime(), 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
	plain.focus();	
}

function popCore(url)
{
	var now = new Date();
	core = window.open(url, 'bahamasCore', 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
	core.focus();	
}

function popPreview(url)
{
	var now = new Date();
	preview = window.open(url, 'bahamasPreview', 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
	preview.focus();	
}

function popLive(url)
{
	var now = new Date();
	preview = window.open(url, 'bahamasLive', 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
	preview.focus();	
}


// modified since don't need for mac
// (not showing flash anyway)

function detectFlashOrMac() {	
	if ( navigator.userAgent.indexOf('Mac') != -1 ) return true;
	// looks like the version they're seeking (in loadHomeSplash()) is 7
	ver = 7;
	if (getFlashVersion() >= ver) {
		return true;
	} else {
		return false;
	}
}

// simple func to open the gallery
var gallery_window;
function popGallery(whichTemplate, whichSpecific) {
	var url = "/bahamas/gallery/main.aspx";
	actualPopGallery(url, whichTemplate, whichSpecific);
}
function popTestGallery(whichTemplate, whichSpecific) {
	var url = "/bahamas/gallery/maintemp.aspx";
	actualPopGallery(url, whichTemplate, whichSpecific);
}

function actualPopGallery(url, whichTemplate, whichSpecific) {
	var tmpl = "home";
	if (whichTemplate != null && whichTemplate.length > 0) { tmpl = whichTemplate; }
	url += "?jumpTemplate=" + tmpl;
	if (whichSpecific != null && whichSpecific.length > 0) { 
		url += "&jumpSpecific=" + whichSpecific;
	}
	if (gallery_window && gallery_window.location && !gallery_window.closed) {
		gallery_window.location.href = url;
	} else {
		gallery_window = window.open(url,'gallery','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=1013,height=700');
		//gallery_window = window.open(url,'gallery','width=1013,height=700,resizable=0');
		//gallery_window = window.open(url,'gallery');
	}
	gallery_window.focus(); 
}


function loadContentFrame(url) {
	//alert("loading \"" + url + "\"");
	top.frames['content'].location = url;
}

function loadFromGallery(url)
{
	if (top.opener != null && !top.opener.closed)
	{
		top.opener.location = url;
		top.opener.focus();
	} else {
		newwindow = window.open(url);
		newwindow.focus();
	}
}
