function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function checkOffsetWidth() {
	if (document.getElementById('tfso_links_offset').offsetWidth > 60) document.getElementById('tfso_links').style.marginLeft = "473px";
}
function openSwfWindow() {
	window.open("/video/", "24SevenOffice", "height=850,width=1350,status=0,resizable=0,location=0,menubar=0,scrollbars=0,toolbar=0,titlebar=0");
}
function validateForm() {
	var form = document.getElementById("frm_bestonline");
	
	if (form.CompanyName.value == '' || form.CompanyName.value.length < 3) {
		alert("Du må fylle inn firmanavn.");
		form.CompanyName.style.backgroundColor = "#ffdbdb";
		form.CompanyName.focus();
		return;
	} else form.CompanyName.style.backgroundColor = "#d0fed8"; 
	
	if (form.ContactFirstName.value == '' || form.ContactFirstName.value.length < 3) {
		alert("Du må fylle inn fornavn.");
		form.ContactFirstName.style.backgroundColor = "#ffdbdb";
		form.ContactFirstName.focus();
		return;
	} else form.ContactFirstName.style.backgroundColor = "#d0fed8"; 
	
	if (form.ContactLastName.value == '' || form.ContactLastName.value.length < 3) {
		alert("Du må fylle inn etternavn.");
		form.ContactLastName.style.backgroundColor = "#ffdbdb";
		form.ContactLastName.focus();
		return;
	} else form.ContactLastName.style.backgroundColor = "#d0fed8"; 
	
	if (form.Phone.value == '' || form.Phone.value.length < 8) {
		alert("Du må fylle inn telefonnummer.");
		form.Phone.style.backgroundColor = "#ffdbdb";
		form.Phone.focus();
		return;
	} else form.Phone.style.backgroundColor = "#d0fed8"; 
	
	if (form.Email.value == '') {
		alert("Du må fylle inn e-postadresse.");
		form.Email.style.backgroundColor = "#ffdbdb";
		form.Email.focus();
		return;
	} else {
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(reg.test(form.Email.value) == false) {
			alert("Feil med e-postadresse.");
			form.Email.style.backgroundColor = "#ffdbdb";
			form.Email.focus();
			return;
		}
		else form.Email.style.backgroundColor = "#d0fed8"; 
	}
	
	form.submit();
		
}

function validateForeningForm() {

	var form = document.getElementById("forening_form");
	
	if (form.ForeningName.value == '' || form.ForeningName.value.length < 3) {
		alert("Du må fylle inn foreningens navn.");
		form.ForeningName.style.backgroundColor = "#ffdbdb";
		form.ForeningName.focus();
		return;
	} else form.ForeningName.style.backgroundColor = "#d0fed8"; 
	
	if (form.ForeningFirstName.value == '' || form.ForeningFirstName.value.length < 3) {
		alert("Du må fylle inn fornavn.");
		form.ForeningFirstName.style.backgroundColor = "#ffdbdb";
		form.ForeningFirstName.focus();
		return;
	} else form.ForeningFirstName.style.backgroundColor = "#d0fed8"; 
	
	if (form.ForeningLastName.value == '' || form.ForeningLastName.value.length < 3) {
		alert("Du må fylle inn etternavn.");
		form.ForeningLastName.style.backgroundColor = "#ffdbdb";
		form.ForeningLastName.focus();
		return;
	} else form.ForeningLastName.style.backgroundColor = "#d0fed8"; 
	
	if (form.ForeningPhone.value == '' || form.ForeningPhone.value.length < 8) {
		alert("Du må fylle inn telefonnummer.");
		form.ForeningPhone.style.backgroundColor = "#ffdbdb";
		form.ForeningPhone.focus();
		return;
	} else form.ForeningPhone.style.backgroundColor = "#d0fed8"; 
	
	if (form.ForeningEmail.value == '') {
		alert("Du må fylle inn e-postadresse.");
		form.ForeningEmail.style.backgroundColor = "#ffdbdb";
		form.ForeningEmail.focus();
		return;
	} else {
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(reg.test(form.ForeningEmail.value) == false) {
			alert("Feil med e-postadresse.");
			form.ForeningEmail.style.backgroundColor = "#ffdbdb";
			form.ForeningEmail.focus();
			return;
		}
		else form.ForeningEmail.style.backgroundColor = "#d0fed8"; 
	}
	
	if (form.ForeningCLA.checked == false) {
		alert("Du må akseptere vilkårene.");
		return;
	}
	
	form.submit();
		
}