
// Flash and CSS init (c) Agents.se - v3.2

var flashver = swfobject.getFlashPlayerVersion();
/*
CSS Browser Selector v0.2.7 *Modified by The Agents
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
*/
var css_browser_selector = function() {
	var
		ua=navigator.userAgent.toLowerCase();
		is=function(t){return ua.indexOf(t) != -1;},
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1)
			:is('firefox/2')?'gecko ff2':is('firefox/3')?'gecko ff3':is('gecko/')?'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('nt 5')?' xp':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();

// Open window
var newWin = null;
function popMeUp(strURL,strType,strWidth,strHeight) {
	if (newWin != null){
		if(!newWin.closed) newWin.close();
	}
	var left=((window.screen.width/2)-(strWidth/2))-12;
	var top=((window.screen.height/2)-(strHeight/2));
	var strOptions="";
	if (strType=="console") strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth+",left="+left+",top="+top;
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth+",left="+left+",top="+top;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth+",left="+left+",top="+top;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
}

// 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+'">'+d+'</a>');
}

// Hide/Show 1 Div
function toggle(a) {
	b = document.getElementById(a).style;
	if (b.display=="none") {
		b.display="block";
	} else {
		b.display="none";
	}
	return false;
}

// Hide/Show 3 objects
function toggle3(a) {
	b = document.getElementById(a).style;
	c = document.getElementById(a+"H").style;
	d = document.getElementById(a+"H2").style;
	if (c.display=="none") {
		c.display="block";
		b.display="none";
		d.display="none";
	} else {
		b.display="block";
		d.display="block";
		c.display="none";
	}
}

// Tree
/*function tree(a,b) {
	if (a == "show") {
		$.ajax({
			type:"POST",
			url:"data_erbjudande.asp",
			data:"page="+b,
			cache:false,
			success:function(a){
				$("#"+b).replaceWith(a);
				$("#"+b+" div.cntnt").slideDown(400);
			}
		});
	} else {
		$("#"+b+" div.cntnt").slideUp(400,function() {
			$.ajax({
				type:"POST",
				url:"data_erbjudande.asp",
				data:"page="+b+"2",
				cache:false,
				success:function(a){
					$("#"+b).replaceWith(a);
				}
			});
		});
	}
	return false;
}
function moreDown(a) {
	$("#"+a+" .moreinfo").slideDown(400);
	return false;
}*/

// Validate form v1
var regEml = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
var regPst1 = /^\d{3}\ \d{2}$/;
var regPst2 = /^\d{5}$/;
var bgok = '#d4ec9f';
var bgerror = '#f5aaaa';

function validate (a,b,c,e) {
	if (e.keyCode != 9 || e.keyCode == null) { // Don't run on tab key
		if (b == "txt") {
			if (a.value.length >= c) a.style.background = bgok;
			else a.style.background = bgerror;
		} else if (b == "eml") {
			if (a.value.match(regEml)) a.style.background = bgok;
			else a.style.background = bgerror;
		} else if (b == "pst") {
			if (a.value.match(regPst1) || a.value.match(regPst2)) a.style.background = bgok;
			else a.style.background = bgerror;
		} else if (b == "drp") {
			if(a.value.length > 0) a.style.background = bgok;
			else a.style.background = bgerror;
		}
		return true;
	}
}

// Go Url
function url(a) {
	document.location.href = a;
}