$(document).ready(function() {

	/* CUFON */
    Cufon.replace('.cufon', {
        hover: true
    });
    Cufon.replace('#subpageContent h2');
    
    /* INPUT DEFAULT TEXT */
   if ($("#s").text() != "") {
        $(this).parent().find("label").hide();
   }
    
   $("#s").focus(function() {
        $(this).parent().find("label").hide();
    });


    $("#s").blur(function() {
        if ($(this).val() == "") {
            $(this).parent().find("label").show();
        }
    });
    
	/* SLIDESHOW */
	$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
	    $(pager).find('li').removeClass('selected') 
	        .filter('li:eq('+currSlideIndex+')').addClass('selected'); 
	        
		    Cufon.replace('#paging .cufon', {
		        hover: true
		    });
	}; 
	
	// LIGHTBOX
	$(".gallery a").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over'//,
		//'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			//return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			//return (title.length ? '<span id="fancybox-title-over">' + title.replace("#/", "</strong> - ").replace("#", "<strong>") + '</span>' : null);
		//}
	});
	
	
	$navUL = $('<ul/>');
	$("#paging").append($navUL);
	
	$("#carousel .scrollingContent").cycle({
		fx: 'scrollHorz', 
		speed:    500, 
		timeout:  5000,
		autostop: true,
		autostopCount: ($(".carouselItem").length + 1), 
		pager: '#paging ul',
	    prev:   '#carouselControls #prev a', 
		next:   '#carouselControls #next a',
		pagerAnchorBuilder: function(idx, slide) { 
		    return '<li class="cufon"><a href="javascript:void(0);"><span>' + (idx + 1) + '</span></a></li>'; 
		}
	});
	
	/* PANELS */
	$(".promoPanel").hoverIntent(function() {
		$(this).find(".panelContent").animate({
			height : '200px',
			marginTop : '-200px'
		}, "fast");
	},function() {
		$(this).find(".panelContent").animate({
			height : '55px',
			marginTop : '-55px'
		}, "fast");
	});
    
	/* SUBMENU */
	
	$("#submenu ul li").not(".selected").find("ul").hide();
	/* $("#submenu ul:first li").not(".selected").hoverIntent( function() {
		if ($(this).find("ul").length > 0) {
			$(this).toggleClass("selected").find("ul").slideToggle();
		}
	}, function() {
		$(this).removeClass("selected").find("ul").slideToggle();
	});
	*/
});
