/* Author: 
Supereightstudio.com
*/


// tooltips
$(function() {
    
$('#example-1').tipsy();

$('#north').tipsy({gravity: 'n'});
$('#south').tipsy({gravity: 's'});
$('#east').tipsy({gravity: 'e'});
$('#west').tipsy({gravity: 'w'});

$('#auto-gravity').tipsy({gravity: $.fn.tipsy.autoNS});

$('.fade').tipsy({fade: true});

$('#example-custom-attribute').tipsy({title: 'id'});
$('#example-callback').tipsy({title: function() { return this.getAttribute('original-title').toUpperCase(); } });
$('#example-fallback').tipsy({fallback: "Where's my tooltip yo'?" });

$('#example-html').tipsy({html: true });

});

$.fn.tipsy.defaults = {
    delayIn: 0,      // delay before showing tooltip (ms)
    delayOut: 0,     // delay before hiding tooltip (ms)
    fade: false,     // fade tooltips in/out?
    fallback: '',    // fallback text to use when no tooltip text
    gravity: 's',    // gravity
    html: false,     // is tooltip content HTML?
    live: false,     // use live event support?
    offset: 0,       // pixel offset of tooltip from element
    opacity: 0.8,    // opacity of tooltip
    title: 'title',  // attribute/callback containing tooltip text
    trigger: 'hover' // how tooltip is triggered - hover | focus | manual
};

// :nth-child
$(function () {
	$("ul#story_list li:nth-child(even) article").addClass("even");
	$("ul#story_list li:nth-child(even) img").addClass("even");
	$("ul#story_list li:nth-child(4n+2)").addClass("story_2");
	$("ul#story_list li:nth-child(4n+3)").addClass("story_3");
	$("ul#story_list li:nth-child(4n+4)").addClass("story_4");
	$("ul#case_study_list li:nth-child(3n+2)").addClass("second");
	$("ul#case_study_list li:nth-child(3n+3)").addClass("third");
	$("ul#case_studies li:nth-child(3n+3)").addClass("last");
});

// ie6/7 form selectors
$(function () {
	$('input[type="text"]').addClass("text");
	$('input[type="checkbox"]').addClass("checkbox");
	$('textarea').addClass("textarea");
});

$(function() {
// Fix for IE6 & 7 to maintain input focus styling
	if ($.browser.msie === true) {
        $('input[type="text"]').bind('focus', function() { 
        	$(this).addClass("ieFocus"); })
            .bind('blur', function() { 
            $(this).removeClass("ieFocus"); 
        });
        
        $('textarea').bind('focus', function() { 
        	$(this).addClass("ieFocus"); })
            .bind('blur', function() { 
            $(this).removeClass("ieFocus"); 
        });
        
        $('input[type="password"]').bind('focus', function() { 
        	$(this).addClass("ieFocus"); })
            .bind('blur', function() { 
            $(this).removeClass("ieFocus"); 
        });
    } 
});

//If Javascript enabled, show more options link/hide more options fields in advanced search
$(function () {
	$('.more_package_info_link').css({"display" : "block"});
	$('.more_package_info').hide();
	
	$('.more_package_info_link').toggle(function(){
		$('.more_package_info').show("fast");
		$(this).children("a").html("- Less about what these packages include");
		$(this).children("a").addClass('open');
		}, function () {
		$('.more_package_info').hide("fast");
		$(this).children("a").removeClass('open');
		$(this).children("a").html("+ More about what these packages include");
	});
});
