// JavaScript Document
$(document).ready(
	function(){
		$("#jsIntroIcon").click(
			function(){
				var type = $("#jsIntroIcon img").attr('src');
				
				if(type == '/images/default/icon/pencil.png'){
					$("#jsIntroIcon img").attr('src', '/images/default/icon/save.png');
					$("#jsIntro").hide();
					$("#jsIntroEditor").show();
				}else{
					var str = $("#jsIntroValue").val();
					if(str.length > 64){
						alert('不得超過64個字');
					}else{
						$("#jsIntroIcon img").attr('src', '/images/default/spinner.gif');
						$.ajax({
							type: 'post',
							url: '/member/ajax.update.intro/',
							dataType: 'json',
							data: 'intro=' + $("#jsIntroValue").val(),
							success: function(data){
								if(data['status'] == 'Y'){
									$("#jsIntroIcon img").attr('src', '/images/default/icon/pencil.png');
									$("#jsIntro").text(data['intro']).show();
									$("#jsIntroEditor").val(data['intro']).hide();
								}else{
									alert(data['status']);
								}
							}
						});
					}
				}
			}
		)
		
		$("#jsIntroValue").keydown(
			function(){
				var str = $(this).val();
				if(str.length > 64){
					alert('不得超過64個字');
				}
			}
		);
	}
);
