

function doRegister()
{
	
	if(document.f_reg.fname.value.length < 2)
	{
		alert('Fyll i förnamn');
	}
	else if(document.f_reg.ename.value.length < 2)
	{
		alert('Fyll i efternamn');
	}
	else if(document.f_reg.adress.value.length < 3)
	{
		alert('Fyll i adress');
	}
	else if(document.f_reg.postnr.value.length < 5)
	{
		alert('Fyll i postnummer');
	}
	else if(document.f_reg.postort.value.length < 3)
	{
		alert('Fyll i postort');
	}
	else if(document.f_reg.telnr.value.length < 7)
	{
		alert('Fyll i telefon');
	}
	else if(!document.f_reg.email.value.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zAZ\-0-9]+\.)+[a-zA-Z]{2,}))$/))
	{
		alert('Det måste vara en fungerande e-postadress');
	}
	else if(!document.f_reg.passwd.value.match(/^\w{8,20}$/))
	{
		alert('Lösenordet måste innehålla minst 8 tecken, stora och små bokstäver och minst en siffra.');
	}
	else if(!document.f_reg.passwd.value.match(/[A-Z]/))
	{
		alert('Lösenordet saknar stor bokstav');
	}
	else if(!document.f_reg.passwd.value.match(/[a-z]/))
	{
		alert('Lösenordet saknar liten bokstav');
	}
	else if(!document.f_reg.passwd.value.match(/\d/))
	{
		alert('Lösenordet saknar siffra');
	}
	else if(document.f_reg.passwd.value != document.f_reg.confp.value)
	{
		alert('Lösenord och Bekräfta lösenord måste stämma överens.');
	}
	else
	{
		document.f_reg.submit();
	}

}

function doLogin()
{
	if(document.f_login.xemail.value.length < 3)
	{
		alert('Fyll i e-postadress');
	}
	else if(document.f_login.xpasswd.value.length < 4)
	{
		alert('Ange lösenord');
	}
	else
	{
		document.f_login.submit();
	}

}

function doSendPasswd()
{
	if(!document.f_psend.email.value.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zAZ\-0-9]+\.)+[a-zA-Z]{2,}))$/))
	{
		alert('Ange e-postadress');
	}
	else
	{
		document.f_psend.submit();
	}

}

function toggle(div_id)
{
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}

function blanket_size(popUpDivVar)
{
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	
	// pos height
	if (typeof window.innerHeight != 'undefined') // Non-IE
	{
		windowHeight = window.innerHeight;
	}
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) // IE 6+ in 'standards compliant mode'
	{
		windowHeight = document.documentElement.clientHeight;
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) // IE 4 compatible
	{
		windowHeight = document.body.clientHeight;
	}

	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	var popBoxHeight = popUpDiv.style.pixelHeight;
	popBoxHeight = 420;
	popUpDiv_height=(windowHeight/2)-(popBoxHeight/2);
	if (popUpDiv_height < 2)
	{
		popUpDiv_height = 2;
	}
	popUpDiv.style.top = popUpDiv_height + 'px';
}

function window_pos(popUpDivVar)
{
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	
	// pos width
	if (typeof window.innerWidth != 'undefined') // Non-IE
	{
		windowWidth = window.innerWidth;
	}
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) // IE 6+ in 'standards compliant mode'
	{
		windowWidth = document.documentElement.clientWidth;
	}
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) // IE 4 compatible
	{
		windowWidth = document.body.clientWidth;
	}

	var popUpDiv = document.getElementById(popUpDivVar);
	var popUpDiv = document.getElementById(popUpDivVar);
	var popBoxWidth = popUpDiv.style.pixelWidth;
	popBoxWidth = 400;
	window_width=(windowWidth/2.2)-(popBoxWidth/2);
	popUpDiv.style.left = window_width + 'px';
}

function popup(windowname)
{
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

