
/***
Equal Height Columns by Rob Glazebrook
http://www.cssnewbie.com/equal-height-columns-with-jquery/
***/
function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	//alert($(this).height());
	//group.css('height', tallest + 'px');
	group.height(tallest);
}

$.fn.setPadding = function(val) {
	alert(val);
	//$('#' + $(this).parent().attr('id')).show();
};

$(document).ready(function(){	

	equalHeight($(".equal_height"));
	
	/***
	Simple jQuery Show|Hide script
	***/
	
	$('.showhide').click(function(){
		$('#prodMenu1').hide();
		$('#prodMenu2').hide();
		$('#prodMenu3').hide();
		$('#' + $(this).attr("rel")).toggle();
	});

	
	/***
	First | Last class for inline lists
	***/
	$('.inline li:first-child').addClass("first");
	$('.inline li:last-child').addClass("last");


	/***
	Empty search form on click
	***/
	$('#q_search').click(function(){

		a = $(this).val();
		if ( a == "vyhľadávanie" )
		{
			$(this).val("");
		}
		
	});
	
	
	/***
	Modify every 3rd item
	***/
	$('#main .content .product').css({'margin-right' : '5px'});
	$('#main .content .product:nth-child(3n+0)').css({
		'margin-right' : '0'
	});
	$('#main .content .product:nth-child(3n+1)').css({
		'clear' : 'left'
	});
	
	var a = '<div class="clr"></div>';
	$('#main .content .product:nth-child(3n)').after($(a));


	/***
	Text page
	***/
	$('.pad.c a[href*=/userfile/image/]:has(img)').addClass('fancybox').attr('rel', 'text_gallery');
	$('.pad.c table img').css({'display': 'inline', 'padding-right': '0'});
	$('.pad.c table[cellpadding]').each(function(){
		var padding = $(this).attr('cellpadding');
		$(this).find('td').each(function(){
			$(this).css('padding', padding + 'px');
		});
		$(this).find('th').each(function(){
			$(this).css('padding', padding + 'px');
		});
	});
	$('.pad.c td[valign]').each(function(){
		$(this).css('vertical-align', $(this).attr('valign'));
	});
	$('.pad.c th[valign]').each(function(){
		$(this).css('vertical-align', $(this).attr('valign'));
	});
	
	/***
	Fire Fancybox for Images
	***/
	$("a.fancybox").fancybox({
		'zoomSpeedIn': 0,
		'zoomSpeedOut': 0,
		'zoomOpacity': false,
		'zoomSpeedChange': 0,
		'overlayShow': false,
		'overlayOpacity': 0.2,
		'hideOnContentClick': true,
		'centerOnScroll': false,
		'imageScale': false
	}); 
	
});
