function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function checkConsultationSubmit(){
  if(document.frmConsultation.name.value==""){
		alert("对不起，请输入姓名");
		document.frmConsultation.name.focus();
		return false;
  }else if(document.frmConsultation.org_id.value=="-1"){
  		alert("对不起，请选择部门");
		return false;
  }else if(document.frmConsultation.title.value==""){
  		alert("对不起，请输入主题");
		document.frmConsultation.title.focus();
		return false;
  }else if(document.frmConsultation.content.value==""){
  		alert("对不起，请输入内容");
		document.frmConsultation.content.focus();
		return false;
  }
	return true;
}

function checkConsultationRevertSubmit(){
  if(document.frmConsultationRevert.content.value==""){
  		alert("对不起，请输入内容");
		ddocument.frmConsultationRevert.content.focus();
		return false;
  }
	return true;
}		
	
var newWindow = null
function windowOpener(loadpos)
{       
        if (! newWindow || newWindow.closed)
        {
        newWindow = window.open(loadpos,"vote","resizable, dependent, width=440, height=280");
        }else
        {
                newWindow.focus();
        }
}

function REGISTER(loadpos)
{       
        if (! newWindow || newWindow.closed)
        {
        newWindow = window.open(loadpos,"REGISTER","resizable, dependent, width=640, height=480");
        }else
        {
                newWindow.focus();
        }
}

function skipUrl(newurl)
{
	if( newurl != '#')
	{
		window.open(newurl,'_blank')
	}
}

function getToday()
{
  cal1 = new Date();
  day = cal1.getDay();
  month = cal1.getMonth();
  date = cal1.getDate();
  year = cal1.getYear();
  if (year< 100) year = 1900 + year;
    cent = parseInt(year/100);
  g = year % 19;
  k = parseInt((cent - 17)/25);
  i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
  i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
  j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
  l = i - j;
  emonth = 3 + parseInt((l + 40)/44);
  edate = l + 28 - 31*parseInt((emonth/4));
  emonth--;
  var dayname = new Array ("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
  var monthname = 
  new Array ("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月" );
  
  var reDate = year+"年"+monthname[month] + date + "日 " + dayname[day];
  
  return reDate;
}

function checkId(puserId, birthDay, gender)
{
    if (puserId.length!=15 && puserId.length!=18)
    {
      return false;
    } else if(puserId.length==15)
	  {
	    if ( puserId.substring(6,8) != birthDay.substring(2,4) || puserId.substring(8,10) != birthDay.substring(5,7) || puserId.substring(10,12) != birthDay.substring(8,10) )
      {
		    return false;
      }
      if ( puserId.substring(14,15)%2 ==1 )
      {
        if (gender!="1" && gender != "男")
          return false;
      } else {
        if (gender!="0" && gender != "女")
          return false;        
      }
      
	  } else if(puserId.length==18) 
	  {
	    if ( puserId.substring(6,10) != birthDay.substring(0,4) || puserId.substring(10,12) != birthDay.substring(5,7) || puserId.substring(12,14) != birthDay.substring(8,10) )
      {
		    return false;
      }	    	  
      if ( puserId.substring(16,17)%2 ==1 )
      {
        if (gender!="1" && gender != "男")
          return false;
      } else {
        if (gender!="0" && gender != "女")
          return false;        
      }
	  } 
    return true;
}
function getYear(year)
{
	if(year>=1900)
		return year;
	else
		return 1900+year;
}

function getSpace0(nn)
{
	if(nn>=10)
		return nn;
	else
		return "0"+nn;
}

function getDate(dtis)
{
	if(dtis==0 || dtis==undefined)
		return "";
   d = new Date(dtis);
   return getYear(d.getYear())+"-"+getSpace0(d.getMonth()+1)+"-"+getSpace0(d.getDate());
}

function getTime(dtis)
{
	if(dtis==0 || dtis==undefined)
		return "";
   d = new Date(dtis);
   return getSpace0(d.getHours())+":"+getSpace0(d.getMinutes())+":"+getSpace0(d.getSeconds());
}

function getDatetime(dtis)
{
	if(dtis==0 || dtis==undefined)
		return "";
	return getDate(dtis)+" "+getTime(dtis);
}

function writeDate(dtis)
{
	return document.writeln(getDate(dtis));
}

function writeTime(dtis)
{
	return document.write(getTime(dtis));
}

function writeDatetime(dtis)
{
	return this.document.writeln(getDatetime(dtis));
}