﻿jQuery(document).ready(function(){
	jQuery(window).load(function(){
		jQuery('.shop_gallery .g_small img, ul#shop_panel li img').each(function(){
			jQuery(this).css('marginTop', (50-jQuery(this).height()/2) + 'px');
		});
		jQuery('ul#shop_panel li img').each(function(){
			jQuery(this).css('marginTop', (20-jQuery(this).height()/2) + 'px');
		});
		jQuery('ul#shop_list li img').each(function(){
			jQuery(this).css('marginTop', ((80-jQuery(this).height())/2) + 'px');
		});
	});
	jQuery('.shop_cats .catin, .shop_prod .buy, ul#shop_list li, .shop_list_main').corner('5px');
	jQuery('.shop_gallery .g_big a').click(function(){
	   var image = new Image();
	   image.src = jQuery(this).find('img').attr('src');
	   var loaded = false;
	   while(loaded == false){
	   	if(image.width != "undefined" && image.height != "undefined"){
	   		loaded = true;
	   	}
	   }
		window.open(image.src, 'Obraz','location=0,status=0,scrollbars=0,width=' + image.width + ',height=' + image.height + ',top=' + (jQuery(window).height()/2-image.height/2) + ',left=' + (jQuery(window).width()/2-image.width/2));
	});
	jQuery('.shop_gallery .g_small a').click(function(){
		jQuery(this).parent().parent().find('.g_big img').attr('src', img_cat + jQuery(this).find('img').attr('src').replace(img_cat, '').substring(1));
	});
	jQuery('.shop_search-s ul li span').click(function(){
		var search_cat = jQuery(this).parent().attr('class').substring(2);
		jQuery('.shop_search-s span.shop_search-s-txt').text(jQuery(this).text());
		jQuery('input[name=search_cat]').val(search_cat);
	});
	jQuery('.shop_search-s').click(function(){
		jQuery(this).find('ul#shop_search_box').slideToggle("normal");
	});
});
