// JavaScript Document
var ids=new Array();
var tenants_by_suite=new Array();
var suites_by_tenant=new Array();
var url = "";

// Scripts for the Flash movie

// This function is called by the Flash movie, which passes a suite number only.
function frc_switchsuite(suite) {
	var tenant = tenants_by_suite[suite];
	if (!tenant) {return false}; // keeps the current info from going away if there's no new info to show
	var suites = suites_by_tenant[tenant];
	frc_switchid(tenant, suites);
}

// This function is called by the Flash movie.
function frc_openlink(suite) {
	var slug = tenants_by_suite[suite];
	if (!slug) {return false}; // keeps the shadowbox from opening if there's no post.
	slug = frc_trimoff(slug);
	frc_openbox(slug);
}

// Opens the page for Bistro, Hall or Meeting SPace
function frc_openlink_byflashname(flashname) {
	var slug = flashname.replace("_", "-");
	window.location = url + "/" + slug;
}

function frc_trace(string) {
	alert (string);
}


// Called by the php

// This function is called by the php.
function frc_openlink_byslug(slug) {
	slug = frc_trimoff(slug);
	frc_openbox(slug);
}

// This function is called by frc_switchsuite or from the php.
function frc_switchid(id, suites) {	
	frc_hideallids();
	frc_showdiv(id);
	frc_makeactive('menu_'+id);
	if (id.substr(0,5) == "avail") {
		select_color = 'gold';
	} else {
		select_color = 'red';
	}	
	frc_thisMovie("FRC_map").select_suites(suites, select_color);
}


// Internal scripts; called only by functions in this file

// put this in for Future Home of Lansdale, which opens the original page rather than -2
function frc_trimoff(str) {
	if (str.substr(str.length-2,2) == "-2") {
		str = str.replace("-2", "");
	}
	return str;
}

function frc_openbox(slug) {
	if (slug.substr(0,5) == "avail") {
		slug = 'available-space';
	}
	Shadowbox.open({
        player:     'iframe',
        content:    slug,
        width:      640,
        height:     480
    });
}

// Called internally, but also now by the Flash when rolling over a public room
function frc_hideallids() {
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		frc_hidediv(ids[i]);
		frc_makeinactive('menu_'+ids[i]);
	}		  
}

function frc_hidediv(id) {
	//hide an element with a specified id
	if (document.getElementById) {
		document.getElementById(id).style.display = 'none';
	}
}

function frc_showdiv(id) {
	//show an element with a specified id	  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
}

function frc_makeactive(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).setAttribute("class", "active");
		document.getElementById(id).setAttribute("className", "active");
	}
}

function frc_makeinactive(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).setAttribute("class", "");
		document.getElementById(id).setAttribute("className", "");
	}
}

function frc_thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}