function meddelaAvtalskund(x, namn)
{
	if (x == 1)
	{
		alert(getPhrase("avtalskund_js_loggedin",""));
	}
	if (x == 2)
	{
		alert(getPhrase("avtalskund_js_loggedout",""));
	}
}

function goToURL(x)
{
	this.location.href=x;
}

function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

function sokRutaFocus(x)
{
	var sokrutadefault = document.getElementById("sokrutadefault").value;
	if (x.value==sokrutadefault)
	{
		x.value='';
		x.style.color='#000000';
	}
}

function sokRutaBlur(x)
{
	var sokrutadefault = document.getElementById("sokrutadefault").value;
	if (x.value=='')
	{
		x.value=sokrutadefault;
		x.style.color='#adadad';
	}
}


function nyhetsbrevRutaFocus(x)
{
	var sokrutadefault = document.getElementById("nyhetsbrevrutadefault").value;
	if (x.value==sokrutadefault)
	{
		x.value='';
		x.style.color='#000000';
	}
}

function nyhetsbrevRutaBlur(x)
{
	var sokrutadefault = document.getElementById("nyhetsbrevrutadefault").value;
	if (x.value=='')
	{
		x.value=sokrutadefault;
		x.style.color='#adadad';
	}
}

var cX = 0;
var cY = 0;
var rX = 0;
var rY = 0;
 
function UpdateCursorPosition(e){
        cX = e.pageX;
        cY = e.pageY;
}
 
function UpdateCursorPositionDocAll(e){
        cX = event.clientX;
        cY = event.clientY;
}
 
if(document.all) {
        document.onmousemove = UpdateCursorPositionDocAll;
} else {
        document.onmousemove = UpdateCursorPosition;
}

function HideContent(d) {
	document.getElementById(d).style.display = "none";
}
 
function ShowContent(d,p) {
	var dd = document.getElementById(d);
        AssignPosition(dd,p);
        dd.style.display = "block";
}

function AssignPosition(d,p) {
if(self.pageYOffset) {
        rX = self.pageXOffset;
        rY = self.pageYOffset;
} else if(document.documentElement && document.documentElement.scrollTop) {
        rX = document.documentElement.scrollLeft;
        rY = document.documentElement.scrollTop;
} else if(document.body) {
        rX = document.body.scrollLeft;
        rY = document.body.scrollTop;
}
 
if(document.all) {
        cX += rX;
        cY += rY;
}
 
if(p == "top") {
        d.style.left = (cX-150) + "px";
        d.style.top = (cY-340) + "px";
} else if(p == "topright") {
        d.style.left = (cX+10) + "px";
        d.style.top = (cY-320) + "px";
} else if(p == "right") {
        d.style.left = (cX+30) + "px";
        d.style.top = (cY-145) + "px";
} else if(p == "bottomright") {
        d.style.left = (cX+30) + "px";
        d.style.top = (cY-0) + "px";
} else if(p == "bottom") {
        d.style.left = (cX-145) + "px";
        d.style.top = (cY+30) + "px";
} else if(p == "bottomleft") {
        d.style.left = (cX-305) + "px";
        d.style.top = (cY+30) + "px";
} else if(p == "left") {
        d.style.left = (cX-340) + "px";
        d.style.top = (cY-145) + "px";
} else if(p == "topleft") {
        d.style.left = (cX-305) + "px";
        d.style.top = (cY-340) + "px";
} else if(p == "custom") {
        d.style.left = "" + "px";
        d.style.top = "" + "px";
}
 
}

var tipsaVanta = false;

function tipsaRutaSubmit(f)
{
	if (tipsaVanta)
	{
		return false;
	}
	
	var e1 = f.kompis.value;
	var e2 = f.epost.value;
	
	if (tipsaCheckEmail(e1) == false || tipsaCheckEmail(e2) == false)
	{
		alert("Du måste ange både din och din kompis e-postadress.");
		return false;
	}
	
	if (f.namn.value.length==0)
	{
		alert("Du måste ange din kompis namn.");
		return false;
	}
	
	tipsaVanta = true;
	setTimeout("tipsaVanta = false", 2000);
	
	$.ajax(
	{
		url:"/tipsaruta.asp",
		type:"POST",
		dataType:"text",
		data:
		{
			"kompis" : e1,
			"namn" : f.namn.value,
			"url" : f.url.value,
			"flera" : f.flera.value,
			"produkt" : f.produkt.value
		},
		success: function(data)
		{
			f.kompis.value="";
			f.epost.value="";
			f.namn.value="";
			
			$("#tipsastatus").show().html("E-post skickat!");
			setTimeout('$("#tipsastatus").fadeOut()', 2000);
		}
	});
	
	return false;
}

function tipsaCheckEmail(x)
{
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(x);
}
