var M = new Class({
		isDown: 0,
		initialize: function(){
			this.btn = $('universHandler');
			this.fx = new Fx.Tween($('univers'), {duration:300});
			//this.btn.addEvent('click', this.change.bind(this));
		},

		change: function(){
			if(this.isDown){
				this.up();
				this.isDown = 0;
				this.btn.className = 'universHandler';
			}else{
				this.down();
				this.isDown = 1;
				this.btn.className = 'universHandler universOn';
			}
		},

		up: function(){
			this.fx.start('height', 109);
		},

		down: function(){
			this.fx.start('height', 327);
		}
	});

function getWeather(){
	var weather = document.getElementById('weatherList');
	new Request.HTML({update:weather}).get('/include/get_weather.php');
}
function getJr(){
	var jr = document.getElementById('jr');
	new Request.HTML({update:jr}).get('/include/jr.php');
}

var MScroll = new Class({
		scrollBox:null,
		delay: 5*1000,
		t: 0,
		Fx:null,
		cur: 0,
		initialize: function(){
			this.scrollBox = $('univers');
			this.scrollBox.addEvent('mouseover', this.pause.bind(this));
			this.scrollBox.addEvent('mouseout', this.start.bind(this));
			this.Fx = new Fx.Scroll(this.scrollBox);
			this.clone();
			this.start();
		},
		
		clone:function(){
			var list = this.scrollBox.getElementsByTagName('li');
			var tem = document.createDocumentFragment();
			for(var i=0; i<6; i++){
				var li = list[i].cloneNode(true);
				tem.appendChild(li);
			}
			this.scrollBox.getElementsByTagName('ul')[0].appendChild(tem);
		},
		
		start: function(){
			clearTimeout(this.t);
			this.t = setTimeout(this.scrolling.bind(this), this.delay);
		},
		
		pause: function(){
			clearInterval(this.t);
		},
		
		scrolling: function(){
			if(this.cur==3){
				this.Fx.set(0,0);
				this.cur=1;
			}else{
				this.cur++;	
			}
			this.Fx.start(0, this.cur*109);
			this.start();
		}
});

var mScroll;
window.addEvent('domready', function(){mScroll = new MScroll; getJr(); getWeather()});

/*
function addBookmark()   
{ 
	try {
			if (document.all) {	
				window.external.addFavorite("http://www.holaes.com/", "千奕国际西班牙留学网");   
			}else if (window.sidebar){ 
				window.sidebar.addPanel("千奕国际西班牙留学网", "http://www.holaes.com/","");
			}else{
				alert("您的浏览器不支持自动加入收藏，请使用Ctrl+D进行手动添加！");
			}
	}catch (ee){
		alert("您的浏览器不支持自动加入收藏，请使用Ctrl+D进行手动添加！！");
	}
}

var isIE=!!window.ActiveXObject;
var isIE6=isIE&&!window.XMLHttpRequest;	
if (isIE6){		
	window.onbeforeunload = addBookmark;
}else {
	window.onunload = addBookmark;
}
*/