// Form Input Hints
(function($) {
    $.fn.hint = function(blurClass) {
        if (!blurClass) {
            blurClass = 'blur';
        }
        return this.each(function() {
            // get jQuery version of 'this'
            var $input = $(this),

                // capture the rest of the variable to allow for reuse
                title = $input.attr('title'),
                $form = $(this.form),
                $win = $(window);
            function remove() {
                if ($input.val() === title && $input.hasClass(blurClass)) {
                    $input.val('').removeClass(blurClass);
                }
            }
            // only apply logic if the element has the attribute
            if (title) {
                // on blur, set value to title attr if text is blank
                $input.blur(function() {
                    if (this.value === '') {
                        $input.val(title).addClass(blurClass);
                    }
                }).focus(remove).blur(); // now change all inputs to title
                // clear the pre-defined text when form is submitted
                $form.submit(remove);
                $win.unload(remove); // handles Firefox's autocomplete
            }
        });
    };
})(jQuery);




// All jQuery functions on page load
$(document).ready(function() {
	
// Newsletter Hint


$("#newsletter .your-name input").attr('title', 'Name'); 
$("#newsletter .your-email input").attr('title', 'Email'); 

$('#newsletter input').hint();
	
	
	  var lis2 = $("ul#gallery_slider a");
for(var i = 0; i < lis2.length; i+=3) {
  lis2.slice(i, i+3).wrapAll("<li></li>"); }
	

	
 //wrap every three elements	
	
var lis = $("#events-slider div.list_holder");
for(var i = 0; i < lis.length; i+=4) {
  lis.slice(i, i+4).wrapAll("<li></li>");
}


	// Cufon Font Replacement
	Cufon.replace('h2');
	Cufon.replace('#navigation li a');
	Cufon.replace('#subscribe li strong');
	Cufon.replace('.speech_bubble span');
	Cufon.replace('#news_ticker_title');
	Cufon.replace('#content_tabs li');
	
	$('#navigation li').hover(function() {
		Cufon.refresh('#navigation li a');
	}, function() {
		setTimeout(function(){ Cufon.refresh('#navigation li a'); }, 25);
	});
	

	
	
	// CAUTION IT'S A THEME PARK AHEAD
	if($('#gallery_slider').is(':visible')) {
		$('#gallery_slider').anythingSlider({
			startStopped    : false, // If autoPlay is on, this can force it to start stopped
			width           : 638,   // Override the default CSS width
			autoPlayLocked : true,
			height: 159,
			theme           : 'metallic',
			easing: 'easeInOutBack',
			delay: 5000
		});
	}
	
	if($('#apparel_slider').is(':visible')) {
		$('#apparel_slider').anythingSlider({
			startStopped    : false, // If autoPlay is on, this can force it to start stopped
			width           : 290,   // Override the default CSS width
			autoPlayLocked : true,
			height: 246,
			theme           : 'default',
			resizeContents : false,
			buildArrows : false,
			easing: 'easeInOutBack',
			delay: 5000
		});
	}
	
	if($('#partners_slider').is(':visible')) {
		$('#partners_slider').anythingSlider({
			startStopped    : false, // If autoPlay is on, this can force it to start stopped
			width           : 290,   // Override the default CSS width
			autoPlayLocked : true,
			height: 244,
			theme           : 'metallic',
			resizeContents : false,
			buildArrows : false,
			easing: 'easeInOutBack',
			delay: 5000
		});
	}
	
	if($('#events-slider').is(':visible')) {
		$('#events-slider').anythingSlider({
			startStopped    : false, // If autoPlay is on, this can force it to start stopped
			width           : 290,   // Override the default CSS width
			autoPlayLocked : true,
			height: 244,
			theme           : 'metallic',
			resizeContents : false,
			buildArrows : false,
			easing: 'easeInOutBack',
			delay: 5000
		});
	}
	
	$('#content_tabs li').click(function() {
		Cufon.refresh('#content_tabs li');
		return false;
	});
	
	$("#content_tabs").tabs("div.tab_container > div" , {
		effect: 'fade'
	});
	
	
	
	
	// SELECT CATEGORY FROM DROPDOWN
	if($('#select_category').is(':visible')) {
		$('#category_title').click(function() {
			$('#category_list').slideToggle();
		});
	};
	
			// News Ticker 
	
	$("#news_ticker #story_flicker").newsticker();	
	
});
