function ChangePhoto(val){
	$("#headimgs").attr("src","/public/images/avatar/"+val+".png");
	
}

function ShowHtml(val){
	
	if(val==2){
		$("#linkhtmls").show();
	}else{
		$("#linkhtmls").hide();
	}
}

function getCaptcha(){
	$.post("/default/auth/captcha", {time:Math.random()},function(data) {
		$("#captchaimg").html('');
		$("#captchaimg").html(data); 
		$("#captcha").unbind('focus');
	});
}


$(document).ready(function(){ 
	//验证码
	$('#captcha').bind('focus', function() {
		getCaptcha();
	});
	
	$("img").lazyload({
		 placeholder : "/public/images/grey.gif",  
		 effect : "fadeIn"
 	});
	 
	$("#contents").find("img").each(function(i){
			if(this.width>600){this.width=600};
	});
	$('#articlecontent img').fancyZoom({scaleImg: true, directory:'/public/images/fancyzoom',closeOnClick: true});
});

function nametrip(namestr){ 
	return "tip_" + namestr.replace(/([a-zA-Z0-9])/g,"-$1");
}


function showResponse(responseText)  { 
	
	if(responseText.status){
		 jQuery.facebox(responseText.message)
		 setTimeout(function(){
		    $.facebox.close();
		 }, 1500 );
		 $("form")[0].reset();
		 
		
	}else{
		if(responseText.isform){
			$(".error").html('');
			$("input,textarea").removeClass("errortips");
			var i=1;
			var first;
			$.each(responseText.message,function(key,val){
				if(key=='captcha')$("#error"+key).show();
				$("#error"+key).html(val.error);
				$("#"+key).addClass("errortips");
				if(i==1){first=key;}
				i++;
			});
			$("#"+first).focus();
			
		}else{
			jQuery.facebox(responseText.message)
			setTimeout(function(){
			    $.facebox.close();
			}, 1500 );
		}
	}
}

