//----------------------------------------------------------------------------
// Common code to include in the title of each web page is listed below.
//----------------------------------------------------------------------------

//  The function below prevents other websites from framing St. Thomas's website //

function page_setup()
{
  if (window !=top) top.location.href = location.href;
}  

//  The function below sets up the current date and time for display //
function get_date()
{
  dayName = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
  monName = new Array ("Jan", "Feb", "March", "April", "May", "June", "July", "August", "Sept", "Oct", "Nov", "Dec")
  now = new Date
  function message(text)
  {
    window.status = text;
  }
  document.write("Today is " + dayName[now.getDay()] +"<br />" +monName[now.getMonth()] +" " +now.getDate() +", " +now.getFullYear() +" ")
}

function make_text_a_title(txt)
{
    document.write("<div id=\"toptitle\"><span id=\"toptext\">")
    document.write(txt)
    document.write("</span><span id=\"topshadow\">")
    document.write(txt)
    document.write("</span></div>")
}
 

//  The function below loads the object mainhead which is the very top portion of each web page //
function load_topofpage()
{
  document.write ("<div id=\"mainhead\">")
  document.write ("<a href=\"index.aspx\"><img src=\"images/stvlogonewred.gif\" alt=\"St. Thomas of Villanova School Logo\" /></a>")
  document.write ("<img src=\"images/stvcathschool.gif\" alt=\"Catholic Early Childhood & Elementary School\" id=\"maincathschool\" />")
  document.write ("<img src=\"images/stvdomainnamearch.gif\" alt=\"stvschool.org\" id=\"stvdomainarch\" />")
  document.write ("<img src=\"images/stvviking.gif\" alt=\"school mascot the vikings\" id=\"stvviking\" />")
  document.write ("</div>")
  document.write ("<div class=\"hr\" style=\"color: black; background-color: black;\"><hr /></div>")
  document.write ("<div class=\"hr\" style=\"color: white; background-color: white;\"><hr /></div>")
  document.write ("<div class=\"hr\" style=\"color: black; background-color: black;\"><hr /></div>")
  document.write ("<div class=\"hr\"><hr /></div>") 
  document.write ("<table>")
  document.write ("<tr id=\"crumbs-top\">")
  document.write ("<td id=\"crumbs\"><a href=\"STVMain.aspx\">Home</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"pdfforms\\brochure1219.pdf\" target=\"_blank\">Brochure</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"stvshoppgm.htm\">Dollar Shopping</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"stvhomework.htm\">Class Assignments</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"stvlunchsched.aspx\">Hot Lunch</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"stvnewsltr.aspx\">Newsletters</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"assign/manage_homework.htm\">Faculty/Staff</a>&nbsp;&nbsp;</td>") 
  document.write ("</tr>")
  document.write ("</table>")
}

function load_topofpage_from_subfolder()
{
  document.write ("<div id=\"mainhead\">")
  document.write ("<a href=\"..\\index.aspx\"><img src=\"../images/stvlogonewred.gif\" alt=\"St. Thomas of Villanova School Logo\" /></a>")
  document.write ("<img src=\"..\\images/stvcathschool.gif\" alt=\"Catholic Early Childhood & Elementary School\" id=\"maincathschool\" />")
  document.write ("<img src=\"..\\images/stvdomainnamearch.gif\" alt=\"stvschool.org\" id=\"stvdomainarch\" />")
  document.write ("<img src=\"..\\images/stvviking.gif\" alt=\"school mascot the vikings\" id=\"stvviking\" />")
  document.write ("</div>")
  document.write ("<div class=\"hr\" style=\"color: black; background-color: black;\"><hr /></div>")
  document.write ("<div class=\"hr\" style=\"color: white; background-color: white;\"><hr /></div>")
  document.write ("<div class=\"hr\" style=\"color: black; background-color: black;\"><hr /></div>")
  document.write ("<div class=\"hr\"><hr /></div>") 
  document.write ("<table>")
  document.write ("<tr id=\"crumbs-top\">")
  document.write ("<td id=\"crumbs\"><a href=\"..\\index.aspx\">Home</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"..\\pdfforms\\brochure1219.pdf\" target=\"_blank\">Brochure</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"..\\stvshoppgm.htm\">Dollar Shopping</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"..\\stvhomework.htm\">Class Assignments</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"..\\stvlunchsched.aspx\">Hot Lunch</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"..\\stvnewsltr.aspx\">Newsletters</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"..\\assign/manage_homework.htm\">Faculty/Staff</a>&nbsp;&nbsp;</td>") 
  document.write ("</tr>")
  document.write ("</table>")
}


function load_navigation( )
{
  document.write ("<tr>")
  document.write ("<td>")
  document.write ("<div id=\"nav\">")
  document.write ("<ul class=\"level1\">") 
  document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">About Us</a>")
  document.write ("<ul class=\"level2\">")  
  document.write ("<li><a href=\"pdfforms\\brochure1219.pdf\" target=\"_blank\">Brochure</a></li>")
  document.write ("<li><a href=\"stvphilosophy.htm\">Our Philosophy</a></li>")
  document.write ("<li><a href=\"stvprofile.htm\">Our School Profile</a></li>")
  document.write ("<li><a href=\"stvachievements.htm\">Achievements</a></li>") 
  document.write ("<li><a href=\"stvoffers.htm\">What We Offer</a></li>")
  document.write ("</ul>")
  document.write ("</li>")
  document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">General Information</a>")
  document.write ("<ul class=\"level2\">")
  document.write ("<li><a href=\"pdfforms\\brochure1219.pdf\" target=\"_blank\">Brochure</a></li>")
  document.write ("<li><a href=\"stvadmissions.htm\">Admissions / Enrollment</a></li>")
  document.write ("<li><a href=\"stvclasstimes.htm\">Daily Class Times</a></li>")
  document.write ("<li><a href=\"stvdirections.htm\">Directions / Map</a></li>")
  document.write ("<li><a href=\"stvdirectory.htm\">School Directory</a></li>")
  document.write ("<li><a href=\"stvtestpgm.htm\">Testing Program</a></li>")
  document.write ("<li><a href=\"stvtextbooks.htm\">Textbook List</a></li>")  
  document.write ("<li><a href=\"stvtuition.htm\">Tuition</a></li>")
  document.write ("<li><a href=\"stvuniform.htm\">Uniform Regulations</a></li>")
  document.write ("</ul>")
  document.write ("</li>")  
  document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">Activites & Events</a>")
  document.write ("<ul class=\"level2\">")
  document.write ("<li><a href=\"index.aspx\">Announcements</a></li>")
  document.write ("<li><a href=\"stvathletics.htm\">Athletics</a></li>")
  //document.write ("<li><a href=\"ShowEvents.aspx\" target=\"_blank\">Athletic Calendar(NewPage)</a></li>")
  //document.write ("<li><a href=\"ShowEvents.aspx\">Athletic Calendar</a></li>")
  document.write ("<li><a href=\"stvcalendar.aspx\">Calendar</a></li>")
  document.write ("<li><a href=\"stvlunchsched.aspx\">Lunch Schedule</a></li>")
  document.write ("<li><a href=\"stvnewsltr.aspx\">Newsletters</a></li>")    
  document.write ("</ul>")
  document.write ("</li>") 
  document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">Programs/Services</a>")
  document.write ("<ul class=\"level2\">")
  document.write ("<li class=\"submenu\"><a href=\"stvbasiccurr.htm\">Academics</a>")
  document.write ("<ul class=\"level3\">")
  document.write ("<li><a href=\"stvbasiccurr.htm\">Basic Curriculum</a></li>")
  document.write ("<li><a href=\"stvcompcurr.htm\">Computer Curriculum</a></li>")
  document.write ("<li><a href=\"stvreligion.htm\">Religion</a></li>")
  document.write ("<li><a href=\"stvspecpgm.htm\">Special Programs</a></li>")
  document.write ("</ul>")
  document.write ("</li>")
  document.write ("<li class=\"submenu\"><a href=\"stvearlychild.htm\">Early Childhood</a>")
  document.write ("<ul class=\"level3\">")
  document.write ("<li><a href=\"stvearlychild.htm\">Overview</a></li>")
  document.write ("<li><a href=\"stvearlychild.htm#threeyears\">3-year old</a></li>")  
  document.write ("<li><a href=\"stvearlychild.htm#fouryears\">4-year old</a></li>")
  document.write ("<li><a href=\"stvearlychild.htm#kinder\">Kindergarten</a></li>") 
  document.write ("</ul>")
  document.write ("</li>")
  document.write ("<li><a href=\"stvextdaycare.htm\">Extended Daycare</a></li>")
  document.write ("<li><a href=\"stvendowfund.htm\">Endowment Fund</a></li>")
  document.write ("</ul>")
  document.write ("</li>")  
  document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">Organizations</a>")
  document.write ("<ul class=\"level2\">")
  document.write ("<li><a href=\"stvfsa.htm\">Family School Assoc.</a></li>")
  document.write ("<li><a href=\"stvschoolboard.htm\">School Board</a></li>") 
  document.write ("</ul>")
  document.write ("</li>")
  document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">Major Fundraisers</a>")
  document.write ("<ul class=\"level2\">")
  document.write ("<li><a href=\"stvlabelcoll.htm\">Label Collection</a></li>")
  document.write ("<li><a href=\"stvlottery.htm\">Lottery</a></li>")
  document.write ("<li><a href=\"stvmarketday.htm\">Market Day</a></li>") 
  document.write ("<li><a href=\"stvshoppgm.htm\">Shopping Program</a></li>")
  document.write ("<li><a href=\"stvtrackathon.htm\">Track-a-thon</a></li>")
  document.write ("</ul>")
  document.write ("</li>")

  //document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">Viking Alumni</a>") //

/*  document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">Volunteering</a>") //
  document.write ("<ul class=\"level2\">") //
  document.write ("<li><a href=\"stvalumni.htm\">Information</a></li>") //
  document.write ("<li><a href=\"stvfacstaff.htm\">Volunteer Sign Up</a></li>") //
  document.write ("</ul>") //
  document.write ("</li>") //  
*/

//  document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">School Resources</a>") //
//  document.write ("<ul class=\"level2\">") //
//  document.write ("<li><a href=\"stvalumni.htm\">Alumni</a></li>") //
//  document.write ("<li><a href=\"stvfacstaff.htm\">Faculty / Staff</a></li>") //
//  document.write ("<li><a href=\"stvstudents.htm\">Students</a></li>")  //
//  document.write ("</ul>") //
//  document.write ("</li>") //  
//  document.write ("<li><a href=\"stvforms.htm\">Forms & Documents</a></li>") //

  //document.write ("<li class=\"submenu\"><a href=\"#\"  onClick=\"refresh();return false\">Testing123</a>") //
  //document.write ("<ul class=\"level2\">") //
  //document.write ("<li><a href=\"Test\\NewFIle1.aspx\">Alumni</a></li>") //
  //document.write ("</ul>") //
  //document.write ("</li>") //  

  //document.write ("<li><a href=\"STVPicGalleryMockup.aspx\">Viking Picture Gallery</a></li>")
  document.write ("<li><a href=\"stvlinks.htm\">Related Links</a></li>")
  document.write ("<li><a href=\"stvsitemap.htm\">Site Map</a></li>")
  document.write ("<li><a href=\"#\" onClick=\"popup('www.stov.org', 'Win1' , 550, 350);return false\">St. Thomas Parish</a></li>")
  document.write ("</ul>")
  document.write ("</div>")
  document.write ("</td>")
  document.write ("</tr>") 
}

function load_footer( )
{
  document.write ("<td id=\"footer\">&copy; Copyright 2004-2009, St. Thomas of Villanova School, All Rights Reserved.</td>")
}

function popup(url, name, width, height)
{
settings=
"toolbar=yes,location=yes,directories=yes,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+width+",height="+height;

MyNewWindow=window.open("http://"+url,name,settings);
}


function popitup(url)
{
	newwindow=window.open(url,'name','height=640,width=700,left=80,top=35,toolbar=yes,menubar=yes,scrollbars=yes,location=yes,resizable=yes,directories=yes,status=yes');
	if (window.focus) {newwindow.focus()}
	return false;
} 

function openpopup(popurl){
	if (null == popurl) {
			return;
		}
	
	window.open(popurl, "_blank");
}


function button_handler()
{
  alert("Note:  The faculty/staff login section is still under construction.")
}  
function formReset()
{
var x=document.forms.teacherForm
x.reset()
}
function refresh()
{
window.location.reload()
}


// ***********************************************************
//
// JAVA SCript code needed for the Dynamic content Rotation
//
//*************************************************************


	// tab script
	function tabPanel() {
	
		this.defaults = {
			
			id: null,
			active: 1,
			interval: null,
			wait: null,
			persist: null,
			tabclass: 'vtab',
			activeclass: 'active',
			callback: null,
			leavecallback: null
		
		};
		
		this.activebackup = null;
		
		for (var n in arguments[0]) { this.defaults[n]=arguments[0][n]; };	
		
		this.getTabs = function() {
				
			var retnode = [];
			var elem = document.getElementById(this.defaults.id).getElementsByTagName('*');
			
			var regexp = new RegExp("(^|\\s)" + this.defaults.tabclass.replace(/\-/g, "\\-") + "(\\s|$)");
		
			for (var i = 0; i < elem.length; i++) {
				if (regexp.test(elem[i].className)) retnode.push(elem[i]);
			}		
		
			return retnode;
		
		};
		
		this.links = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('a');
		this.listitems = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('li');
		
		this.show = function(number) {
			
			for (var i = 0; i < this.tabs.length; i++) {
				
				this.tabs[i].style.display = ((i+1)==number) ? 'block' : 'none';
					
				if ((i+1)==number) {
					this.addClass(this.links[i], this.defaults.activeclass);
					this.addClass(this.listitems[i], this.defaults.activeclass);
				} else {
					this.removeClass(this.links[i], this.defaults.activeclass);
					this.removeClass(this.listitems[i], this.defaults.activeclass);
				}
			
			}
			
			
			if (this.defaults.leavecallback && (number != this.activebackup)) this.defaults.leavecallback(this.defaults.active);
			
			this.activebackup = number;
			
			
			this.defaults.active = number;
			
			if (this.defaults.callback) this.defaults.callback(number);
			
		
		};
		
		
		//tab rotate script
		this.rotate = function(interval) {
		
			this.show(this.defaults.active);
			this.defaults.active++;
		
			if (this.defaults.active > this.tabs.length) this.defaults.active = 1;
		
		
			var self = this;
			
			if (this.defaults.wait) clearTimeout(this.timer2);
			 
			this.timer1 = setTimeout(function(){self.rotate(interval);}, interval*1000);
		
		};
		
		this.next = function() {
			
			this.defaults.active++;
			if(this.defaults.active > this.tabs.length) this.defaults.active = 1;
			this.show(this.defaults.active);
		
		};
		
		this.previous = function() {
			
			this.defaults.active--;
			if(!this.defaults.active) this.defaults.active = this.tabs.length;
			this.show(this.defaults.active);
		
		};
		
		this.gup = function(name) {
			name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regexS = "[\\?&]"+name+"=([^&#]*)";
			var regex = new RegExp( regexS );
			var results = regex.exec( window.location.href );
			if (results == null) return null;
			else return results[1];
		};
		
		this.parseurl = function(tabinterfaceid) {
			
			var result = this.gup(tabinterfaceid);
			
			if (result==null) return null;
			if (parseInt(result)) return parseInt(result); 
			if (document.getElementById(result)) {	
				for (var i=0;i<this.tabs.length;i++) {
					if (this.tabs[i].id == result) return (i+1);
				}
			}
			
			return null;
			
		};
	
		this.createCookie = function(name,value,days) {
			if (days) 
			{
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				expires = "; expires="+date.toGMTString();
			}
			else expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		};
		
		this.readCookie = function(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		};
		
		this.contains = function(el, item, from) {
			return el.indexOf(item, from) != -1;
		};
		
		this.hasClass = function(el, className){
			return this.contains(el.className, className, ' ');
		};
		
		this.addClass = function(el, className){
			if (!this.hasClass(el, className)) el.className = (el.className + ' ' + className).replace(/\s{2,}/g, ' ').replace(/^\s+|\s+$/g, '');
		};
		
		this.removeClass = function(el, className){
			el.className = el.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
			el.className.replace(/\s{2,}/g, ' ').replace(/^\s+|\s+$/g, '');
		};
	
	
		this.tabs = this.getTabs();
		this.defaults.active = (this.parseurl(this.defaults.id)) ? this.parseurl(this.defaults.id) : this.defaults.active;
		if (this.defaults.persist && this.readCookie(this.defaults.id)) this.defaults.active = this.readCookie(this.defaults.id);  
		this.activebackup = this.defaults.active;
		this.show(this.defaults.active);
		
		var self = this;
		for (var i = 0; i < this.links.length; i++) {
		this.links[i].customindex = i+1;
		this.links[i].onclick = function(){ 
			
			if (self.timer1) clearTimeout(self.timer1);
			if (self.timer2) clearTimeout(self.timer2); 
			
			self.show(this.customindex);
			if (self.defaults.persist) self.createCookie(self.defaults.id, this.customindex, 0);
			
			if (self.defaults.wait) self.timer2 = setTimeout(function(){self.rotate(self.defaults.interval);}, self.defaults.wait*1000);
			
			return false;
		};
		}
		
		if (this.defaults.interval) this.rotate(this.defaults.interval);
		
	};
	
