function getW() 
{
      var vw = 
      (document.documentElement && document.documentElement.clientWidth)?document.documentElement.clientWidth:
      (document.body && document.body.clientWidth)?document.body.clientWidth:
      (window.innerWidth)?window.innerWidth-18:
      0;
      return vw;
};

Fx.Properties = Fx.Styles.extend({	
	increase: function(){for (var p in this.now) this.element[p] = this.now[p];}
});

Fx.FlyingScroller = Fx.Properties.extend({
	initialize: function(el, options){
		this.parent(el, options);
		el.style.paddingLeft = (getW() / 2) + 'px';
		this.options = Object.extend(this.options || {}, Object.extend({
			paddingLeft: 0,
			paddingTop: 0
		}, options || {}));
	},
	toElement: function(el, paddingLeft, paddingTop){
		// en IE rula este... this.goTo(el.offsetLeft-(getW() / 2) + 3 * (el.offsetWidth / 2) , el.offsetTop - (paddingTop || this.options.paddingTop || 0));
		this.goTo(el, el.offsetLeft-(getW() / 2) + (el.offsetWidth / 2) , el.offsetTop - (paddingTop || this.options.paddingTop || 0));
	},
	goTo: function(el, x, y){
		theId = el.id;
		this.custom({
			'scrollLeft': [this.element.scrollLeft, x],
			'scrollTop': [this.element.scrollTop, y]
		}).addEvent('onComplete', function() { kiu_showInfoPanel(theId);});
	}
	
});

var kiu_current_panel = false;
var kiu_visible_panel = false;

function setCurrentPanel(panelId){
	kiu_current_panel = 'content'+panelId;
}

function kiu_showInfoPanel(containerId) {
	
	if(!kiu_visible_panel || (kiu_visible_panel!=containerId)) {
		kiu_visible_panel = containerId;
	}else {
		return;
	}

	var theId = containerId.substr(7);
	var infoPanel = $('infopanel'+theId);
	//cleanup warnings
	if(typeof(infoPanel.effect) == 'function'){
		$$('.infopanel').each(function(node){
			if(node.style.right){
				if((node.id!='infopanel'+theId) && (node.style.right == '0px')){
					node.effect('right', {duration:500, transition: Fx.Transitions.quintOut}).start(0, -200);
				}

			}
		})
		infoPanel.effect('right', {duration:500,  transition: Fx.Transitions.quintOut}).start(-200, 0);
	}
	
	
}


function mifuncion(element){
	// i wanna know!
	str = '';
	for(p in element){
		str+= p+': '+ element[p];
	}
	alert(str);
}

window.onload = function() {
	//var slideAppear = new Fx.Style('container', 'opacity', {duration:1200, wait:false}).custom(0, 1);
	var slideOpen = new Fx.Style($('container'), 'height', {duration:1600, wait:false, transition: Fx.Transitions.bounceOut		}).start(440);
	var slideOpen2 = new Fx.Style($('show-wrap'), 'top', {duration:600, wait:true}).set(-500);
	
	function openSlides(){
		slideOpen.start(440);
		slideOpen2.start(50);
		var slideOpen4 = new Fx.Style($('menu'), 'top', {duration:900, wait:true}).custom(-100, 0);
	}

	openSlides.delay(2000);

};
