var addEvent=function(obj,type,fn){
	if(obj.addEventListener){
		obj.addEventListener(type,fn,false);
	}else if(obj.attachEvent){
		obj.attachEvent('on'+type,function(){
			return fn.apply(obj,new Array(window.event));
		});
	}
};

// tall.js this code was never actually executed
/*addEvent(window,'load',function(){
	
	var isMozilla = false;
	var isIE6 = false;
	var isIE7 = false;
	var isWindows = false;
	var uA = navigator.userAgent;
	
	// check for Windows clients
	if (uA.indexOf('Windows') > 0) {
		isWindows = true;
	}
	
	// check for IE clients
	if (uA.indexOf('MSIE') > 0) {
		if (uA.indexOf('6') > 0) {
			isIE6 = true;
		} else if (uA.indexOf('7') > 0) {
			isIE7 = true;
		}
	}
	
	if (isWindows) {
		// adjust font size of nonIE windows browsers
		if (!(isIE6) && (!(isIE7))) {
			var footerDiv = document.getElementById('footer');
			footerDiv.style.fontSize = '9px';
		}
	}
	
	// find tallest of all 4 ULs (offsetHeight) and adjust the rest
	// to the tallest.
	var links = document.getElementById('homemainnav');
	var length = links.childNodes.length;
	var linkChildren = links.childNodes;
	var ULs = [];
	var ULsHeight = [];
	var p = 0;
	
	for (var i=0; i<length; i++) {
		if (linkChildren[i].nodeName == 'UL') {
			ULs[p] = linkChildren[i];
			ULsHeight[p] = linkChildren[i].offsetHeight;
			p++;
		}
	}
	
	var Tallest = Math.max(ULsHeight[0], ULsHeight[1], ULsHeight[2], ULsHeight[3]);
	
	for (var k=0; k<ULsHeight.length; k++) {
		if (ULs[k].offsetHeight < Tallest) {
			ULs[k].style.height = Tallest+'px';
		}
	}
	
	return;
});*/

var ulAbout = null;
var ulAcademics = null;
var ulAdmission = null;
var ulCampusLife = null;
var ulDrops = new Array();

/*function clearBox(){
	var searchBox=document.getElementById('searchBox');
	if(searchBox.value=='Search DCC'){
		searchBox.value='';
	}
}

function resetBox(){
	var searchBox=document.getElementById('searchBox');
	if(searchBox.value!='Search DCC'){
		//searchBox.value = 'Search DCC';
	}
}*/

function trim(s){return s.replace(/^[\s\t\r\n]+/,'').replace(/[\s\t\r\n]+$/,'');} // remove whitespace from beginning and end

function clearBox(el){
	if(el.value == el.defaultValue){ // if box has the default text
		el.value = ''; // blank out box
	}
}

function resetBox(el){
	if(trim(el.value) == ''){ // if box is blank
		el.value = el.defaultValue; // set to the default text
	}
}

function enlargeImage(){
	//blurbDiv = document.getElementById('blurbs');
	//divImgs = blurbDiv.getElementsByTagName("IMG");
	divImgs[0].setAttribute('onclick','window.open(this.src)');
}

addEvent(window,'load',function(){
	
	//blurbDiv = document.getElementById('blurbs');
	//divImgs = blurbDiv.getElementsByTagName("IMG");
	//divImgs[0].setAttribute("onclick", "window.open(this.src)");
	
	var isMozilla = false;
	var isIE6 = false;
	var isIE7 = false;
	var isWindows = false;
	var uA = navigator.userAgent;
	
	// preload dropdown image background gif
	var bgImage = new Image(140,250);
	bgImage.src = '/images/dropdownBG.gif';
	
	// check for Windows clients
	if (uA.indexOf('Windows') > 0) {
		isWindows = true;
	}
	
	// check for IE clients
	if (uA.indexOf('MSIE') > 0) {
		if (uA.indexOf('6') > 0) {
			isIE6 = true;
		} else if (uA.indexOf('7') > 0) {
			isIE7 = true;
		}
	}
	
	// handle for windows fonts
	/*if ( (isWindows) && (!(isIE6)) && (!(isIE7)) ) {
	var headerlinksDIV = document.getElementById('headerlinks');
	var headerlinksDIV2 = document.getElementById('headerlinksHome');
	if (headerlinksDIV) {
	if (headerlinksDIV.className == 'alumnihome') {
	headerlinksDIV.style.marginLeft = '40px';
	} else
	if (headerlinksDIV.className == 'alumnicontent') {
	headerlinksDIV.style.marginLeft = '40px';
	} else {
	headerlinksDIV.style.marginLeft = '50px';
	}
	} else
	if (headerlinksDIV2) {
	
	headerlinksDIV2.style.marginLeft = '50px';
	}
	}*/
	
	// home page
	// find tallest of all 4 ULs (offsetHeight) and adjust the rest
	// to the tallest.
	if (document.getElementById('homemainnav')) {
		var links = document.getElementById('homemainnav');
		var length = links.childNodes.length;
		var linkChildren = links.childNodes;
		var ULs = [];
		var ULsHeight = [];
		var p = 0;
		// only execute if on home page template (if this div exists)
		if (links) {
			for (var i=0; i<length; i++) {
				if (linkChildren[i].nodeName == 'UL') {
					ULs[p] = linkChildren[i];
					ULsHeight[p] = linkChildren[i].offsetHeight;
					p++;
				}
			}
			
			var Tallest = Math.max(ULsHeight[0], ULsHeight[1], ULsHeight[2], ULsHeight[3]);
			
			for (var k=0; k<ULsHeight.length; k++) {
				if (ULs[k].offsetHeight < Tallest) {
					ULs[k].style.height = Tallest+'px';
				}
			}
		}
	}
	
	var rootElementDIV = document.getElementById('topSecondaryNav');
	
	// event listeners
	// if this div exists, create event listener
	if ((document.getElementById('topSecondaryNav') || (document.getElementById('homemainnav')))) {
		// additional test - if page has about UL dropdown, activate event listener
		if (document.getElementById('ulDropAbout')) {
			document.onmousemove = getTarget;
		}
	}
	
	function getoffset(pos) {
		if (pos == 'left') {
			var drop1 = document.getElementById('ulDropAbout');
			//drop1.style.left = drop1.offsetLeft+'px';
			return drop1.offsetLeft+'px';
		}
	}
	
	function getTarget(evt) {
		var evt = (evt) ? evt : ((window.event) ? event : null);
		var evtTargetClass = (evt.target) ? evt.target.className : ((evt.srcElement) ? evt.srcElement.className : null);
		//var evtTargetID = evt.target.id;
		
		var drop1 = document.getElementById('ulDropAbout');
		var drop2 = document.getElementById('ulDropAcademics');
		var drop3 = document.getElementById('ulDropAdmission');
		var drop4 = document.getElementById('ulDropCampusLife');
		//document.getElementById('testjstarget').innerHTML = evtTargetClass;
		//document.getElementById('testjstarget').innerHTML = '<div style="background-color:#fff">ID: '+evtTargetID+'</div>';
		
		var classMatchAbout1 = evtTargetClass.match('ulDrop1');
		var classMatchAbout2 = evtTargetClass.match('drop1');
		
		var classMatchAcadem1 = evtTargetClass.match('academicsDrop');
		var classMatchAcadem2 = evtTargetClass.match('drop2');
		
		var classMatchAdmiss1 = evtTargetClass.match('admissionDrop');
		var classMatchAdmiss2 = evtTargetClass.match('drop3');
		
		var classMatchCampus1 = evtTargetClass.match('campuslifeDrop');
		var classMatchCampus2 = evtTargetClass.match('drop4');
		
		var drop1obj = document.getElementById('aboutUsDrop');
		var drop2obj = document.getElementById('academicsDrop');
		var drop3obj = document.getElementById('admissionDrop');
		var drop4obj = document.getElementById('campuslifeDrop');
		
		if ((classMatchAbout1 == 'ulDrop1') || (classMatchAbout2 == 'drop1') || (evtTargetClass == 'aboutUsDrop')) {
			drop1obj.style.color = '#996';
			drop1.style.display = 'block';
		} else {
			drop1obj.style.color = '#369';
			drop1.style.display = 'none';
		}
		
		if ((classMatchAcadem1 == 'academicsDrop') || (classMatchAcadem2 == 'drop2') || (evtTargetClass == 'ulDrop2')) {
			drop2obj.style.color = '#996';
			drop2.style.display = 'block';
		} else {
			drop2obj.style.color = '#930';
			drop2.style.display = 'none';
		}
		
		if ((classMatchAdmiss1 == 'admissionDrop') || (classMatchAdmiss2 == 'drop3') || (evtTargetClass == 'ulDrop3')) {
			drop3obj.style.color = '#996';
			drop3.style.display = 'block';
		} else {
			drop3obj.style.color = '#636';
			drop3.style.display = 'none';
		}
		
		if ((classMatchCampus1 == 'campuslifeDrop') || (classMatchCampus2 == 'drop4' ) || (evtTargetClass == 'ulDrop4')) {
			drop4obj.style.color = '#996';
			drop4.style.display = 'block';
		} else {
			drop4obj.style.color = '#066';
			drop4.style.display = 'none';
		}
	}
	
	var navDiv = document.getElementById('navContainer');
	var centerDiv = document.getElementById('contentCenter');
	var bodytextDiv = document.getElementById('bodytext');
	var rightDiv = document.getElementById('rightSidebar');
	var containerDiv = document.getElementById('contentContainer');
	var userContainerDiv = document.getElementById('userContentContainer');
	var containerDivHeight = containerDiv.offsetHeight;
	
	if (userContainerDiv) {
		//navDiv.style.height = userContainerDivHeight+'px';
		// do not set the height on dynamic elements
		if((/^\/(scholarships|search|events)\//).test(window.location.pathname)){
			userContainerDiv.style.height = 'auto';
		}else{
			userContainerDiv.style.height = containerDivHeight + 'px';
		}
		//bodytextDiv.style.height = containerDivHeight+'px';
		if (document.getElementById('contentLeft')) {
			if (!(isIE6)) {
				rightDiv.style.height = (containerDivHeight - 33 ) + 'px';
			} else {
				if (document.getElementById('rightDiv')) {
					containerDivHeight = containerDiv.clientHeight;
					rightDiv.style.height = (userContainerDiv.style.height) + 'px';
				}
			}
		}
	}
	
	return;
});

function openDropDown(objID) {
	var obj = document.getElementById(objID);
	if (obj) {
		obj.style.display = 'none';
	}
}

function mapwinOpen() {
	window.open("/popUps/campusmap.html", "CampusMap", "width=1024,height=800,directories=no,menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

function calcCasinoTickets(num) {
	var ticketDiv = document.getElementById('ticketVal');
	var amountDiv = document.getElementById('dollarAmt');
	if (amountDiv.value == 0) {
		amountDiv.value = 30;
	}
	price = (num * 30);
	ticketDiv.value = price;
	amountDiv.value = price;
}

function calcRaceTickets(num) {
	var ticketDiv = document.getElementById('ticketVal');
	var amountDiv = document.getElementById('dollarAmt');
	if (amountDiv.value == 0) {
		amountDiv.value = 75;
	}
	price = (num * 75);
	ticketDiv.value = price;
	amountDiv.value = price;
}

// if there is a text blurb present
/*if (document.getElementById('blurbs')) {
var blurbDiv = document.getElementById('blurbs');
blurbImgs = blurbDiv.getElementsByTagName("IMG");
length = blurbImgs.length;
blurbSRC = blurbImgs[0].src;

link1 = document.createElement("A");
link1.setAttributes("href", blurbSRC);
blurbImgs[0].insertBefore(link1);

}*/

