var index=0;
var index2=1;
var colors = new Array('#FF7E00','#9BDF1E','#12BAA9','#CC0000','#0075FF');
var pics = new Array('bg2','bg3','bg1');
function mainmenu(){
$(" #hnav ul ").css({display: "none"}); // Opera Fix
$(" #hnav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

 
 
 $(document).ready(function(){	
		
	mainmenu();
		slideShow();
});

function slideShow()
{
	setInterval('change()',12000);

}
function change()
{
		$('#mainmenu').animate({backgroundColor: colors[index]},1000);
		index++;
		$('#bgimage'+index2).fadeOut(1500,changePic());
		
		
		if (index==colors.length)
			index=0;
		
}
function changePic()
{
	index2++;
	if (index2>pics.length)
		index2=1;
		
		setTimeout("$('#bgimage'+index2).fadeIn(2500)",1400);

}

var ajaxRequest;  // The variable that makes Ajax possible!
function ajaxReady()
{
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
}
var slinks = new Array('http://web.mit.edu/bmes/www/thebiotech_vol5no1.html','http://web.mit.edu/bmes/www/jjresearch.html','bg1');
var simgsrc = new Array('biotech.jpg','winners.jpg','bg1');
var stitles = new Array('Vol. 5, No. 1, May 2009 of the BioTECH is now out!','Winners of the J&J Research Prize','bg1');
var sbriefs = new Array('Check out the latest edition of the BioTECH! The BioTECH is a publication by the MIT BE-BMES as a vehicle to inform, involve, and mobilize our membership regarding the complex and evolving bioengineering landscape at MIT and nationwide.','Congratulations to the winners of the J&J Research Prize!','bg1');

function getSidebar()
{
	var rand =Math.floor(Math.random()*2);

	var content = "<a href=\""+slinks[rand]+"\"> <img src=\""+simgsrc[rand]+"\" width=200></a><div id=\"rstitle\">BMES-BE NEWS</div><a href=\""+slinks[rand]+"\">"+stitles[rand]+"</a><p>"+sbriefs[rand]+"</p>";
	
	document.getElementById('rsidebar').innerHTML=content;
		
		
	
		
		
}