function autoFireLightbox() 
{
	setTimeout(function() 
	{
		if(document.location.hash && $(document.location.hash.substr(1)).rel.indexOf('lightbox')!=-1) 
		{
			myLightbox.start($(document.location.hash.substr(1)));
		}
	},
		250
	);
}
//Event.observe(window, 'load', autoFireLightbox, false);


/*##########*/
/*   LOGIN  */
/*##########*/
function logg_inn()
{
	document.LOGIN.Submit1.disabled=true;
	var sMeld;
	sMeld = "";
	if (document.LOGIN.user.value == "")
	{sMeld = sMeld + "- Brukernavn må fylles ut.\n";}
	if (document.LOGIN.password.value == "")
	{sMeld = sMeld + "- Passord må fylles ut.\n";}

	if (sMeld == "")
	{
		document.LOGIN.CMD.value="LOGIN";
		document.LOGIN.submit();
	}
	else
	{
		alert(sMeld);
		document.LOGIN.Submit1.disabled=false;
	}
}

function getPassword()
{
	// disable button
	document.FORGOT_PASSWORD.Submit2.disabled = true;

	var sMeld;
	sMeld = "";
	if (document.FORGOT_PASSWORD.email.value == "")
	{sMeld = sMeld + "- E-post må fylles ut.\n";}

	if (sMeld == "")
	{
		document.FORGOT_PASSWORD.CMD.value="GETPASSWORD";
		document.FORGOT_PASSWORD.submit();
	}
	else
	{
		alert(sMeld);
		// button
		document.FORGOT_PASSWORD.Submit2.disabled = false;
	}
}
function viewForgotPassword()
{
	document.getElementById("div_login_box").style.display = "none";
	document.getElementById("div_forgotpassword_box").style.display = "block";
}
/*   END LOGIN  */


/*##########*/
/*   OTHER  */
/*##########*/

/* new on mouse over function */
function over (obj){
	obj.className=obj.className+'_over';
}

/* new on mouse out function */
function out (obj){
	var str=obj.className;
	var pos=str.indexOf("_over")
	obj.className=str.substr(0,pos);
}

// Function that executes function inside input string when enter is pressed.
function doKey(sFunc) {
	if (document.all) {
		whichASC = event.keyCode;
		if(whichASC==13){
			eval(sFunc);
		}       
	}
}

// check search string
function aSearch(){
	if (document.FORM_SEARCH.search.value==''){
		alert('Søkeordet ditt er for kort.');
	}
	else{
		document.FORM_SEARCH.submit();
	}
}


function shareFacebook(strArtUrl,strArtTitle)
{
  var tmpUrl = encodeURIComponent(strArtUrl);
  var tmpTitle = encodeURIComponent(strArtTitle);
  window.open("http://www.facebook.com/sharer.php?u=" + tmpUrl + "&t=" + tmpTitle, "Facebook", "width=645,height=436,location=0,menubar=0,resizabl=1,scrollbars=0,status=0,toolbar=0");
}

/* Function for sharing an article on Nettby */
function shareNettby(strArtUrl,strArtTitle)
{
  var tmpUrl = encodeURIComponent(strArtUrl);
  var tmpTitle = encodeURIComponent(strArtTitle);
  window.open("http://www.nettby.no/user/edit_link.php?name=" + tmpTitle + "&url=" + tmpUrl + "&description=", "Nettby", "width=450,height=430,location=0,menubar=0,resizabl=1,scrollbars=0,status=0,toolbar=0");
}

function shareTwitter(strTitle){
  var tmpUrl = ('http://twitter.com/home?status=Sjekk denne: ' + strTitle).replace('&', '%26');

  window.open(tmpUrl, "Twitter", "width=800,height=430,location=0,menubar=0,resizablE=1,scrollbars=0,status=0,toolbar=0");
}