/// start script added on june 20, 2008 
function openWin(theURL,winName,winFeatures)
{
  window.open(theURL,winName,winFeatures);
}  
function HideSection(hide)
{
	document.getElementById(hide).style.display = 'none';
}
function ShowSection(show, pagename)
{
	document.form1.pagename.value = pagename;
	document.getElementById(show).style.display = 'block';
	document.getElementById(show).style.visibility = 'visible';
}



function validateForm() {
with (document.form1) {
var alertMsg = "The following REQUIRED fields\nhave been left empty:\n";
if (SchoolName.options[SchoolName.selectedIndex].value == "") alertMsg += "\nYour Local School";
if (Zip.value.length != 5) alertMsg += "\nHome Zip Code";
radioOption = -1;
if (alertMsg != "The following REQUIRED fields\nhave been left empty:\n") {
alert(alertMsg);
return false;
} else {
return true;
} } }

function MM_reloadPage(init) 
{  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/// end script added on june 20, 2008 


// JavaScript for opening external links in XHTML document

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

// JavaScript for suckerfish drop-downs <http://www.htmldog.com/articles/suckerfish/>
sfHover = function() {
	var sfEls = document.getElementById("navMain").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

// The qtype function is called to display only questions of a given type.  The types are identified by color.
// This function steps through all of the questions (i.e. li tags) in the FAQIndex div, 
// and hides all of the tags that don't match the color.
// Some of the questions can have more than one color, so we have to use indexOf to match the color.
function qtype(q) {
  var items = document.getElementById("FAQIndex").getElementsByTagName('li')
  //var txt=+items.length+'\n'
  for (i=0; i<items.length;i++) {
    var itemclass = items[i].className
    //txt=txt+i+" "+itemclass+"\n"
    if (itemclass.indexOf(q) > -1 )
      items[i].style.display=''
    else items[i].style.display='none';
  }
  //alert(txt)
  // Unhide the message that tells the user how to display all tags again.
  document.getElementById("seeAll").style.display=""
}

function calendarMain() {
  var calId = 'ou4b6uv2564j9p1d17i0jne4mg@group.calendar.google.com';

  var calendar = new calvis.Calendar();

  // set the CSS IDs for various visual components for the calendar container
  calendar.setCalendarBody('calendarBodyDiv');
  calendar.setNavControl('navControlDiv');
  calendar.setViewControl('viewControlDiv');
  calendar.setStatusControl('statusControlDiv');
  calendar.setEventCallback('click', displayEvent);

  // set the calenar to pull data from this Google Calendar account
  calendar.setPublicCalendar(calId);  

  calendar.setDefaultView('month');
  // display the calendar
  calendar.render();  

  // global lightbox dialog to display event details
  eventWindow = new Widget.Dialog;


}

function displayEvent(event){
  var title = event.getTitle().getText();  
  var date = event.getTimes()[0].getStartTime().getDate();
  var content = event.getContent().getText();  
  var location_ = event.getLocations()[0].getValueString().split('@')[0];

  var eventHtml = [];
  eventHtml.push('<b>Title: </b>');
  eventHtml.push(title);
  eventHtml.push('<br>');
  eventHtml.push('<br>');
  eventHtml.push('<b>When </b>');
  eventHtml.push(date.toString());
  eventHtml.push('<br>');
  eventHtml.push('<br>');
  eventHtml.push('<b>Description:</b>');
  eventHtml.push('<p style="font-size: 12px;">');
  eventHtml.push(content); 
  eventHtml.push('</p>');

  eventHtml.push('<b>Where: </b>');
  eventHtml.push(location_);
  
  // after this the eventHtml is in the DOM  tree
  eventWindow.alert(eventHtml.join(''));

}     


// JavaScript for loading above functions into the page
var PageInitializer = {
    start : function(){
        PageInitializer.addLoadEvent(function(){
            //Add Functions Here
			externalLinks();
			sfHover();
			calvis.ready(calendarMain);
        });
    },
    addLoadEvent:function(f){var w=window;var o=w.onload;if(typeof w.onload!='function'){w.onload=f;}else{w.onload=function(){o();f();}}}
}
PageInitializer.start();