// JavaScript Document
$(document).ready(function() {
						  		
	  	////default search field clear on click. 
//		$("#searchTxt").click(function(){
//		var varSelection = String($(this).val());
//		if(varSelection=="SEARCH"){$(this).val('');}
//		return false;			
//		}); //close $("#searchTxt").click	
//		
//		$("#searchGo").click(function(){
//		$varSearch = "http://www.google.com/search?hl=en&safe=off&q=site%3Abamboodev.com+" + $("#searchTxt").val() + "&btnG=Search";
//		window.open($varSearch);
//		//track panel click with google analytics
//		$varSearch =  $("#searchTxt").val();
//		pageTracker._trackPageview("/search=" + varSearch);
//		return false;			
//		}); //close $("#btnSearchSubmit").click	
		
		//check for # and display appropriate section
	var hash = window.location.hash.substr(1);
		if(hash!=""){
			//alert("yes");
		//$(".contentBox").hide();
		var targetURL = window.location.hash.substr(1);
		//alert(targetURL);
		switch (hash)
			{
			case "home":
			 targetURL = "home.php";
			 break;
			 case "news":
			 targetURL = "news.php";
			 break;
			 case "portfolio":
			 targetURL = "portfolio.htm";
			 break;
			 case "organic":
			 targetURL = "organic.htm";
			 break;
			 case "contact":
			 targetURL = "contact.htm";
			 break;
			}
			//alert(targetURL);
			
			$.ajax({
							method: "get",url: "ajax.php",data: "page="+targetURL,
							beforeSend: function(){$("#cell").fadeOut("slow");}, 
							//complete: function(){}, 
							success: function(html){ //so, if data is retrieved, store it in html
							$("#cell").fadeIn("slow"); //animation
							$("#cell").html(html); //show the html inside #cell div
					 }
				 }); //close $.ajax(
		}
	   
	  
	   var leftPos = 0;
	   $("a.nav").live("click", function(){  				  
		
		$("a.nav").removeClass("active");
		$(this).addClass("active");
		
		var navTarget = $(this).attr("href");
		navTarget=navTarget.toLowerCase();
		navTarget=navTarget.replace("http://www.bamboodev.com", "");
		navTarget=navTarget.replace("http://bamboodev.com", "");
		
		//track panel click with google analytics
		pageTracker._trackPageview("/" + navTarget);
		
			var cellWidth = -1200;
			var targetURL = "";
			
			switch (navTarget)
			{
			case "#home":
			 $("#maskedContentHills").animate({left: "0"}, 1500);
			  $("#maskedContentClouds").animate({left: "0"}, 1500);
			  leftPos = 0;
			  targetURL = "home.php";
			  
			 break;
			 case "#news":
			 $("#maskedContentHills").animate({left: "-1200"}, 1500);
			  $("#maskedContentClouds").animate({left: "-400"}, 1500);
			 leftPos = 1200;
			  targetURL = "news.php";
			 break;
			 case "#portfolio":
			 $("#maskedContentHills").animate({left: "-2400"}, 1500);
			  $("#maskedContentClouds").animate({left: "-800"}, 1500);
			 leftPos = 2400;
			  targetURL = "portfolio.htm";
			  break;
			 case "#organic":
			 $("#maskedContentHills").animate({left: "-3600"}, 1500);
			  $("#maskedContentClouds").animate({left: "-1200"}, 1500);
			 leftPos = 3600;
			  targetURL = "organic.htm";
			  break;
			 case "#contact":
			 $("#maskedContentHills").animate({left: "-4800"}, 1500);
			  $("#maskedContentClouds").animate({left: "-1600"}, 1500);
			 leftPos = 4800;
			  targetURL = "contact.htm";
			  break;
			  
			  case "#testimonials":
			  targetURL = "testimonials.htm";
			  break;
			  
			default:
			//varDistance = (navTarget * cellWidth);
			//$("#maskedContentHills").animate({left: varDistance}, 1500);
			//leftPos = Math.abs(varDistance);
			
			 
			 //case "LEFT":
//			 if (leftPos!="0"){
//				  leftPos = leftPos - 1200;
//				 $("#maskedContentHills").animate({left: -(leftPos)}, 1500);			
//			 }
//			 break;
//			 
//			 case "RIGHT":
//			 if (leftPos!="4800"){
//				  leftPos = leftPos + 1200;
//				 $("#maskedContentHills").animate({left: -(leftPos)}, 1500);
//				 $("#maskedContentClouds").animate({left: -(leftPos/3)}, 1500);
//			 }
//			 
//			 else if (leftPos=="4800"){
//				  leftPos = 0;
//				 $("#maskedContentHills").animate({left: 0}, 1500);	
//				  $("#maskedContentClouds").animate({left: 0}, 1500);
//			 }
//			 break;
		}	
			
			//populate cell with selected content
			//$("#cell").html(targetURL);
			
							$.ajax({
							method: "get",url: "ajax.php",data: "page="+targetURL,
							beforeSend: function(){$("#cell").fadeOut("slow");}, 
							//complete: function(){}, 
							success: function(html){ //so, if data is retrieved, store it in html
							$("#cell").fadeIn("slow"); //animation
							$("#cell").html(html); //show the html inside #cell div
							$("a[rel=portfolio_group]").fancybox({
				'titleShow'     : true
			});
							
					 }
				 }); //close $.ajax(
				 
			//make nav a active
			//$(".nav").removeClass("active");
//			$(this).addClass("active");	
//			//if logo clicked, override active class
//			if (navTarget=='home.htm') {$("#logoNav").removeClass("active"); $("#homeNav").addClass("active"); }
			window.location.hash = navTarget; 
			return false;			
	}); //$("a.nav").click(function(){ 	 END
	
	
	 $("a[rel=portfolio_group]").live("click", function(){  				  
		
		//var largePath = $(this).attr("href");
		//$("#portfolioLarge").attr({ src: largePath });
		
		//$("a.portfolioThumb").fancybox({
//				'titleShow'     : true
//			});
		
		$("a[rel=portfolio_group]").fancybox({
		'titleShow'     : true
			});
		
	   return false;			
	}); //$("a.portfolioThumb").click(function(){ 	 END
	
	//$("a.portfolioThumb").fancybox({
//				'titleShow'     : true
//			});

}); //jQuery $(document).ready END