function closeSearchInfo() {
document.getElementById("searchinfo").style.display="none"; 
}
function openSearchInfo() {
document.getElementById("searchinfo").style.display="block"; 
}


function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}



function print_this()
{
	window.print();
	return true;
}

function fbs_click() 
{
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}



function check_number(thisvalue)
{
	thisvalue=new String(thisvalue);
	if (thisvalue.indexOf(",")!=-1)
	{
		alert("Det måste vara ett riktigt värde i fältet. Som öresavskiljare används '.'.");
		return false;
	}
	if (isNaN(thisvalue))
	{
		alert("Det måste vara ett riktigt värde i fältet.");
		return false;
	}
	return true;
}


function delete_confirm(this_obj,this_form)
{
	if (confirm("Vill du ta bort '"+this_obj+"' ?"))
		this_form.submit();
}



function new_confirm(href)
{
	if (confirm("Vill du skapa ett nytt objekt?"))
		window.location.href(href);

}



function update_confirm(this_obj)
{
	if (confirm("Vill du uppdatera objekt "+this_obj+"?"))
		document.forms.frm_admnews.submit();

}


function check_subscribe()
{

	with (document.forms.frm_subscribe)
	{
		if (check_emailaddress(subscribe_email.value))
		{
			alert("Tack för anmälan.\n\nEn bekräftelse har skickats till din mailadress "+subscribe_email.value);
			submit();
		}
	}
}

function check_emailthis()
{

	with (document.forms.frm_emailthis)
	{
		if (check_emailaddress(emailthis_sendto.value))
		{
			if (check_emailaddress(emailthis_sendfromemail.value))
			{
				submit();
			}
		}
	}
}

function check_login()
{

	with (document.forms.login_check)
	{
		if (login_uname.value!="" && login_pwd.value!="")
			submit();
		else
			alert("Ange både username och password");
	}
}

function check_subscribe2()
{
	alert("Vill du prenumerera på nyhetsbrevet, mata in din emailadress och klicka på länken <Prenumerera>");
	return(false);
}

function check_order()
{
	var res=true;

	with (document.forms.pay_check)
	{


		if (pay_firstname.value=="")
		{
			alert("Var vänlig och fyll i ditt förnamn");
			res=false;
		}

		if (res && pay_lastname.value=="")
		{
			alert("Var vänlig och fyll i ditt efternamn");
			res=false;
		}

		if (res && pay_address1.value=="")
		{
			alert("Var vänlig och fyll i din adress");
			res=false;
		}

		if (res && pay_postalcode.value=="")
		{
			alert("Var vänlig och fyll i ditt postnummer");
			res=false;
		}
/*
		else
		{
			if (res)
			{
			at_str = pay_postalcode.value;
			pos = at_str.length;
			if (pos!=5)
			{	
				alert("Du måste ange ett korrekt postnummer med 5 siffror utan mellanslag.");
				res=false;
			}
			
			if (res)
			{
			while (pos>0)
			{		
				pos--;
				thischar = at_str.charAt(pos);
				if (thischar<'0' || thischar>'9')
				{
					alert("Du måste ange ett korrekt postnummer utan bokstäver.");
					res=false;
				}
			}
			}
			}	
		}
*/
		if (res && pay_city.value=="")
		{
			alert("Var vänlig och fyll i din hemstad");
			res=false;
		}

		if (res && pay_email.value=="")
		{
			alert("Var vänlig och fyll i din emailadress");
			res=false;
		}
		else
		{
			if (res && !check_emailaddress(pay_email.value))
				res=false;

		}
		if (res && pay_email_conf.value=="")
		{
			alert("Var vänlig och konfirmera din emailadress");
			res=false;
		}
		else
		{
			if (res && !check_emailaddress(pay_email_conf.value))
				res=false;

		}
		if (res && pay_email_conf.value!=pay_email.value)
		{
			alert("Emailadresserna är olika. Vänligen ändra.");
			res=false;
		}
		if (res)
			submit();	
	}
}




function check_emailaddress(address)
{
	pos = address.indexOf("@");
	if (pos==-1)
	{		
		alert("Du måste ange en korrekt emailadress");
		return(false);
	}
	pos = address.indexOf(".",pos);
	if (pos==-1)
	{		
		alert("Du måste ange en korrekt emailadress");
		return(false);
	}
	pos = address.indexOf(",",pos);
	if (pos>=0)
	{		
		alert("Du måste ange en korrekt emailadress");
		return(false);
	}
	return(true);

}

function check_blog_comment()
{
	var res=true;

	with (document.forms.frm_blogcomment)
	{


		if (blog_comment.value=="")
		{
			alert("Var vänlig och fyll i en kommentar innan du skickar");
			res=false;
		}

		if (res && blog_comment_author.value=="")
		{
			alert("Var vänlig och fyll i ditt namn innan du skickar");
			res=false;
		}

		if (res && blog_comment_email.value=="")
		{
			alert("Var vänlig och fyll i din emailadress");
			res=false;
		}
		else
		{
			if (res && !check_emailaddress(blog_comment_email.value))
				res=false;

		}
		if (res && bca.value=="")
		{
			alert("Var vänlig och fyll i koden innan du skickar");
			res=false;
		}

		if (res)
			submit();	
	}
}




function newWin(x,y,urlLoc) {
  _winName = "popup";
  _info  = "toolbar=no";      // yes|no 
  _info += ",location=no";    // yes|no 
  _info += ",directories=no"; // yes|no 
  _info += ",status=no";     // yes|no 
  _info += ",menubar=no";     // yes|no 
  _info += ",scrollbars=yes"; // yes|no 
  _info += ",resizable=no";  // yes|no 
  _info += ",dependent";      // close the parent, close the popup, omit if you want otherwise 
  _info += ",height="+y;
  _info += ",width="+x;

  DispWin=window.open(urlLoc,_winName,_info);
} 

