// -----------------------------------------------------------------------------------------------------------
// RAM RUNT BILD-LÄNKAR
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function blured() {
for (a in document.links) document.links[a].onfocus = document.links[a].blur;
} if (document.all) {
document.onmousedown = blured;
}

// -----------------------------------------------------------------------------------------------------------
// POPUP RUTOR
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function PopWin(URLGO,Height,width) {
var winh = Height ;
var winw = width ;
var winl = (screen.width - winw) / 2;
var wint = (screen.height - winh) / 2;
winprops = 'height='+winh+',width='+winw+',top='+wint+',left='+winl+',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,unselectable=on'
  remote = window.open("","",winprops);
  remote.location.href = URLGO;
}

// -----------------------------------------------------------------------------------------------------------
// REGISTRERINGS VALIDATION
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function checkForm()
{
	if(document.form.anv.value == "")
	{
		alert('Du måste fylla i ett användarnamn.');
		document.form.anv.focus();
		return false;
	}	
	else if(document.form.psw.value == "")
	{
		alert('Du måste fylla i ett lösenord.');
		document.form.psw.focus();
		return false;
	}
	else if(document.form.psw2.value == "")
	{
		alert('Du måste repetera ditt lösenord.');
		document.form.psw2.focus();
		return false;
	}
	else if(document.form.psw.value != document.form.psw2.value)
	{
		alert('Lösenorden stämde inte överens.');
		document.form.psw2.focus();
		return false;
	}
	else if(document.form.mail.value == "")
	{
		alert('Du måste fylla i din email.');
		document.form.mail.focus();
		return false;
	}
	else if (!document.form.ruta.checked)
	{
		alert("Du måste acceptera avtalet.");
		document.form.ruta.focus();
		return false;
	}
	if(document.form.verifiering.value == "")
	{
		alert('Du måste fylla i verifierings koden.');
		document.form.verifiering.focus();
		return false;
	}
}


// -----------------------------------------------------------------------------------------------------------
// TEXTAREA FUNKTIONER
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

var list_prompt = "Please enter list item text. Press \"Cancel\" or leave text field empty to exit.";

function resize_text_area(dpixels)
{
	msgfield = (document.all) ? document.all.anv_text : document.forms['post']['anv_text'];

	var box = msgfield;	
	var cur_height = parseInt( box.style.height ) ? parseInt( box.style.height ) : 140;
	var new_height = cur_height + dpixels;

	if (new_height > 0) 
	{
		box.style.height = new_height + "px";
	}

}


function insert_text(open, close)
{
	msgfield = (document.all) ? document.all.anv_text : document.forms['post']['anv_text'];

	// IE support	
	if (document.selection && document.selection.createRange)
	{
		msgfield.focus();
		sel = document.selection.createRange();
		sel.text = open + sel.text + close;
		msgfield.focus();
	}

	// Moz support
	else if (msgfield.selectionStart || msgfield.selectionStart == '0')
	{
		var startPos = msgfield.selectionStart;
		var endPos = msgfield.selectionEnd;

		msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
		msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
		msgfield.focus();
	}

	// Fallback support for other browsers
	else
	{
		msgfield.value += open + close;
		msgfield.focus();
	}

	hide_poped_menu();

	return;
}
