﻿/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <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(at)cherne(dot)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 ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){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.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);

/* Document Ready
/*--------------------------------------------------------------------------*/

$(document).ready(function () {

    if ($('body').hasClass('home')) {
        $('#slider').show();
    }
    else {
        $('#slider').remove();
        $('#header .wrapper').css('border-bottom', '0');
        $('#header').css('border-bottom', '4px solid #CCC');
    }

    social_bookmarks();
    tabs();
    portfolio();

});

function tabs() {

//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

}

function portfolio() {

	//overlays
			$('.portfolio-item').hoverIntent({
				interval: 200,
				over: function () {
						if ($.browser.msie) {
							$(this).find('.overlay, .stat').show().css('z-index', '1000');
						} 
						else {
							$(this).find('.overlay, .stat').fadeIn(100);
						}
				},
				out: function () {
					if ($.browser.msie) {
						$(this).find('.overlay, .stat').hide();
					}
					else {
						$(this).find('.overlay, .stat').fadeOut(200);
					}
				}
			});
				
}

function social_bookmarks() {
    if ($('body').is('.page-id-11, .page-id-2, .page-id-92')) {
        $('.dd_buttons').each(function () {
            $(this).children('.dd_button:eq(0)').css('padding-top', '1px');
            $(this).children('.dd_button:eq(2)').css('width', '90px');
        });
    }
    else {
        $('.dd_buttons').each(function () {
            $(this).children('.dd_button:eq(0)').css('padding-top', '1px');
            $(this).children('.dd_button:eq(1)').css('padding-top', '0px');
            $(this).children('.dd_button:eq(2)').css('width', '90px');
        });
    }
}
