	/*
	* 私人可见时
	*/
	function persons(){
		 $(".fre_fam").slideDown("slow");
		 $(".img").attr("style","");
		 $(".img").attr("src",static_web+"images/ico/privacy2.gif");	
		 $(".img2").attr("style","display:none");
		if ($("input[name='friend']").attr("checked")==true || $("input[name='family']").attr("checked")==true ) {
			$(".img").attr("src",static_web+"images/ico/privacy1.gif");
		}else{
			$(".img").attr("src",static_web+"images/ico/privacy2.gif");
		}
		$(".privacy_1").attr("checked",true);
	}
	function personsSingle(id){
		 $("#pri_"+id).slideDown("slow");
		 $("#pri_img_"+id).attr("style","");
		 $("#pri_img_"+id).attr("src",static_web+"images/ico/privacy2.gif");	
		 $("#pri_img2_"+id).attr("style","display:none");
		if ($("#pri_friend_"+id).attr("checked")==true || $("#pri_family_"+id).attr("checked")==true ) {
			$("#pri_img_"+id).attr("src",static_web+"images/ico/privacy1.gif");
		}else{
			$("#pri_img_"+id).attr("src",static_web+"images/ico/privacy2.gif");
		}
	}
	/*
	* 公共可见时
	*/
	function publics(){
		$(".fre_fam").slideUp("slow");
		$(".img2").attr("style","");
		$(".img2").attr("src",static_web+"images/ico/privacy3.gif");
		$(".img").attr("style","display:none");
		$(".privacy_2").attr("checked",true);
		
	//	$("#img").attr("src","/images/ico/privacy1.gif");
		
	}
	function publicsSingle(id){
		$("#pri_"+id).slideUp("slow");
		$("#pri_img2_"+id).attr("style","");
		$("#pri_img2_"+id).attr("src",static_web+"images/ico/privacy3.gif");
		$("#pri_img_"+id).attr("style","display:none");
		
	//	$("#img").attr("src","/images/ico/privacy1.gif");
		
	}
	/*
	* 朋友，家人可见时
	*/
	function fren_fam(){
		if($(".friend").attr("checked")==true){
			$(".friend").attr("checked",true);
		}else{
			$(".friend").attr("checked",'');
		}
		if($(".family").attr("checked")==true){
			$(".family").attr("checked",true);
		}else{
			$(".family").attr("checked",'');
		}
		
		
		if ($("input[name='friend']").attr("checked")==false && $("input[name='family']").attr("checked")==false ){	
			$(".img").attr("style","");
			$(".img").attr("src",static_web+"images/ico/privacy2.gif");
		}else if ($("input[name='friend']").attr("checked")==true || $("input[name='family']").attr("checked")==true ){	
			$(".img").attr("style","");
			$(".img").attr("src",static_web+"images/ico/privacy1.gif");
		}else{
			$(".img").attr("style","");
			$(".img").attr("src",static_web+"images/ico/privacy2.gif");
		}
	}

	function fren_fam_single(id){
		if($("#pri_friend_"+id).attr("checked")==true){
			$("#pri_friend_"+id).attr("checked",true);
		}else{
			$("#pri_friend_"+id).attr("checked",'');
		}
		if($("#pri_family_"+id).attr("checked")==true){
			$("#pri_family_"+id).attr("checked",true);
		}else{
			$("#pri_family_"+id).attr("checked",'');
		}
		
		if ($("#pri_friend_"+id).attr("checked")==false && $("#pri_family_"+id).attr("checked")==false){	
			$("#pri_img_"+id).attr("style","");
			$("#pri_img_"+id).attr("src",static_web+"images/ico/privacy2.gif");
		}else if($("#pri_friend_"+id).attr("checked")==true || $("#pri_family_"+id).attr("checked")==true){	
			$("#pri_img_"+id).attr("style","");
			$("#pri_img_"+id).attr("src",static_web+"images/ico/privacy1.gif");
		}else{
			$("#pri_img_"+id).attr("style","");
			$("#pri_img_"+id).attr("src",static_web+"images/ico/privacy2.gif");
		}
	}
	/*
	*批量添加标签
	*/
	function AlbumAddtags(){
		$("#moreadd").val('addmore');
		var add_value = $("#add").val();
		add_value = $.trim(add_value);
		if(add_value == null || add_value == '') return false;
		var split_add_value = add_value.split(" ");
	  	var tags = $("input[name='album_tag[]']");
		$.each(split_add_value, function(i, n) {
			n = $.trim(n);
			$.each(tags, function(k, obj) {
				var v = $.trim(obj.value);
				var split_tags = v.split(" ");
				if(jQuery.inArray(n, split_tags) == -1) {
					var value = $.trim(v + ' ' + n);
					obj.value = value;
				}
			})
		});
	}
	function AlbumAddAddress() {
		var add_value = $("#address").val();
		add_value = $.trim(add_value);
		var address = $("input[name='album_address[]']");
		$.each(address, function(k, obj) {
			obj.value = add_value;
		})
	}
	function AlbumAddLatLng() {
		var latlng = $("#lat_lng").val();
		latlng = $.trim(latlng);
		var arrlatlng = $("input[name='album_latlng[]']");
		$.each(arrlatlng, function(k, obj) {
			obj.value = latlng;
		})
	}
	/*
	*添加新相册
	*/
	function addAlbumClasses(uid){
		$.ajax({
			type: "POST",
			url : "/album.php?switch=createalbum",
			data: "&name="+$("#name").val()+"&describes="+$("#describes").val()+'&uid='+uid,
			success:function(msg){
				if(msg != null){
					$(".new_album").slideToggle("slow");
					$("#add_album_classes").html(msg); 
				}
			}
		});
	}
	function setHover(id) {
		$(".add_describe")
		.hover(
			function(){
				$(".hide").addClass("hidden_area");
			},
			function(){
				$(".hide").removeClass("hidden_area");
			}
		);
	}
	
	function setClick(id){
		$("#aa"+id).hide();
		$(".hide hidden_area").removeClass("hide");
	//	$(".hidden_area").show();
		
		$("#"+id).show();
		
	}
	function setClickDes(id){
		$("#Des"+id).hide();
		$(".hide hidden_area").removeClass("hide");
	//	$(".hidden_area").show();
		$("#des"+id).show();
	}
	function updateTitle(id){
		$.ajax({
					type: "POST",
					url : "/album.php?switch=updatetitle",
					data: "&title="+encodeURIComponent($("#textarea"+id).val())+"&albumid="+id,
					
					success:function(msg){
						if(msg==1){
						//	alert($("#textarea"+id).val());
							$("#title"+id).text($("#textarea"+id).val());
						//	$("#header_title"+id).text($("#textarea"+id).val());
						}else{
							alert("failed");
						}
					}
				});	
		$("#"+id).hide();
		$(".add_describe").show();
		
		
		
	}
	function updateDes(id){
		if($("#textareaDes"+id).val() == '') {
			$("#Des"+id).text('点击这里添加描述');						  
		} else {
			$("#Des"+id).text($("#textareaDes"+id).val());
			$.ajax({
					type: "POST",
					url : "/album.php?switch=updatedescrbies",
					data: "&describes="+encodeURIComponent($("#textareaDes"+id).val())+"&albumid="+id,
					
					success:function(msg){
						if(msg==1){
							$("#Des"+id).text($("#textareaDes"+id).val());
						}else{
							alert("failed");
						}
					}
				});
		}
		$("#des"+id).hide();
		$(".add_describe").show();
		
		
		
	}
	function cancelTitle(id){
		$(".add_describe").show();
		
		$("#"+id).hide();
	}
	function cancelDes(id){
		$(".add_describe").show();
		
		$("#des"+id).hide();
	}
	
//隐私设置
  function editFreFam(id){
	  $("#Fre_Fam"+id).show();  
  }
  function cancelEditFreFrm(id){
	  $("#Fre_Fam"+id).hide(); 
  }
  function updateEditFreFrm(id){
	  $.ajax({
					type: "POST",
					url : "/album.php?switch=updatefrefam",
					data: "&friend="+$("#pri_friend_"+id).attr("checked")+"&family="+$("#pri_family_"+id).attr("checked")+"&publics="+$("#public"+id).attr("checked")+"&person="+$("#person"+id).attr("checked")+"&albumid="+id,
					
					success:function(msg){
						if(msg==1){
							 $("#Fre_Fam"+id).hide(); 
							 if($("#person"+id).attr("checked") == true ){
								 if($("#pri_friend_"+id).attr("checked") == false && $("#pri_family_"+id).attr("checked") == false) {
									$("#show"+id).attr("src",static_web+"images/ico/privacy2.gif");
									$("#showRight"+id).attr("src",static_web+"images/ico/privacy2.gif");
								 } else {
									$("#show"+id).attr("src",static_web+"images/ico/privacy1.gif");
									$("#showRight"+id).attr("src",static_web+"images/ico/privacy2.gif");
								 }
							 } else {
								 $("#show"+id).attr("src",static_web+"images/ico/privacy3.gif");
								 $("#showRight"+id).attr("src",static_web+"images/ico/privacy3.gif");
							 }
						}else{
							alert("更新失败，请稍候再试！");
						}
					}
				});	
	  
  }
 //更新照片的拍摄时间
function dateShow(id){
	$("#date").show();
	$(".date_edit").hide();	
	$("#updateDate").bind("click",function(){updateAlbumShootDate(id);});
}
function updateAlbumShootDate(id){
	$.ajax({
			type: "POST",
			url : "/album.php?switch=updatedate",
			data: "&id="+id+"&date="+$("#fm_date").val(),
			success:function(msg){
				
				if(msg ==1){
					alert("success");	
				}else{
					alert("failed");	
				}
			}
		});	
	dateBoxHide();
}
function dateBoxHide(){
	$("#date").hide();
	$(".date_edit").show();
	$(".f_blue").text($("#fm_date").val());
}
//删除照片
function showDelAlbumBox(id,cid){
	myshow('confirmdelmessages');	
	$("#delMesFromTable").bind("click", function(){delAlbumFromClass(id,cid)});
}
function delAlbumFromClass(id,cid){
	$.ajax({
			type: "POST",
			url : "/album.php?switch=delalbum",
			data: "&id="+id+"&cid="+cid+"&counts="+$("#count").val(),
			success:function(msg){
			//	alert(msg);
				if(msg !=null){
					alert("success");	
					window.location="showalbum-cid-cid.html"
				
				}else{
					alert("failed");	
				}
			}
		});	
	hideDelAlbumBox();	
}

function hideDelAlbumBox(){
	dispalymyshow('confirmdelmessages');
	$("#delMesFromTable").unbind("click");
}

//检测便签是否批量添加
function checkMoreAdd() {
	if ($("#address").val() != '' || $("#add").val() != '') {
		if ($("#moreadd").val() != 'addmore') {
			var bin = window.confirm('忘记批量添加了？点击确定自动添加。若不添加，请点取消。');
			if (bin == true) {
				AlbumAddtags();
				AlbumAddAddress()
			} else {
				return true;
			}
			return bin;
		}	
	}
	
}
//删除照片
function delAlbum(id){
	myshow("del_album");
	newId = $("#del"+id).attr("href");
	$("#del").attr("href",newId);
}

//将汉字转换为双字节，返回输入分组的长度
function strLen(classname){
	var sStr,iCount,i,strTemp ; 
	iCount = 0 ;
	sStr = classname.split("");
	for (i = 0 ; i < sStr.length ; i ++){
		strTemp = escape(sStr[i]); 
		if (strTemp.indexOf("%u",0) == -1) { 
			iCount = iCount + 1 ;
		} else {
			iCount = iCount + 2 ;
		}
	}
	return iCount ;
}
function testLen(uid){
	obj = $("#name").val();
	if(strLen(obj)>19){
		alert("名称过长，请重新输入");
		return false;
	}else{
		addAlbumClasses(uid);	
	}
}
//测试 照片的标题
function testAlbumTitle(obj){
	text = $("#"+obj).val();
	if(strLen(text)>26){
		alert("名称过长，请重新输入");
	//	$("#")
		return false;
	}
}
function checkLen(id){
	var c_name = $("#"+id).val();
	var classNameLen = strLen(c_name);	
	if (classNameLen >= 26) {
		var sStr,iCount,i,strTemp ; 
		iCount = 0 ;
		sStr = c_name.split("");
		for (i = 0 ; i < 13 ; i ++){
			strTemp = escape(sStr[i]); 
			if (strTemp.indexOf("%u",0) == -1) { 
				iCount = iCount + 2 ;
			} else {
				iCount = iCount + 1 ;
			}
		}
		var cln = c_name.substr(0, iCount);
		$("#"+id).val(cln);
	}
}