

// CSS init (c) Agents.se - v3.3

/*

CSS Browser Selector v0.3.5 (Feb 05, 2010)

Rafael Lima (http://rafael.adm.br)

http://rafael.adm.br/css_browser_selector

License: http://creativecommons.org/licenses/by/2.5/

Contributors: http://rafael.adm.br/css_browser_selector#contributors

*/

function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);



// No spam e-mail address v2

function noSpam(a,b,c,d) {

	if (d==null) {

		d = c+'@'+b+'.'+a;

	}

	document.write('<a href="mai'+'lto:'+c+'@'+b+'.'+a+'" class="sticky">'+d+'</a>');

}



// Go to url

function go(a) {

	document.location.href = a;

}



// Validate form v3

var regEml = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;

var regDrp = /[^0]/i;

var fvalid = true;

function validate(a,b,c,e,d) {

	if (e.keyCode != 9 || e.keyCode == null) { // Don't run on tab key

		switch (b) {

			case "txt": a.value.length >= c ? g=1 : g=0; break;

			case "eml": a.value.match(regEml) ? g=1 : g=0; break;

			case "drp":	a.value.match(regDrp) ? g=1 : g=0; break;

			case "rad":	a.checked ? g=1 : g=0; break;

		}

		h = "s"+a.id;

		f = document.getElementById(h);

		g ? f.className = "fsignok" : f.className = "fsignalert";

		if (!g) {

			d ? d = d : d = "Invalid field";

			$("#"+h).html('<span class="tooltip" title="!'+d+'">&nbsp;</span>');

			tooltip();

			fvalid = false;

		} else {

			$("#"+h).html("");

		}

		return true;

	}

}

function formgo(a) {

	fvalid = true;

	$("#"+a+" input, #"+a+" select, #"+a+" textarea").each(function(i) {	// Revalidate form

		var b = String($(this).attr("onblur")).split(",");

		if (b[0].indexOf("validate") != -1) {

			b[4].charAt(0) == " " ? c = 2 : c = 1; // FF comp.

			validate(this,b[1].slice(-4,-1),b[2],a,b[4].slice(c,b[4].length-5));

		}

	});

	if (!fvalid) {

		$("#"+a+"_notice").html('<ul class="alert"><li>Alla obligatoriska fält måste fyllas i.</li></ul>');

		$("#"+a+"_notice").hide().slideDown(200,"jswing");

		return false;

	} else {

		$("#form_return").val(a);

		$("#form1").attr("action",$("#form1").attr("action")+"#"+a);

		document.forms[a].submit();

		return false;

	}

}



// Jquery easeing

jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,

{

	def: 'easeInOutExpo',

	swing: function (x, t, b, c, d) {

		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);

	},

	easeInOutExpo: function (x, t, b, c, d) {

		if (t==0) return b;

		if (t==d) return b+c;

		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;

		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;

	},

	easeInOutCubic: function (x, t, b, c, d) {

		if ((t/=d/2) < 1) return c/2*t*t*t + b;

		return c/2*((t-=2)*t*t + 2) + b;

	}

});



// jQuery setup on page load

$(document).ready(function() {

	autoblur();

	tooltip();

});

function autoblur() {

	$(".fwrap input, .fwrap2 input, .fwrap3 input, .fwrap4 input").click(function() {

		this.blur();

	});

	$("select").change(function() {

		$(this).blur();

	});

}



// Tooltip v2

this.tooltip = function(){

	$("span.tooltip").unbind();

	$("span.tooltip").hover(function(e){

		t = this.title;

		this.title = "";

		if (t.charAt(0) == "!") {

			b = t.substring(1);

			$("body").append("<div id='tooltip'>"+ b +"</div>");

			$("#tooltip").css("background","#e60000");

		} else {

			$("body").append("<div id='tooltip'>"+ t +"</div>");

		}

		$("#tooltip")

			.css("top",(e.pageY - 10) + "px")

			.css("left",(e.pageX + 20) + "px")

			.show()

    },

		function(){

			this.title = t;

			$("#tooltip").remove();

    });

	$("span.tooltip").mousemove(function(e){

		$("#tooltip")

			.css("top",(e.pageY - 10) + "px")

			.css("left",(e.pageX + 20) + "px");

	});

}



// Toggle div

function toggle(a,b) {

	if ($("#"+a).is(":hidden")) {

		$("#"+a).slideDown(1000);

		scrollPage(a,b);

	} else {

		$("#"+a).slideUp(800);

	}

	return false;

}

function scrollPage(a,b) {

	if($.browser.safari){bodyelem=$("body")}else{bodyelem=$("html")}

	d = ($("#"+a).offset().top+b)-($(window).height()+bodyelem.scrollTop());

	if (d>30)

	$("html, body").animate({scrollTop:"+="+d+"px"}, 1000);

}



// Show contact

function showcontact(a,b) {

	if (!doubletap) {

		doubletap++;

		setTimeout("dtap()",200);

		if ($("#cme_regarding").val() != "") {

			$(".infobox").slideUp(1000);

			$("#"+a+"2").slideDown(1000);

			scrollPage(a,b);

		} else {

			$(".infobox").slideDown(1000);

			$("#"+a+"2").slideUp(1000);

		}

	}

}



var doubletap = 0;

function dtap() {

	doubletap = 0;

}
