/* ================================================ */
/*                                                  */
/*            Regus Business Centers JS             */
/*             Version 0.1 -- 12.2004               */
/*                                                  */
/* ================================================ */

//wwww
function fnWindowOpen(url, name, options){
	if(!options) options="resizable=1,scrollbars=1";
	newWindow = window.open(url, name, options);
	newWindow.focus();
}

// Browser sniff
function BrowserCheck()
{
	var b = navigator.appName;
	if (b=="Netscape") this.b = "ns";
	else if (b=="Microsoft Internet Explorer") this.b = "ie";
	else this.b = b;
	var c = navigator.appVersion;
	this.AOL = (c.indexOf('AOL')>0);
	this.v = parseInt(c);
	this.ns = (this.b=="ns" && this.v>=4);
	this.ns5 = (this.b=="ns" && this.v==5);
	this.ns6 = (this.b=="ns" && this.v==5);
	this.ie = (this.b=="ie" && this.v>=4);
	this.ie5b = (navigator.userAgent.indexOf('MSIE 5.5')>0);
	this.ie6 = (navigator.userAgent.indexOf('MSIE 6')>0);
	this.gecko = (navigator.userAgent.indexOf('Gecko') > 0);
	if (this.ie5) this.v = 5;
	if (this.ie6) this.v = 6;
}

// automatically create the "is" object
is = new BrowserCheck();

/* toggle an elements display attribute, assumes element is off by default */

function toggleDisplay (v) {
	var element = (typeof v == "string") ? document.getElementById(v) : v;
	menuToClear = v;
	if (element.style.display == 'block') {
		element.style.display = 'none';
	} else {
		element.style.display = 'block';
	}
	
}

// us home page javascript

// swap the ole search boxes on the ole us home page

var lastSearch = 'officesSearch';
var lastSearchLink = 'officesLink';

function swapSearch (id, link) {

	var toShow = document.getElementById(id);
	if (toShow.style.display != 'block') {
		document.getElementById(lastSearch).style.display = 'none';
		lastSearch = id;
		
		document.getElementById(lastSearchLink).className = '';
		lastSearchLink = link;
		
		toShow.style.display = 'block';
		document.getElementById(link).className = 'active';
	} 
	
}
/// <defect number="68"><desc>Added a javascript method that is attached to the country state dropdowns if a state div is provided.</desc>
var _processingStateToggle = false;
var countryRegistrationCount = 0;
var countryDropdownCollection = null;

function getObject(objectId) { 

	if(document.getElementById && document.getElementById(objectId)) { 
	// W3C DOM 
		return document.getElementById(objectId); 
	} 
	else if (document.all && document.all(objectId)) { 
		// MSIE 4 DOM 
		return document.all(objectId); } 
	else if (document.layers && document.layers[objectId]) { // NN 4 DOM.. note: this won't find nested layers return 
		document.layers[objectId]; 
	} 
	else 
	{ 
		return false; 
	} 
} 


var functionIsCityTextboxDefaultLoaded = false;
var countryDataIslandLoaded = false;
function EnableCityControl(citytxtdiv, citycbodiv, countryguid)
{
	var showTextbox = true;
	if(functionIsCityTextboxDefaultLoaded)
	{
		showTextbox = IsCityTextboxDefault();
	}

   if(IsCountryRequireCityTextbox(countryguid))
   {
      showTextbox = true;
   }
   
   if(showTextbox)
   {
	citytxtdiv.style.display = '';
	citytxtdiv.style.visibility = "visible";
	citycbodiv.style.display = 'NONE';
	citycbodiv.style.visibility = "hidden";
   }
   else
   {
	citytxtdiv.style.display = 'NONE';
	citytxtdiv.style.visibility = "hidden";
	citycbodiv.style.display = '';
	citycbodiv.style.visibility = "visible";
   }
}
function IsCountryRequireCityTextbox(countryGuid)
{
	var isFound = false;
	
	if(countryDataIslandLoaded)
	{
		countryGuids.recordset.absoluteposition=1;
		while(!countryGuids.recordset.EOF)
		{
			if(countryGuids.recordset("guid") == countryGuid)
			{
				isFound = true;
			}
			countryGuids.recordset.MoveNext();
		}
	}
	return isFound;
}

var _callToggle = false;

function manageCountryBoundStateCity(state, citytxt, citycbo, country)
{
	if (_callToggle == false)
	{
		_callToggle = true;
		toggleStateDropdown(state,country);
		_callToggle = false;
	}
	
	var stateDiv = getObject(state);
	var countrySelect = getObject(country);
	var cityTxtDiv = getObject(citytxt);
	var cityCboDiv = getObject(citycbo);
	var selectedIndex = -1;
	
	if ((stateDiv != false) && (countrySelect != false) && (cityTxtDiv != false) && (cityCboDiv != false))
	{
		selectedIndex = countrySelect.selectedIndex;
		
		if ((selectedIndex != -1) && (countrySelect.options[selectedIndex].value == '25439b47-af53-46f4-bca8-6a8a2a854b07'))
			stateDiv.style.display = '';	
		else
			stateDiv.style.display = 'NONE';	
			
		if (selectedIndex != -1)
			EnableCityControl(cityTxtDiv, cityCboDiv, countrySelect.options[selectedIndex].value);
	}
		
	return true;	
}
function toggleStateDropdown(state,country)
{
	
	var stateDiv = getObject(state);
	var countrySelect = getObject(country);
	var selectedIndex = -1;

	if ((stateDiv != false) && (countrySelect != false))
	{
		selectedIndex = countrySelect.selectedIndex;
		
		if ((selectedIndex != -1) && (countrySelect.options[selectedIndex].value == '25439b47-af53-46f4-bca8-6a8a2a854b07'))
			stateDiv.style.display = '';	
		else
			stateDiv.style.display = 'NONE';	
	}
	else
	{
		//alert('test');
		return true;
	}

	// first check to see if this is a response to our updates - if not then it's a user request
	// and we need ot update the other select boxes.
	if (_processingStateToggle == false)
	{
		//alert('Country registration count ' + countryRegistrationCount);
		
		// <feature number="19"><desc>fix this bug because get javascript errors that countryDropdownCOllection doesn't exist</desc>
		if (typeof countryDropdownCollection == 'undefined')
		{
			// if doesn't exist return
			return true;
		}
		// </feature>
		
		_processingStateToggle = true;
		// Note - countryDropdownCollection is a variable that is regestered by the template or the housing control.
		// it is the parents responsibility (usually the host control to the different search controls) to make sure 
		// this value exists to syncronize country dropdowns.  countryRegistrationCount is a value that is also registered
		// by the hosting control so that we know how many have been registered and we know how many to loop through and update.
		if ((countryDropdownCollection != null) && (countryRegistrationCount != null))
		{
			//alert("start.selectedIndex: " + selectedIndex);
			var updateCountrySelect;
			
			for(var i=0; i<countryRegistrationCount; i++)
			{
				if (countryDropdownCollection[i] != country)
				{
					updateCountrySelect = getObject(countryDropdownCollection[i]);
					if (updateCountrySelect != false)
					{
						var _selectedIndex = false;
						var _us_index = -1;
						
						for(var x=0;x<updateCountrySelect.options.length;x++)
						{
							if (updateCountrySelect.options[x].value == '25439b47-af53-46f4-bca8-6a8a2a854b07')
							{
								_us_index = x;
							}
							if (updateCountrySelect.options[x].value == countrySelect.options[selectedIndex].value)
							{
								//alert("set index to x: " + x);
								updateCountrySelect.selectedIndex = x;
								_selectedIndex = true;
								//x = updateCountrySelect.options.count;
							}

						}
						
						if (_selectedIndex == true)
						{
							//alert("set to us: "  + _us_index);
							// set to United States as default
							//updateCountrySelect.selectedIndex = _us_index;
						}
						else
						{
							//alert("don't set to us");
							//updateCountrySelect.selectedIndex = countrySelect.selectedIndex;
							updateCountrySelect.onchange();	
						}
					}
				}
			}
		}
//		else
//		{
//			alert('nothing to process');
//		}
		_processingStateToggle = false;
	}
		
	
		
	return true;	
}
///</defect>
function getSelectedSearchTab()
{
	var tabs = new Array('officesSearch','meetingRoomsSearch','virtualOfficesSearch');
	for(var c=0;c<tabs.length;c++){if( document.getElementById(tabs[c]).style.display==('block'))return tabs[c];}
	return '';
}

// Clone of above function for proximity search

var pLastSearch = 'quickFindSearch';
var pLastSearchLink = 'quickFindLink';

function pSwapSearch (id, link) {

	var toShow = document.getElementById(id);
	if (toShow.style.display != 'block') {
		document.getElementById(pLastSearch).style.display = 'none';
		pLastSearch = id;
		
		document.getElementById(pLastSearchLink).className = '';
		pLastSearchLink = link;
		
		toShow.style.display = 'block';
		document.getElementById(link).className = 'active';
	}
}

function pGetSelectedSearchTab()
{
	var tabs = new Array('quickFindSearch','addressSearch','POISearch','centerSearch');
	for(var c=0;c<tabs.length;c++){if( document.getElementById(tabs[c]).style.display==('block'))return tabs[c];}
	return '';
}


// swap the ole grid photos on yon right side

var lastParent = 'oList';
var lastGridImage = 'offices';

function swapgrid (id, parent) {
	document.getElementById(lastParent).className = 'productList';
	lastParent = parent;
	document.getElementById(parent).className = 'productList activeList';
	document.getElementById(lastGridImage + '2x4grid').style.display = 'none';
	lastGridImage = id;
	document.getElementById(id + '2x4grid').style.display = 'block';
}

/* forms */

// enable/disable controls in the same ASP.NET container.
function enableDisableSiblings(source,siblingIds,enable)
{
	var prefix=source.id.substr(0,source.id.lastIndexOf('_')+1);
	var ids=siblingIds.split('|');
	for(var c=0;c<ids.length;c++) document.getElementById(prefix+ids[c]).disabled=(!enable);
}


/* sml addition: 
	without replacing or adding a function, 
	allow function to accept objects in addition to objects' id
	v:variant - argument with unknown type
*/
function getAbsoluteLeft(v) {
	var o = (typeof v == "string") ? document.getElementById(v) : v;
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	oLeft = o.offsetLeft            // Get left position from the parent object
	//alert(o.id+": "+oLeft);
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		//alert(oParent + ": "+oParent.offsetLeft);
		o = oParent;
	}
	// Return left postion
	return oLeft
}

function getAbsoluteTop(v) {
	var o = (typeof v == "string") ? document.getElementById(v) : v;
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	oTop = o.offsetTop; 			// Get left position from the parent object
	//alert(o.id+": "+oTop);
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oTop += oParent.offsetTop 	// Add parent left position
		//alert(oParent + ": "+oParent.offsetTop);
		o = oParent;
	}
	// Return top postion
	return oTop;
}



/* widgets on location details page */
function switchWidget(id) {
	document.getElementById('photoGal').className = "";
	document.getElementById('virtualTour').className = "";
	document.getElementById('floorPlan').className = "";
	
	document.getElementById(id).className = "active";
}

/* tab info area on details page */
function switchTab(id) {
	// display only current info box
	var tabs = new Array('about','pricing','maps','amenities','nearby');
	
	for(i=0;i<tabs.length;i++) {
		document.getElementById(tabs[i]).style.display = "none";
	}
	document.getElementById(id).style.display = "block";
	
	// set current tab to active, set the next one (if exists) to pastActive,
	// set last one to last
	
	// remove all classes
	for(i=0;i<tabsCollection.length;i++) {
		document.getElementById(tabsCollection[i]).className = "";
		
	}
	
	// set which one is active
	for(i=0;i<tabs.length;i++) {
		if(tabs[i] == id) {
			document.getElementById(tabsCollection[i]).className = "active";
		}
	}
	// find out what the next one is, if any (grumble grumble no array.indexOf support)
	var activeIndex=-1;
	for(i=0;i<tabs.length;i++) {
		if(tabs[i] == id) {
			activeIndex = i;
		}
	}
	// set pastActive
	if((activeIndex != -1) && (activeIndex != tabs.length-1)) {
		document.getElementById(tabsCollection[activeIndex+1]).className = "pastActive";
	}
	// and set last
	var j;
	for(i=0;i<tabsCollection.length;i++) {
		if (document.getElementById(tabsCollection[i]).style.display != "none")
		{
			j = i;
		}	
	}
	document.getElementById(tabsCollection[j]).className += " last";
}

/* switching package area colors (confirmation_step1.htm) */

function switchPackage(side) {
	if(side=="left") {
		document.getElementById('tr').className="";
		document.getElementById('br').className="";
		document.getElementById('tl').className="active";
		document.getElementById('bl').className="active";
	}
	if(side=="right") {
		document.getElementById('tr').className="active";
		document.getElementById('br').className="active";
		document.getElementById('tl').className="";
		document.getElementById('bl').className="";
	}
}


function switchCard(which) {
	if(which=="left") {
		document.getElementById('tr').className="";
		document.getElementById('br').className="";
		document.getElementById('tc').className="";
		document.getElementById('bc').className="";
		document.getElementById('tl').className="active";
		document.getElementById('bl').className="active";
	}
	if(which=="right") {
		document.getElementById('tr').className="active";
		document.getElementById('br').className="active";
		document.getElementById('tl').className="";
		document.getElementById('bl').className="";
		document.getElementById('tc').className="";
		document.getElementById('bc').className="";
	}
	if(which=="center") {
		document.getElementById('tr').className="";
		document.getElementById('br').className="";
		document.getElementById('tl').className="";
		document.getElementById('bl').className="";
		document.getElementById('tc').className="active";
		document.getElementById('bc').className="active";
	}
}


// =====================================================================
/* sml 2004.12.10 */
// static animation easing helper
function sml_easing_Regular_easeOut(t,b,c,d)
{ 
	return -c *(t/=d)*(t-2) + b; 
}
// dom helpers


// z sorting
function sml_domApi_initDepths()
{
	sml.domApi.__z = 1000;
}
function sml_domApi_getNextHighestDepth()
{
	return ++sml.domApi.__z;
}
function sml_domApi_moveToHighest(v)
{
	var o = (typeof(v)== "string") ? document.getElementById(v) : v;
	if (document.body.style)
		o.style.zIndex = sml.domApi.getNextHighestDepth();
}
var sml = {};
sml.easing = {};
sml.easing.Regular = {};
sml.easing.Regular.easeOut = sml_easing_Regular_easeOut;
sml.domApi = {};

sml.domApi.__z=0;
sml.domApi.__depthInited=false;
sml.domApi.initDepths          = sml_domApi_initDepths;
sml.domApi.getNextHighestDepth = sml_domApi_getNextHighestDepth;
sml.domApi.moveToHighest       = sml_domApi_moveToHighest;

// =====================================================================
// Recent Location: RecentLoc
// =====================================================================



function RecentLoc(o) //dropDown, toggleLink, id
{
	this.dropDownId   = o.dropDownId;
	this.toggleLinkId = o.toggleLinkId;
	
	
	this.id    = o.id; // unique id by collection
	
	this.borderStyle = "";
	this.state = RecentLoc.STATE_OFF;
	this.tween = {interval:null, t:0, b:null, c:null, d:20};
	
	this.dropDown = null;
	this.toggleLink = null;
	
	this.boxHeight = null;
	this.boxPos = {x0:null, y0:null, x1:null, y1:null};
	this.affectedSelectBoxArray = null;
}
// static func

function RecentLoc_toggleLinkHandler()
{
	var rlc = RecentLocCollection.instance;
	var i = rlc.rl_arr.length;
	while (i--)
	{
		if (this==rlc.rl_arr[i].toggleLink)
		{
			rlc.rl_arr[i].toggleDropDown();
			RecentLocCollection.activeRL = rlc.rl_arr[i];
			break;
		}
	}
	return false;
}
function RecentLoc_animateActiveRL()
{
	var activeRL = RecentLocCollection.activeRL;
	var dd = activeRL.dropDown;
	
	with (activeRL.tween)
	{
		dd.style.height = Math.floor(sml.easing.Regular.easeOut(t, b, c, d))+"px";
		if (t==0) 
		{
			clearInterval(activeRL.tween.interval);
			activeRL.tween.interval = setInterval(RecentLoc.animateActiveRL, 20);
		}
		else if (t==d)
		{
			clearInterval(activeRL.tween.interval);
			
			activeRL.state = (activeRL.state == RecentLoc.STATE_TO_ON) ? RecentLoc.STATE_ON : RecentLoc.STATE_OFF;
			// make sure that the border doesn't stay on when set to off state
			if (activeRL.state == RecentLoc.STATE_ON)
			{
				dd.style.visibility =  "visible";
			}
			else
			{
				if (activeRL.affectedSelectBoxArray)
					for (var i=0; i<activeRL.affectedSelectBoxArray.length; i++)
						activeRL.affectedSelectBoxArray[i].style.visibility = "visible";
				dd.style.visibility =  "hidden";
				RecentLocCollection.activeRL = null;
			}
		}
		t++;
	}
};
RecentLoc.mouseoutTO = 0;
// PAGE UI AFTER INTERACTION
function RecentLoc_mouseOutHandler(e)
{
	if (RecentLocCollection.activeRL)
		RecentLoc.mouseoutTO = setTimeout(RecentLoc.mouseOutLimiter, 500);
}
function RecentLoc_mouseOutLimiter()
{
	if (RecentLocCollection.activeRL)
		RecentLocCollection.activeRL.toggleDropDown();
}
function RecentLoc_mouseOverHandler(e)
{
	if (RecentLocCollection.activeRL)
		clearTimeout(RecentLoc.mouseoutTO);;
}
// method
function RecentLoc_p_init()
{


	var dropDown   = document.getElementById(this.dropDownId);
	var toggleLink = document.getElementById(this.toggleLinkId);
	
	//validate
	if (dropDown && toggleLink)
	{
		this.dropDown = dropDown;
		this.toggleLink = toggleLink;
		this.toggleLink.onclick = RecentLoc.toggleLinkHandler;
		return true;
	}
	return false;	
}

function RecentLoc_p_animate()
{
	if (RecentLocCollection.activeRL != null && RecentLocCollection.activeRL != this)
		RecentLocCollection.activeRL.stopAnimate();
	RecentLocCollection.activeRL = this;
	RecentLoc.animateActiveRL();
}
function RecentLoc_p_stopAnimate()
{
	clearInterval(this.tween.interval);
	this.state = RecentLoc.STATE_OFF;
	if (this.affectedSelectBoxArray)
		for (var i=0; i<this.affectedSelectBoxArray.length; i++)
			this.affectedSelectBoxArray[i].style.visibility = "visible";
	this.dropDown.style.height = "0px";
	this.dropDown.style.visibility = "hidden";
}
function RecentLoc_p_toggleDropDown()
{
	// if animating, let it get done before toggling
	if (this.state != RecentLoc.STATE_OFF && this.state != RecentLoc.STATE_ON)
		return;
	
	clearTimeout(RecentLoc.mouseoutTO);
	var dd = this.dropDown;
	if (this.boxHeight == null)
	{
		dd.style.visibility = "hidden";
		dd.style.display = "block";
		this.boxHeight = dd.offsetHeight;
		dd.style.height = "0";
	
	}
	
	dd.style.visibility = "visible";
	sml.domApi.moveToHighest(dd);
	
	// create select box array only if necessary
	if (!this.affectedSelectBoxArray)
		this.initAffectedSelectBoxArray();

	if (this.affectedSelectBoxArray)
	{	
		// once we have the value, we can toggle display by changing its height property
		if (this.state == RecentLoc.STATE_TO_ON || this.state == RecentLoc.STATE_OFF)
		{
			this.state = RecentLoc.STATE_TO_ON;
			this.tween = {t:0, b:parseInt(dd.style.height), c:this.boxHeight-parseInt(dd.style.height), d:10};
			for (var i=0; i<this.affectedSelectBoxArray.length; i++)
				this.affectedSelectBoxArray[i].style.visibility = "hidden";
			this.trackMouseOut(true);
		}	
		else
		{
			this.state = RecentLoc.STATE_TO_OFF;
			this.tween = {t:0, b:parseInt(dd.style.height), c:-parseInt(dd.style.height), d:10};
			// select box turn on post animation
			this.trackMouseOut(false);
		}
	}
	this.animate();
	
	
}
function RecentLoc_p_initAffectedSelectBoxArray()
{
	// find the dropDown's position
	var box = this.dropDown;
	var boxPos_y = getAbsoluteTop(box);

	var return_arr = new Array();
	var arr = document.getElementsByTagName("select");

	
	// if the element's coordinates overlap with the box, it's affected
	for (var i=0; i<arr.length; i++)
	{
		var selObj = arr[i];
		var selObj_y = getAbsoluteTop(selObj);
		
		var fail = Math.abs(selObj_y-boxPos_y) < this.boxHeight;
		
		if (fail)
			return_arr.push(arr[i]);
	}
	
	this.affectedSelectBoxArray = return_arr
}
function RecentLoc_p_trackMouseOut(track)
{
	if (RecentLocCollection.activeRL)
	{
		clearTimeout(RecentLoc.mouseoutTO);
		this.dropDown.onmouseout  = track ? RecentLoc.mouseOutHandler  : null;
		this.dropDown.onmouseover = track ? RecentLoc.mouseOverHandler : null;
	}
}

RecentLoc.STATE_OFF = 0;
RecentLoc.STATE_TO_ON = 1;
RecentLoc.STATE_ON = 2;
RecentLoc.STATE_TO_OFF = 3;

RecentLoc.animateActiveRL  = RecentLoc_animateActiveRL;
RecentLoc.mouseOverHandler = RecentLoc_mouseOverHandler;
RecentLoc.mouseOutHandler  = RecentLoc_mouseOutHandler;
RecentLoc.mouseOutLimiter  = RecentLoc_mouseOutLimiter;
RecentLoc.toggleLinkHandler = RecentLoc_toggleLinkHandler;

RecentLoc.prototype.init            = RecentLoc_p_init;
RecentLoc.prototype.animate         = RecentLoc_p_animate;
RecentLoc.prototype.stopAnimate     = RecentLoc_p_stopAnimate;
RecentLoc.prototype.toggleDropDown  = RecentLoc_p_toggleDropDown;
RecentLoc.prototype.trackMouseOut   = RecentLoc_p_trackMouseOut;
RecentLoc.prototype.initAffectedSelectBoxArray = RecentLoc_p_initAffectedSelectBoxArray;


// =====================================================================
// Recent Location : RecentLocCollection
// =====================================================================
function RecentLocCollection()
{
	this.rl_arr = new Array();
	this.className = "RecentLocCollection";
	RecentLocCollection.instance = this;
}
function RecentLocCollection_p_addItem(o)
{
	var rl = new RecentLoc(o);
	if (rl.init())
	{
		this.rl_arr.push(rl);
	}
}

RecentLocCollection.instance = null;
RecentLocCollection.activeRL = null;
RecentLocCollection.prototype.addItem = RecentLocCollection_p_addItem;



// =====================================================================
// Context Help 
// =====================================================================
function ContextHelpItem(o)
{
	this.id      = o.id;      // controlled by ContextHelp
	this.linkId  = o.linkId;  // created on html
	this.blockId = o.blockId; // created on html
	this.closeId = o.closeId; // created on html
	this.oLink  = null;
	this.oBlock = null;
	this.oClose = null;
}
function ContextHelpItem_p_init()
{
	
	if (document.getElementById)
	{
		var oLink  = document.getElementById(this.linkId);
		var oBlock = document.getElementById(this.blockId);
		var oClose = document.getElementById(this.closeId);
	}
	
	if (!(oLink && oBlock && oClose))
 	{
 		return false;
 	}
	
	this.oLink  = oLink;
	this.oBlock = oBlock;
	this.oClose = oClose; 	

 	this.oLink.onclick  = ContextHelp.linkHandler;
	this.oClose.onclick = ContextHelp.closeHandler;
	
 	return true;
 }
function ContextHelpItem_p_activate(x,y)
{
	if (this.oBlock.style)
	{
		this.oBlock.style.display = "block";
		this.oBlock.style.left = x + "px";
		this.oBlock.style.top  = y + "px";
	}
}
function ContextHelpItem_p_deactivate()
{
	this.oBlock.style.display = "none";
}
ContextHelpItem.prototype.init       = ContextHelpItem_p_init;
ContextHelpItem.prototype.activate   = ContextHelpItem_p_activate;
ContextHelpItem.prototype.deactivate = ContextHelpItem_p_deactivate;

function ContextHelp()
{
	this.chiArray   = new Array();
	this.activeItem = undefined;
	ContextHelp.instance = this;
}
ContextHelp.instance = undefined;
function ContextHelp_linkHandler(e)
{
	ContextHelp.instance.onItemLink(this);
	return false;
}
function ContextHelp_closeHandler(e)
{
	ContextHelp.instance.onItemClose(this);
	return false;
}
function ContextHelp_getOffendingContainer()
{
	var divTwoCol = document.getElementById("quickSearchTwoCol");
	var divOneCol = document.getElementById("quickSearchOneCol");
	return (divTwoCol || divOneCol);
}
// prototype
function ContextHelp_p_onItemLink(o)
{
	for (var i=0; i<this.chiArray.length; i++)
	{
		if (this.chiArray[i].oLink==o)
		{
			if (typeof(this.activeItem)!='undefined')
			{
				this.activeItem.deactivate();
			}
			this.activeItem = this.chiArray[i];
			var x = getAbsoluteLeft(o)-2;
			var y = getAbsoluteTop(o) -2;
			
			var offendingDiv = ContextHelp.getOffendingContainer();
			if (offendingDiv)
			{
				x -= getAbsoluteLeft(offendingDiv);
				y -= getAbsoluteTop (offendingDiv);
			}
			this.activeItem.activate(x,y);
		}
	}
}
function ContextHelp_p_onItemClose(o)
{
	for (var i=0; i<this.chiArray.length; i++)
	{
		if (typeof(this.activeItem)!='undefined')
		{
			this.activeItem.deactivate();
			this.activeItem = undefined;
		}

	}
}
function ContextHelp_p_addItem(o)
{
	if (document.getElementById)
	{
		o.id = this.chiArray.length;
		var item = new ContextHelpItem(o);
		if (item.init())
		{
			this.chiArray.push(item);
		}
	}
}


ContextHelp.linkHandler           = ContextHelp_linkHandler;
ContextHelp.closeHandler          = ContextHelp_closeHandler;
ContextHelp.getOffendingContainer = ContextHelp_getOffendingContainer;

ContextHelp.prototype.onItemLink  = ContextHelp_p_onItemLink;
ContextHelp.prototype.onItemClose = ContextHelp_p_onItemClose;
ContextHelp.prototype.addItem     = ContextHelp_p_addItem;

// =====================================================================
// for ie5/pc

if(!Array.prototype.push) 
{
	Array.prototype.push = function()
	{
		for (var i=0; i<arguments.length; i++)
		{
			this[this.length] = arguments[i];
		}
		return this.length;
	}
}

// =====================================================================
// init
// =====================================================================
window.onload = function()
{
	sml.domApi.initDepths();
}


/* jeff stuff */

function setGLTimeout() {
	document.getElementById('navglobal').timeout = setTimeout(toggleGL,1000);
}

function killGLTimeout() {
	clearTimeout(document.getElementById('navglobal').timeout);
}

function toggleGL() {
	toggleDisplay('navglobal');
}









// -------------------------------------------------------------------
// DHTML Window Widget- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 15th, 07'
// v1.01: Feb 21th, 07' (see changelog.txt)
// v1.02: March 26th, 07' (see changelog.txt)
// v1.03: May 5th, 07' (see changelog.txt)
// -------------------------------------------------------------------

var dhtmlwindow={
imagefiles:['zsys/windowfiles/min.gif', 'zsys/windowfiles/close.gif', 'zsys/windowfiles/restore.gif', 'zsys/windowfiles/resize.gif'], //Path to 4 images used by script, in that order
ajaxbustcache: true, //Bust caching when fetching a file via Ajax?

minimizeorder: 0,
tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes

init:function(t){
	var domwindow=document.createElement("div") //create dhtml window div
	domwindow.id=t
	domwindow.className="dhtmlwindow"
	var domwindowdata=''
	domwindowdata='<div class="drag-handle">'
	domwindowdata+='DHTML Window <div class="drag-controls"><img src="'+this.imagefiles[0]+'" title="Minimize" /><img src="'+this.imagefiles[1]+'" title="Close" /></div>'
	domwindowdata+='</div>'
	domwindowdata+='<div class="drag-contentarea"></div>'
	domwindowdata+='<div class="drag-statusarea"><div class="drag-resizearea" style="background: transparent url('+this.imagefiles[3]+') top right no-repeat;">&nbsp;</div></div>'
	domwindowdata+='</div>'
	domwindow.innerHTML=domwindowdata
	document.getElementById("dhtmlwindowholder").appendChild(domwindow)
	this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
	var t=document.getElementById(t)
	var divs=t.getElementsByTagName("div")
	for (var i=0; i<divs.length; i++){ //go through divs inside dhtml window and extract all those with class="drag-" prefix
		if (/drag-/.test(divs[i].className))
			t[divs[i].className.replace(/drag-/, "")]=divs[i] //take out the "drag-" prefix for shorter access by name
	}
	t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
	t.handle._parent=t //store back reference to dhtml window
	t.resizearea._parent=t //same
	t.controls._parent=t //same
	t.onclose=function(){return true} //custom event handler "onclose"
	t.onmousedown=function(){dhtmlwindow.zIndexvalue++; this.style.zIndex=dhtmlwindow.zIndexvalue} //Increase z-index of window when focus is on it
	t.handle.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on handle div
	t.resizearea.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on resize div
	t.controls.onclick=dhtmlwindow.enablecontrols
	t.show=function(){dhtmlwindow.show(this)} //public function for showing dhtml window
	t.hide=function(){dhtmlwindow.close(this)} //public function for hiding dhtml window
	t.setSize=function(w, h){dhtmlwindow.setSize(this, w, h)} //public function for setting window dimensions
	t.moveTo=function(x, y){dhtmlwindow.moveTo(this, x, y)} //public function for moving dhtml window (relative to viewpoint)
	t.isResize=function(bol){dhtmlwindow.isResize(this, bol)} //public function for specifying if window is resizable
	t.isScrolling=function(bol){dhtmlwindow.isScrolling(this, bol)} //public function for specifying if window content contains scrollbars
	t.load=function(contenttype, contentsource, title){dhtmlwindow.load(this, contenttype, contentsource, title)} //public function for loading content into window
	this.tobjects[this.tobjects.length]=t
	return t //return reference to dhtml window div
},

open:function(t, contenttype, contentsource, title, attr, recalonload){
	var d=dhtmlwindow //reference dhtml window object
	function getValue(Name){
		var config=new RegExp(Name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
		return (config.test(attr))? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
	}
	if (document.getElementById(t)==null) //if window doesn't exist yet, create it
		t=this.init(t) //return reference to dhtml window div
	else
		t=document.getElementById(t)
	t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
	var xpos=getValue("center")? "middle" : getValue("left") //Get x coord of window
	var ypos=getValue("center")? "middle" : getValue("top") //Get y coord of window
	//t.moveTo(xpos, ypos) //Position window
	if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){ //reposition window when page fully loads with updated window viewpoints?
		if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
			this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		else
			this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	}
	t.isResize(getValue("resize")) //Set whether window is resizable
	t.isScrolling(getValue("scrolling")) //Set whether window should contain scrollbars
	t.style.visibility="visible"
	t.style.display="block"
	t.contentarea.style.display="block"
	t.moveTo(xpos, ypos) //Position window
	t.load(contenttype, contentsource, title)
	if (t.state=="minimized" && t.controls.firstChild.title=="Restore"){ //If window exists and is currently minimized?
		t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0]) //Change "restore" icon within window interface to "minimize" icon
		t.controls.firstChild.setAttribute("title", "Minimize")
		t.state="fullview" //indicate the state of the window as being "fullview"
	}
	return t
},

setSize:function(t, w, h){ //set window size (min is 150px wide by 100px tall)
	t.style.width=Math.max(parseInt(w), 150)+"px"
	t.contentarea.style.height=Math.max(parseInt(h), 100)+"px"
},

moveTo:function(t, x, y){ //move window. Position includes current viewpoint of document
	this.getviewpoint() //Get current viewpoint numbers
	t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
	t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
},

isResize:function(t, bol){ //show or hide resize inteface (part of the status bar)
	t.statusarea.style.display=(bol)? "block" : "none"
	t.resizeBool=(bol)? 1 : 0
},

isScrolling:function(t, bol){ //set whether loaded content contains scrollbars
	t.contentarea.style.overflow=(bol)? "auto" : "hidden"
},

load:function(t, contenttype, contentsource, title){ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
	var contenttype=contenttype.toLowerCase() //convert string to lower case
	if (typeof title!="undefined")
		t.handle.firstChild.nodeValue=title
	if (contenttype=="inline")
		t.contentarea.innerHTML=contentsource
	else if (contenttype=="div"){
		t.contentarea.innerHTML=document.getElementById(contentsource).innerHTML //Populate window with contents of specified div on page
		document.getElementById(contentsource).style.display="none" //hide that div
	}
	else if (contenttype=="iframe"){
		t.contentarea.style.overflow="hidden" //disable window scrollbars, as iframe already contains scrollbars
		if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") //If iframe tag doesn't exist already, create it first
			t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-'+t.id+'"></iframe>'
		window.frames["_iframe-"+t.id].location.replace(contentsource) //set location of iframe window to specified URL
		}
	else if (contenttype=="ajax"){
		this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
	}
	t.contentarea.datatype=contenttype //store contenttype of current window for future reference
},

setupdrag:function(e){
	var d=dhtmlwindow //reference dhtml window object
	var t=this._parent //reference dhtml window div
	d.etarget=this //remember div mouse is currently held down on ("handle" or "resize" div)
	var e=window.event || e
	d.initmousex=e.clientX //store x position of mouse onmousedown
	d.initmousey=e.clientY
	d.initx=parseInt(t.offsetLeft) //store offset x of window div onmousedown
	d.inity=parseInt(t.offsetTop)
	d.width=parseInt(t.offsetWidth) //store width of window div
	d.contentheight=parseInt(t.contentarea.offsetHeight) //store height of window div's content div
	if (t.contentarea.datatype=="iframe"){ //if content of this window div is "iframe"
		t.style.backgroundColor="#F8F8F8" //colorize and hide content div (while window is being dragged)
		t.contentarea.style.visibility="hidden"
	}
	document.onmousemove=d.getdistance //get distance travelled by mouse as it moves
	document.onmouseup=function(){
		if (t.contentarea.datatype=="iframe"){ //restore color and visibility of content div onmouseup
			t.contentarea.style.backgroundColor="white"
			t.contentarea.style.visibility="visible"
		}
		d.stop()
	}
	return false
},

getdistance:function(e){
	var d=dhtmlwindow
	var etarget=d.etarget
	var e=window.event || e
	d.distancex=e.clientX-d.initmousex //horizontal distance travelled relative to starting point
	d.distancey=e.clientY-d.initmousey
	if (etarget.className=="drag-handle") //if target element is "handle" div
		d.move(etarget._parent, e)
	else if (etarget.className=="drag-resizearea") //if target element is "resize" div
		d.resize(etarget._parent, e)
	return false //cancel default dragging behavior
},

getviewpoint:function(){ //get window viewpoint numbers
	var ie=document.all && !window.opera
	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
},

rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
	this.getviewpoint() //Get current window viewpoint numbers
	t.lastx=parseInt((t.style.left || t.offsetLeft))-dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
	t.lasty=parseInt((t.style.top || t.offsetTop))-dhtmlwindow.scroll_top
	t.lastwidth=parseInt(t.style.width) //store last known width of window just before minimizing/ closing
},

move:function(t, e){
	t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
	t.style.top=dhtmlwindow.distancey+dhtmlwindow.inity+"px"
},

resize:function(t, e){
	t.style.width=Math.max(dhtmlwindow.width+dhtmlwindow.distancex, 150)+"px"
	t.contentarea.style.height=Math.max(dhtmlwindow.contentheight+dhtmlwindow.distancey, 100)+"px"
},

enablecontrols:function(e){
	var d=dhtmlwindow
	var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
	if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
		d.minimize(sourceobj, this._parent)
	else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
		d.restore(sourceobj, this._parent)
	else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
		d.close(this._parent)
	return false
},

minimize:function(button, t){
	dhtmlwindow.rememberattrs(t)
	button.setAttribute("src", dhtmlwindow.imagefiles[2])
	button.setAttribute("title", "Restore")
	t.state="minimized" //indicate the state of the window as being "minimized"
	t.contentarea.style.display="none"
	t.statusarea.style.display="none"
	if (typeof t.minimizeorder=="undefined"){ //stack order of minmized window on screen relative to any other minimized windows
		dhtmlwindow.minimizeorder++ //increment order
		t.minimizeorder=dhtmlwindow.minimizeorder
	}
	t.style.left="10px" //left coord of minmized window
	t.style.width="200px"
	var windowspacing=t.minimizeorder*10 //spacing (gap) between each minmized window(s)
	t.style.top=dhtmlwindow.scroll_top+dhtmlwindow.docheight-(t.handle.offsetHeight*t.minimizeorder)-windowspacing+"px"
},

restore:function(button, t){
	dhtmlwindow.getviewpoint()
	button.setAttribute("src", dhtmlwindow.imagefiles[0])
	button.setAttribute("title", "Minimize")
	t.state="fullview" //indicate the state of the window as being "fullview"
	t.style.display="block"
	t.contentarea.style.display="block"
	if (t.resizeBool) //if this window is resizable, enable the resize icon
		t.statusarea.style.display="block"
	t.style.left=parseInt(t.lastx)+dhtmlwindow.scroll_left+"px" //position window to last known x coord just before minimizing
	t.style.top=parseInt(t.lasty)+dhtmlwindow.scroll_top+"px"
	t.style.width=parseInt(t.lastwidth)+"px"
},


close:function(t){
	try{
		var closewinbol=t.onclose()
	}
	catch(err){ //In non IE browsers, all errors are caught, so just run the below
		var closewinbol=true
 }
	finally{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
		if (typeof closewinbol=="undefined"){
			alert("An error has occured somwhere inside your \"onclose\" event handler")
			var closewinbol=true
		}
	}
	if (closewinbol){ //if custom event handler function returns true
		if (t.state!="minimized") //if this window isn't currently minimized
			dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
		t.style.display="none"
	}
	return closewinbol
},

show:function(t){
	if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
		dhtmlwindow.restore(t.controls.firstChild, t) //restore the window using that info
	else
		t.style.display="block"
	t.state="fullview" //indicate the state of the window as being "fullview"
},

ajax_connect:function(url, t){
	var page_request = false
	var bustcacheparameter=""
	if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE6 or below
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	page_request.onreadystatechange=function(){dhtmlwindow.ajax_loadpage(page_request, t)}
	if (this.ajaxbustcache) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
},

ajax_loadpage:function(page_request, t){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
	t.contentarea.innerHTML=page_request.responseText
	}
},


stop:function(){
	dhtmlwindow.etarget=null //clean up
	document.onmousemove=null
	document.onmouseup=null
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
},

cleanup:function(){
	for (var i=0; i<dhtmlwindow.tobjects.length; i++){
		dhtmlwindow.tobjects[i].handle._parent=dhtmlwindow.tobjects[i].resizearea._parent=dhtmlwindow.tobjects[i].controls._parent=null
	}
	window.onload=null
}

} //End dhtmlwindow object

document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=dhtmlwindow.cleanup

// END Script for Popup window ---------------------------

