﻿// JScript 文件

//检查登录用户类型
function CheckUserType()
{
    if (document.getElementById("radioComm").checked==false)
    {
        document.getElementById("dvOrg").style.display="none";
    }
    else
    {
        document.getElementById("dvOrg").style.display="";
    }
}

//折叠二级菜单 duanshaolin by 2007-08-28
function ExpendSub(obj)
{
    var objSub=document.getElementById(obj);
    if (objSub.style.display=="none")
    {
        objSub.style.display="";
    }
    else
    {
        objSub.style.display="none";
    }
}

//检查是否是正确的日期格式  duanshaolin by 2007-09-19
function CheckDate(datestr)
{
	var lthdatestr
	if (datestr != "")
		lthdatestr= datestr.length ;
	else
		lthdatestr=0;
	  
	var tmpy="";
	var tmpm="";
	var tmpd="";
	//var datestr;
	var status;
	status=0;
	if ( lthdatestr== 0)
	return false;


	for (i=0;i<lthdatestr;i++)
	{ 
		if (datestr.charAt(i)== '-')
		{
			status++;
		}
		if (status>2)
		{
			//alert("Invalid format of date!");
			return false;
		}
		if ((status==0) && (datestr.charAt(i)!='-'))
		{
			tmpy=tmpy+datestr.charAt(i)
		}
		if ((status==1) && (datestr.charAt(i)!='-'))
		{
			tmpm=tmpm+datestr.charAt(i)
		}
		if ((status==2) && (datestr.charAt(i)!='-'))
		{
			tmpd=tmpd+datestr.charAt(i)
		}
	}
	year=new String (tmpy);
	month=new String (tmpm);
	day=new String (tmpd)
	//tempdate= new String (year+month+day);
	//alert(tempdate);
	if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
	{
		//alert("Invalid format of date!");
		return false;
	}
	if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
	{
		//alert ("Invalid month or day!");
		return false;
	}
	if (!((year % 4)==0) && (month==2) && (day==29))
	{
		//alert ("This is not a leap year!");
		return false;
	}
	if ((month<=7) && ((month % 2)==0) && (day>=31))
	{
		//alert ("This month is a small month!");
		return false;
	}
	if ((month>=8) && ((month % 2)==1) && (day>=31))
	{
		//alert ("This month is a small month!");
		return false;
	}
	if ((month==2) && (day==30))
	{
		//alert("The Febryary never has this day!");
		return false;
	}
	return true;
}

//比较日期大小  date1如果大于date2，返回true  duanshaolin by 2007-09-19
function CompareDate(date1,date2)//日期比较
{
	if (new Date(date1.replace("-",",")) > new Date(date2.replace("-",",")))
		return true;
	return false;
}


String.prototype.trim = function()
{
    return this.replace(/^\s+/,"").replace(/\s+$/,"");
}

