﻿var Photo = function(options){	
	this.options = $.extend({
		currentCommentPageIndex : 1,
		skin : 'default'
	},options);
}
Photo.prototype = {	
	initAlbumList : function(){
		var deal = this;
		$.getJSON(
			"ajax.ashx",
			{"opta":"album","uid":deal.options.userID,"rnd":Math.random()},
			function(json){
				$("#AlbumList").html(deal.joinHtml(json));
				if(deal.options.isM){
					$("#AlbumList li").each(function(){					
						$(this).mouseover(function(){
							$(this).find(".bianji").show();
						}).mouseout(function(){
							$(this).find(".bianji").hide();
						});
					});
				}
			}
		);	
	},
	joinHtml: function(json){
		var sb = new StringBuffer();
		
		for(var i=0;i<json.length;i++){
			var thisObj = json[i];
			sb.append("<li>");
			sb.append("	  <dl>");
			sb.append("		<dt><a href=\"PhotoList.aspx?aid="+thisObj.AlbumID+"&uid="+thisObj.UserID+"\"><img title=\""+thisObj.Desc+"\" border=\"0\" width=\"100\" height=\"100\" src=\""+this.options.filePath+(thisObj.FrontCoverURL==''?'Images/blog/peason_pic_none.gif':thisObj.FrontCoverURL)+"\"/></a></dt>");
			sb.append("		<dd class=\"mingcheng\">"+thisObj.Title+"</dd>");
			sb.append("		<dd class=\"zhangshu\">共"+thisObj.PhotoCount+"张</dd>");
			if(this.options.isM)
				sb.append("		<dd class=\"bianji\" style=\"display:none;\"><a href=\"javascript:;\" onclick=\"photo.editAlbum(this,"+thisObj.AlbumID+");\">编辑</a>&nbsp;<a href=\"javascript:;\" onclick=\"photo.deleteAlbum(this,"+thisObj.AlbumID+","+thisObj.PhotoCount+")\">删除</a></dd>");
			sb.append("	  </dl>");
			sb.append("	</li>");
		}
		
		return sb.toString();
	},
	getTopNewComment : function(uid){
		var deal = this;
		$.getJSON(
			"ajax.ashx",
			{"opta":"getTopNewComment","uid":uid,"rnd":Math.random()},
			function(json){
				$("#newComment").html(deal.joinTopNewComment(json));
				if(deal.options.isM){
					
					$("#newComment li").each(function(){
						$(this).mouseover(function(){
							$(this).find(".dd_date a").show();
						}).mouseout(function(){
							$(this).find(".dd_date a").hide();
						});
					});
				}
				
			}
		);
	},
	joinTopNewComment : function(json){
		var sb = new StringBuffer();
		var Capacity = 0;
		var percent = 0;
		var sumCapacity = this.options.Capacity/1024;
		var albumCapacity = json.CapacityInfo;
		var commentInfo = json.CommentInfo;
		for(var i=0;i<commentInfo.length;i++){
			var thisObj = commentInfo[i];		
			sb.append("<li><dl>")
			sb.append("<dt><a href=\"showPhoto.aspx?pid="+thisObj.PhotoID+"&aid="+thisObj.AlbumID+"&uid="+this.options.userID+"\"><img src=\"smallImg.aspx?imgPath="+thisObj.Url+"&type=eqluse\" /></a></dt>")
			sb.append("<dd><a href=\"../index.aspx?uid="+thisObj.CommentUserID+"\">"+thisObj.CommentUserName+"</a>:"+thisObj.CommentContent+"</dd>");
			sb.append("<dd class=\"dd_date\">"+thisObj.CommentDate.split(" ")[0]);	
			if(this.options.isM){
				sb.append("&nbsp;<a href=\"javascript:;\" style=\"display:none;\" onclick=\"photo.deleteComment("+thisObj.CommentID+");\">删除</a>")
			}
			sb.append("</dd></dl></li>");
		}
		if(commentInfo.length == 0){
			sb.append("<li>你还没有评论！</li>");
		}
		/*if(json.length > 0)
		{*/
			Capacity = albumCapacity.Capacity || 0;
			var AlbumCount = albumCapacity.AlbumCount;
			var rl = parseFloat(Capacity);		
			percent = rl*100/(sumCapacity*1024);
			var strHtml = "<li>你当前共有"+AlbumCount+"个相册;";
			if(this.options.isM)
				strHtml += "<a href=\"javascript:;\" onclick=\"photo.referrer();\"><span>点击刷新</span></a>";
			strHtml += "</li><li>容量:"+sumCapacity+"MB，使用"+Capacity+"KB，占："+(this.formatFloat(percent,2)||0)+"%</li>";
			$(".tongji").html(strHtml);
		//}		
			
		return sb.toString();
	},
	deleteComment : function(cid,pid){
		if(window.confirm("确定要删除该评论？删除后将无法恢复。"))
		{
			var deal = this;
			$.get(
				"ajax.ashx",
				{"opta":"deleteComment","CommentID":cid},
				function(data){
					if(pid){
						deal.getComment(pid,deal.options.currentCommentPageIndex);
					}else
						deal.getTopNewComment(deal.options.userID);
					
				}
			);
		}
	},
	editAlbum : function(o,aid){
		
		$.getJSON(
			"ajax.ashx",
			{"opta":"getAlbum","albumID":aid,"rnd":Math.random()},
			function(json){				
				$("#albumTitle").val(json.Title);
				$("#albumDesc").val(json.Desc);
			}
		);
		JAlert(o,{					
			title : '修改相册',
			content : "createAlbum",
			GetType : 'controls',		//controls,ajax,string,iframe					
			IsDrag : true,			   
			host:this.options.filePath,
			skin:this.options.skin,
			width:400,
			height:300
		});
		var deal = this;
		$("#createAlbum #btnOK").click(function(){
			deal.amend(aid);
		});
	},
	amend : function(aid){
		var title = $.trim($("#albumTitle").val());
		var desc = $.trim($("#albumDesc").val());
		if(title == ''){
			alert("请输入相册名称！");
			return;
		}
		var deal = this;
	    $.ajax(
			{
				type: "POST",
				url: "ajax.ashx",			
				data: {"opta":"amendAlbum","uid":deal.options.userID,"albumID":aid,"title":title,"desc":desc},			
				success: function(msg){
					alert(msg);					
					$("#albumTitle,#albumDesc").val("");
					window.location.reload();
					$('#windowClose').click();
				}

			}
	    );
	},
	deleteAlbum : function(o,aid,pcount){
		if(window.confirm("确定删除该相册？相册中有"+pcount+"张照片\r\r相册删除后将无法恢复。"))
		{
			$.get(
				"ajax.ashx",
				{"opta":"deleteAlbum","albumID":aid},
				function(data){
					switch(data){
						case "-1":
							alert("系统出现异常，请重新登录！");
						break;
						case "0":
							alert("删除相册时出现了错误，请重试！");
						break;
						case "1":
							alert("删除相册成功！");
						break;
					}
					window.location.reload();
				}	            
			);
		}
	},
	showCreateAlbum : function(o){
		JAlert(o,{					
			title : '创建相册',
			content : "createAlbum",
			GetType : 'controls',		//controls,ajax,string,iframe					
			IsDrag : true,			   
			host:this.options.filePath,
			skin:this.options.skin,
			width:400,
			height:300

		});
		$("#albumTitle,#albumDesc").val("");
		var deal = this;
		$("#createAlbum #btnOK").click(function(){
			deal.createAlbum();
		});
	},
	createAlbum : function(){
		var title = $.trim($("#albumTitle").val());
		var desc = $.trim($("#albumDesc").val());
		if(title == ''){
			alert("请输入相册名称！");
			return;
		}
		var deal = this;
	   $.ajax(
			{
				type: "POST",
				url: "ajax.ashx",			
				data: {"opta":"createAlbum","uid":deal.options.userID,"title":title,"desc":desc},			
				success: function(msg){
					alert(msg);
					$("#albumTitle,#albumDesc").val("");
					window.location.reload();	        
				}			

			}
	   );
	},
	setFrontCover : function(pid){
		if(!this.options.isM){
			alert("你不是该相册的主人，请勿非法操作！");
			return;
		}
		if(!pid){
			var thumb = $("#photoList .mingcheng :checkbox:checked");
			if(thumb.length == 0){
			alert("您还没有选择照片，请勾选一张做封面。");
			return;
			}else if(thumb.length > 1){
				alert("您勾选了多张照片，请勾选一张做封面。");
				return;
			}else{
				pid = thumb.val();
			}			
		}
		/*var thumb = $("#photoList .mingcheng :checkbox:checked");
		if(thumb.length == 0){
			alert("您还没有选择照片，请勾选一张做封面。");
		}else if(thumb.length > 1){
			alert("您勾选了多张照片，请勾选一张做封面。");
		}*/
			//var pid = thumb.val();
			var url = $("#ptitle_"+pid).attr("url");
			$.get(
				"ajax.ashx",
				{
					"opta":"setFrontCover",
					"pid":pid,
					"r":Math.random()
				},function(data){
					if(data == 'ok'){
						alert("设为封面成功！");
						if(document.getElementById("frontCover"))
						{
							$("#frontCover").attr("src","smallImg.aspx?imgPath="+url+"&type=eqluse&w=133&h=133");
						}
					}else{
						alert("设为封面失败！");
					}
				}
			);
			   
				
	},
	savePhotoInfo : function()
    {       
        var photoList = [];
        var empty = false;
        $("input[id^='txtTitle_']").each(
            function(i,o){
                if($.trim(o.value) == '')
                {
                    empty = true;
                }else{
                    var id = o.id.split("_")[1];
                    var json = new Object();
                    json.id = id;
                    json.title = $.trim(o.value);
                    json.desc = $("#txtDesc_"+id).val();
                    
                    photoList.push(json);
                }                   
                
            }
        );
        
        if(empty){
            alert("图片的标题不能为空!");                
        }else{
		  var deal = this;
          $.ajax(
	            {
		            type: "POST",
		            url: "ajax.ashx?opta=savePhotoInfo",			
		            data: JSON.stringify(photoList),			
		            success: function(msg){
		                if(msg == 'ok')
		                    window.location.href="Default.aspx?uid="+deal.options.userID;
		            }			

	            }
	       );
        }
    },
	manage : function(o){
		
		var txt = $(o).text();
		var thumb =  $("#photoList .mingcheng label");
		if(txt == '管理')
		{
			$("#manageInfo").show();
			o.innerHTML = '退出管理';
			thumb.each(function(i,o){	            
				if(o.id.substring(0,7) == 'ptitle_'){
					var id = o.id.substring(7);
					$(this).prepend("<input type='checkbox' value='"+id+"' id='chk_"+id+"' />");
				}
			});
		}else{
			$("#manageInfo").hide();
			o.innerHTML = '管理';
			thumb.each(function(i,o){	            
				if(o.id.substring(0,7) == 'ptitle_'){
					$(this).children().remove("input");
				}
			});
		}
	},
	amendPhotoInfo : function(){
		var thumb = $("#photoList .mingcheng :checkbox:checked"); 
		if(thumb.length == 0){
			alert("请选择需要修改信息的照片。");
			return;
		}else{
			var deal = this;
			var checkedObj = '';
			thumb.each(function(i,o){
				checkedObj += o.value+',';
			});                   
			checkedObj = checkedObj.substring(0,checkedObj.length-1);
			 
			$("#hidCheckedObject").val(checkedObj);
			var formObj = document.getElementById("form1");
			formObj.action = "modifyPhoto.aspx?uid="+deal.options.userID;
			formObj.method = "post";    
			function doSubmit(){
				formObj.submit();
			}
			setTimeout(doSubmit,0);
			
		}
	},
	deletePhoto : function(){
		var thumb = $("#photoList .mingcheng :checked"); 
		if(thumb.length == 0){
			alert("请选择需要删除的照片。");
			return;
		}else{
			var winconf = window.confirm("确定删除照片？\n\n照片删除后将无法恢复。");
			if(winconf){
				var checkedObj = '';
				thumb.each(function(i,o){
					checkedObj += o.value+',';
				});                   
				checkedObj = checkedObj.substring(0,checkedObj.length-1);
				var deal = this;
				$.ajax(
					{
						type: "POST",
						url: "ajax.ashx?opta=deletePhoto&uid="+deal.options.userID,			
						data: checkedObj,			
						success: function(data){			                   
							switch(data){
								case "-1":
									alert("系统出现异常，请重新登录！");
								break;
								case "0":
									alert("删除照片时出现了错误，请重试！");
								break;
								case "1":
									alert("删除照片成功！");
								break;
							}
							
							window.location.reload();
									  
						}

					}
			   );
			}
		}
	},
	allcheck : function(o){
		var thumb =  $("#photoList .mingcheng :checkbox");		
		if(o.checked)
			thumb.attr("checked",true);
		else
			thumb.attr("checked",false);
		
	},
	move : function(o,aid){
		var thumb = $("#photoList .mingcheng :checked"); 
		if(thumb.length == 0){
			alert("请先选择需要移动的照片。");
			return;
		}else{
			var winconf = window.confirm("确定要移动照片至相册"+o.innerText+"?");
			if(winconf){
				var checkedObj = '';
				thumb.each(function(i,o){
					checkedObj += o.value+',';
				});                   
				checkedObj = checkedObj.substring(0,checkedObj.length-1);
				var deal = this;
				$.ajax(
					{
						type: "POST",
						url: "ajax.ashx?opta=movePhoto&albumID="+aid,			
						data: checkedObj,			
						success: function(data){			                   
							
							window.location.reload();
									  
						}

					}
			   );
			}
		}
	},
	showPhoto : function(aid,pid){
		 var deal = this;
		 $.getJSON(
                "ajax.ashx",
                {
                    "opta":"allPhoto",
                    "albumID":aid,
                    "pid":pid,
                    "rnd":Math.random()
                
                },function(json){
	                
	                var start = 0;	
					var sb = new StringBuffer();
	                var arrHTML = [];				
					var obj = json[0];
					for(var i=1;i<json.length;i++){
						
						sb.append("<li>");
						sb.append("   <a href=\""+deal.options.filePath + json[i].URL+"\">");
						sb.append("       <img src=\"smallImg.aspx?imgPath=" + json[i].URL + "&type=eqluse\" title=\"" + json[i].Title + "\" longdesc=\"" + json[i].Desc + "\" class=\"image" + i + "\" pid=\""+json[i].PhotoID+"\" />");
						sb.append("   </a>");
						sb.append("</li>");             

						if(json[i].Start){
							start = i-1;
						}
					}
                      
                      $(".ad-thumb-list").html(sb.toString());
		             var galleries = $('.ad-gallery').adGallery(
		                    {		      
								width:760,
								loader_image:deal.options.filePath+'images/photo/loader.gif',
								//height:10,
		                        start_at_index:start,
		                        callbacks:{		                          
		                            afterImageVisible : function(){
		                                deal.getComment(this.current_id,1);
										deal.options.photoID = this.current_id;
		                            }
		                        }
		                    }
		             );
		            
					if(obj){
						$("#daohangAlbumName").html(obj.Title);
						//$("#daohangTitle").html($(".ad-description-title").text());
					}

		            /* galleries[0].settings.callbacks.afterImageVisible = function(){
		                
		             }		  */           
		             
        		     
	            }
	        );
            
          
	},
	getComment : function(pid,pageIndex){
		 var deal = this;
		 deal.options.currentCommentPageIndex = pageIndex;
		 $.getJSON("ajax.ashx",
			{
				"opta":"getComment",                   
				"pid":pid,
				"pageIndex":pageIndex,				
				"rnd":Math.random()
			
			},function(json){
				json.sort(function(a,b){return a["CommentID"]>b["CommentID"]?1:-1;});				
				
				var sb = new StringBuffer();
				var RecordCount = 0;
				if(json.length > 0){
					RecordCount = json[0].RecordCount;
				}
				if(RecordCount > 5){
					$("#Pager").pagination(RecordCount, {
						num_edge_entries: 2,
						num_display_entries: 5,
						items_per_page:5,
						current_page:pageIndex-1,
						prev_text:"<",
						next_text:">",
						callback: pageselectCallback
					});

					function pageselectCallback(page_id, jq)
					{
						deal.getComment(pid,page_id+1);
						//PageSelect(page_id+1,pid);
					}
					
				}else{
					$("#Pager").empty();	
					deal.options.currentCommentPageIndex = 1;
				}		

				for(var i=0;i<json.length;i++){					
					var currObj = json[i];
					var recommentList = currObj.ReCommentInfo;
					var headimg = deal.options.filePath+(currObj.BlogHead == ''?"/Images/blog/peason_pic_none.gif":currObj.BlogHead);
					
					sb.append("<li>");
					sb.append(" <div class=\"zpplleft\"><a href=\"/blog/index.aspx?uid="+currObj.UserID+"\"><img src=\""+headimg+"\"  width=\"43\" height=\"43\"/></a></div>");
					sb.append(" <div class=\"zpplright\">");
					sb.append(" <p><a href=\"/blog/index.aspx?uid="+currObj.UserID+"\">"+currObj.CommentUserName+"</a>"+currObj.CommentContent.replace(/\n|\r/img,"<br/>")+"</p>");
					sb.append(" <b>"+currObj.CommentDate+"<a href=\"javascript:;\" onclick=\"photo.showReComment("+currObj.CommentID+");\">回复</a>");
					if(deal.options.isM){
						sb.append("<a href=\"javascript:;\" onclick=\"photo.deleteComment("+currObj.CommentID+","+deal.options.photoID+");\">删除</a>")
					}
					sb.append("</b>")
					sb.append(" <div class=\"zpplhuifu\">");
					sb.append(" <ol>");
					recommentList.sort(function(a,b){return a["ReCommentID"]>b["ReCommentID"]?1:-1;});
					for(var j=0;j<recommentList.length;j++){
						var reObj = recommentList[j];
						var reHeadimg = deal.options.filePath+(reObj.BlogHead == ''?"/Images/blog/peason_pic_none.gif":reObj.BlogHead);
						sb.append("     <li>");
						sb.append("         <div class=\"zpplhfleft\"><a href=\"/blog/index.aspx?uid="+reObj.UserID+"\"><img src=\""+reHeadimg+"\" width=\"36\" height=\"36\" /></a></div>");
						sb.append("         <div class=\"zpplhfright\">");
						sb.append("         <p><a href=\"/blog/index.aspx?uid="+reObj.UserID+"\">"+reObj.ReUserName+"</a>"+reObj.ReCommentContent.replace(/\n|\r/img,"<br/>")+"</p>");
						sb.append("         <b>"+reObj.ReCommentDate);
						if(deal.options.isM){
							sb.append("<a href=\"javascript:;\" onclick=\"photo.deleteReComment("+reObj.ReCommentID+");\">删除</a>")
						}
						sb.append("			</b>")
						sb.append("         </div>");
						sb.append("         <div class=\"space\"></div>");
						sb.append("     </li>");
					}
					
					sb.append("<li class=\"hideRecommentText\" id=\"reComment_"+currObj.CommentID+"\">");
					sb.append("  <div><strong>回复：</strong></div>");
					sb.append("  <div class=\"zpplhfleft\"><a href=\"#\"><img /></a></div>");
					sb.append("  <div class=\"zpplhfright\">");
					sb.append("      <textarea name=\"textarea\" id=\"txtReComment_"+currObj.CommentID+"\"  onkeydown=\"photo.setMaxLength(this,300);\" onkeyup=\"photo.setMaxLength(this,300);\"></textarea>");
					sb.append("      <a class=\"anniu2\" href=\"javascript:;\" onclick=\"photo.reComment("+currObj.CommentID+",this);\">回复</a>");
					sb.append("      <a class=\"anniu2\" href=\"javascript:;\" onclick=\"$('#reComment_"+currObj.CommentID+"').hide();\">取消</a>");
					sb.append("  </div>");
					sb.append("  <div class=\"space\"></div>");
					
					sb.append(" </ol>");
					sb.append(" </div>");
					sb.append(" </div>");
					sb.append(" <div class=\"space\"></div>");
					sb.append("</li>");
				
				}
				$(".zpplneirdiv").html("<strong>照片评论</strong>(共"+RecordCount+"条)")
				$("#commentList").html(sb.toString());
			
				$("#commentList li[id^='reComment_'] img").attr("src",$("#headImg").attr("src"));
				
			}
		);    
	},
	deleteReComment : function(recid){
		if(window.confirm("确定要删除该评论？删除后将无法恢复。"))
		{
			var deal = this;
			$.get(
				"ajax.ashx",
				{"opta":"deleteReComment","ReCommentID":recid},
				function(data){					
					deal.getComment(deal.options.photoID,deal.options.currentCommentPageIndex);
				}
			);
		}
	},
	showReComment : function(cid){
		$(".hideRecommentText,.showRecommentText").hide();
		$("#reComment_"+cid).show();
	},
	reComment : function(cid,o){
		var deal = this;
		var uid = new Cookie().get('UserID') || 0;   
		if(uid == 0){			
			deal.showLogin(o);
			return false;
		}else{
			deal.options.SelfUid = uid;						
		}
		var txtReComment = $.trim($("#txtReComment_"+cid).val());
		if(txtReComment == ''){
			alert("回复内容不能为空");
			return;
		}	
		
		$.ajax({
		   type: "POST",
		   url: "ajax.ashx?opta=submitReComment&cid="+cid+"&uid="+deal.options.SelfUid,
		   data: txtReComment,
		   success: function(msg){
			 if(msg == 'ok'){
				deal.getComment(deal.options.photoID,deal.options.currentCommentPageIndex);
				$("#txtReComment_"+cid).empty();
			 }
		   }
		}); 
	},
	submitComment : function(o){
		var deal = this;
		var uid = new Cookie().get('UserID') || 0;   
		if(uid == 0){			
			deal.showLogin(o);
			return false;
		}else{
			deal.options.SelfUid = uid;
		}
		var pid = deal.options.photoID;
		var txtComment = $.trim($("#txtComment").val());
		if(txtComment == ''){
			alert("输入内容不能为空");
			return;
		}
		
		$.ajax({
		   type: "POST",
		   url: "ajax.ashx?opta=submitComment&pid="+pid+"&uid="+deal.options.SelfUid,
		   data: txtComment,
		   success: function(msg){
			 if(msg == 'ok'){
				deal.getComment(pid,deal.options.currentCommentPageIndex);
				$("#txtComment").empty();
			 }
		   }
		}); 
		
	},
	showMoveList : function(o){
		if($.trim($(".ydxz").html()) == ''){
			alert("你还没有其它相册。");
			return false;
		}
		$(o).toggleClass("a_click");
		$(".ydxz").toggle();
	},
	getOtherAlbumName : function(aid){
		var deal = this;
		$.getJSON("ajax.ashx",
			{
				"opta":"getOtherAlbumName", 
				"uid":deal.options.userID,
				"albumID":aid,
				"rnd":Math.random()
			
			},function(json){
				var sb = new StringBuffer();
				for(var i=0;i<json.length;i++){
					var me = json[i];
					sb.append("<li><a href=\"javascript:;\" onclick=\"photo.move(this,"+me.AlbumID+");\">"+me.Title+"</a></li>");
				}
				$(".ydxz").html(sb.toString()).hide();
			}
		);
	},
	referrer : function(){
		this.getTopNewComment(this.options.userID);
	},
	formatFloat : function(src, pos){
		return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);
	},
	setMaxLength : function(o,maxLength){
				
		var thisO = $(o);
		
		if($.trim(thisO.val()).length > maxLength){			
			thisO.val(thisO.val().substring(0,maxLength));
		}
		
		
	},
	modifyAlbumInfo : function(type){
		if(type == 'title'){
			$("#pTitle").hide();
			$("#albumTitle").show();
			$("#txtTitle").val($("#title").text());
		}else{
			$("#pDesc").hide();
			$("#albumDesc").show();
			$("#txtDesc").val($("#desc").text());
		}
	},
	cancel : function(type){
		if(type == 'title'){
			$("#title").html($("#txtTitle").val());
			$("#pTitle").show();
			$("#albumTitle").hide();	            
		}else{
			$("#desc").html($("#txtDesc").val());
			$("#pDesc").show();
			$("#albumDesc").hide();
		}
	},
	updateAlbumInfo : function(type){
		var deal = this;
		var aid = 0;
		var title = '';
		var desc = '';
		if(type == 'title'){
			title = $.trim($("#txtTitle").val());
			desc = $.trim($("#desc").text());	
			aid = $("#title").attr("aid");
			if(title == ''){
				alert("名称不能为空，请输入名称");	   	                            
				return;
			}
		}else{
			title = $.trim($("#title").text());
			desc = $.trim($("#txtDesc").val());	            
			aid = $("#desc").attr("aid");
		}
		
		 $.ajax(
			{
				type: "POST",
				url: "ajax.ashx",			
				data: {"opta":"amendAlbum","uid":deal.options.SelfUid,"albumID":aid,"title":title,"desc":desc},			
				success: function(msg){
					deal.cancel(type);
				}

			}
		);
		
	},
	showLogin : function(o){
		JAlert(o,{					
			title : '用户登录',
			content : "#Login",
			GetType : 'controls',		//controls,ajax,string,iframe					
			IsDrag : true,
			Url : "",
			Data : null,
			host:this.options.filePath,
			skin:this.options.skin,
			width:380,
			height:250

		});
	},
	CheckForm : function(o)
	{
		var deal = this;
		if($.trim($("#txtUserName").val()) == "" || $.trim($("#txtPass").val()) == "")
		{
			alert("请输入用户名和密码");
			return;
		}
		
		var pars = "opta=login&uName="+$.trim($("#txtUserName").val())+"&uPass="+$.trim($("#txtPass").val())+"&rnd="+Math.random();
		
		$.ajax({
		   type: "POST",
		   url: "/Ajax/AjaxPage.aspx",
		   data: pars,
		   success: function(request){				
				if(request == "ok")
				{
					alert("登录成功");					
					$("#windowClose").click();	
					var uid = new Cookie().get('UserID') || 0;
					if(uid == deal.options.userID){
						deal.options.isM = true;
					}
					else{
						deal.options.isM = false;						
					}
				}
				else
				{
					alert("用户名或者密码错误");
				}
		   }

		 });
	}
}

