
window.addEvent('domready', function(){
	var altura = $('contenido-wp').offsetHeight;
	$('pie').setStyle('top',534+altura+70);

////////////////////////////////////////////////////////////////////
	///// ICONOS MARCAS ////////////////////////////////////////////////////////////////////
	var trasicionMarcas = new Fx.Transition(Fx.Transitions.Expo, 3);
	var mCreatividad = $('mCre').effect('margin-top', {transition: trasicionMarcas.easeOut});
	$('mensajeCreatividad').addEvent('mouseenter', function(event){
		mCreatividad.start(160,0);
	});
	$('mensajeCreatividad').addEvent('mouseleave', function(event){
		mCreatividad.stop();
		mCreatividad.start(0,160);
	});
	var mProduccion = $('mPro').effect('margin-top', {transition: trasicionMarcas.easeOut});
	$('mensajeProduccion').addEvent('mouseenter', function(event){
		mProduccion.start(160,0);
	});
	$('mensajeProduccion').addEvent('mouseleave', function(event){
		mProduccion.stop();
		mProduccion.start(0,160);
	});
	var mPlanificacion = $('mPla').effect('margin-top', {transition: trasicionMarcas.easeOut});
	$('mensajePlanificacion').addEvent('mouseenter', function(event){
		mPlanificacion.start(160,0);
	});
	$('mensajePlanificacion').addEvent('mouseleave', function(event){
		mPlanificacion.stop();
		mPlanificacion.start(0,160);
	});
	var mImpresion = $('mImp').effect('margin-top', {transition: trasicionMarcas.easeOut});
	$('mensajeImpresion').addEvent('mouseenter', function(event){
		mImpresion.start(160,0);
	});
	$('mensajeImpresion').addEvent('mouseleave', function(event){
		mImpresion.stop();
		mImpresion.start(0,160);
	});
	
	$('mensajeCreatividad').addEvent('click', function(event){
		document.location = '/creatividad/';
	});
	$('mensajeProduccion').addEvent('click', function(event){
		document.location = '/produccion/';
	});
	$('mensajePlanificacion').addEvent('click', function(event){
		document.location = '/planificacion/';
	});
	$('mensajeImpresion').addEvent('click', function(event){
		document.location = '/impresion/';
	});
	
	var buscador = $('buscador-rapido').effect('top', {transition: trasicionMarcas.easeOut});
	var reloj = { contador: 0 };
	var timeBuscador;
	var controlBuscador = function(){ 
		this.contador++;
		if (this.contador>3) {
			buscador.stop();
			buscador.start(60,-9);
			$clear(timeBuscador);
			this.contador = 0;
		}
	};
	$('menuBuscador').addEvent('mouseenter', function(event){
		if (reloj.contador==0) {
			buscador.start(-9,60);
		} else {
			$clear(timeBuscador);
			reloj.contador = 0;
		}
	});
	$('menuBuscador').addEvent('mouseleave', function(event){
		reloj.contador++;
		timeBuscador = controlBuscador.periodical(100, reloj);
	});
	$('buscador-rapido').addEvent('mouseenter', function(event){
		$clear(timeBuscador);
		reloj.contador = 0;
	});
	$('buscador-rapido').addEvent('mouseleave', function(event){
		reloj.contador++;
		timeBuscador = controlBuscador.periodical(100, reloj);
	});
	
	var contacto = $('contacto-rapido').effect('top', {transition: trasicionMarcas.easeOut});
	var relojC = { contador: 0 };
	var timeContacto;
	var controlContacto = function(){ 
		this.contador++;
		if (this.contador>3) {
			contacto.stop();
			contacto.start(60,-9);
			$clear(timeContacto);
			this.contador = 0;
		}
	};
	$('menuContacto').addEvent('mouseenter', function(event){
		if (relojC.contador==0) {
			contacto.start(-9,60);
		} else {
			$clear(timeContacto);
			relojC.contador = 0;
		}
	});
	$('menuContacto').addEvent('mouseleave', function(event){
		relojC.contador++;
		timeContacto = controlContacto.periodical(100, relojC);
	});
	$('contacto-rapido').addEvent('mouseenter', function(event){
		$clear(timeContacto);
		relojC.contador = 0;
	});
	$('contacto-rapido').addEvent('mouseleave', function(event){
		relojC.contador++;
		timeContacto = controlContacto.periodical(100, relojC);
	});
	
///////////////////////////////////////////////////////////////////
	///// MENU PRINCIPAL ///////////////////////////////////////////////////////////////////
	var inicioSeccion = $('menuLinea').getStyle('margin-left').toInt();
	var trasicionMenu = new Fx.Transition(Fx.Transitions.Expo, 3);
	var mLinea = $('menuLinea').effect('margin-left', {transition: trasicionMenu.easeOut});
	$('menuInicio').addEvent('mouseover',function(){
		mLinea.stop();
		var inicio = $('menuLinea').getStyle('margin-left').toInt();
		mLinea.start(inicio,-160);
	});
	$('menuEquipo').addEvent('mouseover',function(){
		mLinea.stop();
		var inicio = $('menuLinea').getStyle('margin-left').toInt();
		mLinea.start(inicio,-85);
	});
	$('menuEmpresa').addEvent('mouseover',function(){
		mLinea.stop();
		var inicio = $('menuLinea').getStyle('margin-left').toInt();
		mLinea.start(inicio,0);
	});
	$('menuServicios').addEvent('mouseover',function(){
		mLinea.stop();
		var inicio = $('menuLinea').getStyle('margin-left').toInt();
		mLinea.start(inicio,90);
	});
	$('menuProyectos').addEvent('mouseover',function(){
		mLinea.stop();
		var inicio = $('menuLinea').getStyle('margin-left').toInt();
		mLinea.start(inicio,185);
	});
	$('menuContacto').addEvent('mouseover',function(){
		mLinea.stop();
		var inicio = $('menuLinea').getStyle('margin-left').toInt();
		mLinea.start(inicio,283);
	});
	$('menuBuscador').addEvent('mouseover',function(){
		mLinea.stop();
		var inicio = $('menuLinea').getStyle('margin-left').toInt();
		mLinea.start(inicio,377);
	});
	$('menuBotones').addEvent('mouseout',function(){
		mLinea.stop();
		var inicio = $('menuLinea').getStyle('margin-left').toInt();
		mLinea.start(inicio,inicioSeccion);
	});

});

function borraValue(campo,valor){
	if ( campo.value == valor ) { campo.value = ''; }
	else if ( campo.value == '' ) { campo.value = valor; }
}

function frValidar(f){
	if (document.getElementById('frEmail').value=='Email') {
		alert('Rellena al menos el email antes de enviarnos el formulario.');
		return false;
	} else {
		return true;
	}
}

function contactoValidar(f){
	if (document.getElementById('email').value=='' && document.getElementById('telefono').value=='') {
		alert('Rellene al menos el email o el télefono antes de enviarnos el formulario, asi podremos responderle.');
		return false;
	} else {
		return true;
	}
}
