var timerID = null
var timerRunning = false

function FindObj(n, d)
{ //v3.0
	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=FindObj(n,d.layers[i].document);
	return x;
}

function Display()
{ //v3.0
	var i,p,v,obj,args=Display.arguments;
	for (i=2; i<(args.length-2); i+=3)
	{
		if ((obj=FindObj(args[i]))!=null)
		{
			v=args[i+2];
			if (obj.style)
			{
				obj=obj.style;
				v=(v=='show')?'visible':(v='hide')?'hidden':v;
			}
			obj.visibility=v;

			if ((args[0]!="-1")&&(obj.visibility=="visible"))
			{
				if (document.body.offsetWidth>=800)
				{
					obj.left=args[0]-args[1]+(document.body.offsetWidth-760)/2-20;
				}
				else
				{
					obj.left=args[0]-args[1];
				}
			}
		}
	}
}

function locurl(msg_str,url_str)
{
	if (confirm(msg_str))
	{
		window.location=url_str;
	}
}

function checkDate(the_field,msg_str)
{
	if (the_field.value != "")
        {
		var vDate,vYear,vMonth,vDay,vDateLong,vMonth_Day,vMonth_DayLong,vD;
		vDate = the_field.value;
		vYear = vDate.substring(0,4);
		vDateLong = vDate.length;
		vMonth_Day = vDate.substring(5,vDateLong);
		vMonth_DayLong = vMonth_Day.length;
		vD=new Date();
		
		if ((vDate.substring(4,5) !== "-") || (vMonth_Day.indexOf("-") ==-1))
		{
			window.alert(msg_str+"格式输入有误，请以YYYY-MM-DD格式输入ww！");
			the_field.focus();
			return false;
		}
		            
		if (isNaN(vYear) || vYear < 1949 || vYear > vD.getFullYear())
		{
			window.alert(msg_str+"年份值输入有误！应大于1949年且不超过"+vD.getFullYear()+"年!");
			the_field.focus();
			return false;
		}
		
		var vMonth_DayPosition;
		vMonth_DayPosition = vMonth_Day.indexOf("-");            
		vMonth = vMonth_Day.substring(0,vMonth_DayPosition);
		vDay = vMonth_Day.substring((vMonth_DayPosition+1),(vMonth_DayLong+1));
		
		if (isNaN(vMonth) || vMonth < 01 || vMonth > 12)
		{
			window.alert(msg_str+"月份输入有误！");
			the_field.focus();
			return false;
		}
		                       
		if (vMonth == 01 || vMonth == 03 || vMonth == 05 || vMonth == 07|| vMonth == 08 || vMonth == 10 || vMonth == 12)
		{
			if (isNaN(vDay)||vDay > 31)
			{
				window.alert(msg_str+"天数输入有误！大月不超过31天");
				return false;
			}
		}
		
		if (vMonth == 04 || vMonth == 06 || vMonth == 09 || vMonth == 11)
		{
			if (isNaN(vDay)||vDay > 30)
			{
				window.alert(msg_str+"天数输入有误！小月不足31天");
				return false;
			}
		}
		
		if (vMonth == 02)
		{
			if (vYear % 4 == 0 && vYear % 100 || vYear % 400 == 0)
			{
				if (isNaN(vDay)||vDay > 29)
				{
					window.alert(msg_str+"天数输入有误！闰年二月29天");
					the_field.focus();
					return false;
				}
			}
			else
			{
				if (isNaN(vDay)||vDay > 28)
				{
					window.alert(msg_str+"天数输入有误！平年二月28天");
					the_field.focus();
					return false;
				}
			}
		}                        
		return true;
	}
	else
	{
		window.alert("该字段不能为空");
		the_field.focus();
		return false;
	}
}

var htm;
function openwin(htm)
{
	myWin=open(htm, "NewWindow","top=50,left=150,width=576,height=430,toolbar=no,menubar=no,scrollbars=yes,resizable=yes")
}

function view3(Url)
{
	popup1=window.open(Url,"Displaywindow3","left=300,top=200,width=680,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, resizable=no");
}

function view_800_200(Url)
{
   popup1=window.open(Url,"Displaywindow1","left=200,top=200,width=730,height=120,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=no");
}

function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		e.checked="yes"; 
	}
}

function unCheck(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if (e.checked==false)
		{
			e.checked=true; 
		}
		else
		{
			e.checked=false;
		}
	}
}

function startclock()
{
	stopclock();
	showtime();
}

function stopclock()
{
	if(timerRunning)
	{
		clearTimeout(timerID);
		timerRunning = false;
	}
}


function showtime()
{
	var now = new Date();
	now.setTime(now.getTime()+timediff);
	var year = now.getYear();
	var month = now.getMonth() + 1;
	var date = now.getDate();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	var day = now.getDay();
	Day = new MakeArray(7);
	Day[0]="星期天";
	Day[1]="星期一";
	Day[2]="星期二";
	Day[3]="星期三";
	Day[4]="星期四";
	Day[5]="星期五";
	Day[6]="星期六";
	var timeValue = "";
	timeValue += year + "年";
	timeValue += ((month < 10) ? "0" : "") + month + "月";
	timeValue += date + "日  ";
	timeValue += (Day[day]) + "  ";
	timeValue += ((hours <= 12) ? hours : hours - 12);
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
	timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
	timeValue += (hours < 12) ? "上午" : "下午";
	if (document.all.clock)
	{
		clock.innerHTML=timeValue;
	}
	timerID = setTimeout("showtime()",1000);
	timerRunning = true;
}

function MakeArray(size) 
{
	this.length = size;
	for(var i = 1; i <= size; i++)
	{
		this[i] = "";
	}
	return this;
}

function op_confirm(str_confirm)
{
  	if (window.confirm(str_confirm))
  	{
    		return true; 
     	}
     	else
     	{
     		return false;
     	}
}
  