var $j = jQuery.noConflict();
$j(document).ready (function(){
	$j("a.pic").fancybox();
	projectPicGallery();
	productPicGallery();
	bannerPicGallery();
	ftHover();
	contentScroll();
	projHover();
	prodHover();
	prodScroll();
	pressHover();
	stopLink();
	showVideo();
	fixBlogSidebar();
});
function fixMainNav(){
	$j("div#main-nav ul li:first-child").addClass("first");
	$j("div#main-nav ul li:last-child").addClass("last");
}
function fixBlogSidebar(){
    var windowheight = $j(window).height();
	var sbheight = windowheight - 350;
	$j("#sidebar-r").css("min-height", sbheight);
}
function getLastPost(){
	$j("div.main-content div:first-child").addClass("first");
	$j("div.main-content div:last-child").addClass("last");
}
function projectPicGallery(){
	$j('#project-pics').cycle({
		timeout: 0,
        prev: '#project-pics-prev',
        next: '#project-pics-next'
    });
}
function productPicGallery(){
	$j('#prod-pics-pics').cycle({
		timeout: 0,
        prev: '#prev',
        next: '#next'
    });
}
function bannerPicGallery(){
	$j('#banner-pics').cycle({
		fx: 'fade',
		timeout: 6000,
		speed: 1600,
        prev: '#prev',
        next: '#next'
    });
}
function ftHover(){
  $j("div.ft-section").hover(
    function(){
	  var pic_a = 'div#' + $j(this).attr("id") + " a.off img";
	  var pic_b = 'div#' + $j(this).attr("id") + " a.hover img";
	  var pic =  $j(pic_a).attr("src");
	  var pic_hover = $j(pic_b).attr("src");
	  $j(pic_a).attr("src", pic_hover);
	  $j(pic_b).attr("src", pic);
    },
	function(){
	  var pic_a = 'div#' + $j(this).attr("id") + " a.off img";
	  var pic_b = 'div#' + $j(this).attr("id") + " a.hover img";
	  var pic =  $j(pic_a).attr("src");
	  var pic_hover =  $j(pic_b).attr("src");
	  $j(pic_a).attr("src", pic_hover);
	  $j(pic_b).attr("src", pic);
    }
  );	
}
function contentScroll(){
//  $j('body:not(.page-template-tpl-contact-php) div#content-inner').jScrollPane();
}
function projHover(){
  $j("ul#proj-list img").hover(
    function(){
      $j(this).fadeTo("slow", 0.8);
	},
	function(){
	  $j(this).fadeTo("slow", 1.0);
	}
  );
}
function prodHover(){
  $j("ul#prod-list img").hover(
    function(){
      $j(this).fadeTo("slow", 0.8); // This should set the opacity to 100% on hover
	},
	function(){
	  $j(this).fadeTo("slow", 1.0); // This should set the opacity back to 30% on mouseout
	});
}
function prodScroll(){
  $j('div#prod-content-inner').jScrollPane();
}
function pressHover(){
  $j("ul#press-pics img").hover(
    function(){
      $j(this).fadeTo("slow", 0.8); // This should set the opacity to 100% on hover
	},
	function(){
	  $j(this).fadeTo("slow", 1.0); // This should set the opacity back to 30% on mouseout
	}
  );
}
function stopLink(){
  $j('ul#client-pics li').click(function(e){
    e.preventDefault();
  });
}
function showVideo(){
	$j("a.video").click(function(){
		$j.fancybox({
			'padding': 0,
			'autoScale': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			'title': this.title,
			'width': 680,
			'height': 495,
			'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type': 'swf', // <--add a comma here
			'swf': {
				'allowfullscreen': 'true'
			} // <-- flashvars here
		});
		return false;
	});
}
