// Hubsoft.com && SebringCreative.com - Dual licensed under the MIT and GPL licenses.
(function($){$.fn.dumbCrossFade=function(settings){var config={'index':0,'showTime':5000,'transitionTime':1500,'doHoverPause':true,'maxZIndex':100};var timeOut=null;var itemArray=[];function cancelCrossFade(){if(timeOut!==null){window.clearTimeout(timeOut);timeOut=null;}}
function doCrossFade(){timeOut=window.setTimeout(function(){var currentIndex=config.index;var nextIndex=(config.index>=itemArray.length-1)?0:config.index+1;itemArray[currentIndex].css('z-index',(config.maxZIndex-1)+'');itemArray[nextIndex].css('z-index',config.maxZIndex+'');itemArray[nextIndex].fadeIn(config.transitionTime,function(){itemArray[currentIndex].hide();});config.index=nextIndex;doCrossFade();},config.showTime);}
if(settings)$.extend(config,settings);this.each(function(){(itemArray.length===config.index)?$(this).show():$(this).hide();if(config.doHoverPause){$(this).hover(function(){cancelCrossFade();},function(){cancelCrossFade();doCrossFade();});}
itemArray[itemArray.length]=$(this);});doCrossFade();return this;};})(jQuery);

/**
 * @author Alexander Farkas
 */

(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state == 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
            
           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/(\d+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(\d+)(px|\%|em|pt)\s(\d+)(px|\%|em|pt)/);
               return [parseFloat(res[1]),res[2],parseFloat(res[3]),res[4]];
           }
        }
	});
    
})(jQuery);

jQuery(document).ready(function($){
	
	// Superfish menu dropdown
	$('ul.nav').superfish({ 
		delay:       1000,
		animation:   {opacity:'show'}, 
		speed:       'fast',
		autoArrows:  false,
		dropShadows: false
	});
	// Medua Plugin
	$('.media').media();
	// MP3 Plugin
	$('.mp3').media({ height: 20, autoplay: true}); 
	// Gallery Widget
	$('div.latestGallery div.thumbImg').hover(function() {
		$(this).addClass('thumbImg_Hover');
			}, function() {
		$(this).removeClass('thumbImg_Hover');
	});
	$('div.latestGallery div.thumbImg').css('opacity', '0.7');
	$('div.latestGallery div.thumbImg').mouseover(function(){
		$(this).stop().animate({opacity: 1}, {duration:600})
	})
	.mouseout(function(){
		$(this).stop().animate({opacity: 0.7}, {duration:800})
	});
	//Generic hover script
	$('.makeHover, #navbar li.icon_none a, ul.sitewidgetShopUL li a, div.sitewidget.twitter.integrated div#twitter p.profileLink').hover(function(){
		$(this).addClass('addHover');
	}, function(){
		$(this).removeClass('addHover');
	});
	
	


	// .
$('.dumbCrossFade .dumbItem').dumbCrossFade();
		// ..

//my hover function
$('div.hoverit, td.hoverit').mouseover(function(){
	$(this).addClass('hover');
}).mouseout(function(){
	$(this).removeClass('hover');
});


});

