function printReciept(){
    popup = window.open('http://psykiskhelse.laboremus.no/kvittering.asp','print','toolbar=no,menubar=no,width=500,height=500');
    //popup.document.open();
    //popup.document.write("<html><head><link type='text/css' rel='Stylesheet' media='print' href='/novus/style/print.css' /></head><body onload='print()'>");
    //popup.document.write(reciept);
    //popup.document.write("</body></html>");
}
function checkEmail(status){
    if (!status){
        var email = document.getElementById("epost").value;
        if(!email){
            //alert("Du må skrive inn en epostadresse");
            document.getElementById("id7").style.color = "Red";
            return "off";
        }
        else{
            document.getElementById("id7").style.color = "Black";    
            return ;
        }
    }
    return "off";
   
}

function checkFields(){
    var firstname = document.getElementById("firstname").value ;
    var surname = document.getElementById("surname").value ;
    var adr = document.getElementById("adr").value;
    var pnr = document.getElementById("pnr").value;
    var psted = document.getElementById("psted").value;
    var tlf = document.getElementById("tlf").value;
    var gift1 = document.getElementById("gift1").checked;
    var gift2 = document.getElementById("gift2").checked;
    var gift3 = document.getElementById("gift3").checked;
    //var card = document.getElementById("card").checked
    
    
    if(!firstname){
        if(!surname)
            document.getElementById("id1").style.color = "Red";
        else
            document.getElementById("id1").style.color = "black";
    }
    else
        document.getElementById("id1").style.color = "black";
    if(!surname)
        document.getElementById("id2").style.color = "Red";
    else
        document.getElementById("id2").style.color = "black";
    if(!adr)
        document.getElementById("id3").style.color = "Red";
    else
        document.getElementById("id3").style.color = "Black";
    if(!pnr)
        document.getElementById("id4").style.color = "Red";
    else
        document.getElementById("id4").style.color = "black";
    if(!psted)
        document.getElementById("id5").style.color = "Red";
    else
        document.getElementById("id5").style.color = "black";
    if(!tlf)
        document.getElementById("id6").style.color = "Red";
    else
        document.getElementById("id6").style.color = "black";
    //if(((gift1)||(gift2)||(gift3)) && !card){
    if(((gift1)||(gift2)||(gift3))){
        alert("Du må betale med kort for å gi gave");
        return false;
    }
    if((!surname) || (!adr) || (!pnr) || (!psted) || (!tlf)){
        return false;
    }
    else
        document.getElementById("bestilling").submit();
}

function addToBasket(text, url,id,ant){
    /*document.getElementById('add_to_basket').value = ant;
    document.getElementById('id2').value = id;
    document.getElementById("form_butikk").submit();
    */
    if(0<ant>99){
        return false;
    }
    document.form_butikk.add_to_basket.value = ant;
    document.form_butikk.id2.value = id;
    document.form_butikk.action = url //+"#a"+id
    document.form_butikk.submit();
    //addToCart(id,ant,text);
    return true;
}

function addToCart(id,antall,text,strUrl){
	var list=document.getElementById('smallCartList')
	if(antall == 0){
		var newLi = document.createElement('li');
		newLi.setAttribute('id','cs');
		var artT = document.createElement('span');
		artT.setAttribute('class', 'artT');
		artT.innerHTML = text;
		newLi.appendChild(artT);
		list.appendChild(newLi);
		return;
	}
	var newLi = document.createElement('li');
	newLi.setAttribute('id','cs'+id);
	var artT = document.createElement('span');
	artT.setAttribute('class', 'artT');
	artT.innerHTML = text.substring(0,28);
	newLi.appendChild(artT);
	var artRm = document.createElement('span');
	artRm.setAttribute('class', 'artRm');
	artRm.setAttribute('onclick', "removeItem('"+strUrl.replace(/&amp;/,'&')+"','"+id+"')");
	artRm.innerHTML = '<img src="/gfx/cart_delete.png" />';
	newLi.appendChild(artRm)
	var artA = document.createElement('span');
	artA.setAttribute('class', 'artA');
	artA.innerHTML = 'Ant.: '+antall+'&nbsp&nbsp';
	newLi.appendChild(artA)
	
	list.appendChild(newLi);
	
}

function editItem(id){
    alert(id);
}
/*
function removeItem(id){
    document.form_butikk.add_to_basket.value = 0;
    document.form_butikk.id2.value = id;
    document.form_butikk.submit();
    return;
}

*/
function removeItem(url,id){
    document.form_butikk.add_to_basket.value = 0;
    document.form_butikk.id2.value = id;
    document.form_butikk.action = url;
    document.form_butikk.submit();
    return;
}

