cGUI.prototype.buildingVideo = function(id){
	thisMovie('flash').buildingVideo(id);
};

$(function(){
	$('#locator #step1 ul li a').each(function(){
		$(this).show();
		$(this).bind('click',function(){
			GUI.buildingVideo($(this).attr('rel'));
		});
	});
});

var openFlash = function() {
		GUI.resize("360","950","#video_box");
		thisMovie('flash').openEI();
		void(0);
	};
var closeFlash = function() {
		if (typeof thisMovie('flash').closeEI != 'function' || GUI.flashVideoLoaded != 'yes') {
			setTimeout(function(){closeFlash();}, 500);
			return;
		}
		try {
			GUI.resize("210","950","#video_box");
			thisMovie('flash').closeEI();
		} catch(err) {
			setTimeout(function(){closeFlash();}, 500);
		}
		void(0);
	};
var jumpToFlash = function(to) {
		thisMovie('flash').jumpToFlash(to);
		void(0);
	};

var flashVideoLoaded = function() {
	GUI.flashVideoLoaded = 'yes';
	void(0);
};

function thisMovie(movieName) {
         if (navigator.appName.indexOf("Microsoft") != -1) {
             return window[movieName];
         } else {
             return document[movieName];
         }
    };

$(document).ready(function () {
	$("#java_box").fadeOut(1000);
});

hash_test = "";
function pageload(hash, target, source, callback, reurl, history) {
	//$("#java_box").css({"display":"none"});
	if (!target) target = 'content_box';
	if (!source) source = 'content_box';
	if (!callback) callback = 'void(0);';
	if (!reurl) reurl = 'yes';
	if (!history) history = 'yes';
	if(hash) {
		if ( hash != GUI.hash_test) {
			GUI.hash_test = hash;
			GUI.load(hash, target, source,  "GUI.availspaceInit();" + callback, reurl, 'no');
		};
	} else {
		// start page
		$("#load").empty();
	}
	var url_pattern=/^.*\/immediately.html$/;
	if(url_pattern.test(location.href))
		{
		GUI.searchboxMin("yes");
		}
}

var throbberCheck = function(){
	$('#throbber').hide();
	setTimeout(function(){
		throbberCheck();
	}, 1000);
};

$(function () {
	throbberCheck();
	map_crt = "empty";
	$(".map_small").click(
			function(){
				//closeFlash();
				if (map_crt != $(this).attr("name")) {
					$('#throbber').css({'opacity': 0});
					state = $(this).attr("href");
					map = WWW_ROOT + "themes/images/map_small_" + $(this).attr("name") + ".gif";
					map_old = map;
					$('#map_europe img').attr("src", map);
					$('#locator #numResults').hide();
					$('ul.search_list').hide();
					$('#step1, #step2, #step3').css({
						"height": "30px",
						"width": "213px",
						"cursor": "pointer"
					});
					$('#step2, #step3').css({
						"margin-left": "10px"
					});
					GUI.resize(0, 234, "#locator");
					GUI.resize(0, 706, "#finder");
					$("#finder").append("<div id='locator_loading' style='position:absolute; right:125px; top:180px; text-align:center;'><img src='"+WWW_ROOT+"themes/images/throbber.gif'><br/>Loading map</div>");
					$('#map_container').fadeOut(300, function(){
						GUI.load(state, "map_container", 'tmpmap_container', "$('#locator #numResults').hide();GUI.mapInit();","yes","no");
					});
					map_crt = $(this).attr("name");
					$("#locator").click(function(){
							$('#map_container').hide();
							$('#locator #numResults').fadeIn();
							GUI.resize(237, 230, "#finder");
							$('#locator').css({
								"height": "230px"
							});
							GUI.resize(237, 710, "#locator");
							$('#step1, #step2, #step3').css({
								"height": "185px",
								"width": "223px"
							});
							$('#step2, #step3').css({
								"margin-left": "0px"
							});
							map = WWW_ROOT + "themes/images/map_small.gif";
							map_crt = "empty";
							$('#map_europe img').attr("src", map);
							$("#locator").unbind('click');
							GUI.load(WWW_ROOT + LANG_SHORTCUT + '/', 'locator', 'locator', 'GUI.init("no");', 'no','no');//$.getScript("' + JS_LIBS_URL + 'libs/sifr-config.js");
					});
					return false;
				}
				else {
					return false;
				}
			}
	);
	$(".map_small").hover(
		function () {
			map_old = $('#map_europe img').attr("src");
			map = WWW_ROOT + "themes/images/map_small_"+ $(this).attr("name") +".png";
			$('#map_europe img').attr("src",map);
		},
		function () {
			$('#map_europe img').attr("src",map_old);
		}
	);
	$('.map_small').tooltip({
					track: true,
					showURL: false,
					top: 20,
    				left: -5,
					delay: 1000
				});
	GUI.resultInit();
});

cGUI.prototype.availspaceInit = function() {
	$(".more, .news_archive").click(
		function() {
			//closeFlash();
		}
	);
	$('#park_menu a').unbind('click');
	$('#park_menu a').bind('click', function(){
		url = $(this).attr('href');
		GUI.load(url, null, null, 'GUI.availspaceInit();');
		return false;
	});

		$('#result_box a').unbind('click');
		$('#result_box a').bind('click', function(){
			GUI.searchboxMin("yes");
			url = $(this).attr('href');
			//GUI.load(url, 'result_box', 'result_box');
            GUI.load(url, null, null, 'GUI.availspaceInit();', 'no', 'yes');
			return false;
		});

	$('#siteplan_map area').unbind('click');
	$('#siteplan_map area').bind('click', function(){
		$("#throbber").fadeIn();
		url = $(this).attr('href');
		GUI.load(url, null, null, 'GUI.availspaceInit();$("#throbber").fadeOut();');
		return false;
	});

//	$('#numResults').show();
	$('#siteplan_map area').bind('mouseover', function(){
			//alert();
			$('#building_over_'+$(this).attr('rel')).css({'visibility':'visible'});
			$('#building_name_'+$(this).attr('rel')).css({'z-index':'45'});
	});

	$('#siteplan_map area').bind('mouseout', function(){
			$('#building_over_'+$(this).attr('rel')).css({'visibility':'hidden'});
			$('#building_name_'+$(this).attr('rel')).css({'z-index':'1'});
	});
	GUI.resultInit();

	if (APL_LOGGED != "YES") {

		$.getScript('/js/sifr-config.js');

	};

	$('.print').unbind('click').bind('click', function(){
		window.print();
	});


//	$('#numResults').hide();
	$('#park_box h3.aerial').show();
	$('#park_box h3.aerial, #park_box h3.space').css({
		cursor: 'pointer'
	});
	$('#park_box h3.space').bind('click', function(){
		$('#siteplan_div, #siteplan_map, #siteplan_legend').show();
		$('#siteplan_aerial_img').hide();
	});
	$('#park_box h3.aerial').bind('click', function(){
		$('#siteplan_div, #siteplan_map, #siteplan_legend').hide();
		$('#siteplan_aerial_img').show();
	});

	$('#park_box h3.park_detail a').unbind('click');
		$('#park_box h3.park_detail a').bind('click', function(){
				$("#throbber").fadeIn();
		url = $(this).attr('href');
		GUI.load(url, null, null, 'GUI.availspaceInit();');
		return false;
	});

	$('.result_full_page .all').unbind('click');
	$('.result_full_page .all').bind('click', function(){
		$(this).hide();
		if (this.parentNode.nodeName.toLowerCase() == 'li') {
			$(this).parent().parent().find('li').slideDown();
		} else if ($(this).hasClass('parks')) {
			$('.right_box.parks').slideDown();
		} else {
			$('.right_box.builds').slideDown();
		}
	});

    $('#park_box .left_box h3.news_month').css({'cursor': 'pointer'});
    $('#park_box .left_box ul.news_month').hide();
    $('#park_box .left_box h3.news_month').unbind('click');
        $('#park_box .left_box h3.news_month').bind('click', function(){
                var month_ul = '#park_box .left_box ul.news_month#'+$(this).attr('rel');
                if ($(month_ul).css('display') == 'none') {
                    $(month_ul).show();
                } else {
                    $(month_ul).hide();
                }
				//console.log($(month_ul).css('display'));
	});

	$('.building_concept').unbind('click');
	$('.building_concept').bind('click', function(){
		url = $(this).attr('href');
		GUI.load(url, null, null);
		return false;
	});

	browser = new API.getBrowserInfo();
	if ( !browser.ie6 ) $.Lightbox.domReady();

};

cGUI.prototype.mapInit = function() {
	$(".big_map").load(
		function(){
			height = $('#map_container').height()+50;
			GUI.resize(height,234,"#locator");
			GUI.resize(height,(jQuery.browser.msie && parseInt(jQuery.browser.version) == 6)?701:706,"#finder");
			$('#map_container').fadeIn(1500,
				function(){
					$('#locator_loading').remove();
				}
			);
			$('#throbber').css({'opacity': 1});
			$('#step1, #step2, #step3').css({
						"height": "30px",
						"width": "213px",
						"cursor": "pointer"
			});
			$('#step2, #step3').css({
				"margin-left": "10px"
			});
		}
	);
	$('#map_container a').tooltip({
					track: true,
					showURL: false,
					top: 20,
    				left: -5
	});
	$('#map_container a').bind('click', function(){
		url = $(this).attr('href');
		GUI.load(url, null, null, '$(window).scrollTo( $("#content_box"), 1500 );');
		return false;
	});
};
cGUI.prototype.parkInit = function(){
};


$(function(){

	if (APL_LOGGED != "YES") {

		$.getScript('/js/sifr-config.js');

	};

});
