/*JQUERY*/
jQuery.noConflict();

/* SHADOWBOX */
Shadowbox.init();


/* TIMER */
function liftOff() { 
    jQuery(".timer").css({ display: "none" });
 
}

jQuery(function() {
	var liftoffTime = new Date();
	
	liftoffTime = new Date(2011, 9 - 1, 29,18,0,0);

	jQuery('.count-down').countdown({	
		until: liftoffTime, 
		timezone: -4, 
		format: 'HMS', 
		compact: true, 
    	layout: '{hnn}{sep}{mnn}{sep}{snn}',
		onExpiry: liftOff,
		alwaysExpire: true
	});
	
});




/* TABS */
jQuery(document).ready(function() {
	jQuery(".tweet").tweet({
		avatar_size: 48,
		count: 4,
		username: "zestypink",
		loading_text: "loading list..."
  	});

	jQuery('#tabs > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
	jQuery("#featured div > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
	jQuery("#fragment-1").click(function(event){
     	alert("Thanks for visiting!");
   	});


});


/* NAVIGATION */
jQuery(function() {
jQuery.fn.calcSubWidth = function() {
            rowWidth = 0;
            //Calculate row
            jQuery(this).find("ul").each(function() { //for each ul...
                rowWidth += jQuery(this).width(); //Add each ul's width together
            });
        };
var paddingFix = 0;
function megaHoverOver(){
    jQuery(this).find(".sub").stop().fadeTo(0, 1, function(){
    			jQuery(this).css('filter','');
        }).show(); //Find sub and fade it in
     subPaddingLeft = jQuery(this).find('.sub').css('padding-right');
	 subPaddingRight = jQuery(this).find('.sub').css('padding-left');
	 if (subPaddingLeft && subPaddingRight)
	 {
		 subPaddingLeft = parseInt(subPaddingRight.replace('px', ''));
		 subPaddingRight = parseInt(subPaddingRight.replace('px', ''));
		 paddingFix = subPaddingLeft + subPaddingRight;
	 }
    if ( jQuery(this).find(".row").length > 0 ) { //If row exists...

        var biggestRow = 0;	
        jQuery(this).find(".row").each(function() {
            jQuery(this).calcSubWidth(); //Call function to calculate width of all ul's
            //Find biggest row
            if(rowWidth > biggestRow) {
                biggestRow = rowWidth;
            }
        });
        jQuery(this).find(".sub").css({width : biggestRow + paddingFix}); //Set width
        jQuery(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin

    } else { //If row does not exist...
        jQuery(this).calcSubWidth();  //Call function to calculate width of all ul's
        jQuery(this).find(".sub").css({'width' : rowWidth + paddingFix}); //Set Width

    }
}
//On Hover Out
function megaHoverOut(){
  jQuery(this).find(".sub").fadeTo(0, 0, function() { //Fade to 0 opactiy
      jQuery(this).hide();  //after fading, hide it
  });
}

//Set custom configurations
var config = {
     sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
     interval: 0, // number = milliseconds for onMouseOver polling interval
     over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
     timeout: 0, // number = milliseconds delay before onMouseOut
     out: megaHoverOut // function = onMouseOut callback (REQUIRED)
};
jQuery("ul#pronav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
jQuery("ul#pronav li").hoverIntent(config); //Trigger Hover intent with custom configurations
});
