// SuckerFish dropdown menus //
sfHover = function() {
	var sfEls = document.getElementById("mainNav").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"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// Window OnLoad event handler //
function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
				window.onload = func;
		} else {
				window.onload = function() {
						oldonload();
						func();
				}
		}
}


// Random image in secondary navigation //
var images = new Array();
	images[0]="http://www.sl.edu/images/random/0.jpg";
	images[1]="http://www.sl.edu/images/random/1.jpg";
	images[2]="http://www.sl.edu/images/random/2.jpg";
	images[3]="http://www.sl.edu/images/random/3.jpg";
	images[4]="http://www.sl.edu/images/random/4.jpg";
	images[5]="http://www.sl.edu/images/random/5.jpg";
	images[6]="http://www.sl.edu/images/random/6.jpg";
	images[7]="http://www.sl.edu/images/random/7.jpg";
	images[8]="http://www.sl.edu/images/random/8.jpg";
	images[9]="http://www.sl.edu/images/random/9.jpg";
	images[10]="http://www.sl.edu/images/random/10.jpg";
	images[11]="http://www.sl.edu/images/random/11.jpg";
	images[12]="http://www.sl.edu/images/random/12.jpg";
	images[13]="http://www.sl.edu/images/random/13.jpg";
	images[14]="http://www.sl.edu/images/random/14.jpg";
	images[15]="http://www.sl.edu/images/random/15.jpg";
	images[16]="http://www.sl.edu/images/random/16.jpg";
	images[17]="http://www.sl.edu/images/random/17.jpg";
	images[18]="http://www.sl.edu/images/random/18.jpg";
	images[19]="http://www.sl.edu/images/random/19.jpg";
	images[20]="http://www.sl.edu/images/random/20.jpg";
	images[21]="http://www.sl.edu/images/random/21.jpg";
	images[22]="http://www.sl.edu/images/random/22.jpg";
	images[23]="http://www.sl.edu/images/random/23.jpg";
	images[24]="http://www.sl.edu/images/random/24.jpg";
	images[25]="http://www.sl.edu/images/random/25.jpg";
	images[26]="http://www.sl.edu/images/random/26.jpg";
	images[27]="http://www.sl.edu/images/random/27.jpg";
	images[28]="http://www.sl.edu/images/random/28.jpg";
	images[29]="http://www.sl.edu/images/random/29.jpg";
	images[30]="http://www.sl.edu/images/random/30.jpg";
	images[31]="http://www.sl.edu/images/random/31.jpg";
	images[32]="http://www.sl.edu/images/random/32.jpg";
	images[33]="http://www.sl.edu/images/random/33.jpg";
	images[34]="http://www.sl.edu/images/random/34.jpg";
	images[35]="http://www.sl.edu/images/random/35.jpg";
	images[36]="http://www.sl.edu/images/random/36.jpg";
	images[37]="http://www.sl.edu/images/random/37.jpg";
	images[38]="http://www.sl.edu/images/random/38.jpg";
	images[39]="http://www.sl.edu/images/random/39.jpg";
	images[40]="http://www.sl.edu/images/random/40.jpg";
	images[41]="http://www.sl.edu/images/random/41.jpg";
	images[42]="http://www.sl.edu/images/random/42.jpg";
	images[43]="http://www.sl.edu/images/random/43.jpg";
	images[44]="http://www.sl.edu/images/random/44.jpg";
	

function randomImage() {
		if (!document.getElementById) return false;
		if (!document.getElementById("placeholder")) return false;
		var ranImage = Math.floor(Math.random() * images.length);
		var selectedImage = images[ranImage];
		var placeholder = document.getElementById("placeholder");
		placeholder.setAttribute("src", selectedImage);
}

//Set interior of CallToAction div//

var prospectTrad = '<h3>Items of Interest</h3><ul><li><a href="http://www.sl.edu/visit.asp">Visit the Campus</a></li>'
	prospectTrad += '<li><a href="http://www.sl.edu/admissions/applyonline.asp">Apply Online</a></li>'
	prospectTrad += '<li><a href="http://www.sl.edu/finaid/">Learn about Financial Aid</a></li>'
	prospectTrad += '<li><a href="http://www.sl.edu/residencelife/">Move into the Student Residence</a></li>'
	prospectTrad += '<li><a href="http://www.sl.edu/tour.asp">Take an Online Tour</a></li>'
	prospectTrad += '</ul>'
	
var prospectAdult = '<h3>Items of Interest</h3><ul><li><a href="http://www.sl.edu/forms/informationsession.aspx">Attend an Information Session</a></li>'
	prospectAdult += '<li><a href="http://www.sl.edu/cdp/locations.asp">Learn about Off-Campus Locations</a></li>'
	prospectAdult += '<li><a href="http://www.sl.edu/tour.asp">Tour the Main Campus</a></li>'
	prospectAdult += '<li><a href="http://www.sl.edu/career/car_curr_students.htm">Career Counseling</a></li>'
	prospectAdult += '<li><a href="http://www.sl.edu/admissions/applyonline.asp">Apply Online</a></li>'
	prospectAdult += '<li><a href="http://www.sl.edu/programs.asp">Graduate Programs</a></li>'
	prospectAdult += '</ul>'

var current = '<h3>Items of Interest</h3><ul><li><a href="http://www.sl.edu/schedule.asp">Register for classes</a></li>'
	current += '<li><a href="http://www.sl.edu/textbooks.asp">Buy Books</a></li>'
	current += '<li><a href="http://www.sl.edu/news/">Attend an Event</a></li>'
	current += '<li><a href="http://www.sl.edu/studentorgs/">Join a Club</a></li>'
	current += '<li><a href="https://diamond.sl.edu/campusweb/" target="_blank">Use CampusWEB</a></li>'
	current += '<li><a href="http://cms.sl.edu/" target="_blank">Log in to Educator</a></li>'
	current += '<li><a href="http://www.sl.edu/finaid/">Apply for Financial Aid</a></li>'
	current += '<li><a href="http://www.sl.edu/personnel.asp">Contact your Advisor</a></li>'
	current += '<li><a href="http://www.sl.edu/handbooks.asp">Student Handbooks</a></li>'
	current += '</ul>'
	
var parent = '<h3>Items of Interest</h3><ul><li><a href="http://www.sl.edu/tour.asp">Take an Online Tour</a></li>'
	parent += '<li><a href="http://www.sl.edu/finaid/">Learn about Financial Aid</a></li>'
	parent += '<li><a href="http://www.sl.edu/residencelife/">Student Residence</a></li>'
	parent += '<li><a href="http://www.sl.edu/residencelife/safety.asp">Safety Policies</a></li>'
	parent += '<li><a href="http://www.sl.edu/news/">Attend an Event</a></li>'
	parent += '<li><a href="http://www.sl.edu/handbooks.asp">Student Handbooks</a></li>'
	parent += '<li><a href="http://www.sl.edu/calendar.asp">Academic Calendar</a></li>'
	parent += '</ul>'

var alumdonor = '<h3>Items of Interest</h3><ul><li><a href="http://www.sl.edu/news/">Attend an Event</a></li>'
	alumdonor += '<li><a href="http://www.sl.edu/alumni/newdirections.asp">Read New Directions</a></li>'
	alumdonor += '<li><a href="http://www.sl.edu/registrar.asp">Request Transcripts</a></li>'
	alumdonor += '<li><a href="http://www.sl.edu/alumni/howtomakeagift.asp">Donate to the College</a></li>'
	alumdonor += '<li><a href="http://www.sl.edu/career/">Learn about Career Resources</a></li>'
	alumdonor += '</ul>'
	
var facultystaff = '<h3>Items of Interest</h3><ul><li><a href="http://www.sl.edu/personnel.asp">Contact other Personnel</a></li>'
	facultystaff += '<li><a href="https://diamond.sl.edu/campusweb" target="_blank">Use CampusWEB</a></li>'
	facultystaff += '<li><a href="http://www.sl.edu/hr/handbooks.asp">Silver Lake College Policies</a></li>'
	facultystaff += '<li><a href="http://cms.sl.edu/" target="_blank">Use Educator</a></li>'
	facultystaff += '<li><a href="http://www.sl.edu/hr/">Human Resources</a></li>'
	facultystaff += '<li><a href="http://www.sl.edu/library/">Zigmunt Library</a></li>'
	facultystaff += '<li><a href="http://www.sl.edu/departments.asp">Academic Departments</a></li>'
	facultystaff += '<li><a href="http://www.sl.edu/news/">Attend an Event</a></li>'
	facultystaff += '<li><a href="http://www.sl.edu/news/news.asp">Announcements</a></li>'
	facultystaff += '</ul>'
	
var visitor = '<h3>Items of Interest</h3><ul><li><a href="http://www.sl.edu/tour.asp">Take an Online Tour</a></li>'
	visitor += '<li><a href="http://www.sl.edu/facts.asp">Learn about Us</a></li>'
	visitor += '<li><a href="http://www.sl.edu/visit.asp">Visit the campus</a></li>'
	visitor += '<li><a href="http://www.sl.edu/news/">Attend an event</a></li>'
	visitor += '<li><a href="http://www.sl.edu/hr/employment.asp">Apply for a job</a></li>'
	visitor += '<li><a href="http://www.sl.edu/personnel.asp">Contact personnel</a></li>'
	visitor += '<li><a href="http://www.sl.edu/admissions/applyonline.asp">Apply Online</a></li>'
	visitor += '<li><a href="http://www.sl.edu/studentlife.asp">Campus Life</a></li>'
	visitor += '</ul>'
	


// Cookie Behaviors  Script Source URI: http://techpatterns.com/downloads/javascript_cookies.php


// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

/*
only the first 2 parameters are required, the cookie name, the cookie
value. Cookie time is in milliseconds, so the below expires will make the 
number you pass in the Set_Cookie function call the number of days the cookie
lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

Generally you don't need to worry about domain, path or secure for most applications
so unless you need that, leave those parameters blank in the function call.
*/
function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called

function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

//Load visitor information into call to action area as a placeholder for now
// This will catch most individuals who have JavaScript enabled but cookies disabled.

function Load_Options() {
		if (!document.getElementById) return false;
		if (!document.getElementById("listcontainer")) return false;
		var list = document.getElementById("listcontainer");
		list.innerHTML = visitor;
} 
		
function prepareLinks() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i< links.length; i++) {
			links[i].onclick = function() {chooseList(this);}
	}
}

function chooseList(whichAudience) {
		var titletext = whichAudience.getAttribute("title");
			if (titletext=='visitor'){
				Set_Cookie( 'audience', 'visitor', 30, '/', '', '' );
				}
			else if (titletext=='prospectTrad'){ 
  				Set_Cookie( 'audience', 'prospectTrad', 30, '/', '', '' );
				}
			else if (titletext=='prospectAdult'){
  				Set_Cookie( 'audience', 'prospectAdult', 30, '/', '', '' );
				}
			else if (titletext=='current'){
  				Set_Cookie( 'audience', 'current', 30, '/', '', '' );
				}
			else if (titletext=='parent'){
  				Set_Cookie( 'audience', 'parent', 30, '/', '', '' );
				}
			else if (titletext=='alumdonor'){
  				Set_Cookie( 'audience', 'alumdonor', 30, '/', '', '' );
				}
			else if (titletext=='facultystaff'){
  				Set_Cookie( 'audience', 'facultystaff', 30, '/', '', '' );
				}
			else {
				return false;
				}
}


function checkAudience() {
		if (!document.getElementById) return false;
		if (!document.getElementById("listcontainer")) return false;
		var list = document.getElementById("listcontainer");
		var Audience = Get_Cookie( "audience" );
		switch (Audience)
		{
			case "visitor":
				list.innerHTML = visitor;
				break
			case "prospectTrad":
  				list.innerHTML = prospectTrad;
				break
			case "prospectAdult":
  				list.innerHTML = prospectAdult;
				break
			case "current":
  				list.innerHTML = current; 
				break
			case "parent": 
  				list.innerHTML = parent; 
				break
			case "alumdonor":
  				list.innerHTML = alumdonor; 
				break
			case "facultystaff":
  				list.innerHTML = facultystaff;
				break
			default:
  				return false;
		}
}

var quotes = new Array();
	quotes[0] = "&rdquo;Better than a thousand hollow words is one word that brings peace.&ldquo; <cite> &mdash; Buddha</cite>";
	quotes[1] = "&rdquo;Every day we do things, we are things that have to do with peace.  If we are aware of our life&hellip;, our way of looking at things, we will know how to make peace right in the moment we are alive.&ldquo; <cite> &mdash; Thich Nhat Hanh";
	quotes[2] = "&rdquo;We will not learn how to live together in peace by killing each other\'s children <cite> &mdash; Jimmy Carter</cite>";
	quotes[3] = "&rdquo;Peace cannot by achieved through violence, it can only by attained through understanding.&ldquo; <cite> &mdash; Ralph Waldo Emerson</cite>";
	quotes[4] = "&rdquo;If everyone demanded peace instead of another television set, then there\'d be peace.&ldquo; <cite> &mdash; John Lennon</cite>";
	quotes[5] = "&rdquo;Five great enemies of peace inhabit with us&mdash;avarice, ambition, envy, andger and pride; if these were to be banished, we should infallibly enjoy perpetual peace.&ldquo; <cite> &mdash; Petrarch</cite>";
	quotes[6] = "&rdquo;It isn\'t enough to talk about peace.  One must believe in it.  And it isn\'t enough to believe in it.  One must work at it.&ldquo; <cite> &mdash; Eleanor Roosevelt</cite>";
	quotes[7] = "&rdquo;Peace is not the abscence of conflict but the presence of creative alternatives for responding to conflict&mdash;alternatives to passive or aggressive responses, alternatives to violence.&ldquo; <cite> &mdash; Dorothy Thompson</cite>";
	quotes[8] = "&rdquo;Peace will come wherever it is sincerely invited.&ldquo; <cite> &mdash; Alice Walker</cite>";
	quotes[9] = "&rdquo;Most people think of peace as a state of Nothing Bad Happening, or Nothing Much Happening.  Yet if peace is to overtake us and make us the gift of serenity and well-being, it will have to be the state of Something Good Happening.&ldquo; <cite> &mdash; E.B. White</cite>";
	quotes[10] = "&rdquo;If we have no peace, it is because we have forgotten that we belong to each other.&ldquo; <cite> &mdash; Mother Teresa</cite>";
	quotes[11] = "&rdquo;Out of clutter, find simplicity.  From discord, find harmony.  In the middle of difficulty, lies opportunity.&ldquo; <cite> &mdash; Albert Einstein</cite>";
	quotes[12] = "&rdquo;Turn from evil and do good; seek peace and pursue it.&ldquo; <cite> &mdash; Psalm 34:14</cite>";
	quotes[13] = "&rdquo;If it is possible, as far as it depends on you, live at peace with everyone.&ldquo; <cite> &mdash; Romans 12:18</cite>";
	quotes[14] = "&rdquo;Peace I leave with you; my peace I give to you.&ldquo; <cite> &mdash; John 14:27</cite>";

function randomQuote() {
		if (!document.getElementById) return false;
		if (!document.getElementById("placequote")) return false;
		var ranQuote = Math.floor(Math.random() * quotes.length);
		var selectedQuote = quotes[ranQuote];
		var placequote = document.getElementById("placequote");
		placequote.innerHTML = selectedQuote;
}




addLoadEvent(randomQuote);
addLoadEvent(randomImage);
addLoadEvent(Load_Options);
addLoadEvent(prepareLinks);
addLoadEvent(checkAudience);




