

$(document).ready(function() {
/*
	$(".theteamOverlay").hover(
  		function () {
			$(this).next("div").fadeIn("fast");
		},
		function () {
			$(this).next("div").fadeOut("fast");
		}
	);
*/

	if(BrowserDetect.browser!="Explorer"){
		$(".reflectme").reflect({height:.15,opacity:0.3});
	}
	
	$("#work li a[class!=web]").colorbox({transition:"fade", maxHeight:"80%", maxWidth:"80%", scalePhotos:"true", opacity:"0.65", title:" ", rel:"nofollow"});
	
	$("#reel").colorbox({iframe:true, innerWidth:500, innerHeight:380, transition:"fade",opacity:"0.80", title:" ", rel:"nofollow" });


	
	$("#work ul li").hide(); //hide all work
	var total = $("#work ul li").size();
    var count = 1;
	
	var id = 0;
	//var id = <?php if(isset($_GET['id'])) { echo intval($_GET['id']);} else { echo '1';} ?>; // added by m.c. 03/24/10 for deeplinking
	if(id > 1 && id < total+1){
		count = id;
		$("#work ul li:nth-child("+count+")").fadeIn("medium");
	} else {
     	 $("#work ul li:first-child").show(); // default
	}
      
     
	$('#next').click( function() {
        $("#work ul li:nth-child("+count+")").fadeOut("fast", function(){
			if($(this).find(":first").hasClass("video")){
				var str = $(this).html();
				$(this).html("");
				$(this).html(str);
			}
		    count++;
		    if (count == total+1) {
		        count = 1;
		    }
		    $("#work ul li:nth-child("+count+")").fadeIn("medium");
		}
	);
        return false;
      });
	  
	  $('#prev').click( function() {
        $("#work ul li:nth-child("+count+")").fadeOut("fast", function(){
		if($(this).find(":first").hasClass("video")){
				var str = $(this).html();
				$(this).html("");
				$(this).html(str);
			}
        count--;
        if (count < 1) {
          count = total;
        }
        $("#work ul li:nth-child("+count+")").fadeIn("medium");}
);
        return false;
      });
	  
/* footer */
$("#clientform").hide(); 
$("#clientlogin").bind('click', toggleClientLogin);
function toggleClientLogin(){
		$("#clientform").slideToggle("fast");
		return false;
	}	

	  
	/* features page */
	var position = 0;
	
	$('.work #featuredNext').click(function(){
		if(position == 0){
			position = 1;
			nextItemFeatured();
				 return false;
			}});
		
		
	$('.work #featuredPrev').click(function(){
			if(position == 1){
			position = 0;
		prevItemFeatured();
			 return false;
		}});
	
	
	function nextItemFeatured(){
		$(".work #featuredWork").fadeOut("fast", function(){
			$(".work #featuredWork").animate({'top' : "-=450px"});
			$(".work #featuredWork").fadeIn("fast");
			
			}
		);
		
	}
	
	function prevItemFeatured(){
		$(".work #featuredWork").fadeOut("fast", function(){
			$(".work #featuredWork").animate({'top' : "+=450px"},0);
			$(".work #featuredWork").fadeIn("fast");
			
			}
		);
		
	}
	

});
