$(document).ready(function()
{
	$('.del').click(function(e)
	{
		e.preventDefault();
		$(this).parent().parent().remove();
	});
	$('.compare').click(function(e)
	{
		if ($('.compare:checked').size() > 1)
		{
			$('.do_compare').slideDown();
		}
		else
		{
			$('.do_compare').slideUp();
		}
	});
	$('.hoverable').mouseover(function(e)
	{
		$(this).siblings('.hoverable').removeClass('active');
		$(this).addClass('active');
	});
	$('.hoverable').mouseout(function(e)
	{
		$(this).removeClass('active');
	});
	/*$('.gr:not(.not_img)').click(function(e)
	{
		e.preventDefault();
		if ($(this).parent().is('.active'))
		{
			$(this).parent().children('.items').slideUp(450, function()
			{
				$(this).parent().removeClass('active');
			});
		}
		else
		{
			$(this).parent().children('.items').slideDown(450);
			$(this).parent().addClass('active');
		}
	});*/
	$('.show_popup').click(function(e)
	{
		e.preventDefault();
		$('#popup_text').html($(this).parent().parent().children('#text').html());
		$('#popup_title').text($(this).text());
		$('#main_img').attr('src', '/content/images/big_'+$(this).parent().parent().children('#img').text());
		if ($.trim($(this).parent().parent().children('#colors').text()) != '')
		{
			$('#clrs_div').show();
			$('#popup_colors').attr('src', '/content/images/big_'+$(this).parent().parent().children('#colors').text());
		}
		else
		{
			$('#clrs_div').hide();
		}
		$('#rec_popup').html($(this).parent().parent().children('#rec').html());
		$('#popup_img1').html($(this).parent().parent().children('#img1').html());
		$('#popup_img2').html($(this).parent().parent().children('#img2').html());
		$('#popup').show();
		re_init();
	});
	$('.show_popup1').click(function(e)
	{
		e.preventDefault();
		$('#popup_title').text($(this).parent().children('p').children('.show_popup').text());
		$('#popup_text').html($(this).parent().children('#text').html());
		$('#main_img').attr('src', '/content/images/big_'+$(this).parent().children('#img').text());
		if ($.trim($(this).parent().children('#colors').text()) != '')
		{
			$('#clrs_div').show();
			$('#popup_colors').attr('src', '/content/images/big_'+$(this).parent().children('#colors').text());
		}
		else
		{
			$('#clrs_div').hide();
		}
		if ($(this).parent().children('#rec').size() > 0)
		{
			$('#rec_popup').html($(this).parent().children('#rec').html());
			$('#rec_popup').show();
		}
		else
		{
			$('#rec_popup').hide();
		}
		if ($(this).parent().children('#img1').size() > 0)
		{
			$('#popup_img1').html($(this).parent().children('#img1').html());
			$('#popup_img1').show();
		}
		else
		{
			$('#popup_img1').hide();
		}
		if ($(this).parent().children('#img2').size() > 0)
		{
			$('#popup_img2').html($(this).parent().children('#img2').html());
			$('#popup_img2').show();
		}
		else
		{
			$('#popup_img2').hide();
		}
	/*	$('#popup_img1').html($(this).parent().children('#img1').html());
		$('#popup_img2').html($(this).parent().children('#img2').html());*/
		$('#popup').show();
		re_init();
	});
	$('.submit').click(function(e)
	{
		e.preventDefault();
		document.forms[0].submit();
	});
	$('.close').click(function(e)
	{
		e.preventDefault();
		$('#popup').hide();
	});
});

function re_init()
{
	$('.thickbox').live('click', function(e)
	{
		$('#main_img').attr('src', $(this).attr('href'));
		e.preventDefault();
	});
}

