


  var newsArray = new Array(
	new Array('Capoeira Semineri','http://announce.metu.edu.tr/show.php?whereami=showdetails&TR=en_&id=1377'),
	new Array('Esli Danslar Toplulugu 2.tur Dansçi Seçmeleri ve Sahne Arkasi Ekibi Tanisma Toplantisi','http://announce.metu.edu.tr/show.php?whereami=showdetails&TR=en_&id=1373'),
	new Array('Ayva Kupasi Basketbol Müsabakalari','http://announce.metu.edu.tr/show.php?whereami=showdetails&TR=en_&id=1372'),
	new Array('Akademik Basari Nasil Saglanir?-Egitim Programi- PDRM', 'http://announce.metu.edu.tr/show.php?whereami=showdetails&TR=en_&id=1365'),
	new Array('Tenis Partnerlik Servisi', 'http://announce.metu.edu.tr/show.php?whereami=showdetails&TR=en_&id=1361')
	);


    function ItemScroll(instance_name, div_left, div_top, div_width, div_height){

	if (window.ItemScrollInstance != null){
		//window.alert("Only one ItemScroll instance is allowed on a page.");
	}
	window.ItemScrollInstance = this;

	this.name = instance_name;
	this.stepSize = 1;

	this.createDiv = ItemScroll_createDiv;
	this.scroll = ItemScroll_scroll;
	this.start = ItemScroll_start;
	this.stop = ItemScroll_stop;
	this.goon = ItemScroll_goon;

	this.div_left = div_left;
	this.div_top = div_top;
	this.div_width = div_width;
	this.div_height = div_height;
	this.bottom_p = 0;
	this.th = null;

    }


    function ItemScroll_createDiv(){

	var si = window.ItemScrollInstance;

	var i;
	var news = newsArray;
	var div;

	div = document.createElement('div');

	div.id = "news";
	div.style.position = 'absolute';
	div.style.overflow = 'hidden';
	div.style.width = this.div_width;;
	div.style.height = this.div_height;
	div.style.left = this.div_left;
	div.style.top = this.div_top;
	div.style.background = 'rgb(224, 224, 224)';
	div.style.border = '1px solid rgb(100,100,150)';

	div.style.filter = 'alpha(opacity=50)'; //IE specific
	div.style.opacity = 0.5;
	div.style.moz_opacity=0.5;

	div.attributes.setNamedItem(document.createAttribute('onmouseover'));
	div.attributes.getNamedItem('onmouseover').nodeValue = si.name + '.stop()';

	div.attributes.setNamedItem(document.createAttribute('onmouseout'));
	div.attributes.getNamedItem('onmouseout').nodeValue = si.name + '.goon()';

	var last_buttom = 0;
	for(i=0; i<news.length; i++){

		var p = document.createElement('p');
		p.id = 'p_' + i;
		p.style.position = 'absolute';
		p.style.left = 10;
		p.style.top = last_buttom + si.stepSize;
		last_buttom = (news[i][0].length < 60) ? (parseInt(p.style.top) + 20) : (parseInt(p.style.top) + 45);

		var a = document.createElement('a');
		a.href = news[i][1];

		var tn = document.createTextNode(news[i][0]);

		a.appendChild(tn);

		a.style.color ='rgb(0,0,0)';
		a.style.fontSize = '12px';
		a.style.fontFamily = 'Arial, Helvetica, sans-serif';
		a.style.fontWeight = 'bold';

		p.appendChild(a);

		div.appendChild(p);		
		
	}

	this.bottom_p = last_buttom;

	document.getElementsByTagName('body')[0].appendChild(div);
    }

    function ItemScroll_scroll(){

	var si = window.ItemScrollInstance;
	var div_height = this.div_height;
	var div = document.getElementById("news");
	var ps = div.getElementsByTagName("p");

	var i;
	// update the new top positions
	for(i=0; i<ps.length; i++){
		var xx = (parseInt(ps[i].style.top)) ? (parseInt(ps[i].style.top)) : 0;
		ps[i].style.top = xx - si.stepSize;
	}
	si.bottom_p -= si.stepSize;

	var j;
	// move the items that are not displayed to the bottom
	for (j=0; j<ps.length; j++){
		var xx = (parseInt(ps[j].style.top)) ? (parseInt(ps[j].style.top)) : 0;
		if(xx<-20){
			si.bottom_p = (si.div_height > si.bottom_p) ? (si.div_height-20) : si.bottom_p;
			ps[j].style.top = si.bottom_p;
			si.bottom_p += (ps[j].childNodes[0].childNodes[0].length < 50) ? 20 : 50;
		}
	}

    }


    function ItemScroll_start(){
	this.createDiv();
	this.th = window.setInterval(ItemScroll_scroll, 90);
	return;
    }

    function ItemScroll_stop(){
	window.clearInterval(this.th);
	return;
    }

    function ItemScroll_goon(){
	this.th = window.setInterval(ItemScroll_scroll, 90);
	return;
    }


