//************************************************************************************************************************
//	lf_scripts.js
//	Main javascript file for the Lehman FIRST site
//************************************************************************************************************************

// Add CSS and JS references in the HEAD tag of pages
document.write('<script type="text/javascript" src="http://www.lehman.edu/lehman/2008-intermediate-js/nifty.js"></script>');
document.write('<script type="text/javascript" src="http://www.lehman.edu/lehman/2008-intermediate-js/lytebox.js"></script>');


// If used on the landing page of Middle States
//alert(document.location.href);
//if (document.body.id == "msPageHome") {
//}
//if (document.location.href.indexOf("middlestates/index.html") > 0 ) {
//	document.write('<script src="http://www.lehman.edu/lehman/2008-intermediate-js/mootools.v1.11.js" type="text/javascript"><script>');
//	document.write('<script src="http://www.lehman.edu/lehman/2008-intermediate-js/jd.gallery.js" type="text/javascript"><script>');
//	document.write('<script src="http://www.lehman.edu/lehman/2008-intermediate-js/jd.gallery.transitions.js" type="text/javascript"><script>');
//}
if (document.location.href.indexOf("middle-states/") > 0 ) {
	document.write('<script src="http://www.lehman.edu/lehman/2008-intermediate-js/mootools.v1.11.js" type="text/javascript"></script>');
	document.write('<script src="http://www.lehman.edu/lehman/2008-intermediate-js/jd.gallery.js" type="text/javascript"></script>');
	document.write('<script src="http://www.lehman.edu/lehman/2008-intermediate-js/jd.gallery.transitions.js" type="text/javascript"></script>');
}

// Functions List

// Function for Search Box on top right
function searchBoxFunction() { 
   if (document.getElementById)
    var getSearchBoxField = document.getElementById("q");
	getSearchBoxField.onmousedown = function() { if(this.value=='Search at Lehman') this.value=''; }
	getSearchBoxField.onmouseout = function() { if(this.value=='') this.value='Search at Lehman'; }
	getSearchBoxField.onkeydown = function() { if(this.value=='Search at Lehman') this.value=''; }
	getSearchBoxField.onkeyup = function() { if(this.value=='') this.value='Search at Lehman'; }
    return false;
}

function lastUpdated() {
	lastUpdatedDate = new Date(document.lastModified);
	lastUMonth = lastUpdatedDate.getMonth() + 1;
	lastUDay = lastUpdatedDate.getDate();
	lastUYear = lastUpdatedDate.getFullYear();
	var getMainContent = document.getElementById("col01");
	getMainContent.innerHTML += '<p class="timestamp">Last updated: '+lastUMonth+'/'+lastUDay+'/'+lastUYear+'</p>';
}

// Function for Rounded Corners
function createNiftyCorners() { 
	if (!NiftyCheck()) {  return; }
	Rounded("div.moduleWrap","all","#fff","#eee","small border #ccc");
	/*Rounded("ul#nav01UL li","top","transparent","#fff","small border #ccc");*/
}

// Function for removing last child in vertical navigation
function navLastChild() {
var listHandle = document.getElementById("nav02");
var itemHandle = listHandle.lastChild.previousSibling;
while ( itemHandle.nodeType != 1 ) {
itemHandle = itemHandle.previousSibling;
}
//itemHandle.firstChild.style.backgroundImage="none";
itemHandle.style.backgroundImage="none";
}

// Function for photo gallery
function startGallery() {
 if (navigator.userAgent.indexOf('MSIE 6') <= 0) {  
  var myGallery = new gallery($('myGallery'), {
    timed: true,
    defaultTransition: "fadeslideleft"
  });
 }
 else {
  document.getElementById("myGallery").style.display="none";
 }
}

// Function for loading functions
function womOn() {  window.onload = womGo; }
function womGo() {  for(var i = 0; i < woms.length; i++) eval(woms[i]); }
function womAdd(func) {  woms[woms.length] = func; }
var woms = new Array();
// loading functions
womAdd('searchBoxFunction()');
womAdd('createNiftyCorners()');
womAdd('lastUpdated()');
if (document.location.href.indexOf("middle-states/") > 0 ) { womAdd('startGallery()'); }
//womAdd('navLastChild()');
//womAdd('P7_ExpMenu()'); -- this is for the dropdown if used
womOn(); // end of WOM