//dph 5-21-04 
// this file contains all of the JS for the Intranet and is hardlinked in each page
var screen_width = screen.width; // sniffs browser size

// -----------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------
 // This script detects older versions of IE that do not render png graphics properly
 // this originally was in the header.shtml page but was moved for w3c validation

//------------------------------------------------------------------------------------
var months=new Array(13);// date variables script that calls variables in in body on all pages
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)
year = year + 1900;



var llmonth=months[time.getMonth() + 2];/* moves month up one */


var lyear=time.getYear();
if([time.getMonth() + 2]>12)/*rolls month to January when December is current month */
	llmonth="January";
if([time.getMonth() + 2]>12) /* rolls year up in December for January display */
	lyear=[time.getYear()+1];
var dateShow = 21; /* sets day for next months menu to display */ 
// End  of date script -->

//--------menu script-----------------------------------------------------------------------
// -- inclduded in all pages
//document.write("<script type='text/javascript' src='http://www.unit5.org/pepper/dev/menu/c_config.js'></script>");
//document.write("<script type='text/javascript' src='http://www.unit5.org/pepper/dev/menu/c_smartmenus.js'></script>");
//document.write("<script type='text/javascript' src='http://www.unit5.org/pepper/dev/menu/c_addon_fx_shadow.js'></script>");
//document.write("<script type='text/javascript' src='http://www.unit5.org/pepper/dev/menu/c_addon_fx_reveal.js'></script>");
//document.write("<script type='text/javascript' src='http://www.unit5.org/pepper/dev/menu/c_addon_fx_fade.js'></script>");


// Sets cookies for display options
function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}
//---------------------------------------------------------------------------------
function delete_cookie ( cookie_name )

	{
	  var cookie_date = new Date ( );  // current date & time
	  cookie_date.setTime ( cookie_date.getTime() - 1 );
	  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
	}
//---------------------------------------------------------------------------------
function get_cookie ( cookie_name )

	{
	  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

	  if ( results )
	    return ( unescape ( results[1] ) );
  	  else
    	return null;
	}
//---------------------------------------------------------------------------------
/* handles the quick links*/

function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
if (URL == 'null')
	{}
	else
	{
	window.location.href = URL;
	}
}
//---------------------------------------------------------------------------------
 /* handles popup window for lunch menus   */
 
 function StartLunch(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,top=1,left=1,scrollbars=yes,resizable=yes width=800 height=900");
	}

//---------------------------------------------------------------------------------
 /* handles the pop up box*/

function Start(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=700,height=700");
}
//<a href="javascript:Start('http://www.unit5.org')"> Script to use in the body
// ------------------------------------------------------------------------------
// set up for tours of constrcution sites 6-29-09 dph
function Tour(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no,left=0,top=0,width=650,height=500");
}



var school = get_cookie("schoolName");
/*document.write ( "School Name 1 " + school);*/
var school = get_cookie("schoolName2");
/*document.write ( "School Name 2 " + school);*/
var school = get_cookie("schoolName3");
/*document.write ( "School Name 3 " + school);*/
var school = get_cookie("schoolName4");
/*document.write ( "School Name 4 " + school);*/
/*document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\""+ school + ".css\">");*/
  
var theme = get_cookie ( "theme" );
//document.write ( "Hi " + theme );

var setCal = get_cookie ( "setCal" );
/*document.write ( "Hi " + setCal );*/

var browserName=navigator.appName; 
/*document.write(navigator.appName);*/

//---------------------------------------------------------------------------------------------------

// bread crumb sript
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Justin Whitford | http://www.whitford.id.au/ 
modified by David Harris Unit 5 Schools 11-07    */
// breadcrumg array

// this function was written to look at each name of the folder and dislay a propely formatted name in the breadcrumb link
// to add a corrected dislay copy the three lines be sure to capitalize the first letter because of the outword capiatlize function
// David Harris 2-17-08
function nameParse(folderName)
{
	
	var nameParseOut;
	switch (folderName)
		
		{
			case 'Districtinformation':
				nameParseOut = 'District Information';
				break;
			case 'Aboutunit5':
				nameParseOut = 'About Unit 5';
				break;
			case 'Cac':
				nameParseOut = 'CAC';
				break;
			case 'Cec':
				nameParseOut = 'CEC';
				break;
			case 'Dac':
				nameParseOut = 'DAC';
				break;
			case 'Hr':
				nameParseOut = 'Human Resources';
				break;
			case 'Focusgoodnews':
				nameParseOut = 'Focus/Good News';
				break;
			case 'Board':
				nameParseOut = 'Board of Education';
				break;
			case 'Nchsalumni':
				nameParseOut = 'NCHS Alumni';
				break;
			case 'Pda':
				nameParseOut = 'PDA';
				break;
			case 'Secured':
				nameParseOut = 'Staff Intraface';
				break;
			case 'Mediaservices':
				nameParseOut = ' Media Services ';
				break;
			case 'Pdatcr':
				nameParseOut = ' Technology Curriculum Resources ';
				break;
			case 'Staffdirectory':
				nameParseOut = ' Staff Directory ';
				break;
			case 'Mentoringprogram':
				nameParseOut = ' Mentoring Program ';
				break;
			case 'Reportcards':
				nameParseOut = ' Illinois School Report Cards ';
				break;
			case 'Pca':
				nameParseOut = ' Online Conference Approval ';
				break;



			default:
				nameParseOut = folderName;// if no match, passes through original text
				break;
	  
		}
	
	return nameParseOut;
}
//------------------------------------------------------------------------------------

function outword(word) 
	{ // added to capitalize first letter in folder names for asthetics dph
  		lower = word.toLowerCase() 
  		upper = word.toUpperCase() 
  		normal = upper.substring(0,1) + lower.substring(1,lower.length) 
  		return normal
	} 
function parseDir(dirName)
	// not working at the moment 1-23-08 dph
	{
		var dirNameModified = '';
		var name
		switch (dirName) 
			{
		
				case districtinformation: dirNameModified = 'district information'; break;

				default: dirNameModified = dirName;
			}
					
		return dirNameModified;
	}

function breadcrumbs() 

{
	sURL = new String;
  	bits = new Object;
  	var x = 0;
  	var stop = 0;
  	var output = "<a href=/>Home</a> -&#187; ";

  	sURL = location.href;
  	sURL = sURL.slice(8,sURL.length);
  	chunkStart = sURL.indexOf("/");
  	sURL = sURL.slice(chunkStart+1,sURL.length)

  	while(!stop)
  
  		{
    		chunkStart = sURL.indexOf("/");
    
    		if (chunkStart != -1)
    		
    			{
    	 			bits[x] = sURL.slice(0,chunkStart)
    	  			sURL = sURL.slice(chunkStart+1,sURL.length);
    			} 
    		else 
    			{
    	  			stop = 1;
    			}
    		x++;
  		}

  	for(var i in bits)
  	
  		{
    		output += "<a href=\"";
    		
    		for(y=1;y<x-i;y++)
    		
    			{
      				output += "../";
    			}
    
    		output += bits[i] + "/\">" + "[" + nameParse(outword(bits[i])) + "]</a>  ";
  		}
  
  	document.write(output + "[ " + nameParse(document.title) + " ]");
  	document.write(" ");
 
}


function translateSp()// script to include in pages to use Google's translation tool
	
	{
		var pURL;
		pURL = "<a href = 'http://translate.google.com/translate?u=";
		pURL += location.href;
		pURL += "&hl=en&ie=UTF-8&sl=en&tl=es' target = '_blank' title = '*** Haga clic aquí para ver esta página traducida al español. Debido a un formato diferente el sitio puede tener una apariencia ligeramente diferente y alguna funcionalidad se puede perder. ****  Click to view this page translated into Spanish. Due to different formatting the site may have a slightly different appearance and some functionality may be lost. ***'>Español</a>&nbsp;";
		document.write(pURL);	
	}

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.getAttribute("rel") == "external nofollow" || 
					anchor.getAttribute("rel") == "nofollow external" )
					)
				anchor.target = "_blank";
			}
	}
		window.onload = function() {
		externalLinks();
	}
