function dingsubmitsave(submiturl,fromurl,logintype) {	
		 //判断邮箱
         var email_test = /^[\w-\.]+@[\w\.-]*\.[A-Za-z0-9]+$/i;
         var email = $("input[name='s_email']").val();
        if (email.length < 1) {
			alert("请输入您的邮箱！");
			return false;
		}
        if (!email_test.test(email))
		{
			alert("邮箱地址格式错误，请重新输入!");
			return false;}
        if (logintype == 0) {
          //  $("#submit").attr("disabled", true);
			
        }	
		
		//表单组合字符串，如下格式
		/*
		 username: $("input[name='username']").val(), 
		 userpass: $("input[name='userpass']").val(),
         class_depths:$("input[name='class_depths']").val(),
         area_depths:$("input[name='area_depths']").val(),*/
        var evaltxt = "";
        $(".email_subscription input").each(function (i) {    
			if (this.name!= undefined && this.name!=null && this.name!=''){
			  if (evaltxt!="")
				  evaltxt += "," + this.name + ":escape($(\"input[name='" + this.name + "']\").val())";
			  else
				  evaltxt += this.name + ":escape($(\"input[name='" + this.name + "']\").val())";
			}
        });
      evaltxt = "{" + evaltxt + "}";
	  
         //开始提交
         evaltxt = "$.post(submiturl," + evaltxt + ",function(userdata){dingproreg(userdata,fromurl,logintype);},\"text\");";
         //开始处理js;
         eval(evaltxt);
		
}

 /*返回提交成功函数*/
function dingproreg(userdata, fromurl, logintype) {
            //函数开始			
            switch (userdata) {
                case "success":
                    //提交成功
                    alert("订阅成功!");
                   // $("#sucmsg")[0].innerHTML = "您的作品已成功提交！"; 	
                    //window.location.href = fromurl;
                    //return;
                    break;
                case "format error":
                    alert("邮箱地址格式错误，请重新输入！");
                    break;
                case "empty email":
                    alert("邮件不能为空！");
                    break;
				case "have save":
				    alert("对不起，此邮件已订阅！");
                    break;
					
            }
            //if (logintype == 0)
                //$("#submit").attr("disabled", false);
 }
 
function downfile() {
                   alert('本期暂未提供下载文件！');
    }
function isParenttop(obj, pobj) {
   while (obj && obj.tagName.toUpperCase() != 'BODY') {
	   if (obj == pobj)
		   return true;
	   obj = obj.parentNode;
   }
   return false;
}

var isout = false;
$(document).ready(function () {
                   $("#dinghref").click(function () {
                       // $("#liuyan").css("display","block");
                       $("#email_subscription").slideDown();
                       isout = false;
                   });

                   $("#email_subscription").bind("mouseout", function (e) {
                       var flag = true;
                       if (isie)
                           flag = isParenttop(event.toElement, $(this)[0]);
                       else
                           flag = isParenttop(e.relatedTarget, $(this)[0]);
                       if (!flag) {
                           isout = true;
                       }
                   });
                   $("#email_subscription").bind("mouseover", function (e) {
                       var flag = true;
                       if (isie)
                           flag = isParenttop(event.toElement, $(this)[0]);
                       else
                           flag = isParenttop(e.relatedTarget, $(this)[0]);
                       if (flag) {
                           isout = false;
                       }
                   });
                   // $("div:not(#email_subscription)").click(function (e) {});
                   $(document).click(function (e) {
                       var flag = true;
                       if (isie)
                           flag = isParenttop(event.toElement, $("#email_subscription")[0]);
                       else
                           flag = isParenttop(e.relatedTarget, $("#email_subscription")[0]);
                       if (flag) {
                           isout = false;
                       }
                       if (isout) { $("#email_subscription").slideUp(); };
                   });

                   $("#dingsubmit").click(function () {
                       var dingsubmiturl=webd+"dingyue/dingyuesave";
                       var dingfromurl = fromurl;  
                       dingsubmitsave(dingsubmiturl,dingfromurl, 0);            
                  });
});