
$(document).ready(function() {

    // Equalize heights in columns in footer
    //equalHeight($("div.eQ"));

    // select the selected menu item's root parent
    var s0 = $("#leftmenu div[class$='_selected']");
    var s1 = s0.parent().parent().parent();
    if (s1.attr("id") != "leftmenu") {
        var s2 = s1.find("div:first");
        if (!s2.hasClass("menu_box")) {
            s2 = s1.parent().parent().find("div:first");
        }
        s2.attr("class", s2.attr("class") + "_selected");
    }

    // hint all elements with title!=''
    $('input[title!=undefined]').hint();
    $('textarea[title!=undefined]').hint();

    if (initCaller != null) {
        for (var j = 0; j < initCaller.length; j++) {
            eval(initCaller[j].toString());
        }
    }
    // add js to HTML, so you can do css: .JS .onLoadHide{ display: none; }
    $("body").removeClass("NoJS").addClass("JS");

    // toggle next tag with class .toggleThis on click
    $(".toggleNext").click(function() {
        $(this).nextAll(".toggleThis").slideToggle("fast");
        return false;
    });

    // specialized for #mapmenu
    $(".maptoggleNext").click(function() {
        var obj = $(this).nextAll(".toggleThis");
        var up = obj.css("display") == "block";
        $("#mapmenu ul ul .toggleThis").slideUp("fast");
        if (!up) {
            obj.slideDown("fast");
        }
        return false;
    });

    // hack for making colspanned td open / close
    $(".toggleJobVacancy").click(function() {
        var el = $(this).parent().parent().nextAll(".toggleThisJobVacancy");
        if (el.css("display") == "none") {
            el.css("display", "table-row");
        } else {
            el.css("display", "none");
        }
        return false;
    });

    // toggle tip a friend tag
    $("a.icon-mail").click(function() {
        //$(".footer_middle_box").slideToggle("fast");
        $(".footer_middle_box").dialog({
            modal: true
        });
        return false;
    });

    // Table
    $("div.toggleTable").hide();

    $("a.toggleTableLink").click(function() {
        $("div.toggleTable").slideToggle("fast");
        $("a.hideTable").toggle();
        $("a.showTable").toggle();
        return false;
    });

    $("a.blank").live("click", function() {
        var el = $(this);
        window.open(el.attr("href"));
        return false;
       });
    $('a.fasilityLinks').mouseover(function() {
        var link = $(this);
        $('#fasilityText').text(link.attr("id"));
        return false;
    });
    $('a.fasilityLinks').mouseout(function() {
        var link = $(this);
        $('#fasilityText').text("Fasiliteter");
        return false;
    });

 

//       	$("#findpostcode").fancybox({
//       		'width': '75%',
//       		'height': '75%',
//       		'autoScale': false,
//       		'transitionIn': 'none',
//       		'transitionOut': 'none',
//       		'type': 'iframe'
//       	});
   

});

function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}


function printPage() {
	window.print();
}


/* 

Blankwin function 
written by Alen Grakalic, provided by Css Globe (cssglobe.com)
please visit http://cssglobe.com/post/1281/open-external-links-in-new-window-automatically/ for more info
	
*/

this.blankwin = function() {
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.", "").toLowerCase();
	var a = document.getElementsByTagName("a");
	this.check = function(obj) {
		var href = obj.href.toLowerCase();
		return (href.indexOf("http://") != -1 && href.indexOf(hostname) == -1) ? true : false;
	};
	this.set = function(obj) {
		obj.target = "_blank";
		//obj.className = "external";
	};
	for (var i = 0; i < a.length; i++) {
		if (check(a[i])) set(a[i]);
	};
};



// script initiates on page load. 

this.addEvent = function(obj, type, fn) {
	if (obj.attachEvent) {
		obj['e' + type + fn] = fn;
		obj[type + fn] = function() { obj['e' + type + fn](window.event); }
		obj.attachEvent('on' + type, obj[type + fn]);
	} else {
		obj.addEventListener(type, fn, false);
	};
};
addEvent(window, "load", blankwin);

//$("document").ready(function() {
//      $('.gallery').galleryView({
//            panel_width: 600,
//            panel_height: 300,
//            frame_width: 100,
//            frame_height: 100,
//            nav_theme: 'light',
//            fade_panels: true,
//            frame_gap: 5,
//            pause_on_hover:true
//           });

//          });

