/*Вертикальное выравнивание тескта button для firefox*/
function buttons_fix_ff()
{
	buttons = document.getElementsByTagName('button');
	for(i=0; i<buttons.length; i++)
		buttons[i].style.paddingBottom = '3px';
}

if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1)
{
	window.addEventListener("load", buttons_fix_ff, false);
}


$(document).ready(function() {
	// force category selection for the header search form
	$('#productsearchform').submit(function() {
		var search_type_select = $(this).find("select[name*='search_type']");

		if (search_type_select != undefined) {
			if (search_type_select.val() != '') {
				return true;
			}
		}

		return false;
	});


	$("ul.menu li a.subn").mouseover(function() {
		$(this).parent().find("ul.subnav").slideDown('fast').show();
		$(this).parent().find("div.menu-button1").css('color','#000');
		$(this).parent().find("div.menu-button1").css('background','#ddebf1');
		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow');
			$(this).parent().find("div.menu-button1").css('color','#fff');
			$(this).parent().find("div.menu-button1").css('background','#5799ba');
		});
	});

	DD_roundies.addRule('.menu-button1', '3px', true);
	DD_roundies.addRule('.divArtistIntro', '3px', true);
	DD_roundies.addRule('.viewDetails', '2px', true);
	DD_roundies.addRule('.btnAddToCart', '3px', true);

	DD_roundies.addRule('.rndCorners', '3px', true);


	// Masonry plugin for product listing
	$('#photoGallery').masonry({
		singleMode: true,
		itemSelector: '.box'
	});


	// 'View more' action for the featured products page
	$("#featured_view_more").click(function() {
		$('#photoGalleryFeatured').fadeTo(700, 0.1);

		// send request to retrieve a new list of featured products
		$.post(
			'/ajax_request.php',
			{
				ajax_mode: 'featured_products'
			},
			function(data) {
				$('#photoGalleryFeatured').html(data);
				$('#photoGallery').masonry();
				$('#photoGalleryFeatured').fadeTo(700, 1);
			}
		);

		return false;
	});

});
