    window.onresize = resize;
    window.onload = resize;
    
    jQuery.noConflict();

	jQuery(document).ready(function() {
	
        /* related menu functions */
    
		jQuery('div.related-block') . mouseover(function() {
			jQuery('div.related-block') . not(jQuery(this)) . children('div.related-sub-block') . hide();
			jQuery(this) . children('div.related-sub-block') .  show();	
		});

		jQuery('div.related-sub-block') . mouseleave(function() {			
			jQuery(this) . hide();		
		});
        
        jQuery("input.form_input, select.form_input, textarea") . uniform();
		jQuery(":file") . uniform({fileBtnText: 'Выбрать', fileDefaultText: 'Выберите файл'});
        
	});
    
    /* if we resize window, we need to resize related menu and blocks at 'all products' page (product.php) */
    
    function resize()
    {
	   if (window.innerHeight) {
		  theHeight = window.innerHeight;
		  theWidth = window.innerWidth;
	   }
	   else if (document.documentElement && document.documentElement.clientHeight) {
		  theHeight = document.documentElement.clientHeight;
		  theWidth = document.documentElement.clientWidth;
	   }
	   else if (document.body) {
		  theHeight = document.body.clientHeight;
		  theWidth = document.body.clientWidth;
	   }

	   if(theWidth <= 1157)
       {
           if(jQuery('.related-block') . size() % 5 < 3)
                $size = 35 * Math.round((jQuery('.related-block') . size() + 3 - jQuery('.related-block') . size() % 5)  / 5);
           else
                $size = 35 * Math.round(jQuery('.related-block') . size() / 5);
           
           if($size < 35) $size = 35;
                
           jQuery('.related-container') . css('height', $size + 'px');
           jQuery('.related-container span') . css('height', $size + 'px')
       }
       else
       {
           if(jQuery('.related-block') . size() % 6 < 3)
                $size = 35 * Math.round((jQuery('.related-block') . size() + 1) / 6);
           else
                $size = 35 * Math.round(jQuery('.related-block') . size() / 6);
           
           if($size < 35) $size = 35;
                
           jQuery('.related-container') . css('height', $size + 'px');  
           jQuery('.related-container span') . css('height', $size + 'px') 
       }
       
       if(jQuery('.catalog_block') . size() > 0)
       {
            if(theWidth <= 1298 && theWidth >= 1045)
                jQuery('.catalog_block') . css('width', (theWidth - 426) / 2 + 'px');
            else if(theWidth <= 1045)
                jQuery('.catalog_block') . css('width', '312px');
            else
                jQuery('.catalog_block') . css('width', '279px'); 
       }
    }


