(function ($) {
	$(window).load(function () {		
	
		//$('#menu_top li.submenu').first().show();
		//$('#menu_top > ul > li.submenu > ul > li').last().addClass('last');
		//$('#menu_top > ul > li.submenu > ul > li:last').each(function () {
		//	$(this).addClass('last');
		//	alert($(this).html());
		//});
		
		
		$('#menu_top > ul > li.submenu > ul > li:last-child').each(function () {
			$(this).addClass('last');
		});
		
	
		
		$('#menu_top ul li.submenu').prev().addClass('with_submenu');
		
		
		$('#menu_top > ul > li').each(function () {
			if ($(this).hasClass('with_submenu')) {
				$(this).mouseover(function () {
					var submenu = $(this).next();
					$('#menu_top > ul > li.submenu').not(submenu).hide();
					submenu.show();
				});
				
				$(this).next().each(function () {
					var offset = $(this).prev().offset();
					$(this).css('left', offset.left-34);
				});
			} else {
				
				if (!$(this).hasClass('submenu')) {
					$(this).mouseover(function () {
						//alert('pac');
						$('#menu_top > ul > li.submenu').hide();						
					});		
				}	
			}	
		});
		
		$('#menu_top > ul > li.submenu').each(function () {
			$(this).mouseleave(function () {
				$(this).hide();
				//$(this).slideUp();
			});
		});
	
	/*
		$('#menu_top > ul > li.with_submenu').each(function () {
			$(this).mouseleave(function () {
				$(this).next().hide();			
			})
		});
	*/
		
	/*
		$('#menu_top li.submenu > ul > li.submenu').prev().addClass('with_submenu');
		$('#menu_top li.submenu > ul > li.with_submenu').each(function () {
			var aj_em = $(this);
			
			var item_index = (aj_em.index());
	
	
			aj_em.next().each(function () {
				var offset = $(this).prev().offset();
				$(this).css('left', 168);
				$(this).css('top',  offset.top + item_index*18);
			});
	
			aj_em.mouseover(function () { 
				var submenu = $(this).next();
				$('#menu_top li.submenu > ul > li.submenu').not(submenu).slideUp();
				submenu.slideDown('normal');
			});            
		});
	        
		$('#menu_top li.submenu > ul > li.submenu').each(function () {
	            $(this).mouseleave(function () {
	                $(this).slideUp();
	            });
	            $(this).hide();
		});
	*/
		$('#product_info').each(function () {
			if ($(this).html() == "") {
				$(this).hide();
			}
		});
		
		$('#search_form .phrase').focusin(function(){
			//alert('focusin');
			$(this).parent().find('.submit').addClass('active');
			
		});	
		$('#search_form .phrase').focusout(function(){
			//alert('focusout');
			$(this).parent().find('.submit').removeClass('active');
		});	
		
		$('.csc-sitemap > ul > li:first').addClass('first');
		
		
		$('table.team tr').each(function () {
			$(this).find('td:last').each(function () {
				$(this).addClass('last');
			})
		});
		
		
		var product_info_download = $('#product_info table').length;
		var product_info_link = $('#product_info ul').length;
		
		if (!(product_info_download) && !(product_info_link)) {
			$('#product_info').addClass('only_image');
		}
		
		$('.csc-uploads-fileName').each(function () {
			var description = $(this).find('.csc-uploads-description');
			if (description.length) {
				$(this).find('a').html( description.html() );
				description.hide();
			}
		});
		
	});
}) (jQuery);

