$ = jQuery;


$(function(){
	
	/* tegninger rotator */
	$('#latest-drawings').cycle({
		fx: 'zoom',
		fit: true,
		speed : 250,
		width: 300,
		height: 300
	});
	
	$(".clickable").click(function(e){
		window.location = $(this).attr("href");
		return false;
	});
	
	if ($.browser.msie){
		var CORNER_RADIUS = "8px";
		$("#SpecialArea").corner(CORNER_RADIUS);
		$(".wrapper").corner(CORNER_RADIUS);
		$(".round").corner(CORNER_RADIUS);
		$(".content").corner(CORNER_RADIUS);
		$(".button a").corner(CORNER_RADIUS);
		$(".teachers-button a").corner(CORNER_RADIUS);
		$(".ngg-navigation li span.active").corner(CORNER_RADIUS);
		// $("#PrimaryNavigation").uncorner().corner("top"+CORNER_RADIUS);
	}
	
	
	var Persongalleri = function(){
		
		$("#Persongalleri .persongalleri-thumb").click(function(event){
			event.preventDefault();
			$("#Personpresentasjon").css("background", "url("+$(this).attr("img")+") right bottom no-repeat");
			$("#Personpresentasjon .person-name").html($(this).attr("name"));
			$("#Personpresentasjon .person-desc").html($(this).attr("desc"))
			$("#Personpresentasjon").fadeIn("fast");
			$("#Personpresentasjon .person-box").fadeIn("fast");
			$("#Personpresentasjon #intro-text").hide();
		});
		
	}();
	
	
	var TipshefteDropdown = function(){
		
		var menuIsOpen = false;
		var duration = 200;
		
		$("#TipshefteShowList").click(function(event){
			event.preventDefault();
			if(menuIsOpen){
				hideMenu();
			} else {
				showMenu();
			}
		});
		
		$(".tipshefte-list").mouseup(function(event) {
			return false;
		});
		
		$(document).mouseup(function(e) {
			if(!$(e.target).parent("#TipshefteShowList").length) {
				hideMenu();
			}
		});
		
		function showMenu(){
			menuIsOpen = true;
			$(".tipshefte-list").slideDown(duration);
			// $(".change-language").addClass("menu-open");
		}
		
		function hideMenu(){
			// $(".change-language").removeClass("menu-open");
			$(".tipshefte-list").slideUp(duration);
			menuIsOpen = false;
		}
		
		return {
			"showMenu":showMenu,
			"hideMenu":hideMenu
		};
		
	}();
	
});
