var detect = navigator.userAgent.toLowerCase();

function checkIt(string) {
	// Browser check.
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function setUpHome() {
	  //frontFlash();
	  //document.getElementById("featuresbox").style.display="none";
	  searchOption('facultysearch');
	  //setTimeout("slideNews()",4000);  
      document.getElementById('searchtext').blur();
}


function slideNews() {
	Effect.BlindDown('featuresbox');
}

function loadPNGie(inImg) {
	
	if (document.getElementById("projectObject")) {
		
		try {	
			var so = new SWFObject("/flash/frontpage/loadObject.swf", "homepage", "319", "173", "8", "");
			so.addParam("wmode", "transparent");
			so.addVariable("loadPNG",inImg);
			so.write("projectObject");		
		} catch (e) {
			alert(e);
		}
	}
}


function iePNGImage(InImage, InHeight, InWidth) {
	
	var strNewHTML = "<span style=\" width:" + InWidth + "px; height:" + InHeight + "px;"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src='" + InImage + "', sizingMethod='scale');\"></span>"; 
	return "";
}

function showProject(inNum) {
	imageNumber = inNum+1;
	newImg = '<img src="/flash/objects/object'+imageNumber+'.png" width="319" height="173" alt="" />';

	if (checkIt('msie')) {
		loadPNGie("/flash/objects/object"+imageNumber+".png");
	} else {
		document.getElementById("projectObject").innerHTML = newImg;	
	}
	
	setTimeout("appearObject()",7000); 
}

function appearObject() {
	if (checkIt('msie')) {
		document.getElementById("projectObject").style.display="";
	} else {
		Effect.Appear("projectObject");
	}
}

function frontFlash() {
	if (document.getElementById("midFlash")) {
		
		try {	
			var so = new SWFObject("/flash/frontpage/front.swf", "homepage", "760", "314", "7", "#363636",true);
			so.addParam("wmode", "transparent");
			so.setAttribute('redirectUrl', 'javascript: alertNoFlash();');
			so.write("midFlash");
		
		} catch (e) {
			alert(e);
		}
	}
}

function alertNoFlash() {
	document.getElementById("midFlash").innerHTML = "<h2 style='color:#ffffff;'><a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW'>Flash Player 7 Required</a></h2>";
	document.getElementById("midFlash").innerHTML += "<div style='color:#ffffff;'>You can view the content by upgrading or intalling your version of flash player. <a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW'>click here to get Flash</a></div>";
}

function setUpProject() {
	document.getElementById("projectObject").style.display="none";
}

//addEvent(window, "load", frontFlash);
addEvent(window, "load", setUpHome);
//addEvent(window, "load", setUpProject);
addEvent(window, 'load', setUpNews);

function setUpNews() {
	var titles = $$('.newstitle');
	
	// Hide all
	titles.each(function(el) {
		el.hide();
	});
	
	var showNews = function(index) {
		new Effect.Appear(titles[index], { duration: 1 });
		setTimeout(function() {
			hideNews(index);	// Hide the item after the timeout
		}, 5000);
	}
	
	var hideNews = function(index) {
		new Effect.Fade(titles[index], {
			duration: 1,
			afterFinish: function() {
				showNews((index + 1) % titles.length);	// Show the next item after the fade-out
			}
		})
	}
	
	// Show a random item
//	showNews(Math.floor(Math.random() * titles.length));
	showNews(0);
}


