

function number_format( number, decimals, dec_point, thousands_sep ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}



function checkvals(formname)
{
	empty = false;
	
	for (i=0; i<fields.length; i++)
	{
		if (document.getElementById('form_'+fields[i]).value == "")
		{
			empty = true;
			document.getElementById('label_'+fields[i]).className = 'error';
		}
		else
		{

			document.getElementById('label_'+fields[i]).className = '';
		}
	}
	
	for (i=0; i<inputs.length; i++)
	{
		if (document.getElementById('form_'+inputs[i]).checked != true)
		{
			empty = true;
			document.getElementById('label_'+inputs[i]).className = 'error';
		}
		else
		{
			document.getElementById('label_'+inputs[i]).className = '';
		}
	}
	

	if (empty) setTimeout('clearVals()', 1000);
	else formname.submit();
}


function clearVals()
{
	return; // kad nedingtu raudoni
	
	for (i=0; i<fields.length; i++)
	{
		if (document.getElementById('form_'+fields[i]).value == "")
		{
			document.getElementById('label_'+fields[i]).className = '';
		}
	}
	
	for (i=0; i<inputs.length; i++)
	{
		if (document.getElementById('form_'+inputs[i]).checked != true)
		{
			document.getElementById('label_'+inputs[i]).className = '';
		}
	}
}

var imagePath = '';

function changePhoto(i)
{
	
	$('#thumb_'+currentPhoto).removeClass('thumbActive');
	$('#big_photo_img').attr('src', imagePath+'/'+i+'_inner.jpg');
	$('#big_photo_link').attr('href', imagePath+'/'+i+'_big.jpg');

	$('#thumb_'+i).addClass('thumbActive');
	currentPhoto = i;
}

$( document ).ready( function(){
	currentPhoto = 1;
	changePhoto(1);
	
	$('.thumb_link').mouseover(function() {
		$(this).parent().addClass('thumbHover');
	});

	$('.thumb_link').mouseout(function() {
		$(this).parent().removeClass('thumbHover');
	});
	
});




function changeColour(i)
{
	
	$('#colour_'+currentColour).removeClass('colourActive');

	$('#colour_'+i).addClass('colourActive');
	currentColour = i;
	$('#colour_id').attr('value',i);
}

$( document ).ready( function(){

	$('.colour_link').mouseover(function() {
		$(this).parent().addClass('colourHover');
	});

	$('.colour_link').mouseout(function() {
		$(this).parent().removeClass('colourHover');
	});
	
});


function changeType(type, firm, name)
{
	if (type == 'j')
	{
		$('#label_name').html(firm+' <span class="star">*</span>');
		$('#li_code').show();
		$('#li_vat_code').show();
	}
	else
	{
		$('#label_name').html(name+' <span class="star">*</span>');
		$('#li_code').hide();
		$('#li_vat_code').hide();
	}
}
