var pastNoticeCounter = 0;

var notovernotice = 0;

var randomPicCount = 1;

var mainmenu = 'mainmenutdmain';

var oldmenu = 'submain';

var slidingmenu = '';

var slidingmenucount = 3;

var firstimgcount = 1;

var preloadimgcount = 0;

function popupNews() {
	popup = null;
//	popup = window.open('popUpNews.html', 'News','width=800, height=400, left=50, top=50, status=0, resizable=1, scrollbars=1, toolbar=0, menubar=0, directories=0');
	if (popup!=null) popup.focus();
}

function pastnotice() {
	if (document.all.pastnotice.style.display=="block")
		document.all.pastnotice.style.display="none";
	else
		document.all.pastnotice.style.display="block";
}

function firstpage() {
	firsttd1.style.height = '150px';
	firsttd3.style.height = '0px';
	firsttd3.style.display = 'none';
	setTimeout('firstload()',1000);
}

function firstload() {
	firsttd1.style.height = parseInt(firsttd1.style.height) - 10 + 'px';
	firsttd3.style.height = parseInt(firsttd3.style.height) + 20 + 'px';
	firsttd3.style.display = 'block';
	setTimeout('firstreload()',1);
}

function firstreload() {
	preloadimgcount++;
	firsttd1.style.height = parseInt(firsttd1.style.height) - 10 + 'px';
	firsttd3.style.height = parseInt(firsttd3.style.height) + 20 + 'px';
	if (parseInt(firsttd1.style.height) > 0) setTimeout('firstreload()',1);
	else {
		firsttd1.style.display = 'none';
		firstcontainer.style.display = 'block';
		firsttitlelarge.filters[0].Apply();
		firsttitlelarge.style.display = 'block';
		firsttitlelarge.filters[0].Play();
		setTimeout('firsttextreload()',1000);
	}
}

function firsttextreload() {
	firsttitle.filters[0].Apply();
	firsttitlelarge.style.display = "none";
	firsttitlesmall.style.display = "block";
	firsttitle.filters[0].Play();
	
	setTimeout('firstimgreload()',1000);
	setTimeout('firstsetside()',2000);
	
}

function firstsetside() {
	firstsidebackl.style.visibility = "visible";
	firstsidebackr.style.visibility = "visible";
	setTimeout('firstsidescroll()',500);
}

function firstsidescroll() {
/*
	firstsidel.style.top = parseInt(firstsidel.style.top) - 1 + 'px';
	firstsider.style.top = parseInt(firstsider.style.top) + 1 + 'px';
	if (parseInt(firstsidel.style.top) < -235) {
		firstsidel.style.top = '0px';
		firstsider.style.top = '-235px';
	}
	setTimeout('firstsidescroll()',100);
*/
	firstsidel.style.top = parseInt(firstsidel.style.top) - 1 + 'px';
	firstsider.style.top = parseInt(firstsider.style.top) - 1 + 'px';
	if (parseInt(firstsidel.style.top) < -385) {
		firstsidel.style.top = '385px';
		firstsider.style.top = '385px';
	}
	setTimeout('firstsidescroll()',50);
}

function firstimgreload() {
	firstimgcontainer.filters[0].Apply();
	if (firstimgcount==1) {
		firstimg4.style.display = "none"; 
		firstimg1.style.display = "block";
	} else if (firstimgcount==2) {
		firstimg1.style.display = "none"; 
		firstimg2.style.display = "block";
	} else if (firstimgcount==3) {
		firstimg2.style.display = "none"; 
		firstimg3.style.display = "block";
	} else if (firstimgcount==4) {
		firstimg3.style.display = "none"; 
		firstimg4.style.display = "block";
	}
	firstimgcontainer.filters[0].Play();
	firstimgcount++;
	if (firstimgcount==5) firstimgcount = 1;
	setTimeout('firstimgreload()',5000);
}

function firstchange() {
	if (firstsidebackl.style.visibility=="visible") {
		firstsidebackl.style.visibility = "hidden";
		firstsidebackr.style.visibility = "hidden";
	} else {
		firstsidebackl.style.visibility = "visible";
		firstsidebackr.style.visibility = "visible";
	}
}

function firstchange2() {
	if (firstimg1.filters.item("DXImageTransform.Microsoft.Alpha").Opacity==55) {
		firstimg1.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
		firstimg2.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
		firstimg3.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
		firstimg4.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
		firstsidel.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
		firstsider.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
	} else {
		firstimg1.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 55;
		firstimg2.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 55;
		firstimg3.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 55;
		firstimg4.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 55;
		firstsidel.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 55;
		firstsider.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 55;
	}
}

function firstPlay(lay,time,type) {
	lay.filters[0].Apply();
	lay.style.visibility= type; 
	lay.filters[0].Play(duration=time);
}

function firstAll() {
	firstPlay(document.all.Layer3,1.5,'hidden');
	firstPlay(document.all.Layer4,1.5,'hidden');
	setTimeout('secondAll();',1300);
}

function secondAll() {
	firstPlay(document.all.tdtop,2,'hidden');
	firstPlay(document.all.tdbottom,2,'hidden');
	firstPlay(document.all.logoid,1,'visible');
}

function enter(link){
	location=link;
}

function setStatus(text){
	window.status=text;
}

function titlehiddenmenuout(id) {
	if (oldmenu!=id) {
		parent.mainFrame.document.all(oldmenu).filters.item("DXImageTransform.Microsoft.Fade").Apply();
		if (oldmenu=='subhomework')
			parent.mainFrame.document.all.hideLogin.filters.item("DXImageTransform.Microsoft.Fade").Apply();
	}
	parent.mainFrame.subeng.style.display = 'none';
	parent.mainFrame.submain.style.display = 'none';
	parent.mainFrame.subnews.style.display = 'none';
	parent.mainFrame.subbuddh.style.display = 'none';
	parent.mainFrame.subschool.style.display = 'none';
	parent.mainFrame.subschdevelop.style.display = 'none';
	parent.mainFrame.xengsubschool.style.display = 'none';
	parent.mainFrame.subactivity.style.display = 'none';
	parent.mainFrame.subtopic.style.display = 'none';
	parent.mainFrame.subteach.style.display = 'none';
	parent.mainFrame.subextra.style.display = 'none';
	parent.mainFrame.subpta.style.display = 'none';
	parent.mainFrame.subsub.style.display = 'none';
	parent.mainFrame.subinternal.style.display = 'none';
	parent.mainFrame.subpta.style.display = 'none';
	parent.mainFrame.subold.style.display = 'none';
	parent.mainFrame.sublink.style.display = 'none';
	parent.mainFrame.subhomework.style.display = 'none';
	parent.mainFrame.subsu.style.display = 'none';
	parent.mainFrame.subself.style.display = 'none';
	parent.mainFrame.subit.style.display = 'none';
	parent.mainFrame.subcontact.style.display = 'none';
	parent.mainFrame.subeng.style.top = '20px';
	parent.mainFrame.submain.style.top = '20px';
	parent.mainFrame.subnews.style.top = '20px';
	parent.mainFrame.subbuddh.style.top = '20px';
	parent.mainFrame.subschool.style.top = '20px';
	parent.mainFrame.subschdevelop.style.top = '20px';
	parent.mainFrame.xengsubschool.style.top = '20px';
	parent.mainFrame.subactivity.style.top = '20px';
	parent.mainFrame.subtopic.style.top = '20px';
	parent.mainFrame.subteach.style.top = '20px';
	parent.mainFrame.subextra.style.top = '20px';
	parent.mainFrame.subpta.style.top = '20px';
	parent.mainFrame.subold.style.top = '20px';
	parent.mainFrame.subsub.style.top = '20px';
	parent.mainFrame.subinternal.style.top = '20px';
	parent.mainFrame.subpta.style.top = '20px';
	parent.mainFrame.sublink.style.top = '20px';
	parent.mainFrame.subhomework.style.top = '20px';
	parent.mainFrame.subsu.style.top = '20px';
	parent.mainFrame.subself.style.top = '20px';
	parent.mainFrame.subit.style.top = '20px';
	parent.mainFrame.subcontact.style.top = '20px';
	if (oldmenu=='subhomework') {
		parent.mainFrame.document.all.hideLogin.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
		parent.mainFrame.document.all.hideLogin.style.zIndex = 251;
		parent.mainFrame.document.all.hideLogin.style.display = 'inline';
		parent.mainFrame.document.all.hideLogin.style.top = '0px';
	}
	parent.mainFrame.document.all(oldmenu).filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 100;
	parent.mainFrame.document.all(oldmenu).style.zIndex = 251;
	parent.mainFrame.document.all(oldmenu).style.display = 'inline';
	parent.mainFrame.document.all(oldmenu).style.top = '0px';
	if (oldmenu!=id) {
		parent.mainFrame.document.all(oldmenu).filters.item("DXImageTransform.Microsoft.Fade").Play();
		if (oldmenu=='subhomework')
			parent.mainFrame.document.all.hideLogin.filters.item("DXImageTransform.Microsoft.Fade").Play();
	}
}

function titlehiddenmenuover(id) {
	if (oldmenu!=id) {
		slidingmenu = id;
		parent.mainFrame.document.all(oldmenu).filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 0;
		parent.mainFrame.document.all(slidingmenu).filters.item("DXImageTransform.Microsoft.Alpha").Opacity = 45;
		parent.mainFrame.document.all(slidingmenu).style.top = '20px';
		parent.mainFrame.document.all(slidingmenu).style.zIndex = 252;
		parent.mainFrame.document.all(slidingmenu).style.display = 'block';
		submenuslidup();
	}
}

function submenuslidup() {
	parent.mainFrame.document.all(slidingmenu).style.top = parseInt(parent.mainFrame.document.all(slidingmenu).style.top) - slidingmenucount + 'px';
	if (parseInt(parent.mainFrame.document.all(slidingmenu).style.top) > 0) setTimeout('submenuslidup()',20);
	else parent.mainFrame.document.all(slidingmenu).style.top = '0px';
}

function titlehiddenmenuclick(id) {
	oldmenu = id;
	titlehiddenmenuout(id);
}

function tdover(id) {
	if (mainmenu!=id) {
		parent.leftFrame.document.all(id).style.border = '1px solid #c0c0c0';
		parent.leftFrame.document.all(id).style.background = '#e8e8e8';
	}
	parent.mainFrame.document.all.hideLogin.style.display='none';
}

function tdout(id) {
	if (mainmenu!=id) {
		parent.leftFrame.document.all(id).style.border = '1px solid #e0e0e0';
		parent.leftFrame.document.all(id).style.background = '#f8f8f8';
	}
}

function tdclick(id,sub,loc) {
//	if (mainmenu != id) {
		parent.leftFrame.document.all(mainmenu).style.border = '1px solid #e0e0e0';
		parent.leftFrame.document.all(mainmenu).style.background = '#f8f8f8';
		parent.leftFrame.document.all(id).style.border = '1px solid #c0c0c0';
		parent.leftFrame.document.all(id).style.background = '#d8d8d8';
		mainmenu = id;
		parent.mainFrame.document.all.hideLogin.style.display='none';
		if (loc!='none') {
			titlehiddenmenuclick(sub);
			if (sub=='subhomework') 
				if (parent.contentFrame.framemainleft!=null) 
					parent.contentFrame.framemainleft.location = loc;
				else 
					parent.contentFrame.location = 'framemain.html';
			else 
				parent.contentFrame.location = loc;
		}
//	}
}

function randomPic() {
	document.all.randomPicLay.filters[0].Apply();	
	document.all('Layer1').style.display = 'none';
	document.all('Layer2').style.display = 'none';
	document.all('Layer3').style.display = 'none';
	document.all('Layer4').style.display = 'none';
	document.all('Layer'+randomPicCount).style.display = 'block';
	document.all.randomPicLay.filters[0].Play();	
	randomPicCount++;
	if (randomPicCount==5) randomPicCount = 1;
	setTimeout('randomPic()',5000);
}

function scrollingnotice() {
	notovernotice++;
	if (notovernotice==1) {
		rowing.style.top = parseInt(rowing.style.top) - 1 + 'px';
		if (parseInt(rowing.style.top) + rowingtable.clientHeight <= 0) rowing.style.top = '140px';
		setTimeout('scrollingnotice()',50);
		notovernotice--;
	}
}

function timeDifferent(t1,t2) {
	t1 = t1.split('-');
	t1yy = t1[0];
	t1mm = t1[1];
	t1dd = t1[2];
	t2 = t2.split('-');
	t2yy = t2[0];
	t2mm = t2[1];
	t2dd = t2[2];
	d1 = new Date();
	d1.setYear(t1yy);
	d1.setMonth(t1mm-1);
	d1.setDate(t1dd);
	d2 = new Date();
	d2.setYear(t2yy);
	d2.setMonth(t2mm-1);
	d2.setDate(t2dd);
	diff = d1.getTime() - d2.getTime();
	diff = diff/1000/60/60/24;
//	window.alert(diff);
	return diff;
}

function isDate(d) {
	d = d.split('-');
	if (isNaN(d[0])) return false;
	if (isNaN(d[1])) return false;
	if (isNaN(d[2])) return false;
	dyy = parseInt(d[0]);
	dmm = parseInt(d[1]);
	ddd = parseInt(d[2]);
	if ((dmm<1)||(dmm>12)) return false;
	if ((dmm==4)||(dmm==6)||(dmm==9)||(dmm==11)) numOfDay = 30;
	else if (dmm!=2) numOfDay = 31;
	else {
		if ((dyy%4==0)&&((dyy%400==0)||(dyy%100!=0))) noOfDay = 29;
		else noOfDay = 28;
	}
	if ((ddd<1)||(ddd>noOfDay)) return false;
	return true;
}

function check_new(diff,d) {
	yyyy = d.substring(0,4);
	mm = d.substring(5,6);
	tmp_mm = d.substring(6,7);
	if (tmp_mm=='月') {
		dd = d.substring(7,8);
		tmp_dd = d.substring(8,9);
	} else {
		mm += tmp_mm;
		dd = d.substring(8,9);
		tmp_dd = d.substring(9,10);
	}
	if (tmp_dd!='日') dd += tmp_dd;
	aMonthBefore = new Date();
	aMonthBefore.setDate(aMonthBefore.getDate()-diff);
	mm = parseInt(mm)-1;
	thatDate = new Date(yyyy,mm,dd);
	if (thatDate>aMonthBefore) document.write('<img src="img/new1.gif" />');
}

function pastNotice_setSeperator() {
	pastNoticeCounter++;
	if (pastNoticeCounter==4) document.write(
		'<tr style="display:block"> <a name="gopastnotice"> </a>'+
			'<td colspan="2" align="left" valign="top" nowrap class="noticedate"><a href="#gopastnotice" class="noticetext" onClick="pastnotice();">&lt;以往告示&gt; </a> </td>'+
		'</tr>'+
	'</table>'+
	'<table id="pastnotice" width="100%" border="0" cellpadding="0" cellspacing="5">'+
		'<tr>'+
			'<td colspan="2"><hr width="95%" /></td>'+
		'</tr>'
	);
}

function new_image(o) {
	if (typeof(o.nodeName)=="undefined") obj = o[o.length-1];
	else obj = o;

	check_new(14,obj.parentNode.parentNode.firstChild.innerHTML);
}

function isInside(ip) {
	var ipAdd = ip.split('.');
	return ((ipAdd[0]=='127')&&(ipAdd[1]=='0')&&(ipAdd[2]=='0')&&(ipAdd[3]=='1'))||((ipAdd[0]=='218')&&(ipAdd[1]=='189')&&(ipAdd[2]=='203')&&(ipAdd[3]=='32'))||((ipAdd[0]=='218')&&(ipAdd[1]=='189')&&(ipAdd[2]=='203')&&(ipAdd[3]=='25'))||((ipAdd[0]=='10')&&(ipAdd[1]=='131'))	
}


