
/**
 * 浏览器判断
 * 
var bro=$.browser;
var binfo="";
if(bro.msie) {binfo="Microsoft Internet Explorer "+bro.version;}
if(bro.mozilla) {binfo="Mozilla Firefox "+bro.version;}
if(bro.safari) {binfo="Apple Safari "+bro.version;}
if(bro.opera) {binfo="Opera "+bro.version;}
alert(binfo);
$("#browser").html(binfo);
**/

var local_pageNo=1;
var pageSize=12;
var queryData = eval("({'pageNo':'"+local_pageNo+"','pageSize':'"+pageSize+"'})");
var tab_n = 0;

var photoappsContent_height = $("#sheqshappsContent").height();

function resetQueryData(){
	queryData = "";
	queryData = eval("({'pageNo':'"+local_pageNo+"','pageSize':'"+pageSize+"'})");
}

$(document).ready(function(){
	
	var tabs = $( "#tabs" ).tabs();
    tabs.find( ".ui-tabs-nav" ).sortable({
    axis: "x",
    stop: function() {
       tabs.tabs( "refresh" );
    }});
    
	loadUploadPhoto();
	
	$("#uploadbutton").click(function(){
		loadUploadPhoto();
	});
	
	$("#createAlbum").click(function(){
		insertAlbum();
	});
	
   $("#to-my").click(function(){
	   tab_n = 0;
	   resetQueryData();
	   queryData.FIELD_DELETE_FLAG='0';
	   loadPage(1,pageSize);
     });
   $("#to-friend").click(function(){
	   tab_n = 2;
	   resetQueryData();
	   queryData.FIELD_DELETE_FLAG='0';
	   loadPage(1,pageSize);
     });
   $("#to-recycle").click(function(){
	   tab_n = 1;
	   resetQueryData();
	   queryData.FIELD_DELETE_FLAG='1';
	   loadPage(1,pageSize);
     });
});

/**
 * 文件上传
 * @returns {Boolean}
 */
function ajaxFileUpload()
{
    
    $("#loading")
    .ajaxStart(function(){
        $(this).show();
    })//开始上传文件时显示一个图片
    .ajaxComplete(function(){
        $(this).hide();
    });//文件上传完成将图片隐藏起来
    if($.trim($("#userFile").val()).length==0)
    	return false;
    if(("gif,jpg,jpeg,bmp,png").indexOf($("#userFile").val().split(".")[1])==-1){
    	fancyAlert("只上传gif,jpg,jpeg,bmp,png类型的图片！",0);
    	return false;
    }
    
    $.ajaxFileUpload
    (
        {
            url:'jwAppsPhotoAct_upload',//用于文件上传的服务器端请求地址
            secureuri:false,//一般设置为false
            fileElementId:'userFile',//文件上传空间的id属性  <input type="file" id="file" name="file" />
            dataType: 'json',//返回值类型 一般设置为json
            success: function (data, status)  //服务器成功响应处理函数
            {
                if(data.message.file!='undefined'){
                	var albumType = $("#photoType").val();
                	var view_name = data.message.file.split(",")[1];
                	var store_name = data.message.file.split(",")[0];
                	$.sendPost(
	        		          "jwAppsPhotoAct_insertPhoto", 
	        		          {"FIELD_ALBUM_ID":albumType,"FIELD_VIEW_NAME":view_name,"FIELD_STORE_NAME":store_name}, 
	        		          function(data){
	        		        	fancyAlert(data[0].VALUE,1);
	        		        	jQuery.fancybox.close();
	        		        	
	        		          },
	        		          null,
	        		          "json"
	        		       );
                }
                
            },
            error: function (data, status, e)//服务器响应失败处理函数
            {
                alert(e);
            }
        }
    );
    
    return false;

}


    /**
     * 上传页面
     */
    function loadUploadPhoto(){
    	$("#tabs-1").load(gaowj.WEB_APP_NAME+"/jwapp/pages/photo/photoUploadTemp.jsp",function(){
    		resetQueryData();
     	    queryData.FIELD_DELETE_FLAG='0';
    		$.sendPost(
  		          "jwAppsPhotoData_listAll", 
  		          queryData, 
  		          function(data){
  		        		var opetion = "";
  		        		var i=0;
  		        		for(i=0;i<data[0].rowSet.length;i++){
     		 		       var rowData = data[0].rowSet[i];
     		 		       opetion = opetion + " <option value=\""+rowData.RESOURCE_ID+"\">"+rowData.NAME+"</option>";
     		 		    }
  		        		 var target = "上传相册："
  		        		 		      + "<select name=\"photoType\" id=\"photoType\">"
  		        		 		      + opetion 
  		        		 		      + "</select>";
  		        		 $("#albumType").html(target);

  		          },
  		          null,
  		          "json"
  		       );
    	});
    }
    
    /**
     * 相册翻页
     */
    function loadPage(pageNo){
    	local_pageNo = pageNo;
    	queryData.pageNo=local_pageNo;
    	queryData.pageSize=pageSize;
    	$.sendPost(
		          "jwAppsPhotoData_list", 
		          queryData, 
		          function(data){
		        	if(data[0].rowSet.length>0){
		        	 $("#tabs-1").load(gaowj.WEB_APP_NAME+"/jwapp/pages/photo/photoMyTemp.jsp",function(){
		        		 renderDATA(data[0].rowSet,$("#row"),"resizabletable");
		        		 var target = "<div style=\"border-bottom:solid #ccc 1px;width:760px;height:40px;\"><div style=\"margin:10px 0 0 150px;\">"
		        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPage(1);\">首页</a></div>"
		        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPage("+ (pageNo>1?(pageNo -1):pageNo) +");\">上一页</a></div>"
		        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPage("+ (pageNo<data[0].pageCount?(pageNo + 1):pageNo) +");\">下一页</a></div>"
		        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPage("+data[0].pageCount+");\">末页</a></div>"
		        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\">"+data[0].pageNo+"/"+data[0].pageCount+"</div>"
		        			         +"<div style=\"float:left;margin-left:5px;\">到第<input type=\"text\" id=\"toPage\" value=\""+pageNo+"\" onblur=\"if(this.value>"+data[0].pageCount+" || this.value<0) this.value=1\" style=\"width:30px;height:25px;\"/>页</div>"
		        			         +"<div style=\"float:left;margin-left:5px;\"><input type=\"button\" value=\"确定\" onclick=\"loadPage(parseInt(toPage.value));\" class=\"input_btn_12 page_define_btn\"/></div>"
		        			         +"<div></div>";
		        			 
		        		 $("#myphotopage").html(target);
		        		 $("#toPage").numeral();
		        		 
		        		 renderOPE(tab_n);
		        		 if($.browser.safari){
			        		$("#sheqshappsContent").height(photoappsContent_height);
			        	 }
		        	 });
		        	}else{
		        		$("#tabs-1").html("");
		        	}

		          },
		          null,
		          "json"
		       );
    	
    }
    
    /**
     * 添加管理动作
     * @param rows
     * @param pkid
     * @param target
     */
    function renderOPE(n){
    	$("div[id='row']").each(function(i,row){
    	   var v_id = $(row).find("#RESOURCE_ID").text();
    	   var v_name = $(row).find("#NAME").text();
    	   var v_album_photo = $(row).find("#ALBUM_PHOTO").text();
    	   var v_ispassword = $(row).find("#ISPASSWORD").text();
    	   var v_album_photo_count = $(row).find("#ALBUM_PHOTO_COUNT").text();
    	   var v_album_photo_lasttime = $(row).find("#ALBUM_PHOTO_LASTTIME").text();
    	   
    	   var lock_html = "";
    	   if(v_ispassword == '1'){
    		   lock_html = "<img src=\""+gaowj.WEB_APP_NAME+"/gaowj/images/icons/(32,02).png\"/>";
    	   }else{
    		   lock_html = "<img src=\""+gaowj.WEB_APP_NAME+"/gaowj/images/icons/(32,02,01).png\"/>";
    	   }
    	   
    	   var sm_html="";
    	   sm_html =  "<div style=\"color:#09c;\">合计："+v_album_photo_count+"张</div>"
    	            + "<div style=\"color:#09c;\">最后更新：<br/>"+v_album_photo_lasttime.substring(0, 10)+"</div>";//+"<br/>"+v_album_photo_lasttime.substring(10)+"</div>";
    	   
    	   var m_html =  "";
    	   var img_html = lock_html + "<img src=\""+gaowj.WEB_APP_NAME+"/photo/photo.jsp?ls_photo="+v_album_photo+"\" width=\"100\" height=\"75\" style=\"cursor:pointer;\" onclick=\"viewPhoto('"+v_id+"','"+v_ispassword+"');\"/>";
    	   switch(n){
    	     case 0:
    	    	 m_html =  sm_html
    	    		       + "<div style=\"display:inline;margin-right:10px;cursor:pointer;\" onclick=\"modifyAlbum('"+v_id+"');\">管理</div>"
                           + "<div style=\"display:inline;margin-right:10px;cursor:pointer;\" onclick=\"reCycleAlbum('"+v_id+"');\">回收</div>";
    	    	 if(v_name.indexOf("默认")>-1){
    	    		 m_html = sm_html + "<div style=\"display:inline;margin-right:10px;cursor:pointer;\" onclick=\"modifyAlbum('"+v_id+"');\">管理</div>"; 
    	    	 }
    	    	 break;
    	     case 1:
    	    	 m_html =  sm_html
    	    		       + "<div style=\"display:inline;margin-right:10px;cursor:pointer;\" onclick=\"deleteAlbum('"+v_id+"');\">删除</div>"
    	    	           + "<div style=\"display:inline;margin-right:10px;cursor:pointer;\" onclick=\"renewAlbum('"+v_id+"');\">恢复</div>";
  	             break;
    	     default:
    	    	 m_html =  sm_html + "";
  	             break;
    	   }
    	   $(row).find("#operator").html(m_html);
    	   $(row).find("#target3_photo").html(img_html);
    	});
      }
    
    /**
     * 回收相册
     * @param resource_id
     */
    function reCycleAlbum(resource_id){
    	queryData.FIELD_RESOURCE_ID = resource_id;
    	queryData.FIELD_DELETE_FLAG = "1";
    	fancyConfirm("确定此相册移入回收站?",function(){
    		$.sendPost(
  		          "jwAppsPhotoAct_update", 
  		          queryData, 
  		          function(data){
  		        	fancyAlert(data[0].VALUE,1);
  		        	jQuery.fancybox.close();
  		        	queryData.FIELD_RESOURCE_ID = "";
  		        	queryData.FIELD_DELETE_FLAG = "0";
  		        	loadPage(local_pageNo);
  		          },
  		          null,
  		          "json"
  		       );
    	},"提示",1);
    	
    }
    /**
     *恢复相册
     * @param resource_id
     */
    function renewAlbum(resource_id){
    	queryData.FIELD_RESOURCE_ID = resource_id;
    	queryData.FIELD_DELETE_FLAG = "0";
    	fancyConfirm("确定恢复此相册?",function(){
    		$.sendPost(
  		          "jwAppsPhotoAct_update", 
  		          queryData, 
  		          function(data){
  		        	fancyAlert(data[0].VALUE,1);
  		        	jQuery.fancybox.close();
  		        	queryData.FIELD_RESOURCE_ID = "";
  		        	queryData.FIELD_DELETE_FLAG = "1";
  		        	loadPage(local_pageNo);
  		          },
  		          null,
  		          "json"
  		       );
    	},"提示",1);
    	
    }
    /**
     * 删除相册
     * @param resource_id
     */
    function deleteAlbum(resource_id){
    	queryData.deletekey = resource_id;
    	fancyConfirm("确定删除此相册?",function(){
    		$.sendPost(
  		          "jwAppsPhotoAct_delete", 
  		          queryData, 
  		          function(data){
  		        	fancyAlert(data[0].VALUE,1);
  		        	jQuery.fancybox.close();
  		        	queryData.FIELD_RESOURCE_ID = "";
  		        	queryData.FIELD_DELETE_FLAG = "1";
  		        	loadPage(local_pageNo);
  		          },
  		          null,
  		          "json"
  		       );
    	},"提示",2);
    	
    }
    
    /**
     * 相册新增
     */
    
    var insertAlbum = function(){
    	jQuery.fancybox({
			"modal" : false,
			"content" : ""
			        + "<div class=\"popup_header_icon_450\"><div class=\"popup_header_text\">新建相册</div></div>"
			        + "<form id=\"albumFolder\" action=\"\">"
			        + "<div style=\"width:450px;\">"
			        + "<div>"
			        + "<span style=\"line-height:30px;height:33px;\">相册名称：</span><input type=\"text\" id=\"FIELD_NAME\"  name=\"FIELD_NAME\" validate=\"required,maxlength\" maxlengthvalue=\"50\"/>"
			        + "<span style=\"line-height:30px;height:33px;margin-left:5px;\">拍摄地点：</span><input type=\"text\" id=\"FIELD_SITE\" name=\"FIELD_SITE\" validate=\"required,maxlength\" maxlengthvalue=\"50\"/>"
			        + "</div>"
			        + "<div>"
			        + "<span style=\"line-height:30px;height:33px;\">相册描述：</span><input type=\"text\"  id=\"FIELD_DESCRIPTION\" name=\"FIELD_DESCRIPTION\" validate=\"required,maxlength\" maxlengthvalue=\"50\"/>"
			        + "<span style=\"line-height:30px;height:33px;margin-left:5px;\">相册分享：</span>" 
			        + "<select id=\"FIELD_VIEW_PERMISSION\" name=\"FIELD_VIEW_PERMISSION\" style=\"width:148px;*width:132px;\"><option value=\"4\">仅自已</option><option value=\"2\">仅好友</option><option value=\"1\">所有人</option></select>"
			        + "</div>"
			        + "<div>"
			        + "<span style=\"line-height:30px;height:33px;\">创建日期：</span><input type=\"text\"  t=\"date\" readonly=\"readonly\"  id=\"FIELD_CREATE_TIME\" name=\"FIELD_CREATE_TIME\"/>" 
			        + "</div>"
			        + "<div style=\"float:right;margin-right:25px;\"><input type=\"button\" class=\"input_btn right\" id=\"fancyConfirm_ok\"  value=\"确定\" /></div>"
			        + "</div>"
			        + "</form>",
			        onComplete : function() {
			        	
//			        	//名称校验
//			        	var name_checker = $("input#FIELD_NAME").checker().act("keyup").reg(function(){
//			        	    if($.trim($(this).val()).length>50){
//			                    this.checkwrite("输入不应超过50个字！");
//			                    return false;
//			                }
//			        	    if($.trim($(this).val()).length==0){
//			                    this.checkwrite("相册名称不能为空！");
//			                    return false;
//			                }
//			                this.checkwrite(null);
//			                return true;
//			        	});
//			        	
//			        	//地点校验
//			        	var site_checker = $("input#FIELD_SITE").checker().act("keyup").reg(function(){
//			        	    if($.trim($(this).val()).length>50){
//			                    this.checkwrite("输入不应超过50个字！");
//			                    return false;
//			                }
//			        	    if($.trim($(this).val()).length==0){
//			                    this.checkwrite("拍摄地点不能为空！");
//			                    return false;
//			                }
//			                this.checkwrite(null);
//			                return true;
//			        	});
//			        	
//			        	//描述校验
//			        	var description_checker = $("input#FIELD_DESCRIPTION").checker().act("keyup").reg(function(){
//			        	    if($.trim($(this).val()).length>50){
//			                    this.checkwrite("输入不应超过50个字！");
//			                    return false;
//			                }
//			        	    if($.trim($(this).val()).length==0){
//			                    this.checkwrite("相册描述不能为空！");
//			                    return false;
//			                }
//			                this.checkwrite(null);
//			                return true;
//			        	});
			        	
//			        	//时间校验
//			        	var site_checker = $("input#FIELD_CREATE_TIME").checker().act("blur").reg(function(){
//			        	    if(!CheckDate($.trim($(this).val()))){
//			                    this.checkwrite("输入正确的日期(yyyy-mm-dd)！");
//			                    return false;
//			                }
//			                this.checkwrite(null);
//			                return true;
//			        	});
			        	       	
//			        	var dates = $("#FIELD_NAME").datepicker({
//			        		changeMonth : true,
//			        		changeYear : true,
//			        		onSelect : function(selectedDate) {
//			        			var option = this.id == "FIELD_NAME" ? "minDate" : "maxDate", instance = $(this)
//			        					.data("datepicker"), date = $.datepicker.parseDate(
//			        					instance.settings.dateFormat
//			        							|| $.datepicker._defaults.dateFormat, selectedDate,
//			        					instance.settings);
//			        			dates.not(this).datepicker("option", option, date);
//			        		}
//			        	});
			   
			        	// 绑定开始时间字段控件
			        	$("#FIELD_CREATE_TIME").loadMy97DateTime(true);
			        	$("#albumFolder").validateFormBlur();

			        	$("#fancyConfirm_ok").click(function() {
			        		if(!($("#albumFolder").validateSubmit())) return;
//			        		
//			        		if(!(name_checker.exc() && site_checker.exc() && description_checker.exc())){
//				    	        return;
//				    	    }
			        		$.sendPost(
			        		          "jwAppsPhotoAct_insert", 
			        		          $("#albumFolder").getFormVal(), 
			        		          function(data){
			        		        	fancyAlert(data[0].VALUE,1);
			        		        	jQuery.fancybox.close();
			        		        	queryData.FIELD_DELETE_FLAG = "0";
			          		        	queryData.FIELD_RESOURCE_ID = "";
			        		        	loadPage(local_pageNo);
			        		          },
			        		          null,
			        		          "json"
			        		       );
			        		
			        	});
			        	
			        	
			        	
			        }
		});
    };
  
    /**
     * 相册修改
     */
    function modifyAlbum(resource_id){
    	resetQueryData();
    	queryData.FIELD_RESOURCE_ID = resource_id;
    	$.sendPost(
		          "jwAppsPhotoData_list", 
		          queryData, 
		          function(data){
		        	if(data[0].rowSet.length>0){
		        	 $("#tabs-1").load(gaowj.WEB_APP_NAME+"/jwapp/pages/photo/photoAlbumTemp.jsp",function(){
		        		 var target = "<div id=\"photoAlbumDiv\"><form id=\"albumFolderForm\">";
		        		 var resultData = data[0].rowSet[0];
		        		 
		        			 target = target + "<div><input type=\"hidden\" name=\"FIELD_RESOURCE_ID\" value=\""+resource_id+"\"></div>"
		        			                 + "<div style=\"margin:10px 5px 5px 0px;\"><span >相册名称:</span><input style=\"margin:0px 5px -5px 0px;height:25px;width:150px;\" id=\"FIELD_PHOTO_NAME\" name=\"FIELD_NAME\" value=\""+resultData.NAME+"\"/><span id=\"FIELD_PHOTO_NAME_ERROR\" style=\"color:red;\"></span></div>"
		        			                 + "<div style=\"margin:10px 5px 5px 0px;\"><span >拍摄地点:</span><input style=\"margin:0px 5px -5px 0px;height:25px;width:300px;\" id=\"FIELD_PHOTO_SITE\" name=\"FIELD_SITE\" value=\""+resultData.SITE+"\"/><span id=\"FIELD_PHOTO_SITE_ERROR\" style=\"color:red;\"></span></div>"
		        			                 + "<div style=\"margin:10px 5px 5px 0px;\"><span >相册描述:</span><input style=\"margin:0px 5px -5px 0px;height:25px;width:300px;\" id=\"FIELD_PHOTO_DESCRIPTION\" name=\"FIELD_DESCRIPTION\" value=\""+resultData.DESCRIPTION+"\"/><span id=\"FIELD_PHOTO_DESCRIPTION_ERROR\" style=\"color:red;\"></span></div>"
		        			                 + "<div style=\"margin:10px 5px 5px 0px;\"><span >是否分享:</span><select style=\"margin:0px 5px -5px 0px;height:25px;\" id=\"FIELD_PHOTO_SHARE_TYPE\" name=\"FIELD_SHARE_TYPE\">"
		        			                 +		"<option value=\"0\">不可以</option>"
		        			                 +		"<option value=\"1\">可以</option>"
		        			                 + "</select></div>"
		        			                 + "<div style=\"margin:10px 5px 5px 0px;\"><span >浏览权限:</span><select style=\"margin:0px 5px -5px 0px;height:25px;\" id=\"FIELD_PHOTO_VIEW_PERMISSION\" name=\"FIELD_VIEW_PERMISSION\">"
		        			                 +		"<option value=\"1\">所有人</option>"
		        			                 +		"<option value=\"2\">仅好友</option>"
		        			                 +		"<option value=\"3\">指定好友</option>"
		        			                 +		"<option value=\"4\">仅自己</option>"
		        			                 + "</select></div>"
		        			                 + "<div style=\"margin:10px 5px 5px 0px;\"><span >设置密码:</span><select style=\"margin:0px 5px -5px 0px;height:25px;\" id=\"FIELD_PHOTO_ISPASSWORD\" name=\"FIELD_ISPASSWORD\">"
		        			                 +		"<option value=\"0\">否</option>"
		        			                 +		"<option value=\"1\">是</option>"
		        			                 + "</select></div>"
		        			                 + "<div id=\"FIELD_PHOTO_PASSWORD_DIV\" style=\"margin:10px 5px 5px 0px;\"><span >相册密码:</span><input style=\"margin:0px 5px -5px 0px;height:25px;width:300px;\" id=\"FIELD_PHOTO_PASSWORD\" name=\"FIELD_PASSWORD\"/><span id=\"FIELD_PHOTO_PASSWORD_ERROR\" style=\"color:red;\"></span></div>"
		        			                 + "<div style=\"margin:0px 0px 45px 0px;\"><INPUT class=\"input_btn right\" id=\"albumFolderFormSubmit\" type=button value=\"提交\" /><INPUT class=\"input_btn right\" id=\"albumFolderFormReset\" type=\"reset\" value=\"重置\" /></div>"
		        			                 ;

		        		 target = target+"</form></div>";
		        		 $("#albumFolderUpdate").html(target);
		        		 $("#FIELD_PHOTO_SHARE_TYPE").val(resultData.SHARE_TYPE);
		        		 $("#FIELD_PHOTO_VIEW_PERMISSION").val(resultData.VIEW_PERMISSION);
		        		 $("#FIELD_PHOTO_ISPASSWORD").val(resultData.ISPASSWORD);
		        		 if(resultData.ISPASSWORD == '1'){
		        			 $("#FIELD_PHOTO_PASSWORD_DIV").show(); 
		        		 }else{
		        			 $("#FIELD_PHOTO_PASSWORD_DIV").hide();
		        		 }
		        		 
		        		 viewAlbumPhoto(resultData.RESOURCE_ID);
		        		 
		        		 $("#FIELD_PHOTO_ISPASSWORD").change(function(){
		        			 var ispassword = $("#FIELD_PHOTO_ISPASSWORD").val();
		        			 if(ispassword == '1'){
		        				 $("#FIELD_PHOTO_PASSWORD_DIV").show();
		        			 }else{
		        				 $("#FIELD_PHOTO_PASSWORD_DIV").hide();
		        			 }
		        		 });
		        		 $("#albumFolderFormSubmit").click(function(){
		        			 if($.trim($("#FIELD_PHOTO_NAME").val()).length==0){
 			        			$("#FIELD_PHOTO_NAME_ERROR").html("名称不能为空");
 			        			return false;
 			        		}else{
 			        			$("#FIELD_PHOTO_NAME_ERROR").html("");
 			        		}
 			        		if($.trim($("#FIELD_PHOTO_SITE").val()).length==0){
 			        			$("#FIELD_PHOTO_SITE_ERROR").html("拍摄地不能为空");
 			        			return false;	
 			        		}else{
 			        			$("#FIELD_PHOTO_SITE_ERROR").html("");
 			        		} 
 			        		if($.trim($("#FIELD_PHOTO_DESCRIPTION").val()).length==0){
 			        			$("#FIELD_PHOTO_DESCRIPTION_ERROR").html("描述不能为空");
 			        			return false;	
 			        		}else{
 			        			$("#FIELD_PHOTO_DESCRIPTION_ERROR").html("");
 			        		}
 			        		if($.trim($("#FIELD_PHOTO_PASSWORD").val()).length==0 && $("#FIELD_PHOTO_ISPASSWORD").val()=='1'){
 			        			$("#FIELD_PHOTO_PASSWORD_ERROR").html("密码不能为空");
 			        			return false;	
 			        		}else{
 			        			$("#FIELD_PHOTO_PASSWORD_ERROR").html("");
 			        		}
 			        		$.sendPost(
 			        		          "jwAppsPhotoAct_update", 
 			        		          getFormData("albumFolderForm"), 
 			        		          function(data){
 			        		        	fancyAlert(data[0].VALUE,1);
 			        		        	jQuery.fancybox.close();
 			        		        	queryData.FIELD_DELETE_FLAG = "0";
 			          		        	queryData.FIELD_RESOURCE_ID = "";
 			        		          },
 			        		          null,
 			        		          "json"
 			        		       );
		        		 });
		        		 $("#batchDescribePhoto").click(function(){
		        			 var str=getCheckBoxValue("checkboxPhoto");
		        			 if(str==""){
		        				 fancyAlert("请选中要操作相片!",2); 
		        				 return;
		        			 }
		        			 jQuery.fancybox({
		        	    			"modal" : false,
		        	    			"content" : ""
		        	    			        + "<div class=\"popup_header_icon_200\"><div class=\"popup_header_text\">更改说明</div></div>"
		        	    			        + "<form id=\"batchDescribePhotoForm\" action=\"\">"
		        	    			        + "<div style=\"width:200px;\">"
		        	    			        + "<div>"
		        	    			        + "<span style=\"line-height:30px;height:33px;\">描述：</span><input type=\"text\"  id=\"FIELD_REMARK\" name=\"FIELD_REMARK\"/>"
		        	    			        + "<input type=\"hidden\"  id=\"FIELD_RESOURCE_ID\" name=\"FIELD_RESOURCE_ID\" value=\""+str+"\"/>" 
		        	    			        + "</div>"
		        	    			        + "<div id=\"albumPhotoErr\" style=\"float:left;margin-right:25px;\"></div>"
		        	    			        + "<div style=\"float:right;margin-right:25px;\"><input type=\"button\" class=\"input_btn right\" id=\"fancyConfirmPhoto_ok\"  value=\"确定\" /></div>"
		        	    			        + "</div>"
		        	    			        + "</form>",
		        	    			        onComplete : function() {
		        	    			        	//空值检验
		        	    			        	
		        	    			        	$("#fancyConfirmPhoto_ok").click(function() {
		        	    			        		if($.trim($("#FIELD_REMARK").val()).length==0){
		        	    			        			$("#albumPhotoErr").html("<font color='red'>描述不能为空</font>");
		        	    			        			return false;	
		        	    			        		}
		        	    			        		$.sendPost(
		        	    			        		          "jwAppsPhotoAct_batchUpdatePhoto", 
		        	    			        		          getFormData("batchDescribePhotoForm"), 
		        	    			        		          function(data){
		        	    			        		        	fancyAlert(data[0].VALUE,1);
		        	    			        		        	jQuery.fancybox.close();
		        	    			        		        	queryData.FIELD_DELETE_FLAG = "";
		        	    			          		        	queryData.FIELD_RESOURCE_ID = "";
		        	    			          		        	loadPageAlbumManagePhoto(local_pageNo,resource_id);
		        	    			        		          },
		        	    			        		          null,
		        	    			        		          "json"
		        	    			        		       );
		        	    			        		
		        	    			        	});
		        	    			        	
		        	    			        	
		        	    			        	
		        	    			        }
		        	    		});
		        		 });
		        		 $("#batchMovePhoto").click(function(){
		        			 resetQueryData();
		        		 	 queryData.FIELD_DELETE_FLAG='0';
		        		     $.sendPost(
		        				"jwAppsPhotoData_listAll", 
		        				queryData, 
		        				function(data){
		        					var opetion = "";
		    		        		var i=0;
		    		        		for(i=0;i<data[0].rowSet.length;i++){
		     		 		          var rowData = data[0].rowSet[i];
		     		 		          opetion = opetion + " <option value=\""+rowData.RESOURCE_ID+"\">"+rowData.NAME+"</option>";
		     		 		        }
		    		        		 var selectAlbum = ""
		    		        		 		    + "<select name=\"FIELD_ALBUM_ID\" id=\"batchMovePhotoSel_"+resource_id+"\" style=\"width:160px;margin:5px 0 5px 0;\">"
		    		        		 		    + opetion 
		    		        		 		    + "</select>";
		        					//
				        			 var str=getCheckBoxValue("checkboxPhoto");
				        			 if(str==""){
				        				 fancyAlert("请选中要操作相片!",2); 
				        				 return;
				        			 }
				        			 jQuery.fancybox({
				        	    			"modal" : false,
				        	    			"content" : ""
				        	    			        + "<div class=\"popup_header_icon_200\"><div class=\"popup_header_text\">批量转移</div></div>"
				        	    			        + "<form id=\"batchMovePhotoForm\" action=\"\">"
				        	    			        + "<div style=\"width:200px;\">"
				        	    			        + "<div>"
				        	    			        + selectAlbum
				        	    			        + "<input type=\"hidden\"  id=\"FIELD_RESOURCE_ID\" name=\"FIELD_RESOURCE_ID\" value=\""+str+"\"/>" 
				        	    			        + "</div>"
				        	    			        + "<div id=\"albumPhotoErr\" style=\"float:left;margin-right:25px;\"></div>"
				        	    			        + "<div style=\"float:right;margin-right:25px;\"><input type=\"button\" class=\"input_btn right\" id=\"fancyConfirmPhoto_ok\"  value=\"确定\" /></div>"
				        	    			        + "</div>"
				        	    			        + "</form>",
				        	    			        onComplete : function() {
				        	    			        	//空值检验
				        	    			        	
				        	    			        	$("#fancyConfirmPhoto_ok").click(function() {
				        	    			        		
				        	    			        		$.sendPost(
				        	    			        		          "jwAppsPhotoAct_batchUpdatePhoto", 
				        	    			        		          getFormData("batchMovePhotoForm"), 
				        	    			        		          function(data){
				        	    			        		        	fancyAlert(data[0].VALUE,1);
				        	    			        		        	jQuery.fancybox.close();
				        	    			        		        	queryData.FIELD_DELETE_FLAG = "";
				        	    			          		        	queryData.FIELD_RESOURCE_ID = "";
				        	    			          		        	queryData.FIELD_ALBUM_ID = resultData.RESOURCE_ID;
				        	    			          		        	loadPageAlbumManagePhoto(local_pageNo,resource_id);
				        	    			        		          },
				        	    			        		          null,
				        	    			        		          "json"
				        	    			        		       );
				        	    			        		
				        	    			        	});
				        	    			        	
				        	    			        	
				        	    			        	
				        	    			        }
				        	    		});
				        			 //
		        			    },
		   		                null,
		   		                "json"
		   		             );
		        		 });
		        		 
		        	 });
		        	}else{
		        		$("#tabs-1").html("");
		        	}

		          },
		          null,
		          "json"
		       );
    	
    }
    
    function viewAlbumPhoto(photoType){
    	resetQueryData();
    	queryData.FIELD_ALBUM_ID=photoType;
    	//queryData.FIELD_DELETE_FLAG='0';
    	loadPageAlbumManagePhoto(1,photoType);
    }
    
   
    
    /**
     * 相片选择用于增删改
     */
    function loadPageAlbumManagePhoto(pageNo,albumID){
    	local_pageNo = pageNo;
    	queryData.pageNo=local_pageNo;
    	queryData.pageSize=pageSize;
    	queryData.FIELD_ALBUM_ID = albumID;
    	$.sendPost(
		          "jwAppsPhotoData_listPhoto", 
		          queryData, 
		          function(data){
		        	if(data[0].rowSet.length>0){
		        	 $("#albumPhoto").load(gaowj.WEB_APP_NAME+"/jwapp/pages/photo/photoMyDetailManageTemp.jsp",function(){
		        		 renderDATA(data[0].rowSet,$("#row"),"resizabletable");
		        		 
		        		 var target = "<div style=\"border-bottom:solid #ccc 1px;width:760px;height:40px;\"><div style=\"margin:10px 0 0 150px;\">"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPageAlbumManagePhoto(1,'"+albumID+"');\">首页</a></div>"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPageAlbumManagePhoto("+ (pageNo>1?(pageNo -1):pageNo) +",'"+albumID+"');\">上一页</a></div>"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPageAlbumManagePhoto("+ (pageNo<data[0].pageCount?(pageNo + 1):pageNo) +",'"+albumID+"');\">下一页</a></div>"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPageAlbumManagePhoto("+data[0].pageCount+",'"+albumID+"');\">末页</a></div>"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\">"+data[0].pageNo+"/"+data[0].pageCount+"</div>"
        			         +"<div style=\"float:left;margin-left:5px;\">到第<input type=\"text\" id=\"toPage\" value=\""+pageNo+"\" onblur=\"if(this.value>"+data[0].pageCount+" || this.value<0) this.value=1\" style=\"width:30px;height:25px;\"/>页</div>"
        			         +"<div style=\"float:left;margin-left:5px;\"><input type=\"button\" value=\"确定\" onclick=\"loadPageAlbumManagePhoto(parseInt(toPage.value),'"+albumID+"');\" class=\"input_btn_12 page_define_btn\"/></div>"
        			         +"<div></div>";
		        			 
		        		 $("#myphotopage").html(target);
		        		 $("#toPage").numeral();
		        		 
		        		 renderPhotoManageOPE(albumID);
		        		 
		        		 if($.browser.safari){
			        		    var tabs_height = $("#tabs").height();
			        		    $("#sheqshappsContent").height(tabs_height + photoappsContent_height + 800 + 550);
			        	 }
		        	 });
		        	}else{
		        		$("#albumPhoto").html("");
		        	}

		          },
		          null,
		          "json"
		       );
    	
    }
    
    /**
     * 添加相片选择
     * @param rows
     * @param pkid
     * @param target
     */
    function renderPhotoManageOPE(albumID){
    	$("div[id='row']").each(function(i,row){
    	   var v_id = $(row).find("#RESOURCE_ID").text();
    	   var v_store_name = $(row).find("#STORE_NAME").text();
    	   var v_name = $(row).find("#REMARK").text();
    	   var v_delete_flag = $(row).find("#DELETE_FLAG").text();
    	   var v_photoType = $(row).find("#ALBUM_ID").text();
    	   var v_iscover = $(row).find("#ISCOVER").text();
    	   var img_html = "<input name=\"checkboxPhoto\" value=\""+v_id+"\" type=\"checkbox\"><img src=\""+gaowj.WEB_APP_NAME+"/photo/photo.jsp?ls_photo="+v_store_name+"\" width=\"100\" height=\"75\" style=\"cursor:pointer;\" onclick=\"galleryPhoto(this.src);\"/>";
    	   
    	   $(row).find("#target3_photo").html(img_html);
    	   
    	   var cover_target = "<div style=\"color:#09c;cursor:pointer;\" onclick=\"setCover('"+v_id+"','"+v_photoType+"','"+albumID+"')\">设为封面</div>";
    	   if(v_iscover == "1"){
    		   cover_target = "<div style=\"color:#333;cursor:pointer;\">已设封面</div>";
    	   }else{
    		   cover_target = "<div style=\"color:#09c;cursor:pointer;\" onclick=\"setCover('"+v_id+"','"+v_photoType+"','"+albumID+"')\">设为封面</div>";
    	   }
    	   
    	   var del_target = "<div style=\"color:#09c;cursor:pointer;\" onclick=\"reCyclePhoto('"+v_id+"','"+albumID+"')\">回收</div>";
    	   
    	   if(v_delete_flag=="1"){
    		   del_target = "<div style=\"color:#ccc;cursor:pointer;\" onclick=\"renewPhoto('"+v_id+"','"+albumID+"')\">恢复</div>";
    	   }else{
    		   del_target = "<div style=\"color:#09c;cursor:pointer;\" onclick=\"reCyclePhoto('"+v_id+"','"+albumID+"')\">回收</div>"; 
    	   }
    	   
    	   var target =  cover_target
    		           + "<div style=\"color:#09c;cursor:pointer;\" onclick=\"describePhoto('"+v_id+"','"+v_photoType+"','"+v_name+"','"+albumID+"')\">更改说明</div>"
    		           + "<div style=\"color:#09c;cursor:pointer;\" onclick=\"movePhoto('"+v_id+"','"+v_photoType+"','"+albumID+"')\">转移</div>"
    		           + del_target
    		           + "<div style=\"color:#09c;cursor:pointer;\" onclick=\"deletePhoto('"+v_id+"','"+v_delete_flag+"','"+albumID+"')\">删除</div>";
    	   $(row).find("#target3_photo_ope").html(target);
    	   
    	   var target_update = "<div id=\"target3_photo_update_"+v_id+"\" class=\"target3_photo_update\" style=\"float:right;width:100px;height:100px;margin:22px 180px 0 0;*margin:44px 90px 0 0;\">"
    		                 + "</div>";
    	   $(row).find("#target3_photo_update_main").html(target_update);
    	   
    	});
      }
    
    /**
     * 回收相片
     * @param resource_id
     */
    function reCyclePhoto(resource_id,albumID){
    	queryData.FIELD_RESOURCE_ID = resource_id;
    	queryData.FIELD_DELETE_FLAG = "1";
    	fancyConfirm("确定移入回收站?",function(){
    		$.sendPost(
  		          "jwAppsPhotoAct_updatePhoto", 
  		          queryData, 
  		          function(data){
  		        	fancyAlert(data[0].VALUE,1);
  		        	jQuery.fancybox.close();
  		        	queryData.FIELD_RESOURCE_ID = "";
  		        	queryData.FIELD_DELETE_FLAG = "";
  		        	loadPageAlbumManagePhoto(local_pageNo,albumID);
  		          },
  		          null,
  		          "json"
  		       );
    	},"提示",1);
    	
    }
    /**
     * 恢复相片
     * @param resource_id
     */
    function renewPhoto(resource_id,albumID){
    	queryData.FIELD_RESOURCE_ID = resource_id;
    	queryData.FIELD_DELETE_FLAG = "0";
    	fancyConfirm("确定恢复?",function(){
    		$.sendPost(
  		          "jwAppsPhotoAct_updatePhoto", 
  		          queryData, 
  		          function(data){
  		        	fancyAlert(data[0].VALUE,1);
  		        	jQuery.fancybox.close();
  		        	queryData.FIELD_RESOURCE_ID = "";
  		        	queryData.FIELD_DELETE_FLAG = "";
  		        	loadPageAlbumManagePhoto(local_pageNo,albumID);
  		          },
  		          null,
  		          "json"
  		       );
    	},"提示",1);
    	
    }
    /**
     * 删除相片
     * @param resource_id
     */
    function deletePhoto(resource_id,delete_flag,albumID){
    	if(delete_flag!='1'){
    		fancyAlert("相片回收后才能删除!",2);
    		return;
    	}
    	queryData.deletekey = resource_id;
    	fancyConfirm("确定删除此相片?",function(){
    		$.sendPost(
  		          "jwAppsPhotoAct_deletePhoto", 
  		          queryData, 
  		          function(data){
  		        	fancyAlert(data[0].VALUE,1);
  		        	jQuery.fancybox.close();
  		        	queryData.FIELD_RESOURCE_ID = "";
  		        	queryData.FIELD_DELETE_FLAG = "";
  		        	loadPageAlbumManagePhoto(local_pageNo,albumID);
  		          },
  		          null,
  		          "json"
  		       );
    	},"提示",2);
    	
    }
    
    /**
     * 转移相片
     */
    function movePhoto(resource_id,photoType,albumID){
    	resetQueryData();
 	    queryData.FIELD_DELETE_FLAG='0';
		$.sendPost(
		          "jwAppsPhotoData_listAll", 
		          queryData, 
		          function(data){
		        		var opetion = "";
		        		var i=0;
		        		for(i=0;i<data[0].rowSet.length;i++){
 		 		          var rowData = data[0].rowSet[i];
 		 		          opetion = opetion + " <option value=\""+rowData.RESOURCE_ID+"\">"+rowData.NAME+"</option>";
 		 		        }
		        		 var target = "相册："
		        		 		    + "<select name=\"photoType\" id=\"movePhotoSel_"+resource_id+"\" style=\"width:180px;margin-bottom:5px;\">"
		        		 		    + opetion 
		        		 		    + "</select>"
		        		 		    + "<input id=\"toMovePhoto_"+resource_id+"\" type=\"button\" class=\"input_btn\" value=\"提交\"/>";
		        		 $(".target3_photo_update").html("");
		        		 $("#target3_photo_update_"+resource_id).html(target);
		        		 $("#movePhotoSel_"+resource_id).val(photoType);
		        		 $("#toMovePhoto_"+resource_id).click(function(){
		        			 var albumType = $("#movePhotoSel_"+resource_id).val();
		        			 if($.trim(photoType)==$.trim(albumType)){
		        				 fancyAlert("不能转移到自身相册里!",0);
		        				 return;
		        			 }
		        			 queryData.FIELD_RESOURCE_ID = resource_id;
		        			 queryData.FIELD_DELETE_FLAG = "";
		        			 queryData.FIELD_ALBUM_ID = albumType;
		        			 queryData.FIELD_ISCOVER = "0";
		        		     fancyConfirm("确定转移到所选相册?",function(){
		        		    	$.sendPost(
		        		  		    "jwAppsPhotoAct_updatePhoto", 
		        		  		    queryData, 
		        		  		    function(data){
		        		  		        fancyAlert(data[0].VALUE,1);
		        		  		        jQuery.fancybox.close();
		        		  		        queryData.FIELD_RESOURCE_ID = "";
		        		  		        queryData.FIELD_DELETE_FLAG = "";
		        		  		        queryData.FIELD_ALBUM_ID = photoType;
		        		  		        loadPageAlbumManagePhoto(local_pageNo,albumID);
		        		  		     },
		        		  		     null,
		        		  		     "json"
		        		  		 );
		        		      },"提示",1);
		        		 });
		          },
		          null,
		          "json"
		       );
    }
    
    /**
     * 描述相片
     */
    function describePhoto(resource_id,photoType,describe,albumID){
    	var target = "描述："
 		    + "<input type=\"text\" id=\"movePhotoText_"+resource_id+"\" value=\""+describe+"\" style=\"width:180px;margin-bottom:5px;\"/>"
 		    + "<input id=\"toMovePhoto_"+resource_id+"\" type=\"button\" class=\"input_btn\" value=\"提交\"/>";
        $(".target3_photo_update").html("");
        $("#target3_photo_update_"+resource_id).html(target);

        $("#toMovePhoto_"+resource_id).click(function(){
        	   var describe = $("#movePhotoText_"+resource_id).val();
	           queryData.FIELD_RESOURCE_ID = resource_id;
	           queryData.FIELD_DELETE_FLAG = "";
	           queryData.FIELD_REMARK = describe;
	           queryData.FIELD_ALBUM_ID = "";
               fancyConfirm("更改描述?",function(){
    	           $.sendPost(
  		                 "jwAppsPhotoAct_updatePhoto", 
  		                  queryData, 
  		                  function(data){
  		                     fancyAlert(data[0].VALUE,1);
  		                     jQuery.fancybox.close();
  		                     queryData.FIELD_RESOURCE_ID = "";
  		                     queryData.FIELD_DELETE_FLAG = "";
  		                     queryData.FIELD_REMARK = "";
  		                     queryData.FIELD_ALBUM_ID = photoType;
  		                     loadPageAlbumManagePhoto(local_pageNo,albumID);
  		                   },
  		          null,
  		          "json"
  		          );
              },"提示",1);
         });
    }
    
    function setCover(resource_id,photoType,albumID){
    	queryData.FIELD_RESOURCE_ID = resource_id;
        queryData.FIELD_ALBUM_ID = photoType;
    	fancyConfirm("确定设成封面?",function(){
    		$.sendPost(
  		          "jwAppsPhotoAct_setCoverPhoto", 
  		          queryData, 
  		          function(data){
  		        	fancyAlert(data[0].VALUE,1);
  		        	jQuery.fancybox.close();
  		        	queryData.FIELD_RESOURCE_ID = "";
  		        	loadPageAlbumManagePhoto(local_pageNo,albumID);
  		          },
  		          null,
  		          "json"
  		       );
    	},"提示",1);
    }
    
    /**-------------相片操作------------------------**/
    
    function viewPhoto(photoType,ispassword){
    	if(ispassword == '1'){
    		jQuery.fancybox({
    			"modal" : false,
    			"content" : ""
    			        + "<div class=\"popup_header_icon_200\"><div class=\"popup_header_text\">密码解锁</div></div>"
    			        + "<form id=\"checkPasswordPhotoForm\" action=\"\">"
    			        + "<div style=\"width:200px;\">"
    			        + "<div>"
    			        + "<span style=\"line-height:30px;height:33px;\">密码：</span><input type=\"text\"  id=\"FIELD_CHECK_PASSWORD\" name=\"FIELD_PASSWORD\"/>"
    			        + "<input type=\"hidden\"  id=\"FIELD_CHECK_RESOURCE_ID\" name=\"FIELD_RESOURCE_ID\" value=\""+photoType+"\"/>" 
    			        + "</div>"
    			        + "<div id=\"albumCheckPasswordErr\" style=\"float:left;margin-right:25px;\"></div>"
    			        + "<div style=\"float:right;margin-right:25px;\"><input type=\"button\" class=\"input_btn right\" id=\"fancyConfirmCheckPassword_ok\"  value=\"确定\" /></div>"
    			        + "</div>"
    			        + "</form>",
    			        onComplete : function() {
    			        	
    			        	//密码校验
    			        	var password_checker = $("input#FIELD_CHECK_PASSWORD").checker().act("keyup").reg(function(){
    			        	    if($.trim($(this).val()).length>16){
    			                    this.checkwrite("输入不应超过16位！");
    			                    return false;
    			                }
    			        	    if($.trim($(this).val()).length==0){
    			                    this.checkwrite("不能为空！");
    			                    return false;
    			                }
    			                this.checkwrite(null);
    			                return true;
    			        	});
    			        	
    			        	$("#fancyConfirmCheckPassword_ok").click(function() {
    			        		if(!(password_checker.exc())){
    			        			return;	
    			        		}
    			        		$.sendPost(
    			        		          "jwAppsPhotoData_checkAlbumPassword", 
    			        		          getFormData("checkPasswordPhotoForm"), 
    			        		          function(data){
    			        		        	if(data[0].rowSet.CHECK == "true"){
    			        		        	   jQuery.fancybox.close();
    			        		        	   resetQueryData();
    			        		         	   queryData.FIELD_ALBUM_ID=photoType;
    			        		         	   queryData.FIELD_DELETE_FLAG='0';
    			        		         	   loadPagePhoto(1,photoType);
    			        		        	}else{
    			        		        		fancyAlert("解锁失败!",1);
    			        		        		jQuery.fancybox.close();
    			        		        	}
    			        		          },
    			        		          null,
    			        		          "json"
    			        		       );
    			        		
    			        	});
    			        	
    			        	
    			        	
    			        }
    		});
    	}else{
    	   resetQueryData();
    	   queryData.FIELD_ALBUM_ID=photoType;
    	   queryData.FIELD_DELETE_FLAG='0';
    	   loadPagePhoto(1,photoType);
    	}
    }
    
    /**
     * 相片翻页
     */
    function loadPagePhoto(pageNo,photoType){
    	local_pageNo = pageNo;
    	queryData.pageNo=local_pageNo;
    	queryData.pageSize=pageSize;
    	queryData.FIELD_ALBUM_ID = photoType;
    	$.sendPost(
		          "jwAppsPhotoData_listPhoto", 
		          queryData, 
		          function(data){
		        	if(data[0].rowSet.length>0){
		        	 $("#tabs-1").load(gaowj.WEB_APP_NAME+"/jwapp/pages/photo/photoMyDetailTemp.jsp",function(){
		        		 //加载所需JS
		        		 $.getScript(gaowj.WEB_APP_NAME+'/jwapp/common/js/face.js',function(){});
		        		 //
		        		 renderDATA(data[0].rowSet,$("#row"),"resizabletable");
		        		 
		        		 var target = "<div style=\"border-bottom:solid #ccc 1px;width:760px;height:40px;\"><div style=\"margin:10px 0 0 150px;\">"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPagePhoto(1,'"+photoType+"');\">首页</a></div>"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPagePhoto("+ (pageNo>1?(pageNo -1):pageNo) +",'"+photoType+"');\">上一页</a></div>"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPagePhoto("+ (pageNo<data[0].pageCount?(pageNo + 1):pageNo) +",'"+photoType+"');\">下一页</a></div>"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\"><a href=\"#\" style=\"text-decoration:none;\" onclick=\"loadPagePhoto("+data[0].pageCount+",'"+photoType+"');\">末页</a></div>"
        			         +"<div style=\"border:solid #ccc 1px;width:50px;height:25px;float:left;margin-left:5px;\">"+data[0].pageNo+"/"+data[0].pageCount+"</div>"
        			         +"<div style=\"float:left;margin-left:5px;\">到第<input type=\"text\" id=\"toPage\" value=\""+pageNo+"\" onblur=\"if(this.value>"+data[0].pageCount+" || this.value<0) this.value=1\" style=\"width:30px;height:25px;\"/>页</div>"
        			         +"<div style=\"float:left;margin-left:5px;\"><input type=\"button\" value=\"确定\" onclick=\"loadPagePhoto(parseInt(toPage.value),'"+photoType+"');\" class=\"input_btn_12 page_define_btn\"/></div>"
        			         +"<div></div>";
		        			 
		        		 $("#myphotopage").html(target);
		        		 $("#toPage").numeral();
		        		 
		        		 renderPhotoOPE();
		        		 
		        		 var _this = $("#albumnote");
		        		 
		        		 //加载评论
		        		 loadAlbumNote(photoType,$("#albumnotetitler"));
		        		 
		        		//表情
		     		    _this.find("#albumnotefooticon").click(function(){
		     		         reForwardshow("album_note_textarea");
		     		         setFocus(_this.find("#album_note_textarea"));
		     		         return false;
		     		    });
		     		    
		     		    //字数实时统计
		     		   _this.find("#album_note_textarea").artTxtCount(_this.find("#albumnotefootr"),_this.find("#albumnotefootl"),240);
		     		   
		     		   
			        	var album_note_checker = $("TEXTAREA#album_note_textarea").checker().act("keyup").reg(function(){
		        	       if($.trim($(this).val()).length==0){
		                      this.checkwrite("不能为空！");
		                      return false;
		                   }
		                   this.checkwrite(null);
		                   return true;
		        	    });
		     		   
		     		   
		     		   //相册评论提交
		     		  _this.find("#album_note_submit").click(function(){
		     			  if(!(album_note_checker.exc())){
		     				  return;
		     			  }
		     			  var v_note = _this.find("#album_note_textarea").val();
		     			  queryData.FIELD_NOTE_TEXT = v_note;
		     			  $.sendPost(
		     	  		          "jwAppsPhotoAct_insertAlbumNote", 
		     	  		          queryData, 
		     	  		          function(data){
//		     	  		        	fancyAlert(data[0].VALUE,1);
//		     	  		        	jQuery.fancybox.close();
		     	  		        	$("TEXTAREA#album_note_textarea").val('');
		     	  		        	loadAlbumNote(photoType,$("#albumnotetitler"));
		     	  		          },
		     	  		          null,
		     	  		          "json"
		     	  		   );
		     		  });

		        	 });
		        	}else{
		        		$("#tabs-1").html("");
		        	}

		          },
		          null,
		          "json"
		       );
    	
    }
    
    /**
     * 加载相册评论
     */
    function loadAlbumNote(photoType,$this){
    	var v_query = {};
    	v_query.FIELD_ALBUM_ID = photoType;
    	$.sendPost(
 		   "jwAppsPhotoData_listAllAlbumNote", 
 		   v_query, 
 		   function(data){
 		     var noteData = data[0].rowSet;
 		     var target = "";		      
 		     for(var i=0;i<noteData.length;i++){
 		        var target_ope_delete = "";
 	 		    if(gaowj.session.userCode == noteData[i].NOTE_CREATOR_ID){
 	 		    	target_ope_delete = "<div onclick=\"deleteAlbumNote('"+photoType+"','"+noteData[i].RESOURCE_ID+"')\" style=\"cursor:pointer;float:right;margin:-15px 5px 0 0;width:20px;height:20px;background:url("+gaowj.WEB_APP_NAME+"/jwapp/common/image/common/notice_close_btn.png) no-repeat;\"></div>"; 
 	 		    }else{
 	 		    	target_ope_delete = "";
 	 		    }
 		    	var v_temp = "<div id=\"albumnote_"+noteData[i].RESOURCE_ID+"\" style=\"background:#ccc;margin:10px 0 0 0;\">"
 		    	            + "<div style=\"margin:5px 0 0 20px;\">"+noteData[i].NOTE_CREATOR_ID+"&nbsp;&nbsp;"+noteData[i].NOTE_MODIFYTIME+"</div>"
 		    	            + target_ope_delete
 		    	            + "<table style=\"margin:5px 0 0 30px;width:720px;overflow:auto;word-break:break-all;\" border=\"0\"><tr><td valign=\"top\"><span>"+convertImg(noteData[i].NOTE_TEXT)+"</span></td></tr></table>"
 		    	            + "</div>";
 		    	target = target + v_temp;
 		     }
 		    $this.html(target);
 		   },
 		   null,
 		   "json"
 	    );
    }
    
    var deleteAlbumNote = function(photoType,noteID){
    	var v_query = {};
    	v_query.FIELD_ALBUM_ID = photoType;
    	v_query.FIELD_RESOURCE_ID = noteID;
    	$.sendPost(
 		    "jwAppsPhotoAct_deleteAlbumNote", 
 		    v_query, 
 		    function(data){
 		       loadAlbumNote(photoType,$("#albumnotetitler"));
 		    },
 		    null,
 		    "json"
 		 );
    };
    
    /**
     * 添加管理动作
     * @param rows
     * @param pkid
     * @param target
     */
    function renderPhotoOPE(){
    	$("div[id='row']").each(function(i,row){
    	   var v_id = $(row).find("#RESOURCE_ID").text();
    	   var v_store_name = $(row).find("#STORE_NAME").text();
    	   var v_name = $(row).find("#REMARK").text();
    	   var img_html = "<img src=\""+gaowj.WEB_APP_NAME+"/photo/photo.jsp?ls_photo="+v_store_name+"\" width=\"100\" height=\"75\" style=\"cursor:pointer;\" onclick=\"galleryPhoto(this.src);\"/>";
    	   
    	   $(row).find("#target3_photo").html(img_html);
    	});
      }
    
    function galleryPhoto(resource_id){
    	$.sendPost(
		          "jwAppsPhotoData_listPhoto", 
		          queryData, 
		          function(data){
		        	if(data[0].rowSet.length>0){
		        	 $("#tabs-1").load(gaowj.WEB_APP_NAME+"/jwapp/pages/photo/photoDetailTemp.jsp",function(){
		        		 var target = "<ul id=\"myGalleryPhoto\">";
		        		 var view_id = 1;
		        		 $.each(data[0].rowSet, function(i,n){
		        			 target = target + "<li><img resource_id=\""+n.RESOURCE_ID+"\" id=\"gallery"+(i+1)+"\" src=\""+gaowj.WEB_APP_NAME+"/photo/photo.jsp?ls_photo="+(n.STORE_NAME)+"\" alt=\""+(n.REMARK)+"\" /></li>";
		        			 
		        			 if(resource_id.indexOf(n.STORE_NAME)>-1){
		        				 view_id = i + 1;
		        			 }
		        		   });
		        		 target = target+"</ul>"; 
		        		 $("#Gallerymyphoto").html(target);
		        		 $(function(){
		        				$('#myGalleryPhoto').galleryView({
		        					start_frame: view_id,
		        		            filmstrip_position: 'right',
		        		            enable_overlays: false,
		        		            overlay_position: 'top',
		        		            panel_animation: 'fade',
		        		            panel_width:680,
		        		            panel_height:380
		        		        });
		        				
		        			});
		        	 });
		        	}else{
		        		$("#tabs-1").html("");
		        	}

		          },
		          null,
		          "json"
		       );
    	
    }
    
    function photo_note(resource_id){
      $("#photonote_list_ope").load(gaowj.WEB_APP_NAME+"/jwapp/pages/photo/photoDetailNoteTemp.jsp",function(){
    	  /*------------------相片评论--------------------------------*/
 		 //加载评论
 		 loadPhotoNote(resource_id,$("#photonotetitler"));
 		 
 		 var _this = $("#photonote");
 		 
 		//表情
 	    _this.find("#photonotefooticon").click(function(){
 	         reForwardshow("photo_note_textarea");
 	         setFocus(_this.find("#photo_note_textarea"));
 	         return false;
 	    });
 	    
 	    //字数实时统计
 	   _this.find("#photo_note_textarea").artTxtCount(_this.find("#photonotefootr"),_this.find("#photonotefootl"),240);
 	   
 	   
    	  var photo_note_checker = $("TEXTAREA#photo_note_textarea").checker().act("keyup").reg(function(){
 	       if($.trim($(this).val()).length==0){
              this.checkwrite("不能为空！");
              return false;
           }
           this.checkwrite(null);
           return true;
 	    });
    	  
 	   //相片评论提交
 	   $("#photo_note_submit").click(function(){
 		  if(!(photo_note_checker.exc())){
 			  return;
 		  }
 		  var v_note = _this.find("#photo_note_textarea").val();
 		  var v_query = {};
 		  v_query.FIELD_NOTE_TEXT = v_note;
 		  v_query.FIELD_PHOTO_ID = resource_id;
 		  $.sendPost(
   		          "jwAppsPhotoAct_insertPhotoNote", 
   		          v_query, 
   		          function(data){
   		        	$("TEXTAREA#photo_note_textarea").val('');
   		        	loadPhotoNote(resource_id,$("#photonotetitler"));
   		          },
   		          null,
   		          "json"
   		   );
 	   });
      });
    }
    
    /**
     * 加载相片评论
     */
    function loadPhotoNote(photoID,$this){
    	var v_query = {};
    	v_query.FIELD_PHOTO_ID = photoID;
    	$.sendPost(
 		   "jwAppsPhotoData_listAllPhotoNote", 
 		   v_query, 
 		   function(data){
 		     var noteData = data[0].rowSet;
 		     var target = "";		      
 		     for(var i=0;i<noteData.length;i++){
 		        var target_ope_delete = "";
 	 		    if(gaowj.session.userCode == noteData[i].NOTE_CREATOR_ID){
 	 		    	target_ope_delete = "<div onclick=\"deletePhotoNote('"+photoID+"','"+noteData[i].RESOURCE_ID+"')\" style=\"cursor:pointer;float:right;margin:-15px 5px 0 0;width:20px;height:20px;background:url("+gaowj.WEB_APP_NAME+"/jwapp/common/image/common/notice_close_btn.png) no-repeat;\"></div>"; 
 	 		    }else{
 	 		    	target_ope_delete = "";
 	 		    }
 		    	var v_temp = "<div id=\"photonote_"+noteData[i].RESOURCE_ID+"\" style=\"background:#ccc;margin:10px 0 0 0;\">"
 		    	            + "<div style=\"margin:5px 0 0 20px;\">"+noteData[i].NOTE_CREATOR_ID+"&nbsp;&nbsp;"+noteData[i].NOTE_MODIFYTIME+"</div>"
 		    	            + target_ope_delete
 		    	            + "<table style=\"margin:5px 0 0 30px;width:720px;overflow:auto;word-break:break-all;\" border=\"0\"><tr><td valign=\"top\"><span>"+convertImg(noteData[i].NOTE_TEXT)+"</span></td></tr></table>"
 		    	            + "</div>";
 		    	target = target + v_temp;
 		     }
 		    $this.html(target);
 		   },
 		   null,
 		   "json"
 	    );
    }
    
    var deletePhotoNote = function(photoID,noteID){
    	var v_query = {};
    	v_query.FIELD_PHOTO_ID = photoID;
    	v_query.FIELD_RESOURCE_ID = noteID;
    	$.sendPost(
 		    "jwAppsPhotoAct_deletePhotoNote", 
 		    v_query, 
 		    function(data){
 		       loadPhotoNote(photoID,$("#photonotetitler"));
 		    },
 		    null,
 		    "json"
 		 );
    };
    