// Tipsa en vän

function Tipsa(bild) {
	
			var myWidth = 0, myHeight = 0;
			if( typeof( window.innerWidth ) == 'number' ) {

				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
			}
			myWidth = (myWidth/2)-275;
			myHeight = (myHeight/2)-200;
			props = window.open('collection/tipsmail.php?id='+bild, 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=550, height=400, left = '+myWidth+', top ='+myHeight);
		} 
		
function Zoom(bild,bredd,hojd) {
			var myWidth = 0, myHeight = 0;
			if( typeof( window.innerWidth ) == 'number' ) {

				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
			}

			hojd = hojd + 120;
			marginleft = Math.round((myWidth/2)-(bredd/2));
			margintop = Math.round((myHeight/2)-(hojd/2));
			if(margintop<0) {
				margintop = 20;
			}
			props = window.open('collection/zoom.php?id='+bild, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width='+(bredd+20)+', height='+hojd+', left ='+marginleft+', top = '+margintop);
		} 
		
function validate_epost()
{
var error="";
var emailFilter=/^.+@.+\..{2,3}$/;
var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
var input = document.getElementById('mtgrns_epost');
var error_msg = document.getElementById('error_epost');
if ((illegalChars.test(input.value)) || !(emailFilter.test(input.value))) {
	error_msg.style.display="block";
	error = "Fyll i en korrekt epost adress.\n";
	}
else 	{
		error_msg.style.display="none";
		error = "";
		}
return error;
}

function validate_namn(input)
{
var error="";
var illegalCharsLogin = /[^a-zåäöA-ZÅÄÖ\s]/;
var input = document.getElementById('mtgrns_namn');
var error_msg = document.getElementById('error_mtgrnamn');
if ((input.value.length < 2) || (illegalCharsLogin.test(input.value))) {
			error_msg.style.display="block";
			error = "Fyll i mottagarens namn.\n";
	 		}
		
else		{
			error_msg.style.display="none";
			error = "";
			}
return error;
}

function validate_namn2()
{
var error="";
var illegalCharsLogin = /[^a-zåäöA-ZÅÄÖ\s]/;
var input = document.getElementById('namn');
var error_msg = document.getElementById('error_namn');
if ((input.value.length < 2) || (illegalCharsLogin.test(input.value))) {
			error_msg.style.display="block";
			error = "Fyll i ditt namn.\n";
	 		}
		
else		{
			error_msg.style.display="none";
			error = "";
			}
return error;
}

function validate_form(theForm)
{
    var why = "";
    why += validate_namn(theForm.namn.value);
	why += validate_namn2(theForm.mtgrns_namn.value);
	why += validate_epost(theForm.mtgrns_epost.value);

    if (why != "") {
       return false;
    }
return true;
}

function show()
{
	document.getElementById('rules').style.display="block";
}
