/**
 * @author kenchase
 */

/*** Client Project Page ***/

function clientprojNav(){
 	 jQuery.noConflict();
	 
	 jQuery(document).ready(function () {
       var htmlStr = jQuery("li.active").html();
	   
	   if(htmlStr == "Web" || htmlStr == "Interactive"){
	   	jQuery("#work-text-content a img").show();	
	   }
	   else{
	   	jQuery("#work-text-content a img").hide();
	   }
	   
	   jQuery("#main-pics").show();
	   jQuery("#work-cat-nav ul li:first").addClass("active");
	   jQuery("#work-pic-nav ul li:first").addClass("active");
	   
	 });
	
	 jQuery("#work-cat-nav li").click(function() {
	 	
	   jQuery("#work-cat-nav li").removeClass("active");
	   jQuery("#work-cat-nav li").removeClass("hover");
	   jQuery("#work-pic-nav li").removeClass("active");
		
	   var showme = "div#" + jQuery (this).attr("class") + " img.pic-0";
	   var showpicnav = "div#work-pic-nav ul." + jQuery(this).attr("class");
	   var htmlStr = jQuery(this).html();
	   
	   jQuery("div.work-cat img.pic").hide();
	   jQuery("div#work-pic-nav ul").hide();
       jQuery(showme).show();
	   jQuery(showpicnav).show();
   
	   jQuery(this).addClass("active");
       jQuery("#work-pic-nav ul li:first-child").addClass("active");
	   
	   if(htmlStr == "Web" || htmlStr == "Interactive"){
	   	jQuery("#work-text-content a img").show();	
	   }
	   else{
	   	jQuery("#work-text-content a img").hide();
	   }
	 });
	 
	 jQuery("#work-cat-nav ul li").hover(
	   function () { 
	     jQuery(this).addClass("hover");  
       },
       function () { 
	     jQuery(this).removeClass("hover");     
     });
	 
	 jQuery("#work-pic-nav li").click(function() {
	   
	   jQuery("#work-pic-nav li").removeClass("active");
	   jQuery("#work-pic-nav li").removeClass("hover");
	   
	   var showpic = "div#" + jQuery(this).parent().attr("class") + " img." + jQuery(this).attr("class");
	   
	   jQuery("div.work-cat img.pic").hide();   
       jQuery(showpic).show();
	   jQuery(this).addClass("active"); 
	   
	  }
	 );
	 
	 jQuery("#work-pic-nav ul li").hover(
	   function () { 
	     jQuery(this).addClass("hover");  
       },
       function () { 
	     jQuery(this).removeClass("hover");     
     });
}

/*** Work Pages ***/

function clientworkNav(){
	jQuery.noConflict();
	var picpath = "http://www.zoomedia.ca/wp-content/uploads/";
	
	jQuery(document).ready(function(){
	
		var url = location.href;
		var match = /page/.test(url)
		
		var post = jQuery(document).getUrlParam("post");
		
		if (jQuery(document).getUrlParam("post") && !match) {
			var showpost = "div#main-pic-box-" + post;
			jQuery("#proj-thumb-nav").hide();
			jQuery("div.main-pic-box").hide();
			jQuery(".main-pic-box-img img").hide();
			jQuery(".main-pic-box-img img.main-pic-0").show();
			jQuery(showpost).show();
		}
		else {
			jQuery("div#proj-thumb-nav").show();
			jQuery("div.main-pic-box").hide();
		}
		
		jQuery("#main-pics").show();
		jQuery(".pic-nav li").removeClass("active");
		jQuery(".pic-nav li.main-pic-0").addClass("active");
		
	});
	
	jQuery(".thumb-item img").hover(function(){
		var newpicsrc = picpath + jQuery(this).attr("class");
		jQuery(this).attr("src", newpicsrc);
	}, function(){
		var oldpicsrc = picpath + jQuery(this).attr("id");
		jQuery(this).attr("src", oldpicsrc);
	});
	
	jQuery(".thumb-item img").click(function(){
	    jQuery(".main-pic-box-img img").hide();
		jQuery("#proj-thumb-nav").hide();
		jQuery(".main-pic-box").hide();
		var showme = "#main-" + jQuery(this).parent().attr("id");
		jQuery(showme).show();
		jQuery("img.main-pic-0").show();
		
		if (jQuery(showme).is(":first-child")) {
			jQuery("p.prev-pic").hide();
		}
		else {
			jQuery("p.prev-pic").show();
		}
		if (jQuery(showme).is(":last-child")) {
			jQuery("p.next-pic").hide();
		}
		else {
			jQuery("p.next-pic").show();
		}
	});
	
	jQuery("p.next-pic").click(function(){

        jQuery(".pic-nav li").removeClass("active");
		jQuery("li.main-pic-0").addClass("active");

		jQuery(this).parent().parent().hide();
			
		if (jQuery(this).parent().parent().next().is(":last-child")) {
			jQuery("p.next-pic").hide();
		}
		else {
			jQuery("p.prev-pic").show();
		}
		jQuery(this).parent().parent().next().show();
		jQuery(".main-pic-box-img img").hide();
		jQuery("img.main-pic-0").show();
	});
		
	jQuery("p.prev-pic").click(function(){

        jQuery(".pic-nav li").removeClass("active");
		jQuery("li.main-pic-0").addClass("active");
		
		jQuery(this).parent().parent().hide();

		if (jQuery(this).parent().parent().prev().is(":first-child")) {
			jQuery("p.prev-pic").hide();
		}
		else {
			jQuery("p.next-pic").show();
		}

		jQuery(this).parent().parent().prev().show();
		jQuery(".main-pic-box-img img").hide();
		jQuery("img.main-pic-0").show();
	});
	
	jQuery(".main-pic-box img.main-pic-close").click(function(){
		
		jQuery(".main-pic-box-img img").hide();
		jQuery(".main-pic-box").hide();
		jQuery("#proj-thumb-nav").show();
	});
	
	jQuery(".pic-nav li").click(function(){
	
	  jQuery(".pic-nav li").removeClass("active");
	  jQuery(".pic-nav li").removeClass("hover");
	  var imgsrc = jQuery(this).attr("class");
	  
	  jQuery(this).addClass("active");
	  jQuery(".main-pic-box-img img").hide();
	  jQuery("img." + imgsrc).show();
	});
	
	jQuery(".pic-nav li").hover(function(){
		jQuery(this).addClass("hover");
		}, function(){
		jQuery(this).removeClass("hover");
	});
}
