// ******************对话框******************
var B_Action_Code=null;
//------设置对话框结构------
function Get_Box_Parth(Ac){
	if(Ac==null){Ac=0;}
	var Parth_Code="";
	if(Ac==0){//背景层
		Parth_Code="<div id=\"Back_Alpha_Div\" style=\"position:absolute; width:100%; height:"+$(document).height()+"px; left:0px; top:0px; z-index:998; background:#FFF; filter:Alpha(opacity=50);opacity:0.5; -moz-opacity:0.5;\"></div>";
	}else if(Ac==1){//对话框
		Parth_Code+="<div id=\"Box_Div\" style=\"position:absolute; border:8px solid #68CEFF; background:#FFF; z-index:999; display:none;\">";
		Parth_Code+="<div id=\"Box_Main\" style=\"padding:12px;\">";	
		Parth_Code+="</div></div>"	
	}else if(Ac==2){//会员登录头部
		Parth_Code+="<div style=\"clear:both; overflow:hidden;\">";
		Parth_Code+="<div style=\"float:left;\"><img src=\"/System/Images/Box/MemberLogin_Logi.gif\" width=\"143\" height=\"46\" alt=\"会员登录\"/></div>";
		Parth_Code+="<div style=\"float:right;\"><a href=\"/Register/\" target=\"_blank\" style=\"font-size:12px; color:#999;\">[会员注册]</a>&nbsp;&nbsp;<img src=\"/System/Images/Box/CloseB.jpg\" width=\"26\" height=\"15\" alt=\"关闭\" align=\"absmiddle\" style=\"cursor:pointer;\" onclick=\"CloseMsgBox();\" /></div></div>";
		Parth_Code+="<div style=\"clear:both; padding-top:12px;\"></div>";
	}else if(Ac==3){//内容框
		Parth_Code+="<div style=\"padding:0px 10px;\">";
		Parth_Code+="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		Parth_Code+="<tr><td align=\"left\" width=\"90\" valign=\"middle\"><img id=\"Box_Icon\" src=\"\"></td>";
		Parth_Code+="<td id=\"Box_Content\" align=\"left\" valign=\"middle\" style=\"line-height:22px; color:#666; font-size:14px;\"></td></tr>";
		Parth_Code+="</table></div>";
	}else if(Ac==4){//确定按钮
		Parth_Code+="<div style=\"padding-top:10px; text-align:center;\">";
		Parth_Code+="<label><input type=\"button\" name=\"button2\" id=\"Box_button\" value=\" 确 定 \" style=\"cursor:pointer ;width:81px; height:30px; border:none; cursor:pointer; background:url(/System/Images/Box/Button1.gif) top center no-repeat; color:#666;\" onclick=\"Box_Box_ShowCode();\" /></label></div>";
	}else if(Ac==5){//Loading
		Parth_Code+="<div style=\"text-align:center; padding:10px 0px 8px 10px;\"><img src=\"/System/Images/Box/Loading2.gif\" width=\"220\" height=\"33\" /></div>";
		Parth_Code+="<div id=\"Box_Content\" style=\"text-align:center; color:#666; font-size:14px;\"></div>";
	}else if(Ac==6){//会员登录输入框、按钮
		Parth_Code+="<div id=\"MemberLoginInputBox\" style=\"clear:both; overflow:hidden; padding-top:4px;\">";
		Parth_Code+="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";
		Parth_Code+="<tr><td align=\"right\" width=\"130\" style=\"font-size:14px;\">手机号：</td>";
		Parth_Code+="<td><input name=\"Box_UserNameInput\" type=\"text\" id=\"Box_UserNameInput\" style=\"width:180px; height:20px; font-size:14px;\" maxlength=\"50\" /></td>";
		Parth_Code+="</tr><tr>";
		Parth_Code+="<td align=\"right\" style=\"font-size:14px;\">密码：</td>";
		Parth_Code+="<td><input name=\"Box_UserPwdInput\" type=\"password\" id=\"Box_UserPwdInput\" style=\"width:180px; height:20px; font-size:14px;\" maxlength=\"50\" /></td>";
		Parth_Code+="</tr><tr>";
		Parth_Code+="<td align=\"right\" style=\"font-size:14px;\">验证码：</td>";
		Parth_Code+="<td><input name=\"Box_CodeInput\" type=\"text\" id=\"Box_CodeInput\" style=\"width:40px; height:20px; font-size:14px;\" maxlength=\"4\"  onkeydown=\"if(event.keyCode==13){Box_LoginButton();}\" />";
		Parth_Code+="&nbsp;<img id=\"Box_CodeShow\" src=\"/System/Images/loading.gif\" align=\"absmiddle\" onClick=\"Box_ShowCode();\" style=\"cursor:pointer;\" title=\"点击刷新验证码\" /></td></tr><tr>";
		Parth_Code+="<td align=\"right\">&nbsp;</td>";
		Parth_Code+="<td><input type=\"button\" name=\"Box_LoginSubmit\" id=\"Box_LoginSubmit\" value=\"会员登录\" style=\"width:90px; height:32px; cursor:pointer;\" onclick=\"Box_LoginButton();\" /></td>";
		Parth_Code+="</tr></table></div>";
	}	
	return Parth_Code;
}

//------打开对话框-----(对话框样式,宽,高,提示信息样式,按确定后执行)
function OpenMsgBox(BoxStyle,W,H,Content,MsgStyle,DoAction){
	CloseMsgBox();
	//初始化参数
	if(BoxStyle==null){BoxStyle=1;}
	if(W==null){W=400;}
	if(H==null){H=120;}
	if(MsgStyle==null){MsgStyle=1;}
	if(DoAction==null || DoAction==""){DoAction="CloseMsgBox();";}
	B_Action_Code=DoAction;
	//设置坐标
	L=Box_Get_WindowPx("L")/2-W/2;
	T=Box_Get_WindowPx("T")-H/2;
	//载入部件
	$(document.body).append(Get_Box_Parth(0));
	$(document.body).append(Get_Box_Parth(1));
	if(BoxStyle==1){//*******提示框********
		$("#Box_Main").append(Get_Box_Parth(3));
		$("#Box_Main").append(Get_Box_Parth(4));
		$("#Box_Icon").attr("src","/System/Images/Box/Box_Icon"+MsgStyle+".gif"); 
	}else if(BoxStyle==2){//*******Loading框********
		$("#Box_Main").append(Get_Box_Parth(5));
	}
	//设置部件
	$("#Box_Div").css({width:W+"px", height:H+"px", left:L+"px", top:T+"px"});	
	$("#Box_Content").append(Content); 
	//显示对话框
	$("#Box_Div").fadeIn("fast");
}

//------打开会员登录对话框-----(验证程序地址,参数,登陆后跳转到地址)
function OpenMemberLoginBox(ActionPage,sUrlPM,sReUrl){
	CloseMsgBox();
	//初始化参数
	W=450; H=240;
	ActionPageAddress=ActionPage; UrlPM=sUrlPM; 
	if(sReUrl!=null){ReUrl=sReUrl;}
	//设置坐标
	L=Box_Get_WindowPx("L")/2-W/2;
	T=Box_Get_WindowPx("T")-H/2;
	//载入部件
	$(document.body).append(Get_Box_Parth(0));
	$(document.body).append(Get_Box_Parth(1));
	$("#Box_Main").append(Get_Box_Parth(2));
	$("#Box_Main").append(Get_Box_Parth(6));
	//设置部件
	$("#Box_Div").css({width:W+"px", height:H+"px", left:L+"px", top:T+"px"});	
	//显示对话框
	$("#Box_Div").fadeIn("fast");
	//获取验证码
	Box_ShowCode();
}

//------关闭对话框-----
function CloseMsgBox(){
	$("#Back_Alpha_Div").remove();
	$("#Box_Div").remove();
}

//------获取屏幕大小-----
function Box_Get_WindowPx(Parth){
	var PxNum=null;
	if(Parth=="L"){
		PxNum=$(document.body).width();
	}else if(Parth=="T"){
		Scroll_T=$(window).scrollTop();
		if(window.screen.availHeight > document.body.offsetHeight){HH=document.body.offsetHeight;}else{HH=window.screen.availHeight-120;}
		Screen_H=HH;		
		PxNum=Screen_H/2+Scroll_T;
	}
	return PxNum;
}

//------执行按钮----
function Box_Box_ShowCode(){
	CloseMsgBox();
	if(B_Action_Code!=null){eval(B_Action_Code);}
}

//------获取验证码----
function Box_ShowCode(){document.getElementById("Box_CodeShow").src="/System/Inc/GetCode.asp?"+Math.random();$("#Code").blur();}

//------执行登录按钮----
var ActionPageAddress=""; var UrlPM=""; var ReUrl="/Member/";
function Box_LoginButton(){
	if($.trim($("#Box_UserNameInput").val())==""){
		alert("请输入手机号！");$("#Box_UserNameInput").focus();
	}else if($.trim($("#Box_UserPwdInput").val())==""){
		alert("请输入密码！");$("#Box_UserPwdInput").focus();
	}else if($.trim($("#Box_CodeInput").val())=="" || $.trim($("#Box_CodeInput").val()).length<4){
		alert("请输入四位数字的验证码！");$("#Box_CodeInput").focus();
	}else{
		//显示Loding
		$("#MemberLoginInputBox").hide();
		$("#Box_Main").append(Get_Box_Parth(5));
		$("#Box_Content").append("会员登录中，请稍后..."); 
		//提交信息
		$.ajax({type: "POST", url: ActionPageAddress, 
		   data: UrlPM+"&ReUrl="+ReUrl+"&UserName="+$.trim($("#Box_UserNameInput").val())+"&UserPwd="+$.trim($("#Box_UserPwdInput").val())+"&Code="+$.trim($("#Box_CodeInput").val()), 
		   dataType: "script",
		   success:function(data){data;}
		});
	}
}
