$(function () {
	
$('#compare').find('select').bind('change', function (e) {
	$form = $(this).parents('form').eq(0);
	$form.trigger('submit');
});

$('ul.productSpecsLarge').each(function () {
	var $fieldset = $(this);
	
	if (! $fieldset.find('li').size()) {
		$fieldset.parents('.h3').eq(0).remove();
	}
});

$('#poll-form')
	.bind('submit', function (e) {
		var selected = $(this).find('input:radio:checked').size();
		if (! selected) {
			e.preventDefault();
			alert('لطفا یک گزینه را انتخاب کنید.');
		}
	});
	
$('.navigation li')
	.each(function () {
		if ($(this).find('ul').size() > 0) {
			$(this).addClass('parent');
		}
	});
	
$('.product-view-list tbody tr')
	.css('cursor', 'pointer')
	.bind('click', function (e) {
		$a = $(this).find('.product-view-list-info a');
		window.location.href = $a.attr('href');
	});


/*	
$('.product-view-grid').each(function (i) {
	var j = i + 1;
	
	if (! (j % 2)) {
		return true;
	}
	var first = j;
	var second = j + 1;
	
	var $first = $('.product-view-grid').eq(first-1);
	var $second = $('.product-view-grid').eq(second-1);
	
	var first_height = $first.height();
	var second_height = $second.height();
	
	var height = (first_height > second_height) ? first_height : second_height;
	// console.log(height);
	// $first.height(height);
	// $second.height(height);
});
*/

$('.product-view-grid')
	.css('cursor', 'pointer')
	.bind('mouseenter', function (e) {
		$(this).css('background', '#ffc');
	})
	.bind('mouseleave', function (e) {
		$(this).css('background', 'transparent');
	})
	.bind('click', function (e) {
		$a = $(this).find('.full-information a');
		window.location.href = $a.attr('href');
	});
		
});
