//	***************************************************************************************
//	This general.js file contains general setup information for the jQuery/JavaScript tools
//	***************************************************************************************

/*
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */
(function(b){b.fn.superfish=function(k){var g=b.fn.superfish,j=g.c,f=b(['<span class="',j.arrowClass,'"> &#187;</span>'].join("")),i=function(){var c=b(this),l=d(c);clearTimeout(l.sfTimer);c.showSuperfishUl().siblings().hideSuperfishUl()},e=function(){var c=b(this),m=d(c),l=g.op;clearTimeout(m.sfTimer);m.sfTimer=setTimeout(function(){l.retainPath=(b.inArray(c[0],l.$path)>-1);c.hideSuperfishUl();if(l.$path.length&&c.parents(["li.",l.hoverClass].join("")).length<1){i.call(l.$path)}},l.delay)},d=function(c){var l=c.parents(["ul.",j.menuClass,":first"].join(""))[0];g.op=g.o[l.serial];return l},h=function(c){c.addClass(j.anchorClass).append(f.clone())};return this.each(function(){var c=this.serial=g.o.length;var m=b.extend({},g.defaults,k);m.$path=b("li."+m.pathClass,this).slice(0,m.pathLevels).each(function(){b(this).addClass([m.hoverClass,j.bcClass].join(" ")).filter("li:has(ul)").removeClass(m.pathClass)});g.o[c]=g.op=m;b("li:has(ul)",this)[(b.fn.hoverIntent&&!m.disableHI)?"hoverIntent":"hover"](i,e).each(function(){if(m.autoArrows){h(b(">a:first-child",this))}}).not("."+j.bcClass).hideSuperfishUl();var l=b("a",this);l.each(function(n){var o=l.eq(n).parents("li");l.eq(n).focus(function(){i.call(o)}).blur(function(){e.call(o)})});m.onInit.call(this)}).each(function(){var c=[j.menuClass];if(g.op.dropShadows&&!(b.browser.msie&&b.browser.version<7)){c.push(j.shadowClass)}b(this).addClass(c.join(" "))})};var a=b.fn.superfish;a.o=[];a.op={};a.IE7fix=function(){var c=a.op;if(b.browser.msie&&b.browser.version>6&&c.dropShadows&&c.animation.opacity!=undefined){this.toggleClass(a.c.shadowClass+"-off")}};a.c={bcClass:"sf-breadcrumb",menuClass:"sf-js-enabled",anchorClass:"sf-with-ul",arrowClass:"sf-sub-indicator",shadowClass:"sf-shadow"};a.defaults={hoverClass:"sfHover",pathClass:"overideThisToUse",pathLevels:1,delay:800,animationOpen:{opacity:"show"},animationClose:{opacity:"hide"},speed:"normal",autoArrows:true,dropShadows:true,disableHI:false,onInit:function(){},onBeforeShow:function(){},onShow:function(){},onHide:function(){}};b.fn.extend({hideSuperfishUl:function(){var d=b.fn.superfish.op,c=b("li."+d.hoverClass,this).add(this);c.find(">ul").animate(d.animationClose,d.speed,function(){b(this).css("visibility","hidden");c.removeClass(d.hoverClass);d.onBeforeShow.call(c)});return this},showSuperfishUl:function(){var d=b.fn.superfish.op,c=this.addClass(d.hoverClass).find(">ul:hidden").css("visibility","visible");d.onBeforeShow.call(c);c.animate(d.animationOpen,d.speed,function(){d.onShow.call(this)});return this}})})(jQuery);


$(document).ready(function(){ 

//InitialiseSuperfish DropDown Menu
$("#main-nav ul").superfish({
	animationOpen:{opacity:'show',height:'show'}, //fade-in and slide-down animation
	speed:'400',// faster animation speed
	autoArrows:true,// disable generation of arrow mark-up
	dropShadows:false// disable drop shadows
	});
	

// HOME >> jQuery Tools Scrollable
// custom easing called "custom"
$.easing.custom = function (x, t, b, c, d) {
	var s = 1.70158; 
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}
// Remove scrollbar in JS
$('#slider').css('overflow', 'hidden');
  
var api = $("#slider").scrollable({
//	items: '.items',
	easing: 'custom',
	speed: 1500,
	circular: true
// use the navigator plugin
}).autoscroll(6000);


// Fancybox Gallery Setting
$(".photoGallery a").fancybox({
		'transitionIn'	:'elastic',
		'transitionOut'	:'fade',
		'overlayColor'	:'#111',
		'padding'		:6,
		'titlePosition'	:'over'
		});


// Fancybox iFrame
$("a.iframe").fancybox({
		'width'			:720,
		'height'		:540,
		'transitionIn'	:'elastic',
		'transitionOut'	:'fade',
		'overlayColor'	:'#111',
		'padding'		:6,
		'centerOnScroll':true,
		'titlePosition'	:'over'
		});



// jQuery Tools TABs
$(".post-table ul.tab").tabs("div.tab-wrap > ul", {effect:"slide"});



// initialize jQuery Tools Tooltip
$(".credits a[title]").tooltip({
	effect: 'slide',
	opacity: 0.9,
	position: 'top center'
});
$(".social a[title]").tooltip({
	effect: 'slide',
	opacity: 0.9,
	position: 'bottom center',
	direction: 'down'
});


// Fading Back-to-Top Button
$('#top').css('cursor', 'pointer').click(function(){
$('body,html').animate({ scrollTop: 0 },  800);  
});


// Sliding Effect
$("a#promo").hover(function(){
// on mouse over
$(this).stop().animate({top: -14},"slow");
},function() {
// on mouse out
$(this).stop().animate({top: 0},"slow");
});


// PDF Hover Icon
$('a[href$=.pdf]').before('<img style="display:inline; padding-right:10px; vertical-align:middle" src="/wp-content/themes/carlomagno/images/pdf.gif" alt="PDF"/>');

}); // end document ready 
