jQuery(document).ready(function() {
	
	$('.slideshow').cycle({
	    fx: 'scrollLeft',
	    speed: 300,
	    pause: true,
	    pager: '#promonav',
	    pagerAnchorBuilder: function(idx, slide) { 
	        return null; 
	    } 
	});	
	
	$('#promonav a').click(function() {		
		count = parseInt($(this).attr('rel'));
		$('.slideshow').cycle(count); 
    	return false;		
	});
    
	$('.nivoSlider').nivoSlider({
		effect: 'fade'
	});
	
	$("#storedropdown").change(function() {
        if ($(this).val()) {
            window.open($(this).val(), '_self');            
        }
    });
    
    $('#storefilter li a').each(function(){
		var coords = $(this).attr('rel').split('-');
		$(this).parent().css({left: coords[0] + 'px', top: coords[1] + 'px', display: 'block'})
			.hide()
			.fadeIn()
			.click(function(){
				
				$('#storefilter li').removeClass('selected');
				$(this).addClass('selected');
				
				thisItem = $(this).children('a').attr('class');				
				
				if (thisItem != "all") {
				
					$('#storelist li[class='+thisItem+']').stop()
						.animate({							
							'height' : '150px'							
						}).css({'display' : 'block'});
																		
					$('#storelist li[class!='+thisItem+']').stop()
						.animate({							
							'height' : 0							
						}).css({'display' : 'none'});
						
				} else {
								
					$('#storelist li').stop()
						.animate({			
							'height' : '150px'
						}).css({'display' : 'block'});
						
				}
				
			});
	});
	
	
	var cookieName = 'dailypita';
	var cookieOptions = {expires: 7, path: '/'};	
	
	$('#btn-dailypita, #dailypita-popup, #featpita').fancybox({
		overlayColor: '#000000',
		overlayOpacity: 0.7
	});	
	if ($.cookie(cookieName) != 'pop') {
		$("#dailypita-popup").trigger('click');
		$.cookie(cookieName, 'pop', cookieOptions);
	}
	
});
