function getItemPrice(form_name, n) {
	$.post('/functions/get_price.php', 
	$('#'+form_name).serialize()+'&n='+n+'&form='+form_name, function(data) { if (data) { eval(data); } });
}

function addItem(form_name, n) {
	$.post('/functions/add_item.php', 
	$('#'+form_name).serialize()+'&n='+n+'&form='+form_name, function(data) { if (data) { eval(data); } });
}

var helpImage = new Array();

function showHelp(n, type, form_name, width, height) {
	if (document.getElementById('help_'+n) != undefined) {
		clearTimeout(helpImage[n]);
		if (type == 'static') {
			$('#help_'+n).fadeIn('fast');
			$('#help_line_'+n).fadeIn('fast');
		} else {
			$.post('/functions/dynamic_image.php', 
			$('#'+form_name).serialize()+'&n='+n+'&width='+width+'&height='+height, function(data) { if (data) { eval(data); } });
			
		}
	}
}

function hideHelp(n) {
	if (document.getElementById('help_'+n) != undefined) {
		helpImage[n] = setTimeout("$('#help_"+n+"').fadeOut('fast');$('#help_line_"+n+"').fadeOut('fast');", 100);
	}
}
// 3D UPDATE
function fetch(){
	var type,a,b,c,d,e,h,L,design;
	
	window = 0;
	
	this.setType = function(typeInput){
		type = typeInput;
		
		if(type < 6){
			$('#e').attr('disabled','disabled');
			$('#h').attr('disabled','disabled');
		}
		else{
			$('#e').removeAttr('disabled');
			$('#h').removeAttr('disabled');
		}
	}
	
	this.calc = function(){
		
		a = $('#a').val();
		b = $('#b').val();
		c = $('#c').val();
		d = $('#d').val();
		e = $('#e').val();
		h = $('#h').val();
		L = $('#L').val();
		design = $('#design').val();
		
		if(a<100)a=100;
		if(b<100)b=100;
		if(c<100)c=100;
		if(d<100)d=100;
		if(L<100)L=100;
		
		if(type == 1){
			e = (a-c)/2;
			h = (b-d)/2;
		}
		
		if(type == 2){
			e = a - c;
			h = 0;
		}
		
		if(type == 3){
			e = 0;
			h = 0;
		}
		
		if(type == 4){
			e = (a-c)/2;
			h = 0;
		}
		
		if(type == 5){
			e = 0;
			h = (b-d)/2;
		}
		
		$('#a').val(a);
		$('#b').val(b);
		$('#c').val(c);
		$('#d').val(d);
		$('#e').val(e);
		$('#h').val(h);
		$('#L').val(L);
		
	}
	
	this.getPrice = function(){
		$('#produkt').load('/all.php?type=pris&a='+a+'&b='+b+'&c='+c+'&d='+d+'&e='+e+'&h='+h+'&L='+L+'&design='+design);
	}
	
	this.getImg = function(){
		src = '/all.php?type=tod&a='+a+'&b='+b+'&c='+c+'&d='+d+'&e='+e+'&h='+h+'&L='+L+'&design='+design;
		$('.preview > img').attr('src',(src));
	}
	
	this.get3D = function(){
		try{
		if(show3D){
			show3D.close();
		}
		}
		catch(Exception){}
		
		url = '/all.php?type=tred&a='+a+'&b='+b+'&c='+c+'&d='+d+'&e='+e+'&h='+h+'&L='+L+'&design='+design;
		show3D = window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=750, height=500");
		show3D.focus();

		
	}
	
	//this.setType(1);
}
