function validate_cmslogin(form) {
	var f = form;
	if(f.email.value == "") {
	 	alert("Vennligst skriv inn ditt brukernavn.");
		f.email.focus();
		return false;
	} else if(f.password.value == "") {
 		alert("Vennligst skriv inn ditt passord.");
		f.password.focus();
		return false;
	}
	urchinTracker('/login/cms');
	return true;
}
function validate_maillogin(form) {
	var g = form;
	if(g._user.value == "") {
 		alert("Vennligst skriv inn ditt brukernavn.");
		g._user.focus();
		return false;
	} else if(g._pass.value == "") {
 		alert("Vennligst skriv inn ditt passord.");
		g._pass.focus();
		return false;
	}
	urchinTracker('/login/webmail');
	return true;
}

function change_login_choice(elem){
	if (elem == '1'){
		document.getElementById('logintab1').style.display = 'block';
		document.getElementById('logintab2').style.display = 'none';
	} else if (elem == '2'){
		document.getElementById('logintab1').style.display = 'none';
		document.getElementById('logintab2').style.display = 'block';
	}
}

// use these to fix select boxes in IE. Used in webshop -> products that got variants. onblur onfocus
function expandSELECT(sel) {
  sel.style.width = '';
}
function contractSELECT(sel) {
  sel.style.width = '180px';
}

function toggle_comments(c) {
	obj=document.getElementById(c);
	visible=(obj.style.display!="none")
		
	if (visible) {
	 obj.style.display="none";
	} else {
	  obj.style.display="block";
	}
}

function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function show_large(n) {
		var pos = "center";
		var w = 620;
		var h = 600;
		if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
		else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
		window.open("/picture.php?p=" + n,"sample","height=" + h + ",width=" + w + ",top=" +TopPosition+",left="+LeftPosition+",status=no,location=no,toolbar=no,directories=no,scrollbars=1,menubar=no,resizable");
	}
	
function net17025_validate_sok(form) {
	if( (form.type.value == "0") && (form.customer.value == "0") && (form.str.value == "") ) {
		alert("Du må spesifisere søket");
	} else {
		form.dosearch.value = "1";	
		form.submit();
	}
}

function page_search() {
	var form = document.form_page_search;
	if(form.str.value == "") {
		alert("Du må skrive inn et søkeord");
	} else {
		form.submit();
	}	
	
}
function popup_pic (src){
	document.getElementById('overlay_img').src = src;
	var objImagePreloader = new Image();
	objImagePreloader.src = src;
	var i = 0;
	// Get page sizes
	var arrPageSizes = ___getPageSize();
	// Get page scroll
	var arrPageScroll = ___getPageScroll();
	// Calculate top and left offset for the jquery-lightbox div object and show it
	document.getElementById('waxpadhangerwaxpadautoid1').style.width = arrPageSizes[0]+'px';
	document.getElementById('waxpadhangerwaxpadautoid1').style.height = arrPageSizes[1]+'px';
	document.getElementById('waxpadvertseedwaxpadautoid1').style.top =  arrPageScroll[1] + (arrPageSizes[3] / 10)+'px';
	document.getElementById('waxpadvertseedwaxpadautoid1').style.left =	arrPageScroll[0]+'px';
	document.getElementById('waxpadvertseedwaxpadautoid1').style.width = arrPageSizes[0]+'px';
	document.getElementById('waxpadhangerwaxpadautoid1').style.display = 'block';
	document.getElementById('waxpadvertseedwaxpadautoid1').style.display = 'block';
}

/**
/ THIRD FUNCTION
* getPageSize() by quirksmode.com
*
* @return Array Return an array with page width, height and window width, height
*/
function ___getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
};

/**
/ THIRD FUNCTION
* getPageScroll() by quirksmode.com
*
* @return Array Return an array with x,y page scroll values.
*/
function ___getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
};

function filterFileType(field, ext) {
if (field.value.indexOf('.' + ext) == -1) {
	return false;
}
	return true;
}


function validate_guestbook() {
	var form;
	form = document.form_guestbook;
	if(form.author.value == "") {
		alert("Du må skrive inn ditt navn");
		form.author.focus();
		return false;
	} else if (form.title.value == "") {
		alert("Du må skrive inn en tittel");
		form.title.focus();
		return false;
	} else if (tinyMCE.getContent() == "") {
		alert("Du må skrive inn en melding");
		form.comment.focus();
		return false;
	} else if (form.userdigit.value == "") {
		alert("Du må skrive inn en kode");
		form.userdigit.focus();
		return false;
	} else {
		form.submit();	
	}
}

function validate_comments() {
	var form;
	form = document.form_comments;
	if(form.author.value == "") {
		alert("Du må skrive inn ditt navn");
		form.author.focus();
		return false;
	} else if (form.comment.value == "") {
		alert("Du må skrive inn en kommentar");
		form.comment.focus();
		return false;
	} else if (form.userdigit.value == "") {
		alert("Du må skrive inn en kode");
		form.userdigit.focus();
		return false;
	} else {
		form.submit();	
	}
}

function validate_comments_blogg(n) {
	var form;
	form = document.getElementById("form_comments" + n);

	if(form.author.value == "") {
		alert("Du må skrive inn ditt navn");
		form.author.focus();
		return false;
	} else if (form.comment.value == "") {
		alert("Du må skrive inn en kommentar");
		form.comment.focus();
		return false;
	} else if (form.userdigit.value == "") {
		alert("Du må skrive inn en kode");
		form.userdigit.focus();
		return false;
	} else {
		form.submit();	
	}
}

function jump_blog(targ,selObj,restore,cid,loc){ //v3.0
	if(selObj.options[selObj.selectedIndex].value != 0) {
	  eval(targ+".location='"+loc+"/index.php?cid=" +cid +"&entry="+selObj.options[selObj.selectedIndex].value+"'");
	}
}

function shareFacebook(strArtUrl,strArtTitle){
	var tmpUrl = encodeURIComponent(strArtUrl);
	var tmpTitle = encodeURIComponent(strArtTitle);
	window.open("http://www.facebook.com/sharer.php?t=" + tmpTitle + "&u=" + tmpUrl, "Facebook", "width=645,height=436,location=0,menubar=0,resizabl=1,scrollbars=0,status=0,toolbar=0");
}
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 search_blog() {
	if((document.form_page_searchblog.search.value != "") && (document.form_page_searchblog.search.value != "Søk")) {
		document.form_page_searchblog.submit();	
	}
}
