
function colup(id)
{ id.style.background='#ff8800'; }
function coldo(id)
{ id.style.background='#dd0050'; }
function colup2(id)
{ id.style.background='#dd0050'; id.style.color='#ffffff'; }
function coldo2(id)
{ id.style.background=''; id.style.color='#000000'; }
function colup3(id)
{ id.style.background='#dd0050'; }
function coldo3(id)
{ id.style.background='#ff8800'; }

function goout(niche,uu,om)
{
	top.location='index.html?oo='+niche+'&p='+uu+'&o='+om;
}
var overm=false;
var lefty;
document.onmousemove=findxy;
function hintshow(tekst,bred,lef)
{
//	overm=true;
//	lefty=lef;
//	findxy();
//	document.all.hintkasse.style.visibility='visible';
//	document.all.hintkassetekst.innerHTML=tekst;
//	document.all.hintkasse.style.width=bred;
}
function findxy()
{
//	if(overm)
//	{
//		document.all.hintkasse.style.top=event.clientY+document.body.scrollTop+20-55;
//		document.all.hintkasse.style.left=event.clientX+document.body.scrollLeft+lefty+10+25;
//	}
}
function hinthide()
{
//	hintkasse.style.visibility='hidden';
//	document.all.hintkasse.style.visibility='hidden';
//	overm=false;
}
function toframe(ur)
{
	self.location.href=ur;
}
function beast(s)
{
	window.open(s,'_blank','height=600,width=800,left=0,top=0,status=no,toolbar=no,menubar=no,location=no,titlebar=no,scrollbars=no,resizable=no');
}
function ghost(s,x,y)
{
	window.open(s,'_blank','height='+y+',width='+x+',left=0,top=0,status=no,toolbar=no,menubar=no,location=no,titlebar=no,scrollbars=no,resizable=no');
}
function printpreview(s)
{
	window.open('printpreview.html?s='+s,'_blank','height=500,width=500,left=0,top=0,status=no,toolbar=no,menubar=no,location=no,titlebar=no,scrollbars=yes,resizable=no');
}
function printopgave(s)
{
	window.open('printopgave.html?s='+s,'_blank','height=500,width=500,left=0,top=0,status=no,toolbar=no,menubar=no,location=no,titlebar=no,scrollbars=yes,resizable=no');
}

function printpage()
{
	tv=parseInt(navigator.appVersion);
	if(tv>=4) window.print();
	else alert("Din browser understøtter ikke denne funktion.");
}

function calcme()
{
//	prisen=<?php echo $priser[0];?>-125;
//	if(document.all.mybox2.value==1) prisen+=<?php echo $priser[1];?>;
//	if(document.all.mybox3.value==1) prisen+=<?php echo $priser[2];?>;
//	if(document.all.mybox4.value==1) prisen+=<?php echo $priser[3];?>;
//	document.all("res1").value=prisen;
//	document.all("res2").value=prisen+125;
}

function formvalidation(thisform)
{
	with (thisform)
	{
		if(emailvalidation(email,"Email adressen er ikke gyldig.")==false) {email.focus(); return false;};
		if(emptyvalidation(opgavenavn,"Opgavens navn mangler.")==false) {opgavenavn.focus(); return false;};
		if(emptyvalidation(beskrivelse,"Bekrivelse mangler.")==false) {beskrivelse.focus(); return false;};
		if(emptyvalidation(navn,"Dit navn mangler.")==false) {navn.focus(); return false;};
		if(emptyvalidation(adresse,"Din adresse mangler.")==false) {adresse.focus(); return false;};
		if(valuevalidation(postnummer,0,9999,"Postnummeret er ikke gyldigt.","|")==false) {postnummer.focus(); return false;};
		if(emptyvalidation(by,"Navnet på byen mangler.")==false) {by.focus(); return false;};
		if(valuevalidation(telefon,0,99999999,"Telefonnummeret er ikke gyldigt. Angiv kun 8 cifre UDEN forkode (eksempelvis +45)","|")==false) {telefon.focus(); return false;};

//		if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//		if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};

	}
} 

function loginvalidation(thisform)
{
	with (thisform)
	{
		if(emailvalidation(email,"Email adressen er ikke gyldig.")==false) {email.focus(); return false;};
	}
}

function changevalidation(thisform)
{
	with (thisform)
	{
		if(emailvalidation(email,"Email adressen er ikke gyldig.")==false) {email.focus(); return false;};
		if(emptyvalidation(password,"Password mangler.")==false) {password.focus(); return false;};
	}
}

function tipvalidation(thisform)
{
	with (thisform)
	{
		if(emptyvalidation(afsendernavn,"Du mangler at angive dit navn.")==false) {afsendernavn.focus(); return false;};
		if(emptyvalidation(modtagernavn,"Du mangler at angive navnet på modtageren.")==false) {modtagernavn.focus(); return false;};
		if(emailvalidation(modtageremail,"Email adressen er ikke gyldig.")==false) {modtageremail.focus(); return false;};
		if(emptyvalidation(teksten,"Du har ikke tilføjet en tekst.")==false) {teksten.focus(); return false;};
	}
} 


function profilvalidation(thisform)
{
	with (thisform)
	{
		if(emptyvalidation(password,"Password mangler.")==false) {password.focus(); return false;};
		if(emptyvalidation(firmanavn,"Firmanavn mangler.")==false) {firmanavn.focus(); return false;};
		if(emptyvalidation(adresse,"Adresse mangler.")==false) {adresse.focus(); return false;};
		if(emptyvalidation(saldo,"Saldo mangler.")==false) {saldo.focus(); return false;};
		if(emptyvalidation(byen,"Navnet på byen mangler.")==false) {byen.focus(); return false;};
		if(valuevalidation(postnummer,0,9999,"Postnummeret er ikke gyldigt.","|")==false) {postnummer.focus(); return false;};
		if(valuevalidation(telefon,0,99999999,"Telefonnummeret er ikke gyldigt. Angiv kun 8 cifre UDEN forkode (eksempelvis +45)","|")==false) {telefon.focus(); return false;};
		if(emailvalidation(email,"Email er ikke gyldig.")==false) {email.focus(); return false;};
	}
} 

function emailvalidation(entered, alertbox)
{
	with (entered)
	{
		apos=value.indexOf("@"); 
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
		{
			if (alertbox) {alert(alertbox);} return false;
		}
		else return true;
	}
} 

function emptyvalidation(entered, alertbox)
{
	with (entered)
	{
		if (value==null || value=="")
		{if (alertbox!="") {alert(alertbox);} return false;}
		else return true;
	}
} 

function valuevalidation(entered, min, max, alertbox, datatype)
{
	with (entered)
	{
		checkvalue=parseFloat(value);
		if (datatype)
		{
			smalldatatype=datatype.toLowerCase();
			if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
		}
		if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
		{
			if (alertbox!="") {alert(alertbox);} return false;
		}
		else return true;
	}
} 
