/*
MooShow 0.13
http://www.marker.es
----------------------------------------
bassed in Moogets - MorphList 0.5 (formerly SlideList, aka Fancy Menu)
Copyright: Guillermo Rauch <http://devthought.com/> - Distributed under MIT - Keep this message! 
*/
document.addEvent('domready', function () {
       $('footer').getChildren()[3].setStyles({
       "margin-left":"1px",
       "float":"none",
       "display":"inline-block"
       });
       $("menu_lang").getChildren()[0].getChildren().each(
            function(el){
               
                el.addEvent("mousedown",function(ev){
                var menu=$("menu_inicio").getChildren()[0].getChildren();   
                 
                    switch (el.id){
                        case "eu":
                           menu[0].getChildren()[0].set('text',"Garapena");
                           menu[1].getChildren()[0].set('text',"Komunikazioa");
                           menu[2].getChildren()[0].set('text',"Webguneako paper-zorroa");
                           menu[2].getChildren()[0].setStyle('paddingTop',18);
                           menu[3].getChildren()[0].set('text',"Micromarker");
                           $('footer').innerHTML=$('footer').innerHTML.replace("teléfono","telefonoa");
                           $('footer').innerHTML=$('footer').innerHTML.replace("telephone","telefonoa");
                           $('footer').innerHTML=$('footer').innerHTML.replace("burlada","burlata");
                           $('footer').innerHTML=$('footer').innerHTML.replace("navarra","nafarroa");
                           $('footer').innerHTML=$('footer').innerHTML.replace("calle merindad de sangüesa 1 entreplanta e","zangozako merinaldea, 1, solairuartea e");
                           $('footer').innerHTML=$('footer').innerHTML.replace("street merindad de sangüesa mezzanine 1e","zangozako merinaldea, 1, solairuartea e");
                           $('footer').innerHTML=$('footer').innerHTML.replace("&amp;hl=es&amp;msa=0","&amp;hl=eu&amp;msa=0");
                           $('footer').innerHTML=$('footer').innerHTML.replace("&amp;hl=en&amp;msa=0","&amp;hl=eu&amp;msa=0");
                           
                           //$('footer').getChildren()[3].setStyle("margin-left","100px");
                           $('footer').getChildren()[3].getChildren()[0].set('text',"nola heldu?");
			   $('headerInfo').innerHTML="WEBGUNEAK - PAMPLONA - BURLADA - NAVARRA";
			   $('headerInfo').setStyle('margin-left','-170px');
                        break;
                        case "en":
                           menu[0].getChildren()[0].set('text',"Developement");
                           menu[1].getChildren()[0].set('text',"Communication");
                           menu[0].getChildren()[0].setStyle('font-size',"17.5px");
                           menu[1].getChildren()[0].setStyle('font-size',"17.5px");
                           menu[2].getChildren()[0].setStyle('font-size',"17.5px");
                           menu[3].getChildren()[0].setStyle('font-size',"17.5px");
                           menu[2].getChildren()[0].set('text',"Web portfolio");
                            menu[2].getChildren()[0].setStyle('paddingTop',30);
                           menu[3].getChildren()[0].set('text',"Micromarker");
                           $('footer').innerHTML=$('footer').innerHTML.replace("teléfono","telephone");
                           $('footer').innerHTML=$('footer').innerHTML.replace("telefonoa","telephone");
                           $('footer').innerHTML=$('footer').innerHTML.replace("burlata","burlada");
                           $('footer').innerHTML=$('footer').innerHTML.replace("nafarroa","navarra");
                           $('footer').innerHTML=$('footer').innerHTML.replace("calle merindad de sangüesa 1 entreplanta e","street merindad de sangüesa mezzanine 1e");
                           $('footer').innerHTML=$('footer').innerHTML.replace("zangozako merinaldea, 1, solairuartea e","street merindad de sangüesa mezzanine 1e");
                           $('footer').innerHTML=$('footer').innerHTML.replace("&amp;hl=es&amp;msa=0","&amp;hl=en&amp;msa=0");
                           $('footer').innerHTML=$('footer').innerHTML.replace("&amp;hl=eu&amp;msa=0","&amp;hl=en&amp;msa=0");
                          // $('footer').getChildren()[3].setStyle("margin-left","92px");
                           $('footer').getChildren()[3].getChildren()[0].set('text',"how to get here?");
			   $('headerInfo').innerHTML="WEB PAGE DESIGN IN PAMPLONA - BURLADA - NAVARRA";
			   $('headerInfo').setStyle('margin-left','-190px');
                        break;
                        default:
                           menu[0].getChildren()[0].set('text',"Desarrollo");
                           menu[1].getChildren()[0].set('text',"Comunicación");
                           menu[2].getChildren()[0].set('text',"Portafolio web");
                           menu[2].getChildren()[0].setStyle('paddingTop',30);
                           menu[3].getChildren()[0].set('text',"Micromarker");
                           $('footer').innerHTML=$('footer').innerHTML.replace("telefonoa","teléfono");
                           $('footer').innerHTML=$('footer').innerHTML.replace("telephone","teléfono");
                           $('footer').innerHTML=$('footer').innerHTML.replace("burlata","burlada");
                           $('footer').innerHTML=$('footer').innerHTML.replace("nafarroa","navarra");
                           $('footer').innerHTML=$('footer').innerHTML.replace("zangozako merinaldea, 1, solairuartea e","calle merindad de sangüesa 1 entreplanta e");
                           $('footer').innerHTML=$('footer').innerHTML.replace("street merindad de sangüesa mezzanine 1e","calle merindad de sangüesa 1 entreplanta e");
                           $('footer').innerHTML=$('footer').innerHTML.replace("&amp;hl=eu&amp;msa=0","&amp;hl=es&amp;msa=0");
                           $('footer').innerHTML=$('footer').innerHTML.replace("&amp;hl=en&amp;msa=0","&amp;hl=es&amp;msa=0");
                          // $('footer').getChildren()[3].setStyle("margin-left","97px");
                           $('footer').getChildren()[3].getChildren()[0].set('text',"¿cómo llegar?");
			   $('headerInfo').innerHTML="DISEÑO PÁGINAS WEB EN PAMPLONA - BURLADA - NAVARRA";
			   $('headerInfo').setStyle('margin-left','-210px');
                         break;    
                     }
                })
       
            }
      )
})

var MorphList = new Class({   
	
	Implements: [Events, Options],
	
	options: {/*             
		onClick: $empty,
		onMorph: $empty,*/
		morph: { 'link': 'cancel' }
	},
	
	initialize: function(menu, options) {
		var that = this;
		this.setOptions(options);
		this.content =$('contenidos');
		this.menu = $(menu);
		this.menuitems = this.menu.getChildren();
		this.contentitems = this.content.getChildren();
		this.menuitems.addEvents({
			
			mouseover : function(){
                       if(!this.getProperty('title_js')){
                            this.set('title_js',this.get('title'));
			                this.set('title','');
			           //alert(this.getProperty('title_js'))
			           }
			          },

            mousedown: function(){ 
            if(!this.getProperty('title_js')){
                            this.set('title_js',this.get('title'));
			                this.set('title','');
			           //alert(this.getProperty('title_js'))
			           }
			 
            if(this.getProperty('title_js')){
            that.morphTo(this);}
            return false;	
            }		
		});  
		 
		this.bg = new Element('li', {'class': 'background'});
		
		this.bg.inject(this.menu).set('morph', this.options.morph);
		this.setCurrent(this.menu.getElement('.current'));

	},          
    
    mousedown: function(ev, item) {

		this.setCurrent(item, true);
		return false;
		//this.fireEvent('onClick', [ev, item]);
	},
	
	setCurrent: function(el, effect,l){  
		if(el && ! this.current) {
			this.bg.set('styles', { left: el.offsetLeft  });
			(effect) ? this.bg.fade('hide').fade('in') : this.bg.fade('show');
			if (this.options.mode=="marginLeft"){
			var elemento=el.id.split("_")[1];
			$("contenidos").set('styles', { marginLeft : -el.get('title_js')  });
			(effect) ? $(elemento).fade('hide').fade('in') : $(elemento).fade('show');
			}else {
			$("contenidos").set('styles', { marginTop : -el.get('title_js')  });
			(effect) ? $(el.id).fade('hide').fade('in') : $(el.id).fade('show');
			}

		}
		
		if(this.current) this.current.removeClass('current');
		if(el) this.current = el.addClass('current');
		
	},         
         
	morphTo: function(to) {
		if(! this.current) return; 
		this.bg.morph({
			left: to.offsetLeft
			
		});
		if (this.options.mode=="marginLeft"){

		    $("contenidos").morph({
			    marginLeft : -to.get('title_js')
			});
        }else{
		    $("contenidos").morph({
			    marginTop : -to.get('title_js')
			});        
        }
        if(this.current) this.current.removeClass('current');
		if(to) this.current = to.addClass('current');
		
$clear(mov);
$clear(siz);
$('bar').setStyle('width',"0px");
mov=move.periodical(12000);
siz=size.periodical(120);
		
        
		this.fireEvent('onMorph', to);
	}

});
var mov="";
var siz="";
window.addEvent('domready', function() {
new MorphList($('menu_inicio').getElement('ul'), {mode: "marginLeft",tipo: "normal",transition: Fx.Transitions.backOut, duration: 600,onClick: function(ev, item) { 
ev.stop();  
}
});
new MorphList($('menu_lang').getElement('ul'), {mode: "marginTop",tipo: "lang",transition: Fx.Transitions.backOut, duration: 600,onClick: function(ev, item) { ev.stop(); }});
mov=move.periodical(12000);
siz=size.periodical(120);
})
function size(){
    if ($('bar').getStyle('width')=="100px"){
        $('bar').setStyle('width',"0px");
    }
    $('bar').setStyle('width',$('bar').getStyle('width').toInt()+1);
}
function move(){
    var actual="";
    $('menu_inicio').getChildren()[0].getChildren().each(function(el,i){
        if(el.hasClass('current')==true){
            actual=i; 
        }
    })
    $('menu_inicio').getChildren()[0].getChildren().each(function(el,i){
        if(actual==3&&i==0||actual+1==i){
            el.fireEvent('mousedown');
        }
       
    })

}


