$(document).ready(function(){
	
	$('#smallimage').click(function() {
		var s_width, b_width, s_height, b_height, k, p = 2;
		s_width = $(this).attr('width');
		s_height = $(this).attr('height');
		if($(this).attr('class') == 'sm')
		{
		 k = p;
		 $(this).attr('class','bg')
		}
		else
		{
		 k = 1/p;
		 $(this).attr('class','sm')			
		}
		b_width = s_width * k;
		b_height = s_height * k;
		$(this).attr('width', b_width);
		$(this).attr('height', b_height);
	});
	
	$('#different').click(function() {
	
		if($('.eye').css('display')=='none')
			$('.eye').fadeIn();
		else
			$('.eye').fadeOut();
			
		if($('.second').css('display')=='none')
			$('.second').fadeIn();
		else
			$('.second').fadeOut();
			
	});
	
	$('#kolvo').change(function() {
		/*
		if($('#kolvo2').css('display')=='none')
			$("#kolvo2").val($("#kolvo").val());		
			*/
	});
	
	$('#kolvo, #kolvo2').change(function() {
		/*
		if($('#kolvo2').css('display')=='none')
			$("#kolvo2").val($("#kolvo").val());	
			*/
			
		var kol, kol2, pr, fpr;
		kol = eval($('#kolvo').val());
		kol2 = eval($('#kolvo2').val());
		
		kol = kol + kol2;
		
		$('.pr_item').each(function(index) {
			if(kol >= $(this).attr('value_from') && kol <=$(this).attr('value_to'))
			{
				pr = $(this).attr('value');		
			}
			if($(this).attr('value_from') == 1 || ($(this).attr('value_from')=="" && $(this).attr('value_to')==""))
				fpr = $(this).attr('value');
	    
	  });
	   
	  	if(!pr) pr = fpr;
	  	pr = eval(pr);
	  	s = pr + ' руб.';
	  	$('div#kol_price').html(s); 
	  	//alert (s);
			
	});


	
	$('select.check_param').change(function() {
		/*
		var left_id;
		left_id = $(this).attr("id");
		right_id = left_id + '_2';
		if($('#'+right_id).css('display')=='none')
        	$('#'+right_id).val($(this).val()+'0');	
        	*/
	});
	

        $('#searchbutton').click(function() {
	
		if($('.popupsearch').css('display')=='none')
		$('.popupsearch').fadeIn();
		else
		$('.popupsearch').fadeOut();  
	});


	});
	



