﻿front=true;

function inputFocus(id,tekst) {
    var inputbox = document.getElementById(id);
    if (inputbox.value==tekst||inputbox.value==""){
	  inputbox.style.color = "black";
	  inputbox.value = "";
	  inputbox.focus();
    }
}

function soegUnFocus(id,tekst) {
    var inputbox = document.getElementById(id);
    if (inputbox.value=="") {
	  inputbox.value = tekst;
    }
}


function showCartOptions(id,prodtype) {
if (prodtype == 0) {
        var prodContainerId = 'editFieldsID' + id;
        document.getElementById(prodContainerId).style.display = 'block';
}
}

function addToBasket(id) {
    var submitid = 'multiForm' + id;
    var form = document.getElementById(submitid);
    form.submit();
}

function writePrice(price) {
    var itemPrice = price.toString().replace(/\./g,',');
    if (itemPrice.length - itemPrice.search(/,/) == 2 ){
        itemPrice = itemPrice + '0';
    }
    else if (itemPrice.search(/,/) < 1) {
        itemPrice = itemPrice + ',00';
    }
    
    var tmp = '';
    var c = 0;
    for (var i=itemPrice.length-1; i>=0; i--)
    {
        c++;
        tmp = itemPrice.substr(i,1) + tmp;
        if (c == 6 && i > 0)
        {
        tmp = '.' + tmp;
        c = 0;
        }
    }
    itemPrice = 'kr. ' + tmp;
    return itemPrice;
}
