﻿var ifau = {};
	ifau.base = function() {
	return {
	    init: 
	        function () {		
		        // Sets minimum height of container element
//		        ifau.base.setContainerHeight();
//		        $(window).bind("resize", ifau.base.setContainerHeight);
//		        
                var containerElement = $("#content"),
			        windowHeight = $(window).height();
        			
		        if (containerElement.length > 0 && containerElement.height() < windowHeight) {
			        containerElement.css("min-height", windowHeight - 320);
		        }
        		
		        //used in "fokusområde" pages
		        var subjectInfoHeight = $(".subject-info").height() +"px";
		        $(".subject-info").css("height", "200px");
        		
		        //subjects-info
	            $(".subject-fade-ball").toggle(function() {
                    $(".subject-info").animate({ height: subjectInfoHeight}, 1000);
                    $(".subject-fade").animate({ height: subjectInfoHeight}, 1000);
                    $(".subject-fade").fadeOut();
                    $(".subject-fade-ball").fadeOut();
                },function() {
                    $(this).animate({ height:'200px'  }, 1000);
                    $(".subject-fade").fadeIn();
                    $(".subject-fade-ball").fadeIn();
                    $(".subject-fade").animate({ height: '200px'}, 1000); 
                });
    		
		        //Publishedlinks year toggling
		        $(".year").click(function(){
		            var nod = this.parentNode;
		            $(nod).find(".yearSection").toggle("slow");
		        });
        		
		        //Slides down subjects
		         $(".subject-bar").click(function () {
                  $(".subject-list").slideToggle("slow");
                  $(".subject-ball").slideToggle("slow");
                    return false;
                });
            
		        //Converts DDL to a rullgardin
		         $(".subjectdropdown").hide();
                    var $children = $(".subjectdropdown").children();
                    $(".subjectdropdown option").each(function () {
                        if(this.text != "Ämnen"){
                         $("<li><a href=\"" + this.value  + "\" alt=\"" + this.text + "\">" + this.text + "</a></li>").appendTo(".subject-list");
                        }
                 }); 
                 
                 //Opens in a new window
                 $("a[rel=external]").click(function () {
                    window.open(this.getAttribute("href"));
                    return false;
                });
	        },
	    setContainerHeight:
	        function () {
		        $("#mainContent").css("min-height", ($(document).height() - $("#footer").height() - $("#header").height()) + "px");
	        }
	        };
	    }();

$(document).ready(ifau.base.init());


