$(document).ready(function() {
	
	$('#counter a').css('opacity', '0.3');
	
	$("td#badd input[type='checkbox']").click(function () {
		$("#count_ithem").load("/order/.badd.php?pro_id=" + $(this).attr("id") + "&count=1");
	});
	
	$("td#badd img").click(function () {
		var input = $("input#" + $(this).attr("id"));
		if (input.attr('checked')) {
			input.attr('checked', false);
		} else {
			input.attr('checked', true);
		}

		$("#count_ithem").load("/order/.badd.php?pro_id=" + $(this).attr("id") + "&count=1");
	});

	$(".pass img").click(function () { 
		document.forms['loginform'].submit();
	});

	if($('.lftable input').val() != '') {
		$('.lftable span').css('color', '#ffffff');
	} else {
		$('.lftable span').css('color', '#a5a5a5');
	}
	
	
	$('.brandmenu a img').hover(
		function () {
			
			if ($(this).attr('class') != 'sel'){
				var srcString = $(this).attr('src');
				$(this).attr('src', srcString.replace('\.png','_h.png'));
			}
		}, 
		function () {
			if ($(this).attr('class') != 'sel'){
				var srcString = $(this).attr('src');
				$(this).attr('src', srcString.replace('_h\.png','.png'));
			}
		}
	);
	
	var srcString = '';
	var brandDir = location.pathname.replace('/', '');
	var brandDir = brandDir.replace('/', '');
	
	if (brandDir != '')
		var srcString = $('.brandmenu a img#' + brandDir).attr('src');

	if (brandDir != '' && srcString){
		$('.brandmenu a img#' + brandDir).attr('src', srcString.replace('\.png','_h.png'));
		$('.brandmenu a img#' + brandDir).attr('class', 'sel');
	}
	
	
	//чекбокс юрлица
	$('#urtr').click(function() {
		hideandshow();
	});
	hideandshow();
});

function hideandshow(){
	if($('#urtr').attr('checked')){
			$('#uf').show(600);
		} else {
			$('#uf').hide(600);
		}
}

function of(str) {
	$('.' + str + ' span').css('color', '#ffffff');
}

function ob(str) {
	if($('.' + str + ' input').val() == '')
		$('.' + str + ' span').css('color', '#a5a5a5');
}
