////////////////////////////////////////////////////////////
// start of Jeff Isabella'a functions                     //
////////////////////////////////////////////////////////////
function RedirectToIndividual(strSection) {
    list = document.getElementById(strSection); 
    selectedIndex = list.selectedIndex; 
    selectedName = list.options[selectedIndex].value;
    url = "/civiceducation/eXpressionsGallery/expressionsGallery09/gallery/" + strSection + "/" + selectedName + ".asp"; 
    window.location = url;
} 

function RedirectToMathAward(strAward) {
    url = "/civiceducation/eXpressionsGallery/expressionsgallery09/gallery/math/" + strAward + ".asp"; 
    window.location = url; 
}

function RedirectToMathAwardFromList() {
    mathList = document.getElementById("math"); 
    strAward = mathList.options[mathList.selectedIndex].value; 
    RedirectToMathAward(strAward); 
} 

function ShowHideHomepageParagraphs(shouldParagraphsBeDisplayed) { 
    newState = "block"; 
    if(shouldParagraphsBeDisplayed == "false") 
        newState = "none"; 
    document.getElementById('AdditionalHomeParagraphs').style.display = newState; 
} 

function ShowHideReadMoreButton(shouldReadMoreButtonBeDisplayed) {
    newState = "block"; 
    if(shouldReadMoreButtonBeDisplayed == "false") 
        newState = "none"; 
    document.getElementById('ReadMoreButton').style.display = newState;
}

////////////////////////////////////////////////////////////
// end of Jeff Isabella's functions                       //
////////////////////////////////////////////////////////////

//First and Last LI Selector
//Note: Prototype Driven
function liFirstLast() {
	var firstLIs =	$$('ul > li:first-child');
	var lastLIs = $$('ul > li:last-child');
	
	firstLIs.each(function(liFirst) {
		liFirst.addClassName('first');
		});
		
	lastLIs.each(function(liLast) {
		liLast.addClassName('last');
	});
}

//Input Clear
//Clears text inputs on a page on focus
//Note: Prototype driven
function inputClear() {
	var textInputs = $$('input[type="text"]');
	
	textInputs.each(function(textInput){
		textInput.initialValue = textInput.value;
		textInput.observe('focus', function(event) {
			if(textInput.value == textInput.initialValue){
				textInput.clear();
			}
		});
		textInput.observe('blur', function(event){
			if(textInput.value.blank() == true) {
				textInput.value = textInput.initialValue;
			}
		});
	});
}

// Cookie Functions
// Set the cookie 
function setCookie(name,value,days) { 
	if (days) { 
		var date = new Date(); 
		date.setTime(date.getTime()+(days*24*60*60*1000)); 
		var expires = ";expires="+date.toGMTString(); 
	} else { 
		expires = ""; 
	} 
	document.cookie = name+"="+value+expires+";"; 
}

// Read the cookie 
function readCookie(name) { 
	var needle = name + "="; 
	var cookieArray = document.cookie.split(';'); 
	for(var i=0;i < cookieArray.length;i++) { 
		var pair = cookieArray[i]; 
		while (pair.charAt(0)==' ') { 
			pair = pair.substring(1, pair.length); 
		} 
		if (pair.indexOf(needle) == 0) { 
			return pair.substring(needle.length, pair.length); 
		} 
	} 
	return null; 
}

//Replacement for Window Onload - Loads before images, cross-browser
document.observe("dom:loaded", function() {
	//dynamicShadow('/images/global/shadow.png', 'page-container', 16, 0);
	liFirstLast(); // Adds classes 'first' and 'last' to respective LIs
});
