function getCookie(NavnPaacookie)
{ if (document.cookie.length > 0) 
{ begin = document.cookie.indexOf(NavnPaacookie+"="); 
if (begin != -1) 
{ begin += NavnPaacookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 
}

function setCookie(NavnPaacookie, value, expiredays) 
{ var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NavnPaacookie + "=" + escape(value) + 
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NavnPaacookie) 
{ if (getCookie(NavnPaacookie)) {
document.cookie = NavnPaacookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

}

function KoebPlade(KoebId)  {

Check=-1
HarKoebt=getCookie("Plader");

if (HarKoebt!=null) {Check=HarKoebt.indexOf(":"+KoebId+":")};

if (Check==-1) {

	if (HarKoebt==null){
	setCookie("Plader",":"+KoebId+":",2)
	alert('Du har nu lagt en plade i din indkøbskurv.\nDu kan til enhver tid se, hvilke plader du er ved at købe,\nved at trykke på "Indkøbskurv" i menuen\nDenne besked vises kun en gang')
	}
	else
	{
	setCookie("Plader",HarKoebt+",:"+KoebId+":",2)
	}

//alert("Pladen er nu lagt i indkøbskurven")
}
else
{
alert("Pladen ER allerede i din indkøbskurv ! ! !")
};

}

function CheckPlade(KoebId)  {
Check=-1
HarKoebt=getCookie("Plader");

if (HarKoebt!=null) {Check=HarKoebt.indexOf(":"+KoebId+":")};

if (Check==-1) {

}
else
{
return true
};
}


function GaaTilKurv(){

KoebtePlader=getCookie("Plader")
window.location.href = "kurv.asp?Plader=" + KoebtePlader;

}

function ToemKurv(){

delCookie("Plader")
location.href = "kurv.asp?Plader=Toemt"

}

function Fjern(Id){
Id = ":" + Id + ":"
Foer=getCookie("Plader")
Nu=""

Splittet=Foer.split(",")

for (t=0; t<=Splittet.length-1; t=t+1)
{

if (Splittet[t]!=Id) {
 Nu=Nu+Splittet[t]

 Nu=Nu+","


 }

}

Nu=Nu.substring(0,Nu.length-1)

setCookie("Plader",Nu,2)

if (Nu=="") {location.href = "kurv.asp?Plader=Toemt"
}
else
{
location.href = "kurv.asp?Plader="+Nu
}

}



function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
} 

// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
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 tilmailformvalidation(thisform) {
	with (thisform){
		if (emailvalidation(email,"Ugyldig Email!")==false) {email.focus(); return false;};
	}
}

function contactformvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(realname,"Du skal skrive dit navn!")==false) {realname.focus(); return false;};
if (emptyvalidation(Besked,"Du skal skrive en besked!")==false) {Besked.focus(); return false;};
}
}

function orderformvalidation(thisform)
{
with (thisform)
{
if (emptyvalidation(realname,"Du skal skrive dit fulde navn!")==false) {realname.focus(); return false;};
if (emptyvalidation(Adresse,"Du skal skrive din adresse!")==false) {Adresse.focus(); return false;};
if (emptyvalidation(Postnummer_og_By,"Du skal skrive postnummer og by")==false) {Postnummer_og_By.focus(); return false;};
if (emailvalidation(Email,"Ugyldig Email!")==false) {Email.focus(); return false;};
}
}
