//new Effect.Move(object, { x: 0, y: 0, mode: 'absolute' });
window.onload= function(){
	log('trying move');
	//GUI.Position.move(document.getElementById('weatherbox'), -100, 0, 1000);
	
	
	window.weather_box = new weatherbox(null, document.getElementById('weatherbox'), window);
}

weatherbox = Prototype.construct({
	elements:null,
	initialize:function(parameters, node, base){
		this.container = node;
		this.elements = [];
		
		current_left = 0;
		
		for(var i in this.container.childNodes){
			node = this.container.childNodes[i];
			
			if(node.nodeType != 1) continue;
			
			if(node.tagName.toLowerCase() == 'div'){
				this.elements.push(node);
			}
			
			
			node.style.left = current_left +'px';
			current_left += node.offsetWidth + 10;
		}
		
		this.total_left = current_left;
		log(this.elements);
		
		this.playing = true;
		//setInterval($handler(this,'start'), 200);
		//setTimeout($bind(this,'start'), 10);
		
		if ((oil.browser.is_ie) && (oil.browser.engine.version == 7)) this.start_ie();
		else this.start();
	},
	start:function(){
		// current x and ys of all elements to be calculated, if one falls off, put it at the end
		lefts = this.lefts = [];
		
		for(var i in this.elements){
			node = this.elements[i];
			lefts[i] = (node.offsetLeft - 2) + 'px';
			
			// if weve shifted past left overflow
			if(node.offsetLeft < (0-node.offsetWidth)){
				lefts[i] = (this.total_left - node.offsetWidth) + 'px';
			}
			node.style.left = lefts[i]
		}

		this.do_scroll();
		
		setTimeout($bind(this,'start'), 20);
	},
	start_ie:function(){
		// current x and ys of all elements to be calculated, if one falls off, put it at the end
		lefts = this.lefts = [];
		
		for(var i in this.elements){
			node = this.elements[i];
			lefts[i] = (node.offsetLeft - 1) + 'px';
			
			// if weve shifted past left overflow
			if(node.offsetLeft < (0-node.offsetWidth)){
				lefts[i] = (this.total_left - node.offsetWidth) + 'px';
			}
			node.style.left = lefts[i]
		}

		this.do_scroll();
		
		setTimeout($bind(this,'start_ie'), 30);
	},
	pause:function(){
		this.playing = false;
		setTimeout($bind(this,'play'), 2000);
	},
	play:function(){
		this.playing = true;
	},
	do_scroll:function(){
		
		for(var i in this.elements){
			//node.style.display = 'none';
			this.elements[i].style.left = this.lefts[i];
		}
		return;
	},
	stop:function(){
	
	}
});

function sinus(x){
return 250*((x/30)*(x/30))+150;
}
