$(document).ready( function() {
	
	$('a.offer').mouseover(function() {
		$(this).parent().children('.subMenuContainer').show();
		
		$(this).parent().hover(function() {  
         }, function(){  
             $(this).parent().find(".subMenuContainer").hide();
        }); 
		
	});
	
	$('a.company').mouseover(function() {
		$(this).parent().children('.subMenuContainer').show();
   
		$(this).parent().hover(function() {  
         }, function(){  
             $(this).parent().find(".subMenuContainer").hide();
        }); 
		
	});
	
	$('a.quality').mouseover(function() {
		$(this).parent().children('.subMenuContainer').show();
   
		$(this).parent().hover(function() {  
         }, function(){  
             $(this).parent().find(".subMenuContainer").hide();
        }); 
		
	});
	
	$("div.point").mouseover(function() {
		var pinId = $(this).attr('id');
		var pinNr = pinId.substring(3);
		$('.map .od'+pinNr).show();
		$(this).children('.pin').children('div').show();
	});
	
	$("div.point").mouseout(function() {
		var pinId = $(this).attr('id');
		var pinNr = pinId.substring(3);
		$('.map .od'+pinNr).hide();
		$(this).children('.pin').children('div').hide();
	});
	
	$(".punktyZbiorki li").mouseover(function() {
		var oId = $(this).attr('class');
		var oNr = oId.substring(1);
		$(this).addClass('highlight');
		$('#pin'+oNr).children('.pin').show();
		
		$(this).mouseout(function() {
			var oId = $(this).attr('class');
			var oNr = oId.substring(1);
			$(this).removeClass('highlight');
			$('#pin'+oNr).children('.pin').hide();
		});
	});
	
	$(".searchfield").blur(function() {
		var $value = $(this).val();
		
			$(this).val($value);

	});
	
	$(".searchfield").focus(function() {
		$(this).val('');
	});
	
});

	function slideSwitch() {
		var $active = $('#photos div.active');
		
		if ( $active.length == 0 ){
			$active = $('#photos div:last');
		}
		
		var $next =  $active.next().length ? $active.next() : $('#photos div:first');
		
		//var $next = $active.next();    
		$next.addClass('active');
		$active.removeClass('active');
	}

	$(function() {
		setInterval( "slideSwitch()", 2000 );
		$('.subMenuContainer').css('zIndex', 9999);
		$('.menuContainer').css('zIndex', 9999);
	});
	
	

