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 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") {
		/*
		var helve = {
			src: WWW_ROOT + 'data/files/sifr.swf',
			forceWidth: true,
			fitExactly: true,
			transparent: true
		};
		
		sIFR.replace(helve, {
			selector: '#park_box h2',
			css: ['.sIFR-root { color:#D91023; font-size: 24px; height:30px;}'],
			onReplacement: function(){
				$('#park_box h2').css({
					padding: '20px 0px 0px 10px',
					height: '30px'
				});
			}
		});
		sIFR.replace(helve, {
			selector: '#result_box h2',
			css: ['.sIFR-root { color:#FFFFFF; font-size: 16px; background-color: #606060;}'],
			onReplacement: function(){
				$('#result_box h2').css({
					padding: '7px 0px 0px 10px'
				});
			}
		});
		sIFR.replace(helve, {
			selector: '#park_box.building h3',
			css: ['.sIFR-root { color:#D91023; font-size: 16px;}'],
			onReplacement: function(){
			}
		});
		sIFR.replace(helve, {
			selector: '#result_box h3.title',
			forceSingleLine: true,
			css: ['.sIFR-root { color:#D91023; font-size: 24px;}'],
			onReplacement: function(){
			}
		});
		sIFR.replace(helve, {
			selector: '#park_box.news_page h3',
			tuneHeight: -8,
			css: ['.sIFR-root { color:#616163; font-size: 14px; height: 13px;}'],
			onReplacement: function(){
				$('#park_box.news_page h3').css({
					padding: '1px 0px 5px 10px',
					margin: '0px 0px -5px 0px'
				});
			}
		});
		sIFR.replace(helve, {
			selector: "#park_menu ul li.a a",
			forceSingleLine: true,
			css: ['.sIFR-root { font-size: 11px; color: #616163; height: 27px; text-transform:uppercase; cursor: pointer;}'],
			onReplacement: function(){
				$('#park_menu ul li.a a').css({
					padding: '7px 15px 0px 15px'
				});
			}
		});
		sIFR.replace(helve, {
			selector: '#park_menu ul li.active a',
			forceSingleLine: true,
			css: ['.sIFR-root { font-size: 11px; color: #FFFFFF; height: 27px; text-transform:uppercase; cursor: pointer;}'],
			onReplacement: function(){
				$('#park_menu ul li.active a').css({
					padding: '7px 15px 0px 15px'
				});
			}
		});
		sIFR.replace(helve, {
			selector: '#park_menu .search_back',
			forceSingleLine: true,
			css: ['.sIFR-root { font-size: 11px; color: #616163; height: 27px; text-transform:uppercase; cursor: pointer;}'],
			onReplacement: function(){
				$('#park_menu .search_back').css({
					padding: '3px 0px 0px 0px'
				});
			}
		});
			
	 sIFR.replace(helve, {
	 selector: '.news_page .left_box ul li a.active',
	 css: [
	 '.sIFR-root { color:#D91023; font-size: 13px;}'
	 ],
	 onReplacement: function(){
	 }
	 });
	 
			 
			 
		sIFR.replace(helve, {
			selector: '#locator h2, #finder h2',
			css: [
					'.sIFR-root { color:#616161; background-color: #E0E4E7; padding-left: 35px; height: 22px; cursor:pointer;}'
				],
			onReplacement: function(){
					 $('#locator h2, #finder h2').css({
						 padding: '8px 0px 0px 37px',
						 height: '22px'
					 });
			 }
		});
		
		sIFR.replace(helve, {
			selector: '#locator h3',
			css: [
					'.sIFR-root { color:#616161; font-size: 13px; background-color: #FFFFFF; height: 22px; cursor:pointer;}'
				],
			onReplacement: function(){
					 $('#locator h3').css({
						 padding: '8px 0px 0px 30px',
						 height: '22px'
					 });
			 }
		});
		sIFR.replace(helve, {
			selector: '.left_box h2, .right_box h2',
			css: [
					'.sIFR-root { color:#FFFFFF; font-size: 16pt; background-color: #606060;}'
				],
			onReplacement: function(){
					 $('.left_box h2, .right_box h2').css({
						 padding: '10px 0px 0px 10px',
						 height: '20px'
					 });
			 }
		});
		sIFR.replace(helve, {
			selector: '#park_box h2',
			css: [
					'.sIFR-root { color:#D91023; font-size: 20px; height:35px;}'
				],
			onReplacement: function(){
					 $('#park_box h2').css({
						 padding: '20px 0px 0px 10px',
						 height: '35px'
					 });
			 }
		});
		sIFR.replace(helve, {
			selector: '.news_page .right_box h1',
			css: [
					'.sIFR-root { color:#5F5F5F; font-size: 20px;}'
				],
			onReplacement: function(){
					 $('.news_page .right_box h1').css({
						 padding: '7px 0px 0px 0px'
					 });
			 }
		});	 
	 
		sIFR.activate();
		*/
	};

//	$('#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(){
});