// JavaScript Document
$(document).ready(function() {
	
	//-Hiding the close button and the dynamic content by default.
	$('#close_panel, #dynamicload>div').hide();
	
	//-Slidedown on click
	$('.btn_slide').click(function(e){
		$('.active_content').hide().removeClass('active_content');
		$('#panel').height($(document).height()).slideDown(700, function(){
			$('#close_panel').fadeIn('fast');
		});
		$('#nav a:not(.btn_work, .btn_promo)').addClass('underline');
		e.preventDefault();
	});	
	
	//-Load content for Home
	/*$('.btn_home').click(function(e){
		$('#panel_home').fadeIn('fast').addClass('active_content');		
		e.preventDefault();
	});*/
	
	//-Load content for People
	$('.btn_people').click(function(e){
		$('#panel_people').fadeIn('fast').addClass('active_content');
		$('#nav a').removeClass('active');
		$(this).addClass('active');
		e.preventDefault();
	});
	
	//-Load content for Services
	$('.btn_services').click(function(e){
		$('#panel_services').fadeIn('fast').addClass('active_content');
		$('#nav a').removeClass('active');
		$(this).addClass('active');
		e.preventDefault();
	});
	
	//-Load content for Clients
	$('.btn_clients').click(function(e){
		$('#panel_clients').fadeIn('fast').addClass('active_content');
		$('#nav a').removeClass('active');
		$(this).addClass('active');
		e.preventDefault();
	});
	
	//-Load content for Contact
	$('.btn_contact').click(function(e){
		$('#panel_contact').fadeIn('fast').addClass('active_content');
		$('#nav a').removeClass('active');
		$(this).addClass('active');
		e.preventDefault();
	});
	
	//-Close Slideup on click
	$('.btn_slide_close').click(function(e){
		$('#panel').slideUp(1000, function(){
			$('.active_content').hide().removeClass('active_content');
			$('#nav a').removeClass('active');
			$('#nav a:not(.btn_work .btn_promo)').removeClass('underline');
		});
		e.preventDefault();
	});

	//-Default Sliding Panel
	/*$('#panel').height($(document).height()).slideDown(1000, function(){	
		$('#panel_home').fadeIn('fast').addClass('active_content');	
		$('#nav a:not(.btn_work, .btn_promo)').addClass('underline');
		$('#close_panel').fadeIn('fast');
	});*/



/* SHADOWS */
$('#header, #slider_wrap_shadow, a.project_th').dropShadow({
		left    : 0,
		top     : 0,
		blur    : 2,
		opacity : 0.3,
		color   : '#000000',
		swap    : false
});



/* TWITTER */
$(window).load(function(){
$('ul#twitter_update_list a[href^="http://"]')
  .attr("target", "_blank");
});

$('#twitter').getTwitter({
	userName: 'vanillashakemed',
	numTweets: 2,
	loaderText: 'Loading tweets...',
	slideIn: true,
	showHeading: true,
	headingText: 'Latest Tweets',
	showProfileLink: true
});



/* FANCY BOX */
$("a[rel=latest_projects]").fancybox({
	'transitionIn'	:	'elastic',
	'transitionOut'	:	'elastic',
	'speedIn'		:	600, 
	'speedOut'		:	200, 
	'overlayShow'	:	true,
	'titlePosition' :   'outside',
});



/* FORM FIELDS VALUES */
/* original source: http://buildinternet.com/2009/01/changing-form-input-styles-on-focus-with-jquery/ */
$('input[type="text"],textarea').addClass("idleField");
$('input[type="text"],textarea').focus(function() {
	$(this).removeClass("idleField").addClass("focusField");
	if (this.value == this.defaultValue){ 
		this.value = '';
	}
	if(this.value != this.defaultValue){
		this.select();
	}
});
$('input[type="text"],textarea').blur(function() {
	$(this).removeClass("focusField").addClass("idleField");
	if ($.trim(this.value) == ''){
		this.value = (this.defaultValue ? this.defaultValue : '');
	}
});


//document ready ends
});



/* EQUAL HEIGHTS */
function equalHeight(group) {
   tallest = 0;
   group.each(function() {
      thisHeight = $(this).height();
      if(thisHeight > tallest) {
         tallest = thisHeight;
      }
   });
   group.height(tallest);
}
$(document).ready(function() {
   equalHeight($(".footer_box"));
});

