function popnewsubject(mid)
{
   var subdiv=document.getElementById('newsubject_'+mid);
   var detaildiv=document.getElementById('detailsub_'+mid);
   var s_url=document.getElementById('s_url_'+mid);
   subdiv.style.display="block";
   detaildiv.style.display="none";
   s_url.value=location.href;
}
function popnewdetail(mid,subid,subtitileid,subtitle){
  var detaildiv=document.getElementById('detailsub_'+mid);
  var subdiv=document.getElementById('newsubject_'+mid);
  var subtitlespan=document.getElementById(subtitileid);
  var d_url=document.getElementById('d_url_'+mid);
  var d_subid=document.getElementById('d_subid_'+mid);
  detaildiv.style.display="block";
  subdiv.style.display="none";
  subtitlespan.innerHTML=subtitle;
  d_subid.value=subid;
  d_url.value=location.href;
  if(document.height<500){
   document.height='500px';
  }
}

  function module_mm_change(objid){
    var obj=document.getElementById(objid);
    if(obj!=undefined){
      if(obj.style.display=='' || obj.style.display=='block'){
        module_hide(objid);
      }else{
        module_show(objid);
      }
    }else{
      alert('Faint!');
    }
  }
  function module_show(objid){
    document.getElementById(objid).style.display='block';
  }
  function module_hide(objid){
    document.getElementById(objid).style.display='none';
  }

function trim(str)
{
     if(str == null) return "" ;
     while( str.charAt(0) == ' ' )
     {
        str = str.substring(1,str.length);
     }
     while( str.charAt(str.length-1) == ' ' )
     {
       str = str.substring(0,str.length-1);
    }
   return str ;
}

 function checktitle(mid){
                  var pat3=/^[a-zA-Z]+$/g;
                    var pat4=/[\b\u4e00-\u9fa5]/;
                    var title=document.getElementById('title_'+mid);
                    var titlediv=document.getElementById('titlediv_'+mid);
                  if((this.trim(title.value))==""){
                    titlediv.innerHTML="<font color='red'>标题不能为空</font>（2-200）字节，中文或英文！";
                    return 0;
                  }else if(!(this.trim(title.value)).match(pat3) && !(this.trim(title.value)).match(pat4)){
                  titlediv.innerHTML="<font color='red'>标题格式错误</font>（2-200）字节，中文或英文！";
                  return 0;

                  }else{
                  titlediv.innerHTML="（2-10）字节，中文或英文！";
                  return 1;
                  }
}
function checkcontent(mid){
  var content=document.getElementById('content_'+mid);
  var contentdiv=document.getElementById('contentdiv_'+mid);
  if((this.trim(content.value))==""){
   contentdiv.innerHTML="<font color='red'>网站内容不能为空</font>（不大于200字）为了方便阅读，请简概括主要内容！";
   return 0;
  }else if((this.trim(content.value)).length>200){
   contentdiv.innerHTML="<font color='red'>长度不能大于200</font>（不大于200字）为了方便阅读，请简概括主要内容！";
   return 0;
  }else{
  contentdiv.innerHTML="（不大于200字）为了方便阅读，请简概括主要内容！";
  return 1;
  }
}
function checkemail(mid){
           var emailPat=/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
           var linkemail=document.getElementById('linkemail_'+mid);
           var emaildiv=document.getElementById('emaildiv_'+mid);
          if((this.trim(linkemail.value))==""){
            emaildiv.innerHTML="<font color='red'>电子邮件为必填</font>例如(spring@126.com)";
            return 0;
          }else if (!linkemail.value.match(emailPat)){
            emaildiv.innerHTML="<font color='red'>电子邮件格式错误</font>例如(spring@126.com)";
            return 0;
          }else{
            emaildiv.innerHTML="例如(spring@126.com)";
            return 1;
          }
}

function formsubmit(mid){
	var form=document.getElementById('newsadd_'+mid);
  if(document.getElementById('d_childuserid_'+mid).value!=0){
    form.submit();
    return;
  }
  if(this.checktitle(mid)==1 && this.checkemail(mid)==1){
    form.submit();
    return;
  }
}
function d_checkcontent(mid){
	var d_content=document.getElementById('d_content_'+mid);
	var d_contentdiv=document.getElementById('d_contentdiv_'+mid);
  if((this.trim(d_content.value))==""){
    d_contentdiv.innerHTML="<font color='red'>网站内容不能为空</font>（不大于200字）为了方便阅读，请简概括主要内容！";
    return 0;
  }else if((this.trim(d_content.value)).length>200){
    d_contentdiv.innerHTML="<font color='red'>长度不能大于200</font>（不大于200字）为了方便阅读，请简概括主要内容！";
    return 0;
  }else{
  d_contentdiv.innerHTML="（不大于200字）为了方便阅读，请简概括主要内容！";
  return 1;
  }
 }
function d_checkemail(mid){
   var emailPat=/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
   var d_linkemail=document.getElementById('d_linkemail_'+mid);
   var d_emaildiv=document.getElementById('d_emaildiv_'+mid);
  if((this.trim(d_linkemail.value))==""){
    d_emaildiv.innerHTML="<font color='red'>电子邮件为必填</font>例如(spring@126.com)";
    return 0;
  }else if (!d_linkemail.value.match(emailPat)){
    d_emaildiv.innerHTML="<font color='red'>电子邮件格式错误</font>例如(spring@126.com)";
    return 0;
  }else{
    d_emaildiv.innerHTML="例如(spring@126.com)";
    return 1;
  }
}
function d_formsubmit(mid){
  var form=document.getElementById('newdetailform_'+mid);
  if(document.getElementById('d_childuserid_'+mid).value!=0){
    form.submit();
    return;
  }
  if(this.d_checkcontent(mid)==1&&this.d_checkemail(mid)==1){
    form.submit();
    return;
  }
}
function searchmtype(key,type,url,width,height){
	var keyvalue=document.getElementById(''+key);
	var typevalue=document.getElementById(''+type);
	url=url+"&keyword="+keyvalue.value+"&mtypeid="+typevalue.value;
	alert(url);
	window.open(url,'_blank','width='+width+',height='+height);
}