var itemHeight = 58;

var currentNews = 0;
var itemsDisplayed = 3;

function loadBanner()
{
	var i = Math.floor(Math.random((new Date()).getTime()) * 4);
	//alert(document.getElementById("splash-bar").style.backgroundImage);
	document.getElementById("splash-bar").style.backgroundImage = "url(imgs/banners/banner" + i + ".jpg)";
	//alert(document.getElementById("splash-bar").style.background);
	
	//document.getElementById("splash-bar").style.backgroundImage = "url(imgs/banners/banner0.jpg)";
}

function loadColumns()
{
  var keynotespeakers = [];
  keynotespeakers[0] = {img:"imgs/gates.jpg", alt:"Bill Gates", title:"Keynote Speakers", text:"William H. Gates, Chairman of Microsoft Corporation, and Co-Chairman of the Bill and Melinda Gates Foundation, will deliver a keynote address at the ICTD 2009 conference on the 18th of April, 2009."};
  keynotespeakers[1] = {img:"imgs/CAPBraga_sm2.jpg", alt:"Carlos A. Primo Braga", title:"Keynote Speakers", text:"Carlos A. Primo Braga, Director, Economic Policy and Debt in the Poverty Reduction and Economic Management Network (PREM) at The World Bank, will deliver a keynote address at the ICTD 2009 conference in April 2009."};

	var organizers = [];
	organizers[0] = {img:"imgs/organizers/dias.jpg", alt:"M. Bernardine Dias", title:"Organizers", text:"Conference Chair<br/><a href='http://www.cs.cmu.edu/~mbdias'>M. Bernardine Dias, Ph.D.</a>, Founder and Director, TechBridgeWorld; Assistant Research Professor, Carnegie Mellon University"}; 
	organizers[1] = {img:"imgs/organizers/heeks.jpg", alt:"Richard Heeks", title:"Organizers", text:"Program Committee Co-Chair<br/><a href='http://www.sed.manchester.ac.uk/idpm/staff/heeks_richard.htm'>Richard Heeks, Ph.D.</a>, Professor of Development Informatics, The University of Manchester"};
	organizers[2] = {img:"imgs/organizers/tongia.jpg", alt:"Rahul Tongia", title:"Organizers", text:"Program Committee Co-Chair<br/><a href='http://www.epp.cmu.edu/httpdocs/people/bios/tongia.html'>Rahul Tongia, Ph.D.</a>, Associate Director, TechBridgeWorld, Senior Systems Scientist, Carnegie Mellon University, Program Coordinator, CSTEP"};
	organizers[3] = {img:"imgs/organizers/mertz.jpg", alt:"Joseph Mertz", title:"Organizers", text:"Workshops and Panels Co-Chair<br/>Joseph Mertz, Ph.D., Associate Director, TechBridgeWorld, Associate Teaching Professor, Carnegie Mellon University"};
	organizers[4] = {img:"imgs/organizers/harras.jpg", alt:"Khaled Harras", title:"Organizers", text:"Demo Chair<br/>Khaled Harras, PhD., Carnegie Mellon University in Qatar"};
	organizers[5] = {img:"imgs/organizers/cooper.jpg", alt:"Yonina Cooper", title:"Organizers", text:"Publications Chair<br/>Yonina Cooper, PhD., Carnegie Mellon University in Qatar"};
	organizers[6] = {img:"imgs/organizers/parikh.jpg", alt:"Tapan Parikh", title:"Organizers", text:"Poster Chair<br/>Tapan Parikh, PhD., UC Berkeley"};
	organizers[7] = {img:"imgs/organizers/nanayakkara.jpg", alt:"Thrishantha Nanayakkara", title:"Organizers", text:"Publications Chair<br/>Thrishantha Nanayakkara, PhD., Harvard University and University of Moratuwa, Sri Lanka"};
	
	var venue = []
	venue[0] = {img:"imgs/venue/venue1_small.jpg", alt:"Venue", title:"Venue", text:"Carnegie Mellon Qatar offers students in the Gulf access to one of the most highly regarded universities in the United States. Annually ranked one of the country's top-performing institutions, Carnegie Mellon's programs in computer science and business are among its leading assets."};
	venue[1] = {img:"imgs/venue/venue2_small.jpg", alt:"Venue", title:"Venue", text:"Carnegie Mellon Qatar offers students in the Gulf access to one of the most highly regarded universities in the United States. Annually ranked one of the country's top-performing institutions, Carnegie Mellon's programs in computer science and business are among its leading assets."};
	venue[2] = {img:"imgs/venue/venue3_small.jpg", alt:"Venue", title:"Venue", text:"Carnegie Mellon Qatar offers students in the Gulf access to one of the most highly regarded universities in the United States. Annually ranked one of the country's top-performing institutions, Carnegie Mellon's programs in computer science and business are among its leading assets."};
	
	var sponsors = [];
	sponsors[0] = {img:"imgs/sponsors/cmuq_panel_small.jpg", alt:"CMU Qatar", title:"Sponsors", text:"<a href='http://www.qatar.cmu.edu'>Carnegie Mellon University Qatar</a><br/>Carnegie Mellon University in Qatar is committed to bringing the best in interdisciplinary education and research to Qatar and the surrounding region."};
	sponsors[1] = {img:"imgs/sponsors/tbw_panel_small.jpg", alt:"TechBridgeWorld", title:"Sponsors", text:"<a href='http://www.techbridgeworld.org'>TechBridgeWorld, Carnegie Mellon University</a><br/>Organizing Partner<br/>TechBridgeWorld innovates and implements technology solutions to meet sustainable development needs around the world."};
	sponsors[2] = {img:"imgs/sponsors/ictqatar_panel_small.jpg", alt:"ictQatar", title:"Sponsors", text:"<a href='http://www.ict.gov.qa/output/Page2.asp'>ictQatar</a><br/>Organizing Partner<br/>"};
	sponsors[3] = {img:"imgs/sponsors/ibm_panel_small.jpg", alt:"IBM", title:"Sponsors", text:"<a href='http://www.ibm.com'>IBM</a><br/>Bronze Sponsor<br/>"};
	sponsors[4] = {img:"imgs/sponsors/qnrf_panel_small.jpg", alt:"Qatar National Research Fund", title:"Sponsors", text:"<a href='http://www.qnrf.org/'>Qatar National Research Fund</a><br/>Platinum Sponsor<br/>"};
    sponsors[5] = {img:"imgs/sponsors/exxonmobil_panel_small.jpg", alt:"ExxonMobil", title:"Sponsors", text:"<a href='htp://www.exxonmobil.com'>ExxonMobil</a><br/>Gold Sponsor<br/>"};
    sponsors[6] = {img:"imgs/sponsors/idrc_panel_small.jpg", alt:"IDRC", title:"Sponsors", text:"<a href='http://www.idrc.ca/en/ev-1-201-1-DO_TOPIC.html'>The International Development Research Centre (IDRC)</a><br/>Platinum Sponsor<br/>"};
    sponsors[7] = {img:"imgs/sponsors/qtel_panel_small.gif", alt:"Qtel", title:"Sponsors", text:"<a href='http://www.qtel.com.qa/'>Qatar Telecom (Qtel)</a><br/>Platinum Sponsor<br/>"};
    sponsors[8] = {img:"imgs/sponsors/microsoft_panel_small.png", alt:"Microsoft", title:"Sponsors", text:"<a href='http://www.microsoft.com/'>Microsoft</a><br/>Gold Sponsor<br/>"};
    sponsors[9] = {img:"imgs/sponsors/cs_cmuq_panel_small.jpg", alt:"CS @ CMU-Q", title:"Sponsors", text:"<a href='http://www.qatar.cmu.edu/education/?pg=cs'>Computer Science Department, Carnegie Mellon University Qatar</a><br/>Bronze Sponsor<br/>"};
    sponsors[10] = {img:"imgs/sponsors/IEEE_logo_panel_small.jpg", alt:"IEEE", title:"Sponsors", text:"<a href='http://www.ieee.org/'>IEEE</a><br/>Technical Sponsor<br/>"};
    sponsors[11] = {img:"imgs/sponsors/ACM_logo_panel_small.jpg", alt:"ACM", title:"Sponsors", text:"<a href='http://www.acm.org/'>ACM</a><br/>Technical Sponsor<br/>"};
    sponsors[12] = {img:"imgs/sponsors/JCC_panel_small.jpg", alt:"Al Jazeera Children's Channel", title:"Sponsors", text:"<a href='http://www.jcctv.net/'>Al Jazeera Children's Channel</a><br/>Media Sponsor<br/>"};
		
  load(1, keynotespeakers);
	load(2, venue);
	load(3, organizers);
	load(4, sponsors);
}

function news_scroll(newPos)
{
	var curPos = parseInt(document.getElementById('news-list').style.top.split("px")[0], 10);
	if (curPos == newPos)
		return;
	var diff = newPos - curPos;
	var frames = 8.;
	for (var i=1; i<=frames; i++)
		setTimeout("scroll(" + (curPos + (diff)*i/frames) + ")", 200*i/frames);
}

function scroll(pos)
{
	document.getElementById('news-list').style.top = pos + "px";
}

function news_newer()
{
	var newsList = document.getElementById('news-list');
	var totalNews = newsList.getElementsByTagName("li").length;

	currentNews--;
	if (currentNews <= 0)
		currentNews = 0;

	if (currentNews == 0)
		document.getElementById('newer').style.visibility = 'hidden';
	else
		document.getElementById('newer').style.visibility = 'visible';
	document.getElementById('older').style.visibility='visible';

	//newsList.style.top = (-50*currentNews) + "px";
	news_scroll(-itemHeight*currentNews);
}


function news_older()
{
	var newsList = document.getElementById('news-list');
	var totalNews = newsList.getElementsByTagName("li").length;

	currentNews++;
	if (currentNews >= totalNews-itemsDisplayed)
		currentNews = totalNews-itemsDisplayed;

	if (currentNews == totalNews-itemsDisplayed)
		document.getElementById('older').style.visibility='hidden';
	else
		document.getElementById('older').style.visibility='visible';
	document.getElementById('newer').style.visibility='visible';

	//newsList.style.top = (-50*currentNews) + "px";
	news_scroll(-itemHeight*currentNews);
}

function load(id, list)
{
	var content = list[Math.floor(Math.random((new Date()).getTime()) * list.length)];

	var img = document.getElementById("img" + id);
	img.src = content.img;
	img.alt = content.alt;
	
	document.getElementById("title" + id).innerHTML = content.title;
	
	document.getElementById("content" + id).innerHTML = content.text;
}

