jQuery.noConflict();
var $j = jQuery;
$j(function(){
	$j("a.joinEmailLink, a.joinlink").click(function(event){
		event.stopPropagation();
        event.preventDefault();
		$j("#overlay").css({
		    height: $j(document).height()+"px",
		    opacity: 0.7
		}).fadeIn(500,function(){
			$j("#overlay-content").load(site_url+'/join',function(){
				$j("#overlay-content").css({
					left: ($j(document).width()-417)/2+'px',
					top: (window.height-300)/2+'px'
				}).fadeIn(200);
				$j("#signUpBlk div.content p").css({display: 'block'});
			});
		});
		return false;
	});
	
	$j("a.open").live("mouseover",function(){
		$j("a.open").removeAttr("title");
	});
	
	$j("input[name='cancel']").live("click",function(){
		$j("#overlay-content").fadeOut(200,function(){
			$j("#overlay").fadeOut(500).html('');
		});
	});
	
	$j("#overlay").click(function(){
		$j("#overlay-content").fadeOut(200,function(){
			$j("#overlay").fadeOut(500).html('');
		});
	});
	
	$j("#sendbutton").live("click",function(){
		if($j("#usermessagea").hasClass("failure")){
			$j("#usermessagea").css({
				padding: '0 15px 15px 15px',
				top: $j("#signUpBlk").height()+"px",
				height: $j("#usermessagea").height()+"px"
			}).slideDown(200);
		} else {
			$j("#usermessagea").css({
				display: 'block',
				position: 'relative',
				background: 'transparent',
				top: '20px',
				color: '#777'
			});
			$j("#signUpBlk div.content p").css({display: 'none'});
		}
	});
	
	$j("a.close-join").live("click",function(){
		$j("#overlay-content").fadeOut(200,function(){
			$j("#overlay").fadeOut(500).html('');
		});
	});
	
	$j("#sortby, #filterby").change(function(){
		if($j("#filterby").size() >= 1){
			document.location.href = 'http://'+document.location.host+document.location.pathname+'?'+$j("#sortby").val()+'&'+$j("#filterby").val();
		} else {
			document.location.href = 'http://'+document.location.host+document.location.pathname+'?'+$j("#sortby").val();
		}
	});
	
	if($j(".content .info").size() >= 1){
		var infoTop = $j(".content .info").css("top").substr(0,$j(".content .info").css("top").length-2)*1+90;
		var height = ($j(".content .info").height() > $j(".content .sidebar").height()) ? $j(".content .info").height() : $j(".content .sidebar").height();
		$j("#wrapper").css({height: height+infoTop+"px"});
	}
	$j(".subNavBlock li ul li:nth-child(3)").css({background: 'none'});
	
	
	if($j("h1.h1").text() == 'Cinereach Blog'){
		$j("ul.infoNav li a[title='Blog']").parent().addClass("active");
	} else if($j("h1.h1").text() == 'Press'){
		$j("ul.infoNav li a[title='Press']").parent().addClass("active");
	}
	
	$j("a.mask").mouseover(function(){
		$j(this).children("img").css({top: '-146px'});
	}).mouseout(function(){
		$j(this).children("img").css({top: '0'});

	});
	
	$j("a.small-mask").mouseover(function(){
		$j(this).children("img").css({top: '-73px'});
	}).mouseout(function(){
		$j(this).children("img").css({top: '0'});

	});
	
	if($j("object + p").size() >= 1){
		$j("object + p").remove();
	}
	
});