function toggle(obj) {
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '');
}

function hide(obj) {
	var el = document.getElementById(obj);
	el.style.display = 'none';
}


Cufon.replace('.nav-item a', {hover: true});
Cufon.replace('.more', {hover: true});
Cufon.replace('.WidgetTitle h2');
Cufon.replace('.openmap', {hover: true});
Cufon.replace('.button', {hover: true});
Cufon.replace('.ui-tabs-nav', {hover: true});
Cufon.replace('#alphabet', {hover: true});
Cufon.replace('h3', { fontFamily: 'Helen Bg' }); 
Cufon.replace('#secondline a', { fontFamily: 'Helen Bg', hover: true });

$(document).ready(function() {
	
	OpenMap();
	function OpenMap(){
	$('.buildings-map-holder').animate({
		width: "980px",
		marginLeft: "-490px",
		opacity: "1"
	}, 1000);
	$('.buildings-map').animate({
		height: "360px"
	}, 500);
	$(".openmap").addClass("opened");
	}
	function CloseMap(){
	$('.buildings-map-holder').animate({
		width: "100px",
		marginLeft: "0",
		opacity: "1"
	}, 1000);
	$('.buildings-map').animate({
		height: "0"
	}, 500);
	$(".building-num").css("display", "none");
	$(".openmap").removeClass("opened");
	}
	
	//tooltip
	
	$(".buildings a").hover(
	function () {
    $(".building-num").fadeIn("fast");
		posX = $(this).position().left+20;
		posY = $(this).position().top-30;
		$(".building-num").css("left", posX);
		$(".building-num").css("top", posY);
		numValue = $(this).attr("rel");
		$(".building-num").css("background-image", "url(/img/dot" + numValue + ".png)");
		$(".building-num").html($(this).html());
		$(".building-num").attr("id", numValue);
		Cufon.replace('.building-num');
		//
  },
  function () {
    $('.building-num').css({"display" : "none"});
		$(".building-num").removeAttr("id")
  }
	);
	
	$(".openmap").click(function() {
		if($(".openmap").hasClass("opened")){
			CloseMap();
		}else{
			OpenMap();
		}
		Cufon.replace('.openmap', {hover: true});
	});
	
	//LocalNavigation is absolute positioned
	
	var subnavElement = document.getElementById('LocalNavigation');

	if(subnavElement){
		NavPosition = $("#LocalNavigation").height() + $("#LocalNavigation").position().top;
		ContentPosition = $("#Content").position().top + $("#Content").height();
		if(ContentPosition<NavPosition){
			$("#Content").css("height", NavPosition-$("#Content").position().top-20);
		}
	}
	
  
	EnlargeImage();
	function EnlargeImage()
	{
  	$('#Content.building-page').animate({
  		height: "53px"
  	}, 500);
  
  
    $(".building #LocalNavigation").css("display", "none");  
  
  	$(".opencontent").addClass("opened");
	}
	
	function ShowContent()
	{
  	$('#ContentWrapper').animate({
  		height: "370px"
  	}, 500);
  	$('#InnerContent').animate({
  		height: "340px"
  	}, 500);
  	$('#Content.building-page').animate({
  		height: "370px"
  	}, 500);
    $(".building #LocalNavigation").css("display", "block");
  	$(".opencontent").removeClass("opened");
	}
	
	//tooltip
	

	
	$(".opencontent").click(function() {
		if($(".opencontent").hasClass("opened")){
			ShowContent();
		}else{
			EnlargeImage();
		}
		Cufon.replace('.opencontent', {hover: true});
	});
});



