if (document.getElementById){
	if(pag=='index.php'){
		document.write('<style type="text/css">#elmenu {display: none;} </style>');
	} else {
		document.write('<style type="text/css">#elmenucontent {display: none;} </style>');
	}
	// link de contacto
	function veacontacto(desde){
		if(document.getElementById('desde')&&document.getElementById('acontacto')){
			document.getElementById('desde').value=desde;
			document.getElementById('acontacto').submit();
		}
	} 
};


//*************funciones****************
function desplegablesunfx(cual){
	window['myVerticalSlide'+cual] = new Fx.Slide('desplegable'+cual).hide();
		$('toggler'+cual).addEvent('click', function(){
		if(window['myVerticalSlide'+cual].open){$('toggler'+cual).setStyle('background-position', '0 0');}else{$('toggler'+cual).setStyle('background-position', '0 -30px');};
		window['myVerticalSlide'+cual].toggle();
	});	
}

function funcmessenger(){	
	window.messabierto=false;
		var logofx = new Fx.Tween('messenger');
		logofx.start('margin-top', '-20', '0');
		$$('#messenger span').addEvent('mouseenter', function(){
			if(!window.messabierto)logofx.set('margin-top', 3);
		 });
		$$('#messenger span').addEvent('mouseleave', function(){
			if(!window.messabierto)logofx.set('margin-top', 0);
		 });
		//apertura messenger
		if(!Browser.Engine.trident4){ //si no es ie6
			window.veomess = new Fx.Tween('messenger',{duration:150, transition: Fx.Transitions.Quad.easeIn});
			$$('#messenger span').addEvent('click',function(){
				if(!window.messabierto){
					
					veomess.start('margin-top',223).chain(function(){window.messabierto=true;});
				}
			});
		//cerrar messenger
			$('precontenedor').addEvent('click',function(){
				if(window.messabierto){
					veomess.set('margin-top',0);window.messabierto=false;
				}
			});
		}
	}
	
	
//menu
function funcmenu(){
	function abrir(){
		$('elmenu').setStyle('width','1000px');
		veomenu.start('margin-left',0).chain(function(){window.menuabierto=true});
	}
	function cerrar(){
		veomenu.set('margin-left',-1000);
		$('elmenu').setStyle('width',60);
		window.menuabierto=false;
	}
		
		$('elmenucontent').setStyle('display','block');
		$('elmenu').setStyle('width',60);
		var veomenu = new Fx.Tween('elmenucontent',{duration:150, mode:'horizontal', transition: Fx.Transitions.Quad.easeOut}).set('margin-left',-1000);
		window.menuabierto=false;
		
		$('elmenubot').addEvent('click',function(){ 
			if(!window.menuabierto){abrir();
			}else{
				if(window.menuabierto){cerrar();}
			}
		});
		window.onscroll = function(){
			if(window.menuabierto){cerrar();}
		}
		$('precontenedor').addEvent('click',function(){
			if(window.menuabierto){cerrar();}
		 });
}



//**************domready******************
window.addEvent('domready', function() {
	//headerflash
	if(hasRightVersion && document.getElementById('headerflash')) {fohead.write("headerflash");}
									 
	//menu
	    funcmenu();
									 
	// desplegables sunfx
		if (document.getElementById('desplegable1'))desplegablesunfx(1);
		if (document.getElementById('desplegable2'))desplegablesunfx(2);

	//acordion sunfx
	if (document.getElementById('acordeonsunfx')){
		var myAccordion = new Accordion($('acordeonsunfx'), 'h3.h4acordion', 'div.contenidoacor', {
			opacity: false,
			onActive: function(toggler, element){
	
			},
			onBackground: function(toggler, element){
	
			}
		});
	}
		if (document.getElementById('hsacordionh')){
		var myAccordion = new Accordion($('hsacordionh'), 'div.hshtitulo', 'div.hsacordioncontenido', {
			opacity: false,
			onActive: function(toggler, element){
	
			},
			onBackground: function(toggler, element){
	
			}
		});
	}

	//animación logo
	if (document.getElementById('mainlogo')){	
		var logofx = new Fx.Tween('mainlogo',{duration:1200});
		logofx.start('margin-top', 125, 0);
		$$('#mainlogo img').addEvent('mouseenter', function(){
			$('mainlogo').setStyle('margin-top',5);
		 });
		$$('#mainlogo img').addEvent('mouseleave', function(){
			$('mainlogo').setStyle('margin-top',0);
		 });
	}

	//animaciòn contacto
	if (document.getElementById('contacto')){	
		var logofx = new Fx.Tween('contacto');
		logofx.start('margin-top', '-20', '0');
		$$('#contacto img').addEvent('mouseenter', function(){
			$('contacto').setStyle('margin-top',3);
		 });
		$$('#contacto img').addEvent('mouseleave', function(){
			$('contacto').setStyle('margin-top',0);
		 });
	}
	
	//animaciòn tel
	if (document.getElementById('telmain')){	
		var logofx = new Fx.Tween('telmain');
		logofx.start('margin-top', '-20', '0');
		$$('#telmain img').addEvent('mouseenter', function(){
			$('telmain').setStyle('margin-top',3);
		 });
		$$('#telmain img').addEvent('mouseleave', function(){
			$('telmain').setStyle('margin-top',0);
		 });
	}

	//animaciòn messenger
	//if (document.getElementById('messenger'))funcmessenger();
	
	//brillos en links y pestañas
	if(!Browser.Engine.trident4){ //si no es ie6
		var laspics = $$('#info div p a, #info ul.navbar a, #info p a, #info .logos a, #logobronceado a, #info #enpestanas2 .colizqp2 li');
		laspics.each(function(element) {
		var fx = new Fx.Tween(element, {duration:150, wait:false});
		element.addEvent('mouseenter', function(){
				fx.start('opacity', '.3').chain(function(){fx.start('opacity', '1')});
			});
	 
			element.addEvent('mouseleave', function(){
				fx.start('opacity', '1');
			});
		});
	}
	
	//enpestanas2 (camas)
	if (document.getElementById('enpestanas2')){myTabs2 = new mootabs('enpestanas2', {width: 'auto', height: '350px', activateOnLoad: 'first', duration: 1000})};
	
	//smooth anchors
	new SmoothScroll({ duration: 600 }, window);

});
