﻿/// <reference path="jquery-1.3.2-vsdoc2.js" />

// Cufon
Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');

$(document).ready(function() {
    //sætter højde på bgOverlay div
    doOverlay();
    $("a.anchorLink").anchorAnimate();
});

$.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination},
									     { duration: 1500, easing: "easeOutQuart"},
//									     settings.speed,
									     function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}

jQuery(function($){
    var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
    $(document).keydown(function(e) {
        kkeys.push( e.keyCode );
        if ( kkeys.toString().indexOf( konami ) >= 0 ){
            $(document).unbind('keydown',arguments.callee);
        	$("#rain").fadeIn().load("/custom/rain.html");
        }
    });
});

function doOverlay() {
    $('#bgOverlayRest').height($(document).height()-256);
};

//box anim cases
function boxAnimOver(element) {
    $(document).ready(function() {
        $(".casesOverviewContent", element.parentNode).animate({ top: '-=38px' }, 350);
    });
}

function boxAnimOut(element) {
    $(document).ready(function() {
        $(".casesOverviewContent", element.parentNode).animate({ top: '+=38px' }, 350);
    });
}

function boxAnimLink(element) {
    $(document).ready(function() {
        var linkValue = $("a", element.parentNode).attr("href");
        if (linkValue != undefined || linkValue != null) {
            location.href = $("a", element.parentNode).attr("href");
        }
    });
}

// UL scanner
// Takes all UL that are found inside #contentRightContent and attache classes to every secound li.
$(document).ready(function() {
    $("#contentRightContent").find("ul").show(function() {

        if ($("li:first", this).hasClass("head")) {
            $("li:even", this).addClass("contentRightContentLiStyle_r2");
            $("li:odd", this).addClass("contentRightContentLiStyle_r1");
            $("li:first", this).removeClass("contentRightContentLiStyle_r2");
        }
        else {
            $("li:even", this).addClass("contentRightContentLiStyle_r1");
            $("li:odd", this).addClass("contentRightContentLiStyle_r2");
        }
        
    });
});
