$(function(){





/*-----------------------------------------------------------------------------------*/
/*	Slider - http://slidesjs.com/
/*-----------------------------------------------------------------------------------*/
				if ($().slides) {
			
					$('#slider').css({ display : 'block' });
						
					$("#slider").slides({
						preload: true,
						preloadImage: '../images/slider/loading.gif',
						play: 6000, //Auto play time. Set to 0 to stop auto rotate. 6000
						width: 960,
						pause: 4500,
						slideSpeed: 1000, //Slide rotation speed.
						generatePagination: true,
						hoverPause: true,
						autoHeight: true
					});	
					
				}
				
/*-----------------------------------------------------------------------------------*/
/*	Fading Buttons - http://greg-j.com/2008/07/21/hover-fading-transition-with-$/
/*-----------------------------------------------------------------------------------*/		

	$('.fadeThis').append('<span class="hover"></span>').each(function () {
	  var $span = $('> span.hover', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(500, 1);
	  }, function () {
	    $span.stop().fadeTo(500, 0);
	  });
	});

/*-----------------------------------------------------------------------------------*/
/*	Equal Heights Plugin 															  /
/*-----------------------------------------------------------------------------------*/		
/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 * 
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
 *
 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
 * 
 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
 * 
 */

(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","auto");
		});
	}
})($);

$(function() {
$('.service h4').equalHeights();
$('.service p').equalHeights(200,800);
});

/*-----------------------------------------------------------------------------------*/
/*	Show/Hide Content - http://rpardz.com/blog/show-hide-content-$-tutorial/
/*-----------------------------------------------------------------------------------
	
    $('.open-content').hide().before('<div class="container_12"><a href="#" id="toggle-content" class="button"><div id="expand-button" ></div></a></div><div id="toggle-top" style="width:100%"></div>');
	$('a#toggle-content').click(function() {
		$('.open-content').slideToggle(1000);
		return false;
	});
	
	*/	
/*-----------------------------------------------------------------------------------*/
/*	FancyBox  - http://fancybox.net/
/*-----------------------------------------------------------------------------------*/	
			$("#various1").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
			
			$("a.portfolio").fancybox();
			
			
/*-----------------------------------------------------------------------------------*/
/*	Mosaic Image Hover   - http://buildinternet.com/project/mosaic/1.0/
/*-----------------------------------------------------------------------------------*/	
				$('.circle').mosaic({
					opacity : 0.8	//Opacity for overlay (0-1)
				});
				
				$('.fade').mosaic();
				
/*-----------------------------------------------------------------------------------*/
/*	Add Class to Tag Cloud (WP prep work) - http://www.simplethemes.com/blog/entry/style-wordpress-tags/
/*-----------------------------------------------------------------------------------*/					
		$('p.tags a').wrap('<span class="jg-tags" />');
		
		
/*-----------------------------------------------------------------------------------*/
/*	Navigation -  http://users.tpg.com.au/j_birch/plugins/superfish/
/*-----------------------------------------------------------------------------------*/		
		$("ul.sf-menu").superfish(); 
   

   
		

   
});


$(window).load(function () {
// Handler for .ready() called.
    var $el, leftPos, newWidth;
        $mainNav = $("#main-nav");
        pageOffset = $mainNav.offset().left;
        
 	$mainNav.append('<li id="magic-line" style="z-index:10;"></li>');
    var $magicLine = $("#magic-line");


// Fixing the offset if the window changes size
$(window).resize(function() {
pageOffset = $mainNav.offset().left;
});


    $magicLine.width($(".active").width())
        .height($mainNav.height())
        .css("left", $(".active a").offset().left - pageOffset)
        
        //.css("left", $(".active a").position().left)
        .data("origLeft", $(".active").position().left)
        .data("origWidth", $magicLine.width())
        .data("origColor", $(".active").attr("rel"));
            
    $("#main-nav>li").hover(function() {
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el./*parent()*/width();
        $magicLine.stop().animate({
            left: leftPos,
            width: newWidth,
            backgroundColor: $el.attr("rel")
        })
    }, function() {
        $magicLine.stop().animate({
            left: $magicLine.data("origLeft"),
            width: $magicLine.data("origWidth"),
            backgroundColor: $magicLine.data("origColor")
        });    
    });
    
    /* Kick IE into gear */
    $(".active a").mouseenter();
    
    });






