function traegulv()
{
	this.vareid=0;
	this.tilbudsindex = 100;
	this.vorpris = 0;
	this.pakke=1;
	
	this.pop_calculator = function(pack, navn) { // Åbn areal udregner
		window_name='pop_calculator';
		props = 'width=250,height=495, resizable=no, scrollbars=no, toolbars=no, location=no, directories=no, status=no, menubar=no, copyhistory=no';
		window.open('includes/calc_m2_packs.php?pack='+pack+'&name='+navn+'&vareid='+this.vareid, window_name, props);
	}
	
	this.calc_price_m2 = function() {
		if(parseInt(document.getElementById('antal_'+this.vareid).value)) {
			pris = this.vorpris * parseInt(document.getElementById('antal_'+this.vareid).value);
			if(this.tilbudsindex < 100) {
				i=(100-this.tilbudsindex)/100;
				pris = pris-(pris*i);
			}
			document.getElementById('pris_'+this.vareid).value="DKK "+this.CurrencyFormatted(pris);
			
			m2 = parseInt(document.getElementById('antal_'+this.vareid).value) * this.pakke;
			document.getElementById('m2_'+this.vareid).value=this.CurrencyFormatted(m2);
		}
	}
	
	this.CurrencyFormatted = function(amount)
	{
		var i = parseFloat(amount);
		if(isNaN(i)) { i = 0.00; }
		var minus = '';
		if(i < 0) { minus = '-'; }
		i = Math.abs(i);
		i = parseInt((i + .005) * 100);
		i = i / 100;
		s = new String(i);
		if(s.indexOf('.') < 0) { s += '.00'; }
		if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
		s = minus + s;
		s=s.replace(".", ",");
		return s;
	}

	this.vareprove_submit = function() {
		document.getElementById('vareprove_'+this.vareid).value='1';
		document.getElementById('pris_'+this.vareid).value="DKK 10,00";
		document.getElementById('formen_'+this.vareid).submit();
	}
	
	this.tilbehor = function() {
		window_name='pop_tilbehor';
		props = 'width=450,height=550, resizable=no, scrollbars=yes, toolbars=no, location=no, directories=no, status=no, menubar=no, copyhistory=no';
		window.open('includes/tilbehor.php?vareid='+this.vareid, window_name, props);
	}
}
