// JavaScript Document
function over(e) {
	
	var child = Event.element(e);
	if (child.className=='pestana') {
		child.className = 'pestanahover';
	}
	else {
		child.className = 'pestana';
	}
	
}
function overParent(e) {
	var child = Event.element(e);
	child = child.parentNode;
	if (child.className=='pestana') {
		child.className = 'pestanahover';
	}
	else {
		child.className = 'pestana';
	}
	
}


function overRamos(e) {
	
	var child = Event.element(e);
	if (child.className=='ramos') {
		child.className = 'ramoshover';
	}
	else {
		child.className = 'ramos';
	}
	
}
function overRamosParent(e) {
	var child = Event.element(e);
	child = child.parentNode;
	if (child.className=='ramos') {
		child.className = 'ramoshover';
	}
	else {
		child.className = 'ramos';
	}
	
}

function overTira(e) {
	
	var child = Event.element(e);
	if (child.className=='texto') {
		child.className = 'textohover';
	}
	else {
		child.className = 'texto';
	}
	
}
function overTiraParent(e) {
	var child = Event.element(e);
	child = child.parentNode;
	if (child.className=='texto') {
		child.className = 'textohover';
	}
	else {
		child.className = 'texto';
	}
	
}

function overDestacada(e) {
	var child = Event.element(e);
	
	if (child.className=='pestana_destacada') {
		child.className = 'pestana_destacadahover';
	}
	else {
		child.className = 'pestana_destacada';
	}
}
function overDestacadaParent(e) {
	var child = Event.element(e);
	child = child.parentNode;
	
	if (child.className=='pestana_destacada') {
		child.className = 'pestana_destacadahover';
	}
	else {
		child.className = 'pestana_destacada';
	}
}

function clickDestacado(e) {
	var child = Event.element(e).up(1);
	var url = child.down('a', 1);
	
	if (url!=undefined){
		window.location = url;
	}
}

function clickDestaca(e) {
	var child = Event.element(e).up('.destaca');
	var url = child.down('a').href;
	if (url!=undefined){
		window.location = url;
	}
}

function click(e) {
	var child = Event.element(e);
	var url = child.childNodes[0].href;
	
	if (url!=undefined){
		window.location = url;
	}
}

function showLayer(e) {
	var child = Event.element(e);
	
	// show o hide capa + turn arrow
	var option = $$("."+child.id);
	option.each(function(obj){
		obj.style.display = obj.style.display==""?'none':'';
	});

	var obj = $(child.id);
	obj.className = obj.className=="arrowdown"?'arrow':'arrowdown';
	
	child.className = obj.className=="arrowdown"?'opcion_over':'opcion';
}

function showLayer2(e) {
	var child = Event.element(e);
	
	// show o hide capa + turn arrow
	var option = $$("."+child.id);
	option.each(function(obj){
		obj.style.display = obj.style.display==""?'none':'';
	});

	var obj = $(child.id);
	obj.className = obj.className=="mini_arrowdown"?'mini_arrow':'mini_arrowdown';
}


function showLayer_transporte(e) {
	var child = Event.element(e);
	
	// show o hide capa + turn arrow
	var option = $$("."+child.id);
	option.each(function(obj){
		obj.style.display = obj.style.display==""?'none':'';
	});

	var obj = $(child.id);
	obj.className = obj.className=="opcion_transporte_down"?'opcion_transporte':'opcion_transporte_down';
}

function showLayer_telefonos(e) {
	var child = Event.element(e);
	// show o hide capa + turn arrow
	var option = $$("."+child.id);
	option.each(function(obj){
		obj.style.display = obj.style.display==""?'none':'';
	});

	var obj = $(child.id);
	obj.className = obj.className=="arrowdown"?'arrow':'arrowdown';
		
}

window.onload = function() {
	// over de las pestañas
	var option = $$('#pestanaContainer .pestana');
	option.each(function(obj){
		Event.observe(obj, 'click', click, true);
		Event.observe(obj, 'mouseout', over, true);
		Event.observe(obj, 'mouseover', over, true);
	});
	var option = $$('#pestanaContainer .pestana a');
	option.each(function(obj){
		Event.observe(obj, 'mouseout', overParent, true);
		Event.observe(obj, 'mouseover', overParent, true);
	});


	// over de la pestaña destacada
	var option = $$('#pestanaContainer .pestana_destacada');
	option.each(function(obj){
		Event.observe(obj, 'mouseout', overDestacada, true);
		Event.observe(obj, 'mouseover', overDestacada, true);
	});
	var option = $$('#pestanaContainer .pestana_destacada a');
	option.each(function(obj){
		Event.observe(obj, 'mouseout', overDestacadaParent, true);
		Event.observe(obj, 'mouseover', overDestacadaParent, true);
	});


	if ($('ramos')!=null) {
		var option = $$('.ramos');
		option.each(function(obj){
			Event.observe(obj, 'click', click, true);
			Event.observe(obj, 'mouseout', overRamos, true);
			Event.observe(obj, 'mouseover', overRamos, true);
		});
		var option = $$('.ramos a');
		option.each(function(obj){
			Event.observe(obj, 'mouseout', overRamosParent, true);
			Event.observe(obj, 'mouseover', overRamosParent, true);
		});
	}
	
	if ($('tira')!=null) {
		var option = $$('.tira');
		option.each(function(obj){
			Event.observe(obj, 'click', clickDestacado, true);
			Event.observe(obj, 'mouseout', overTira, true);
			Event.observe(obj, 'mouseover', overTira, true);
		});
		var option = $$('.tira a');
		option.each(function(obj){
			Event.observe(obj, 'mouseout', overTiraParent, true);
			Event.observe(obj, 'mouseover', overTiraParent, true);
		});
	}
	if ($('destaca')!=null) {
		var option = $$('.destaca');
		option.each(function(obj){
			Event.observe(obj, 'click', clickDestaca, true);
			/*Event.observe(obj, 'mouseout', overDestacado, true);
			Event.observe(obj, 'mouseover', overDestacado, true);*/
		});
		var option = $$('.destaca a');
		option.each(function(obj){
			/*Event.observe(obj, 'mouseout', overDestacadoParent, true);
			Event.observe(obj, 'mouseover', overDestacadoParent, true);*/
		});
	}
	
	if ($('desplegable')!=null) {
		var option = $$('#desplegable .opcion');
		option.each(function(obj){
			Event.observe(obj, 'click', showLayer, true);
			
			// de paso los ocultamos por defecto
			var optionx = $$("."+obj.id);
			optionx.each(function(objx){
				objx.style.display = objx.style.display==""?'none':'';
			});
			
		});
		
		var option = $$('#desplegable .opcion_boldRojo');
		option.each(function(obj){
			Event.observe(obj, 'click', showLayer2, true);
			
			// de paso los ocultamos por defecto
			var optionx = $$("."+obj.id);
			optionx.each(function(objx){
				objx.style.display = objx.style.display==""?'none':'';
			});
			
		});
		
		var option = $$('#desplegable .opcion_transporte');
		option.each(function(obj){
			Event.observe(obj, 'click', showLayer_transporte, true);
			
			// de paso los ocultamos por defecto
			var optionx = $$("."+obj.id);
			optionx.each(function(objx){
				objx.style.display = objx.style.display==""?'none':'';
			});
			
		});
		
		var option = $$('#desplegable .flecha_tel');
		option.each(function(obj){
			Event.observe(obj, 'click', showLayer_telefonos, true);
			
			// de paso los ocultamos por defecto
			
			var optionx = $$("."+obj.id);
			optionx.each(function(objx){
				objx.style.display = objx.style.display==""?'none':'';
			});
			
		});
	}
	if($('contenedor1')!=null){
	var capa_img1 = document.getElementById("contenedor1");
	capa_img1.style.display = 'none';
	var capa_img2 = document.getElementById("contenedor2");
	capa_img2.style.display = 'none';
	}
	
	// oculta la capa del video de la HOME
	div = document.getElementById('contenido1');
	if(div!=null){
	//Element.Methods.setOpacity(div,0);
	//div.opacity =1;
	div.filter = "alpha(opacity=0)";
	//div.style.display='none';
	div2 = document.getElementById('contenido2');
	//div2.opacity =1;
	div2.filter = "alpha(opacity=0)";
	//div2.style.display='none';
	}
}
/*Muestra la capa de los videos*/
function opacity(opacStart, opacEnd, millisec, num) {
div = document.getElementById('contenido'+num);
div.style.display = 'block';
var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + div + "','"+ num +"','"+opacEnd+"')",(timer * speed));
            timer++;
			
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + div + "','"+ num +"','"+opacEnd+"')",(timer * speed));
            timer++;
			div.style.display='block';
        }
    }
}
//change the opacity for different browsers
//CARGA o ELIMINA EL VIDEO EN CUESTIÓN DEPENDIENDO DE LA OPACIDAD(0-100) Y EL VALOR FINAL DE LA OPACIDAD(0-100)
function changeOpac(opacity, object, numvideo,valor) {
	
   /* object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";*/
	//Element.Methods.setOpacity(objectIE,opacity/100);
	if(opacity==0){
		div.style.display='none';
	}
	if(opacity==100 && valor==0){
		if($('player')!=null){
			var borraVideo=document.getElementById('player');
			borraVideo.parentNode.removeChild(borraVideo);
		}
	}
	if(opacity==100 && valor==100){
		var creaVideo=document.getElementById('video'+numvideo);
			creaVideo.innerHTML="<div id='player'></div>";
			swfobject.embedSWF("player.swf?file=flv/video"+numvideo+".flv&autostart=true",'player', "413", "268", "8.0.0"); 
	}
}
//Layer seccion Contrata tu seguro de vida - Sencillos pasos
function muestraCapa(e){
	var capa_img = document.getElementById("contenedor"+e);
	capa_img.style.display = '';
}
function escondeCapa(e){
	var capa_img = document.getElementById("contenedor"+e);
	capa_img.style.display = 'none';
}

// añadir a favoritos
function add() {
if (window.sidebar&&window.sidebar.addPanel)
	window.sidebar.addPanel("URQUIA & BAS - Correduría de seguros","http://www.google.com","");
else
	window.external.AddFavorite("http://www.google.com","URQUIA & BAS - Correduría de seguros")
}
