// JavaScript Document
$(document).ready(function(){
/*var hash = window.location.hash.substr(1);
	var href = $('#primaryNav li a').each(function(){
		var href2 = $(this).attr('href');
		if(hash==href2.substr(1)){
			var toLoad = hash+' #loadArea';
			$('#loadArea').load(toLoad);
		}	
		});	
		
		$('.homeLink').click(function(){
			pageTracker._trackPageview('/home/');
		});
		$('.blogLink').click(function(){
			pageTracker._trackPageview('/blog/');
		});
		$('.avLink').click(function(){
			pageTracker._trackPageview('/av/');
		});
		$('.testimonialsLink').click(function(){  
			pageTracker._trackPageview('/testimonials/');
		});
		$('.infoLink').click(function(){
			pageTracker._trackPageview('/info/'); 
		});*/
	/*page to page ajax load
	ajaxVar();*/
	/*$('#primaryNav li a').live('click', function() {
		var toLoad = $(this).attr('href').substr(0) +' #loadArea';
		var toClass = $(this).attr('href').substr(0);
		$(this).addClass('active');
		$('.active').not(this).removeClass('active');
				if (toClass == '/blog') {
				  $('#primaryContent').animate({height: "235"});
				  $('#contentLeft, #sidebarRight').fadeIn();
				  }
				  if (toClass == '/') {
				  $('#primaryContent').animate({height: "400"});
				  $('#contentLeft, #sidebarRight').hide();
				  }
				  if (toClass == '/av') {
				  $('#primaryContent').animate({height: "900"});
				  $('#contentLeft, #sidebarRight').hide();
				  }
				  if (toClass == '/testimonials') {
				  $('#primaryContent').animate({height: "500"});
				  $('#contentLeft, #sidebarRight').hide();
				  }
				  if (toClass == '/info') {
				  $('#primaryContent').animate({height: "600"});
				  $('#contentLeft, #sidebarRight').hide();
				  }				  
		
		//var toLoadSec = $(this).attr('href').substr(2)+' .loadArea2';
		$('#fadeArea').animate({marginTop: "600"}).fadeOut('slow',loadContent);
		//$('#load').remove();
		//$('#wrapper').append('<span id="load">LOADING...</span>');
		$('#load').fadeIn('normal');
		
		//window.location.hash = $(this).attr('href').substr(1,$(this).attr('href').length-0);
		function fadeBW() {
		$('.featureImage2Hover, .blogImage2Hover').delay(1500).fadeOut(500);
		}
		function loadContent() {
			$('#loadArea').empty();
			$('#loadArea').load(toLoad,'', function() {
				$('.featureArea ul li:first').before($('.featureArea ul li:last'));
				$('.featureArea ul li:first').before($('.featureArea ul li:last'));
				$('.featureArea2 ul li:first').before($('.featureArea2 ul li:last'));
				$('.featureArea2 ul li:first').before($('.featureArea2 ul li:last'));
				$('.featureArea ul, .featureArea2 ul,').css({'left' : -280}, showNewContent())
			});
			//$('.loadArea2').load(toLoadSec, showBodyContent())
			
	function showNewContent() {
			$('#fadeArea').animate({marginTop: "0"}).fadeIn('fast',hideLoader()); 
		}

		function hideLoader() {
			$('#load').fadeOut('normal', fadeBW());
		}
		}
		return false;
	});
	ajax load section, and adjust height for the slider area
		function ajaxVar() {
			var loc = location.href;
			
			if (loc == 'http://www.wearepapertiger.com/') {
			  $('#primaryContent').animate({height: "400"});
			  $('#contentLeft, #sidebarRight').hide();
			  }
			  if (loc == 'http://www.wearepapertiger.com/blog') {
			  $('#primaryContent').animate({height: "235"});
			  $('#contentLeft, #sidebarRight').fadeIn();
			  }
			  if (loc == 'http://www.wearepapertiger.com/av') {
			  $('#primaryContent').animate({height: "900"});
			  $('#contentLeft, #sidebarRight').hide();
			  }
			  if (loc == 'http://www.wearepapertiger.com/testimonials') {
			  $('#primaryContent').animate({height: "500"});
			  $('#contentLeft, #sidebarRight').hide();
			  }
			  if (loc == 'http://www.wearepapertiger.com/info') {
			  $('#primaryContent').animate({height: "600"});
			  $('#contentLeft, #sidebarRight').hide();
			  }	
		}
		
		
	
	end ajax area */
	
////////////////////////////////////////////////////////////////////////////////////////////////	


		$('.featureImage2Hover, .blogImage2Hover').delay(1500).fadeOut(500);
		
		
/*	this section contains the contact area and a couple hover scripts	*/
// hide all hover overlays
	$('.featureImage2Hover').delay(1500).fadeOut(500);
// slide effect for contact area
	$('#contactTab').hover(function(){
		$('.tabOpen.active, .contactHover.active').stop(true, true).animate({opacity: "1"});
		$('.contactClosed.active').stop(true, true).animate({opacity: "0"});
		},
		function(){	
		$('.tabOpen.active, .contactHover.active').stop(true, true).animate({opacity: "0"});
		$('.contactClosed.active').stop(true, true).animate({opacity: "1"});
		});
		
	$('#contactTab').toggle(function(){
		$('#contactUs').animate({top: "0"}); 
		$('.contactHover, .contactClosed').removeClass('active').animate({opacity: "0"});
		$('.contactOpen, .tabOpen').animate({opacity: "1"}).removeClass('active');
		$('#contactTab').removeClass('active').css("background-image", "url(/images/site_images/header/contactTab.png)");
		},
		function(){
		$('#contactUs').animate({top: "-435"});
		$('.contactHover, .contactClosed').addClass('active').animate({opacity: "1"});
		$('.contactOpen, .tabOpen').animate({opacity: "0"}).addClass('active');
		$('#contactTab').addClass('active').css("background-image", "url(/images/site_images/header/contactTab.png)"); 
		}); 
		
		$('.featureItem, .featureItem2, .blogItem').live('mouseover', function(){
			$(this).find('.featureImage2Hover, .blogImage2Hover').stop(true, true).fadeIn();
			});
				$('.featureItem, .featureItem2, .blogItem').live('mouseout', function(){
			$(this).find('.featureImage2Hover, .blogImage2Hover').stop(true, true).fadeOut();
			});

		  


	/*twitter feed*/
		(function(b){b.extend({jTwitter:function(d,a,c){if(!(d=="undefined"||a=="undefined")){if(b.isFunction(a)){c=a;a=5}b.getJSON("http://twitter.com/status/user_timeline/"+d+".json?count="+a+"&callback=?",function(e){b.isFunction(c)&&c.call(this,e)})}}})})(jQuery);
		// Get latest 6 tweets by jQueryHowto
	$.jTwitter('wearepapertiger', 1, function(data){
	$('.twitterBlurb').empty();
	$.each(data, function(i, post){
	$('.twitterBlurb').append(
	'<div class="post">'
	+' <a class="txt" href="http://www.twitter.com/wearepapertiger">'
	// See output-demo.js file for details
	+ post.text
	+' </a>'
	+'</div>'
	);
	});
	
});
/*end twitter feed*/
	
////////////////////////////////////////////////////////////////////////////////////////////////	
/*portfolio detail ajax area*/

 function closeDetail() {
	$('.portDetail').stop(true, true).animate({marginLeft :"2000"});
	$('.portDetail').stop(true, true).fadeOut();
	
	$('.portDetail').removeClass('lit');
	$('.detailOverlay').fadeOut();
		}
	$('.x').live("click", function () {
		closeDetail();
	});
	
	$('.featureArea ul li, .featureArea2 ul li').live("click", function (){ 
	var varTitle = $(this).find('.varTitle').html();
	var imgURL = $(this).find('.varImg ').attr("href");
		var varDesc = $(this).find('.varDesc').html();
		var varLink = $(this).find('.varLink').html();
		var varURL = $(this).find('.varURL').html();
		$('.detailImage').html('<img src="' + imgURL + '"/>');
		$('.detailTitle').html(varTitle);
		$('.detailCopy').html(varDesc);
		if (varURL == '#') {
			 
			  }
			  else
			  {
			   $('.detailProjLink').html('<a target="_blank" href="' + varURL + '"><img src="/images/site_images/launchProject.jpg"/>' + '</a>');
			  }
		
		$('.detailLink').html('<a href="' + varLink + '"><img src="/images/site_images/moreProject.jpg"/>' + '</a>');
	$('.portDetail').stop(true, true).show().stop(true, true).animate({marginLeft :"-480"});
	$('.portDetail').addClass('lit');
	$('.detailOverlay').fadeIn();
	
	});
	
	$('.detailOverlay').live("click", function (){
		closeDetail();
	}); 
	
	var imgURL = $(this).find('.varImg').data("imgURL");
	
		
////////////////////////////////////////////////////////////////////////////////////////////////	
/*site slider areas!*/

	//home page slider
var speed = 5000;
	//grab the width and calculate left value
	//var 280 = $('.featureArea ul li').outerWidth(); 
	//var -280 = 280 * (-1); 

	$('.featureArea ul li:first').before($('.featureArea ul li:last'));
	$('.featureArea ul li:first').before($('.featureArea ul li:last'));
	 $('.featureArea2 ul li:first').before($('.featureArea2 ul li:last'));
	  $('.featureArea2 ul li:first').before($('.featureArea2 ul li:last'));
	$('.featureArea ul').css({'left' : -280});
	$('.featureArea2 ul').css({'left' : -280});
	
		$('.featureLeft').live('click', function() {           
		var left_indent = parseInt($('.featureArea ul').css('left')) + 280;
		$('.featureArea ul').animate({'left' : left_indent}, 600, 'easeInOutQuint', function(){          	
		$('.featureArea ul li:first').before($('.featureArea ul li:last')); 
		$('.featureArea ul').css({'left' : -280});
		});
	$('.featureArea2 ul').delay(40).animate({'left' : left_indent}, 600, 'easeInOutQuint', function(){    
            $('.featureArea2 ul li:first').before($('.featureArea2 ul li:last'));
			$('.featureArea2 ul').css({'left' : -280});
		});            
		return false; 
	});
	
	$('.featureRight').live('click', function() {
		var left_indent = parseInt($('.featureArea ul').css('left')) - 280;
		$('.featureArea ul').animate({'left' : left_indent}, 600, 'easeInOutQuint',  function () {
			$('.featureArea ul li:last').after($('.featureArea ul li:first'));    
			$('.featureArea ul').css({'left' : -280});
			});
		$('.featureArea2 ul').delay(40).animate({'left' : left_indent}, 600, 'easeInOutQuint',  function () {
			$('.featureArea2 ul li:last').after($('.featureArea2 ul li:first'));  
			$('.featureArea2 ul').css({'left' : -280});
		});
		return false;
	});
	

});