var debug = false;
var loadingContent = false;
var contenturl = '';
var leftMenuAction = "leftMenu.do";

function handleError()
{
	if( loadingContent == false )
	{
		return false;
	}
	else if( top.getGoingBack() )
	{
		top.setGoingBack(false);
	}
	else
	{
		loadContentWindow(contenturl);
	}
}
self.onerror = handleError;

//sync left and top menus
function syncMenus(primaryOn, secondaryOn, level3On, level4On)
{
   //top.resetGoingBack();
   //top.syncTopMenu(primaryOn,secondaryOn,level3On,level4On);
   top.syncAllMenus(primaryOn, secondaryOn, level3On, level4On)
}

/*function syncLeftMenu(fn_menuId, fn_level3On, fn_level4On)
{
		
		top.frames[1].frames[0].syncMenu(fn_level3On, fn_level4On, fn_menuId);
}*/

function loadContent()
{
	loadingContent = true;
	contenturl = arguments[0];
	if(top.frames[1].length<2)
	{
		top.frames[1].window.location.href="content-window.jsp?contentPage="+arguments[0];
	}
	if( arguments.length == 1 )
	{
		if( (arguments[0] == null ) || ( arguments[0] == "" ) ) return;
		top.frames[1].frames[1].window.location.href = arguments[0];
	}
	if( arguments.length == 2 )
	{
		if( (arguments[0] == null ) || ( arguments[0] == "" ) ) return;
		eval("top."+arguments[1]+".window.location.href = arguments[0]");
	}
}

function loadContentWindow(url)
{
	top.frames[1].window.location.href = "content-window.jsp?contentPage="+url;
}

function reloadTopMenu()
{
	top.frames[0].window.location.href = top.frames[0].window.location.href;
}

function loadExternalContent(url, level3On, level4On, menuId)
{
   var leftMenuUrl =    leftMenuAction + "?level3On=" + level3On +
                        "&level4On=" + level4On +
                        "&menuId=" + menuId;
	//var v_url = "content-window.jsp?contentPage=" + escape(url) +
	//												"&leftMenuUrl=" + escape(top.frames[1].frames[0].window.location.href);
	var v_url = "content-window.jsp?contentPage=" + escape(url) +
													"&leftMenuUrl=" + escape(leftMenuUrl);
                  
	top.frames[1].window.location.href = v_url;
}

function back()
{	
	top.setGoingBack(true);
	top.frames[1].frames[1].history.back(); /* This is for netscape 4.7 */	
}

function refresh()
{
	top.frames[1].frames[1].history.go(0);
}

function checkGoingBack(callingPage)
{	

	if ( top.getGoingBack() )
	{
		if ( callingPage == "topMenu" )	
		{
			//topMenu frame has come back		
			if( top.getTopBack() )
			{	
				top.resetGoingBack();
				return false;
			}
			else top.setTopBack(true);
		}	
		else if ( callingPage == "leftMenu" )	
		{
			//leftMenu frame has come back
			if(debug) alert("inside left, getLeftBack()=="+top.getLeftBack());
			if( top.getLeftBack() )
			{		
				top.resetGoingBack();
				return false;
			}
			else
			{				
				top.setLeftBack(true);
				if(debug) alert("setLeftBack to true, getLeftBack()=="+top.getLeftBack());
			}
		}

		back();
		return true;
	}
}

//My bit !

function casaAvailability()
 {
  window.open('http://www.rentors.org/calendar.cfm?pid=27979',config='Availability','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=500,height=900');
 }
function quintaAvailability()
 {
  window.open('http://www.rentors.org/calendar.cfm?pid=48861',config='Availability','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=500,height=900');
 }
function map()
 {
   window.open('http://www.mapquest.com/maps/map.adp?zoom=9&mapdata=lZfCwkldBIwVcefR2kQkK9kue1tXvE22SPx9Tmy59m5GKJkYPJNt0UDh4k0UmtdYJqtXocUjt3FTxDRyho6a97wp2jDbteJC%2f8Eekv4Zuy1zFSyEBncfqvG0u1EtA2ChPyQzvQ%2fFawFYlDExExwo7nYrIc85bnM0ttFIElMw61X8LOJVhDoJus3Zx8YT5aFvXpEIZfIl60GgXpd6N0zzrzgcuKFFelvW8KiNgm5NHaod17y3ynCDhaGJIG%2bexu0Fu7HNKnaxW6dww0iS5ZHoaqduOV5wV7s19aVDSUAQrXlzX%2b0uJZqmqpyrI8TpqumB7po3K2orzhL325eyLWfiUrIJpVN3vaSnfbp%2bkhpSzph0dIXi8GEshNcSXLCJeufQ','Detailed',config='toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=900,height=900');
 }
function cheveral()
 {
   window.open('http://www.cheveral.com','Cheveral',config='toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes');
 }
function weather()
 {
  window.open('http://www.weather.com/outlook/travel/local/33908?whatprefs=WeatherLocalTravel','Weather',config='toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=900,height=900');
 }
function flightSearch()
 {
  window.open('http://www.google.co.uk/search?q=cheap+flights+to+Florida&ie=UTF-8&oe=UTF-8&hl=en&btnG=Google+Search&meta=','Flights',config='toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=900,height=900');
 }
function carSearch()
 {
  window.open('http://www.google.co.uk/search?q=Florida+Car+Hire&ie=UTF-8&oe=UTF-8&hl=en&btnG=Google+Search&meta=','Flights',config='toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=900,height=900');
 }
function whatsOn()
 {
  window.open('http://cityguide.news-press.com/fe/Calendar/Search.asp','Events',config='toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=900,height=900');
 }
 function terms()
 {
  window.open('./terms.htm','Terms',config='toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=500,height=900');
 }
function openWin(url,name) {
	popup = window.open(url,name,config='scrollbars=yes,resizable=yes,left=50,top=50,width=750,height=550,status=no,location=no,toolbar=yes');
	popup.focus();
}
function openWin2(url,name) {
	popup = window.open(url,name,config='scrollbars=yes,resizable=yes,left=50,top=50,width=1050,height=800,status=no,location=no,toolbar=yes');
	popup.focus();
}

function callPage(where){
	//popWin = open("temperatures.htm","Boing","width=300,height=300,resizable=1");
	//alert(where);
	//void this.document.open('Temperatures/temperatures.htm','windy','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,scrollbars=no,width=500,height=900');
	window.location=where;
}
function callPopUp(where){
	popWin = open(where,'',config='scrollbars=yes,resizable=1,left=50,top=50,width=1000,height=700,status=no,location=no,toolbar=yes');
}
function newSrc(where)
{
	parent.document.getElementById("mainFrame").src=where
}
function writeAdditionalHtml(doc){

	var msg = "<IFRAME id=\"waitMsg\" src=\"file://wait.htm\" ";
	msg += "width=\"250\" height=\"140\" ";
	msg += "MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\" SCROLLING=\"NO\"";
	msg += "></IFRAME>";

	doc.write(msg);
}