/* 
* Skeleton V1.0.2
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 5/20/2011
*/	
	

$(document).ready(function() {

	/* Hover Effects on home page gallery
	================================================== */
	
	$('.p-item .cell-wrapper').each(function () {
	  var $div = $('> div.p-item-hover', this);
	  var $span = $('> div.item-text', this);
/*
	  $(this).bind('hover click', function () {
	    $div.stop().fadeTo(200, .25);
	    $span.stop().fadeTo(200, .95);
	  }, function () {
	    $div.stop().fadeTo(200, 0);
			$span.stop().fadeTo(200, 0);
	  });
*/
		$(this).bind({
			mouseenter: function(){
				$div.stop().fadeTo(200, .25);
	    	$span.stop().fadeTo(200, .95);
			},
			mouseleave: function(){
	    	$div.stop().fadeTo(200, 0);
				$span.stop().fadeTo(200, 0);
			},
			click: function(){
				if($div.css('opacity') == 0){
					$div.stop().fadeTo(200, .25);
	    		$span.stop().fadeTo(200, .95);
	    	}else{
	    		$div.stop().fadeTo(200, 0);
					$span.stop().fadeTo(200, 0);
	    	}
			}
		});
	});

	/* Slide effect for "get in touch"
	================================================== */

	// run the currently selected effect
	function runEffect() {
		// get effect type from 
		var selectedEffect = 'slide'

		// most effect types need no options passed by default
		var options = { direction: "up" };

		// run the effect
		$( "#getn" ).toggle( selectedEffect, options, 500, callback );
	};

	//callback function 
	function callback() {
		setTimeout(function() {
			$( "#effect:visible" ).removeAttr( "style" ).fadeOut();
		}, 500 );
	};

	// Toggle contact info
	$( ".toggle" ).click(function() {
		runEffect();
		if($(this).hasClass('active')) 
			$(this).removeClass('active'); 
		else $(this).addClass('active');
		return false;
	});

	$( "#effect" ).hide();
	
	/* end "get in touch" */

	/* Tabs Activiation
	================================================== */
	var tabs = $('ul.tabs'),
	    tabsContent = $('ul.tabs-content');
	
	tabs.each(function(i) {
		//Get all tabs
		var tab = $(this).find('> li > a');
		tab.click(function(e) {
			
			//Get Location of tab's content
			var contentLocation = $(this).attr('href') + "Tab";
			
			//Let go if not a hashed one
			if(contentLocation.charAt(0)=="#") {
			
				e.preventDefault();
			
				//Make Tab Active
				tab.removeClass('active');
				$(this).addClass('active');
				
				//Show Tab Content
				$(contentLocation).show().siblings().hide();
				
			} 
		});
	}); 
	/* end Tabs */

});
