
// Flash and CSS init (c) Agents.se - v3.0

var flashver = deconcept.SWFObjectUtil.getPlayerVersion()['major'];

// CSS Browser Selector   v0.2.3
// Documentation:         http://rafael.adm.br/css_browser_selector
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)) ? ((is('mac') ? 'ieMac ' : '') + 'ie ie' + RegExp.$1)
			: is('gecko/') ? 'gecko' : is('opera') ? 'opera' : is('konqueror') ? 'konqueror' : is('applewebkit/') ? 'webkit safari' : is('mozilla/') ? 'gecko' : '',
		os = (is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : 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();
}

// Open window (Old - not to be used)
function openWindow(site,name,left,top,width,height,scroll,toolbar,menubar) {
	if (left=="middle") {
		var varx = ((window.screen.width/2) - (width/2))-12;
	} else {
		var varx = left;
	}
	if (top=="middle") {
		var vary = ((window.screen.height/2) - (height/2));
	} else {
		var vary = top;
	}
	window.open(site,name,"width="+width+",height="+height+",left="+varx+",top="+vary+",location=no,toolbar="+toolbar+",directories=no,status=no,scrollbars="+scroll+",resizable=no,copyhistory=no,menubar="+menubar);
}

function popmeup(a) {
	openWindow("pop_text.aspx?"+a,"popper","middle","middle","580","580","yes","no","no");
}
function printme(a) {
	openWindow("pop_print.aspx?"+a,"popperprint","middle","middle","580","580","yes","yes","yes");
}
function cancelbooking(a,b) {
	b = confirm(b);
	if (b) {
		document.location.href = "kundsidor_bokningar.aspx?"+a;
	}
}

// No spam e-mail address
function noSpam(a,b,c) {
	document.write('<a href="mai'+'lto:'+c+'@'+b+'.'+a+'">'+c+'@'+b+'.'+a+'</a>');
}

// Cloak password field v2
function cloakpass(a,b,c) {
	d = b.split(":").join("_");
	switch(a) {
		case 0:
			e = "<input name=" + b + " id=" + d + " type=\"text\" value=\"L&ouml;senord\" size=\"8\" class=\"fstyle6\" onfocus=\"cloakpass(1, this.name, this.form.name);\" />";
			cloakwrite(e);
		break;
		case 1:
			e = "<input name=" + b + " id=" + d + " type=\"password\" size=\"8\" class=\"fstyle6\" onblur=\"if(this.value==''){cloakpass(0, this.name, this.form.name);}\" />";
			cloakwrite(e);
			document[c][b].focus();	// Browser comp workaround
			document[c][b].select();
			document[c][b].focus();
			document[c][b].select();
			document[c][b].focus();
			document[c][b].select();
		break;
	}
}
function cloakwrite(a) {
//	if (check.b == "ie") {
//		document.all.pwfield.innerHTML = a;
//	} else {
	document.getElementById("pwfield").innerHTML = a;
//	}
}

// Go to url
var gourl = "";
function go() {
	document.location.href = gourl;
}
function url(a) {
	gourl = a;
	b = "";
	if (a) {
		b = "http://www.lexicon.se/";
	}
	window.status = b + a;
}

// Get mouse position
var mouseX, mouseY;
function getMousePos(e) {
	if (!e)
	var e = window.event||window.Event;
	if('undefined'!=typeof e.pageX) {
		mouseX = e.pageX;
		mouseY = e.pageY;
	} else {
		mouseX = e.clientX + document.documentElement.scrollLeft;
		mouseY = e.clientY + document.documentElement.scrollTop;
	}
}
if(window.Event && document.captureEvents)
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMousePos;

// Bildfråga markering
function markera() {
	a = document.getElementById("markering");
	b = document.getElementById("bild");
	var offsetx = offsety = 0;
	if (b.offsetParent) {
		offsetx = b.offsetLeft
		offsety = b.offsetTop
		while (b = b.offsetParent) {
			offsetx += b.offsetLeft
			offsety += b.offsetTop
		}
	}
	c = mouseX-offsetx;
	d = mouseY-offsety;
	a.style.left = c-3+"px";
	a.style.top = d-19+"px";
	a.style.display="block";
	document.Form1.mousex.value = c;
	document.Form1.mousey.value = d;
	return false;
}
