// JavaScript Document

// nav menu - li hover 
$(function() {
	$('#browse, .hoveranimate').hover(function() {
		$(this).stop().animate({ "opacity" : 1 },400);
	}, function() {
		$(this).stop().animate({ "opacity" : .6 },400);
	});
});

// next/prev hover 
$(function() {
	$('.arrow a').hover(function() {
		$(this).stop().animate({ "opacity" : 1 },400);
	}, function() {
		$(this).stop().animate({ "opacity" : .6 },400);
	});
});


// studio page - photo hover
$(function() {
	$('#teamgallery li').hover(function() {
		$('#teamgallery li').stop().animate({ "opacity" : .4 },800);
		$(this).stop().animate({ "opacity" : 1 },500);
	}, function() {
		$(this).stop().animate({ "opacity" : .4 },500);
		$('#teamgallery li').stop().animate({ "opacity" : 1 },800);
	});
});

		
		
// projects pages - generates thumbnails for available images
$(function() {
    $('ul#imagemenu li img').hover(function() {
        var rel = $(this).attr('rel');
    if  ( $('ul#horizontal #'+rel).is('.visible') || $('ul#vertical #'+rel).is('.visible') ) {
    } else if (rel == 'image01' || rel == 'image03' || rel == 'image05' || rel == 'image07' ) {
        $('ul#horizontal img').fadeOut(500).removeClass('visible');
        $('ul#horizontal #'+rel).fadeIn(500).addClass('visible');
    } else {
        $('ul#vertical img').fadeOut(500).removeClass('visible');
        $('ul#vertical #'+rel).fadeIn(500).addClass('visible');
    } }, function() {
	return false;
    });
});


// projects pages - image thumbnail hover
$(function() {
	$('#imagemenu li img').hover(function() {
		$(this).stop().animate({ "opacity" : 1 });
	}, function() {
		$(this).stop().animate({ "opacity" : .3 });
	});
});


// properties pages - menu thumbnail hover
$(function() {
	$('.propmenu li').hover(function() {
	var rel = $(this).attr('class');
	if  ( rel != 'current' ) {
		$('.tooltip2').stop().animate({ "opacity" : 0 });
		$('#'+rel).stop().animate({ "opacity" : 1 });
	} }, function() {
	var rel = $(this).attr('class');
		$('#'+rel).stop().animate({ "opacity" : 0 });
		$('.current .tooltip2').stop().animate({ "opacity" : 1 });
	 });
});




// tooltips
$(function() {
		$(".moreinfo").tooltip({ position: "center right", delay: 60, offset: [0,8], effect: 'fade', tipClass: 'tooltip2', relative: 'true' })
});


// email link
function mailMe(sDom, sUser){ return("mail"+"to:"+sUser+"@"+sDom.replace(/%23/g,".")); }



// index page slideshow
function slideSwitch() {
    var $active = $('.slideshow img.active');
    if ( $active.length == 0 ) $active = $('.slideshow img:last');
    var $next =  $active.next().length ? $active.next()
        : $('.slideshow img:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1500, function() {
            $active.removeClass('active last-active');
        });
}
$(function() {
    setInterval( "slideSwitch()", 5000 );
});


function slideSwitchRight() {

    var $active = $('.slideshowright img.active');
    if ( $active.length == 0 ) $active = $('.slideshowright img:last');
    var $next =  $active.next().length ? $active.next()
        : $('.slideshowright img:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
	.delay(1000)
        .addClass('active')
        .animate({opacity: 1.0}, 1500, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitchRight()", 5000 );
});

/**
* 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);

