//-------------CALENDAR FUNCTIONS

var dayWinState=0;
var monthStatic=1;
var dayStatic=1;

function selMonth(id){
	if (monthStatic==0 || dayStatic==0) return;
	if (id==lastCal) return;
	monthStatic=0;
	if (dayWinState!=0) closeDay(dayWinState);
	document.getElementById('tabs').style.top=21-(id*21)+'px';
	document.getElementById(lastCal).style.zIndex=1;
	document.getElementById(lastCal).style.position='absolute';
	document.getElementById(lastCal).style.left='1px';
	document.getElementById(id).style.zIndex=2;
	document.getElementById(id).style.position='relative';
	clearInterval(clock);
	if (id > lastCal) setTimeout('curtain('+id+')',1);
	if (id < lastCal) {
		document.getElementById(id).style.left='560px'
		setTimeout('curtainRight('+id+')',1);
	}
}
function curtain(id2){
	var fix=(id2==1&&parseInt(document.getElementById('1').style.left)==-19)?-1:0
	document.getElementById(id2).style.left=(parseInt(document.getElementById(id2).style.left)+20)+'px';
	if (parseInt(document.getElementById(id2).style.left)<0) {
		setTimeout('curtain('+id2+')',1);
	} else {
		monthStatic=1;
		document.getElementById(lastCal).style.left='-580px';
		lastCal=id2;
		if (document.getElementById && dayStatic) clock=setInterval('updateTime()',document.all?1:1000);
	}
}
function curtainRight(id3){
	var fix=(id3==1&&parseInt(document.getElementById('1').style.left)==21)?-1:0
	document.getElementById(id3).style.left=(parseInt(document.getElementById(id3).style.left)-20)+'px';
	if (parseInt(document.getElementById(id3).style.left)>1) {
		setTimeout('curtainRight('+id3+')',1);
	} else {
		monthStatic=1;
		document.getElementById(lastCal).style.left='-580px';
		lastCal=id3;
		if (document.getElementById && dayStatic) clock=setInterval('updateTime()',document.all?1:1000);
	}
}
function selDay(win){
	dayStatic=0;
	if (dayWinState!=0) closeDay(dayWinState);
	clearInterval(clock);
	if (win!=dayWinState) setTimeout('raiseDay('+win+')',1);
}
function raiseDay(win){
	document.getElementById(win).style.top=(parseInt(document.getElementById(win).style.top)-20)+'px';
	if (parseInt(document.getElementById(win).style.top)>-340) {
		setTimeout('raiseDay('+win+')',1);
	} else {
		dayStatic=1;
		if (document.getElementById && monthStatic) clock=setInterval('updateTime()',document.all?1:1000);
		document.getElementById(win+'A').style.overflow='auto';
		dayWinState=win;
	}
}
function closeDay(win){
	dayStatic=0;
	clearInterval(clock);
	document.getElementById(win+'A').style.overflow='hidden';
	setTimeout('lowerDay('+win+')',1);
}
function lowerDay(win){
	document.getElementById(win).style.top=(parseInt(document.getElementById(win).style.top)+20)+'px';
	if (parseInt(document.getElementById(win).style.top)<0) {
		setTimeout('lowerDay('+win+')',1);
	} else {
		dayStatic=1;
		if (document.getElementById && monthStatic) clock=setInterval('updateTime()',document.all?1:1000);
		dayWinState=0;
	}
}

//--------------------STUDENTS IN ACTION IMAGE ROTATOR SCRIPT ----------------------

var imgOpac=99; imgIdx=0; numPics=4; frmNum=4;

function startCycle(){
	setInterval('cycle()',3000)
//	preLoad();
 }
 
function cycle(){
	imgIdx=(imgIdx<numPics)?imgIdx+1:1;
	timr3=setInterval('imgFadeDown('+ imgIdx +','+ ((imgIdx<numPics)?imgIdx+1:1)+')',5);
}

function imgFadeDown(prev,next){
	if (imgOpac==99){
		prevImg=eval('document.images.img' + frmNum + prev).style;
		nextImg=eval('document.images.img' + frmNum + next).style;
		nextImg.visibility='visible';
	}
	if (imgOpac>0){
		imgOpac-=33;
		imgOpacOther=imgOpac/100;
		prevImg.filter='alpha(opacity='+imgOpac+')';
		nextImg.filter='alpha(opacity='+(99-imgOpac)+')';
		prevImg.MozOpacity=imgOpacOther;
		nextImg.MozOpacity=(.99-imgOpacOther);
		prevImg.opacity=imgOpacOther;
		nextImg.opacity=(.99-imgOpacOther);
		prevImg.KhtmlOpacity=imgOpacOther;
		nextImg.KhtmlOpacity=(.99-imgOpacOther);
	} else {
		prevImg.visibility='hidden';
		imgOpac=99;
		if (frmNum==1){
			frmNum=4;
			clearInterval(timr3);
			return;
		}
		frmNum-=1;
	  	
	}
}

	var prevScroll=0;
	
	function closeVid(){
		document.getElementById('vidHolder').style.display='none';
		document.getElementById('screen').style.display='none';
		document.getElementById('videoFile').src='';
		document.documentElement.style.overflow='auto';
		if (window.pageYOffset) window.scrollBy(0,prevScroll);
	}
	
	function showVid(str){
		if (window.pageYOffset) prevScroll=window.pageYOffset;

		document.documentElement.style.overflow='hidden';

		var w=document.documentElement.clientWidth;
		var h=document.documentElement.clientHeight;

		with (document.getElementById('vidHolder').style){
			display='block';
			position= 'absolute';
			zIndex=101;
			top=(window.pageYOffset ? (window.pageYOffset) : document.documentElement.scrollTop)+(h-400)/2+'px';
			left='0px';;
			width = w + 'px';
		}
		
		with (document.getElementById('screen').style){
			top=(window.pageYOffset ? (window.pageYOffset) : (document.documentElement.scrollTop!=0?document.documentElement.scrollTop:document.body.scrollTop))+'px'
			left='0px';
			width=w+50+'px';
			height=h+10+'px';;
			backgroundColor='black';
			filter='alpha(opacity=80)';
			opacity='0.80';
			display='block';
			zIndex=100;
		}
		document.getElementById('videoFile').src=str;
	}


/*-------------------------------HANDBOOK SCRIPT -------------------*/

function setupHandbook(){

	var lis=document.getElementsByTagName('li');
	for (i=0;i<lis.length;i++){
		if (lis[i].parentNode.className=='handbook' || lis[i].parentNode.id=='dresscode'){
			lis[i].onclick=function(ev){
				if (document.all) {
					window.event.cancelBubble=true;
				} else {
					ev.stopPropagation();
				}
				showSub(this)
			};
		} else {
			lis[i].onclick=function(ev){
				if (document.all) {
					window.event.cancelBubble=true;
				} else {
					ev.stopPropagation();
				}
			};
		}
	}
}

function showSub(obj){
	var subs=obj.getElementsByTagName('ul');
	for (i=0;i<subs.length;i++){
		if (subs[i].parentNode==obj){
			if (subs[i].className!='open'){
				subs[i].className='open';
				subs[i].parentNode.style.listStyleImage='url(images/topic-contract.gif)';
			} else {
				subs[i].className='';
				subs[i].parentNode.style.listStyleImage='url(images/topic-expand.gif)';
			}
		}
	}
}
function expand(obj){
	obj.innerHTML=(obj.innerHTML=='[ Expand All ]'?'[ Collapse All ]':'[ Expand All ]');
	var uls=document.getElementsByTagName('ul');
	for (i=0;i<uls.length;i++){
		if (uls[i].className!='handbook') uls[i].className=(uls[i].className!='open'?'open':'');
	}
}



