
jQuery.fn.center = function (absolute) {
    return this.each(function () {
        var t = jQuery(this);

        t.css({
            position:    absolute ? 'absolute' : 'fixed', 
            left:        '50%', 
            top:        '50%', 
            zIndex:        '99'
        }).css({
            marginLeft:    '-' + (t.outerWidth() / 2) + 'px', 
            marginTop:    '-' + (t.outerHeight() / 2) + 'px'
        });

        if (absolute) {
            t.css({
                marginTop:    parseInt(t.css('marginTop'), 10) + jQuery(window).scrollTop(), 
                marginLeft:    parseInt(t.css('marginLeft'), 10) + jQuery(window).scrollLeft()
            });
        }
    });
};




// Sätt in magisk kod här: 
$(document).ready(function() {
	
	$("ul.medarbetarlista li:nth-child(4n)").addClass('fixer');
	
	
        $('ul.medarbetarlista li h3').each(function() {
            var h = $(this).html();
            var index = h.indexOf(' ');
            if(index == -1) {
                index = h.length;
            }
            $(this).html('' + h.substring(0, index) + '<br/>' + h.substring(index, h.length));
        });	
$("ul.faq li").click(function(event){
var currentq = $(this).children('.faq-svar');
if (currentq.is(":hidden")) {
$(this).children('.faq-svar').slideDown(400, "easeInCirc");
$('ul.faq li').removeClass('highlight');
$(this).addClass('highlight');
} else {
$(this).children('.faq-svar').slideUp(400, "easeOutCirc");
$('ul.faq li').removeClass('highlight');
}
event.preventDefault();
});

$('.menu ul li a.top').hover(function(){
$(this).addClass("hovermatrix");
},function () {
$(this).removeClass("hovermatrix");
});


$('.bread a#b').hover(function(){
$(this).addClass('b2');
},function () {
$(this).removeClass("b2");
});
$('.bread a#r').hover(function(){
$(this).addClass('r2');
},function () {
$(this).removeClass("r2");
});
$('.bread a#o').hover(function(){
$(this).addClass('o2');
},function () {
$(this).removeClass("o2");
});
$('.bread a#g').hover(function(){
$(this).addClass('g2');
},function () {
$(this).removeClass("g2");
});


$('.fade').delay(800).fadeIn('slow');
$('img.bild2').delay(400).fadeIn('slow');

$("input.namn").attr("value", "förnamn");
var text1 = "förnamn";
$("input.namn").focus(function() {
$(this).addClass("active");
if($(this).attr("value") == text1) $(this).attr("value", "");
});
$("input.namn").blur(function() {
$(this).removeClass("active");
if($(this).attr("value") == "") $(this).attr("value", text1);
});

$("input.efternamn").attr("value", "efternamn");
var text2 = "efternamn";
$("input.efternamn").focus(function() {
$(this).addClass("active");
if($(this).attr("value") == text2) $(this).attr("value", "");
});
$("input.efternamn").blur(function() {
$(this).removeClass("active");
if($(this).attr("value") == "") $(this).attr("value", text2);
});

$("input.epost").attr("value", "epost");
var text3 = "epost";
$("input.epost").focus(function() {
$(this).addClass("active");
if($(this).attr("value") == text3) $(this).attr("value", "");
});
$("input.epost").blur(function() {
$(this).removeClass("active");
if($(this).attr("value") == "") $(this).attr("value", text3);
});

$("input.foretag").attr("value", "företag");
var text4 = "företag";
$("input.foretag").focus(function() {
$(this).addClass("active");
if($(this).attr("value") == text4) $(this).attr("value", "");
});
$("input.foretag").blur(function() {
$(this).removeClass("active");
if($(this).attr("value") == "") $(this).attr("value", text4);
});

$("textarea.offert").attr("value", "förfrågan");
var text5 = "förfrågan";
$("textarea.offert").focus(function() {
$(this).addClass("active");
if($(this).attr("value") == text5) $(this).attr("value", "");
});
$("textarea.offert").blur(function() {
$(this).removeClass("active");
if($(this).attr("value") == "") $(this).attr("value", text5);
});



/* $("ul.medarbetarlista li:nth-child(4n)").css("margin-right", "0");  */

//niklas h4xx kod

$('ul#faq li').click(function(event){
	var currentq = $(this).children('.theAnswer');
	
	if (currentq.is(':hidden')) {
	
		$(this).children('.theAnswer').slideDown(100);
		} else {
		$(this).children('.theAnswer').slideUp(100);
		}
		
		event.preventDefault();
	});


$('ul#stepsnav li a').click(function(e){
	var currentStep = $(this).attr('id');
	e.preventDefault();
	
	if(currentStep == 'nr1'){
		$('.slidewrap ul').stop().animate({'marginLeft':'0px'});
	} else if (currentStep == 'nr2'){
		$('.slidewrap ul').stop().animate({'marginLeft':'-400px'});
	} else if (currentStep == 'nr3'){
		$('.slidewrap ul').stop().animate({'marginLeft':'-800px'});
	} else if (currentStep == 'nr4'){
		$('.slidewrap ul').stop().animate({'marginLeft':'-1200px'});
	} else if (currentStep == 'nr5'){
		$('.slidewrap ul').stop().animate({'marginLeft':'-1600px'});
	} else if (currentStep == 'nr6'){
		$('.slidewrap ul').stop().animate({'marginLeft':'-2000px'});
	}
});


});
/*
var tid;
jQuery(function($) {
tid = setTimeout(knapp, 0);
});
function knapp() {
$("a.ansok-nu img").animate({width: 170, height: 170 }, 2000, "easeOutSine",  function() {
$("a.ansok-nu img").animate({width: 179, height: 179}, 2000 , "easeInSine");	
tid = setTimeout(knapp, 0);
});
}
 */
