currentTab = 1;
$( document ).ready( function(){
	$('.tab_link' ).click(function () { 
		/*$(this).removeClass('act');
		currentTab = 
		if ( $( this ).attr( 'class' ) != 'active' ) {
			$( this ).parent().find( 'dt' ).removeClass( 'active' );
			$( this ).parent().find( 'dd' ).slideUp( 200 );
			
			$( this ).addClass( 'active' );
			$( this ).next( 'dd' ).slideDown( 200 );
		}*/
		$('#action_'+currentTab).hide();
		$('#tab_link_id_'+currentTab).removeClass('act');
		
		currentTab = ($(this).html());
		$('#tab_link_id_'+currentTab).addClass('act');
		$('#action_'+currentTab).show();
	});
	
});






function activeProductOver(currentId, imgActive)
{
	$('#status_img_'+currentId).attr( 'src', imgActive);
	
	
}

function activeProductOut(currentId, imgActive, imgOut)
{
	$('#status_img_'+currentId).attr( 'src', imgOut);
	
	$('#status_img_'+activeProduct).attr( 'src', imgActive);
}

function activeProductIn(currentId, imgOut, imgActive, ajaxUrl)
{
	imgUrl = 'http://www.pc-shop.lt/static/images/tmp/loading.gif';
	
	document.getElementById('product_content').innerHTML = '<div id="product_content"><div style="padding: 50px 0 0 0px; width: 306px; height: 500px"><img src="'+imgUrl+'" /></div></div>';

	$('#status_img_'+activeProduct).attr( 'src', imgOut);
	activeProduct = currentId;
	$('#status_img_'+activeProduct).attr( 'src', imgActive);

	$.ajax({
   type: "GET",
   url: ajaxUrl,
   success: function(msg){
   //	alert(msg);
   document.getElementById('product_content').innerHTML = msg;
     $('#product_content').html(msg);
   }
 });

}


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 changeType(type)
{
	if (type == 'j')
	{
		//$('#label_name').html('Įmonės pavadinimas <span class="star">*</span>');
		$('#li_company_name').show();
		$('#li_code').show();
		$('#li_vat_code').show();
	}
	else
	{
	//	$('#label_name').html('Vardas pavardė <span class="star">*</span>');
		$('#li_company_name').hide();
		$('#li_code').hide();
		$('#li_vat_code').hide();
	}
}
