/**************************    PESTANAS       *********************************/
var introtabs = Class.create();
introtabs.prototype = {
  initialize: function(container, options) {
	  	this.fadefx,
		this.tmout,
		this.max_tabs,		
		this.options = Object.extend({
			classNames: {
				tabContent: 'tabcontent',
				tab:      	'tab',
				tabActive:  'selected'
			},
			contentSuffix: 'cnt',
			sep:		  '_',	
			onEvent:      'click',
			effects:      true,
			tabActive:	 ( typeof(tabActiva) == "undefined" ) ? 'tab1' : 'tab'+tabActiva,
			duration: 	  '0.8',
			rotacion: 	  ( typeof(tabActiva) == "undefined" ),			
			intervalo:	  15000,
			id_activo: 	  ( typeof(tabActiva) == "undefined" ) ? 1 : tabActiva
		}, options || {} );
	var tabsid = [];	
  	container = $(container);
  	var tabs = $$("#" + container.id + " ." + this.options.classNames.tab);
	this.options.tabActive = container.id + this.options.sep + this.options.tabActive;
	this.options.max_tabs = tabs.length;
  	tabs.each(function(tab) {
      Event.observe(tab, this.options.onEvent, this.activate.bind(this, container, tab, true), false);
      tab.id = container.id + this.options.sep + tab.href.split("#").last();
      tab.href = "javascript:;";
    }.bind(this));
  	$$("#" + container.id + " ." + this.options.classNames.tabContent).invoke("hide");
  	$(this.options.tabActive + this.options.sep + this.options.contentSuffix).show(); 	
//	$(this.options.tabActive + this.options.sep + this.options.contentSuffix).setStyle ( { display: 'inline' } );
  	$(this.options.tabActive).addClassName(this.options.classNames.tabActive);
	$(this.options.tabActive+'_opener').className = ($(this.options.tabActive+'_opener').className.indexOf('_selected') >= 0) ? $(this.options.tabActive+'_opener').className : $(this.options.tabActive+'_opener').className + "_selected";			
	$(this.options.tabActive+'_closer').className = ($(this.options.tabActive+'_closer').className.indexOf('_selected') >= 0) ? $(this.options.tabActive+'_closer').className : $(this.options.tabActive+'_closer').className + "_selected";			
	$(this.options.tabActive+'_tabber').className = ($(this.options.tabActive+'_tabber').className.indexOf('_selected') >= 0) ? $(this.options.tabActive+'_tabber').className : $(this.options.tabActive+'_tabber').className + "_selected";							

	if ( this.options.rotacion ) { 
	
		var th = this;		
		this.tmout = setInterval(  function(){
											th.options.id_activo = ( th.options.id_activo < th.options.max_tabs ) ? ( th.options.id_activo + 1 ) : 1;														
										   	th.activate(container,$( container.id + th.options.sep + 'tab'+(th.options.id_activo ) ));											
											}
											,th.options.intervalo);		
	}

  },
  activate: function( container, tab, para ){
	  	if ( para ) { 
			clearInterval(this.tmout); 
		}
		if( tab.id != this.options.tabActive ){			
			if(this.options.effects){			
				if (this.fadefx)	this.fadefx.cancel();
				this.fadefx = new Effect.Fade( $( this.options.tabActive + this.options.sep + this.options.contentSuffix),{queue:"front", duration:this.options.duration });
				this.fadefx = new Effect.Appear( $( tab.id + this.options.sep + this.options.contentSuffix ),{queue: "end",duration:this.options.duration});			
			}
			else{
				$(this.options.tabActive + this.options.sep + this.options.contentSuffix).hide();
				$(tab.id + this.options.sep + this.options.contentSuffix).show();				
			}
			tab.addClassName(this.options.classNames.tabActive);
			$(tab.id+'_opener').className += ($(tab.id+'_opener').className.indexOf('_selected') >= 0) ? '' : '_selected';			
			$(tab.id+'_closer').className += ($(tab.id+'_closer').className.indexOf('_selected') >= 0) ? '' : '_selected';			
			$(tab.id+'_tabber').className += ($(tab.id+'_tabber').className.indexOf('_selected') >= 0) ? '' : '_selected';			
			
			$(this.options.tabActive).removeClassName("selected");
			$(this.options.tabActive+'_opener').className = $(this.options.tabActive+'_opener').className.replace('_selected', '');
			$(this.options.tabActive+'_closer').className = $(this.options.tabActive+'_closer').className.replace('_selected', '');
			$(this.options.tabActive+'_tabber').className = $(this.options.tabActive+'_tabber').className.replace('_selected', '');

			this.options.tabActive = tab.id;
		} 
		return false;		
  }
}
/**************************    PESTANAS       *********************************/

/**************************    BARRA SECCION    ******************************/
var BarraSeccion = Class.create({								
  initialize: function( module ) {
    this.start( module );
  },
  start: function(modulo) {   
	var sec_height = (modulo.section[0]) ? ( modulo.section[0].offsetHeight + 5 ) : 0;
	var tit_height = 0 ;
	for ( var i = 0; i < modulo.tit.length; i++ ) {
		tit_height += modulo.tit[i].offsetHeight + 5;		
	}
	var pre_height = 0 ;
	for ( var i = 0; i < modulo.antetit.length; i++ ) {
		pre_height += modulo.antetit[i].offsetHeight + 5;		
	}	
	var acumulado = sec_height;
	var altura = ( sec_height + tit_height + pre_height );
	if (modulo.section[0]) { 
		modulo.section[0].setStyle({ marginTop: '-'+altura+'px', marginBottom: '0px', paddingBottom: '5px' });
		acumulado = modulo.section[0].offsetHeight;
		altura = altura - acumulado;
	}
	

	for ( var i = 0; i < modulo.childNodes.length; i++ ) {		
		if ( modulo.childNodes[i] 
					&& (modulo.childNodes[i].className && modulo.childNodes[i].className.indexOf('title') >= 0 ) 
					|| (modulo.childNodes[i].tagName && modulo.childNodes[i].tagName.toLowerCase() == 'h3')
		) {			
			var el = modulo.childNodes[i];
			el.setStyle({ marginTop: '-'+altura+'px', marginBottom: '0px', paddingBottom: '5px' });
			altura = altura - el.offsetHeight;			
		}
	}

  },
  moveTo: function(container,element) {   
	Position.prepare();
  }
}); 
/**************************    BARRA SECCION    ******************************/



/**************************    HEROBOXES    *********************************/
var heronew = Class.create();
heronew.prototype = {
  initialize: function(query) {
	var container = query.container;
	this.options = Object.extend({} , arguments[0] || {}  );
    this.photos = this.options.photos || 3;
	this.onEvent = this.options.onEvent || 'mouseover';
	this.onEventOff = this.options.onEventOff || 'mouseout';
	this.onScroll = this.options.onScroll || 'click';
	this.mode = this.options.mode || "lite";
	this.effects = this.options.effects || true;
	this.fxduration = this.options.fxduration || 0.5;
	this.tabSel;
	this.tabSelText; 
	this.fx;
	this.fxfade;
	this.fxscroll;
	this.numElements;
	this.imgwidth;
	this.originalPosition;
	this.actual;
	this.posactual;
	this.waiting = false;
	this.timeoutwait;
	this.start(container);
  },
  start: function(container) {   
  	container = $(container);	
  	var elems = container.select("div.scrollerImg");
	if (this.mode == 'lite')	this.imgwidth = 57;
	else if (this.mode == 'medium')	this.imgwidth = 75;
	else if (this.mode == 'complete') this.imgwidth = 96;
	else if (this.mode == 'eshop') this.imgwidth = 605;
	else if (this.mode == 'extendedlite') this.imgwidth = 55;
	else if (this.mode == 'linked') this.imgwidth = 450;
	else if (this.mode == 'news') this.imgwidth = 470;
	this.numElements = elems.length-(this.photos);
	this.originalPosition = this.photos*this.imgwidth*(-1);
	this.posactual = this.originalPosition;
	this.actual = 1;
	var prev = container.select("div.contentpager ul.pager li a.prev")[0];
	var next = container.select("div.contentpager ul.pager li a.next")[0];
	var scroller = container.select(".scrollerhbn")[0];
	var elemsContainer = container.select(".heronew");
	elemsContainer[0].setStyle({left:this.posactual + 'px'});
	prev.href = "javascript:;";	
	prev.observe(this.onScroll, this.movePrev.bind(this,scroller,container,false));				
	next.href = "javascript:;";	
	next.observe(this.onScroll, this.moveNext.bind(this,scroller,container,false));	
	var i=1;
	var j=this.numElements-this.photos+1;
	if (this.numElements<=this.photos){
		prev.setStyle({display:"none"});
		next.setStyle({display:"none"});
	}	
	elems.each(function(elem) {
		if (this.mode == 'lite' || this.mode == 'extendedlite'){
			if (container.select("div.sipos" + j + "aux")[0]){
				var img = container.select("div.sipos" + j + "aux")[0];	
				var layer = container.select(".sipos" + j + "_th")[0];
				Event.observe(img, this.onEvent, this.activate.bind(this, container, j, img), false);
				Event.observe(layer, this.onEventOff, this.desactivate.bind(this, container, i, img), false);
				j++;
			}else{		
				var img = container.select("div.sipos" + i)[0];
				var layer = container.select(".sipos" + i + "_th")[0];
				container.select(".sipos" + i + "_th")[0].style.display = 'none';	
				Event.observe(img, this.onEvent, this.activate.bind(this, container, i, img), false);
				Event.observe(layer, this.onEventOff, this.desactivate.bind(this, container, i, img), false);
				i++;
				if (i==elems.length-this.photos)
					j = elems.length-this.photos+1;		
			}			
		}else if (this.mode == 'medium'){
			if (container.select("div.sipos" + j + "aux")[0]){
				var text = container.select("div.stpos" + j)[0];
				var img = container.select("div.sipos" + j + "aux")[0];	
				Event.observe(img, this.onEvent, this.activate.bind(this, container, j, img, text, tab), false);
				j++;
			}else{		
				var text = container.select("div.stpos" + i)[0];
				var img = container.select("div.sipos" + i)[0];
				if (elem.hasClassName('sipos1')){
					img.addClassName('sisel');
					text.addClassName('stsel');
				}else{
					text.setStyle({display:'none'});
				}
				Event.observe(img, this.onEvent, this.activate.bind(this, container, i, img, text, tab), false);
				i++;
				if (i==elems.length-this.photos)
					j = elems.length-this.photos+1;
			}		
		}else if (this.mode == 'complete'){		
			if (container.select("div.sipos" + j + "aux")[0]){
				var text = container.select("div.stpos" + j)[0];
				var tab = container.select("div.ttpos" + j)[0];
				var img = container.select("div.sipos" + j + "aux")[0];	
				Event.observe(img, this.onEvent, this.activate.bind(this, container, j, img, text, tab), false);
				j++;
			}else{		
				var text = container.select("div.stpos" + i)[0];
				var tab = container.select("div.ttpos" + i)[0];
				var img = container.select("div.sipos" + i)[0];
				if (elem.hasClassName('sipos1')){
					img.addClassName('sisel');
					text.addClassName('stsel');
					tab.addClassName('ttsel');		
					this.tabSel = tab;
					this.tabSelText=tab.select("h2")[0].innerHTML;
				}else{
					text.setStyle({display:'none'});
				}
				Event.observe(img, this.onEvent, this.activate.bind(this, container, i, img, text, tab), false);
				i++;
				if (i==elems.length-this.photos)
					j = elems.length-this.photos+1;

			}
		}else if (this.mode == 'linked'){		
			if (container.select("div.sipos" + j + "aux")[0]){
				var img = container.select("div.sipos" + j + "aux")[0];	
				j++;
			}else{		
				var img = container.select("div.sipos" + i)[0];
				if (elem.hasClassName('sipos1')){
					img.addClassName('sisel');
				}
				i++;
				if (i==elems.length-this.photos)
					j = elems.length-this.photos+1;
			}	
			var imglinks = img.select("ul li a");
			var lengthlinks = imglinks[0].childNodes[0].length + imglinks[1].childNodes[0].length + imglinks[2].childNodes[0].length;
			imglinks.each(function(elem) {
				var linkpercent = parseInt(elem.childNodes[0].length*100/lengthlinks);
				elem.setStyle({width: linkpercent-1 + '%'});
			}.bind(this));
		}
    }.bind(this));
  },
  wait: function(){
	 clearTimeout(this.timeoutwaiting);
	 this.waiting = false;
  },
  desactivate: function(container, index, img){
	//this.fxfade = new Effect.Fade(container.select(".sipos" + index + "_th")[0],{queue:{position:"front", scope:'txt'},duration:0.3});
	container.select(".sipos" + index + "_th")[0].hide();
  },
  activate: function(container, index, img, text, tab){
	if (this.mode == 'lite' || this.mode == 'extendedlite'){ 
		/*var imgSelected = container.select("div.sisel")[0];
		if (imgSelected)	imgSelected.removeClassName('sisel');
		img.addClassName('sisel');*/
		var layer = container.select(".sipos" + index + "_th")[0];
		var layersel = container.select(".sipos_th_sel")[0];
		if (layersel)	layersel.removeClassName('sipos_th_sel');
		layer.addClassName('sipos_th_sel');
		layer.setStyle({left:img.offsetLeft + this.posactual - (17) + 'px'});
		if (this.fxfade){
			this.fxfade.cancel();
			layersel.hide();
		}
		this.fxfade = new Effect.Appear(layer,{queue:{position:"end", scope:'layer'},duration:0.5});
	}else if (this.mode == 'medium'){
		var txtSelected = container.select("div.stsel")[0];
		var imgSelected = container.select("div.sisel")[0];
		txtSelected.removeClassName('stsel');
		imgSelected.removeClassName('sisel');
		text.addClassName('stsel');
		img.addClassName('sisel');
		if (this.effects){
			if (this.fxfade)	this.fxfade.cancel();
			this.fxfade = new Effect.Fade(txtSelected,{queue:{position:"front", scope:'txt'},duration:0.1});				
			this.fxfade = new Effect.Appear(text,{queue:{position:"end", scope:'txt'},duration:0.1});
		}else{
			txtSelected.hide();
			text.show();
		}
	}else{
		var txtSelected = container.select("div.stsel")[0];
		var imgSelected = container.select("div.sisel")[0];
		var tabSelected = container.select("div.ttsel")[0];
		txtSelected.removeClassName('stsel');
		imgSelected.removeClassName('sisel');
		tabSelected.removeClassName('ttsel');
		text.addClassName('stsel');
		img.addClassName('sisel');
		tab.addClassName('ttsel');
		var posx = img.offsetLeft + this.posactual;	
		this.tabSel.select("h2")[0].innerHTML = tab.select("h2")[0].innerHTML;
		if (text.hasClassName('stpos1')) 
			this.tabSel.select("h2")[0].innerHTML = this.tabSelText;
		else 
			this.tabSel.select("h2")[0].innerHTML = tab.select("h2")[0].innerHTML;
		if (this.effects){
			if (this.fx)	this.fx.cancel();
			this.fx = new Effect.Move(this.tabSel,{x:posx,y:0,mode:'absolute',transition: Effect.Transitions.spring});
			if (this.fxfade)	this.fxfade.cancel();
			this.fxfade = new Effect.Fade(txtSelected,{queue:{position:"front", scope:'txt'},duration:0.1});				
			this.fxfade = new Effect.Appear(text,{queue:{position:"end", scope:'txt'},duration:0.1});
		}else{
			this.tabSel.setStyle({left:posx + 'px'});
			txtSelected.hide();
			text.show();
		}
	}
	return false;		
  },
  moveNext: function(scroller,container,activated) { 
  	if (!this.waiting){
		this.waiting = true;
		this.actual++;
		var element = container.select('.heronew')[0];
		if (this.posactual==(this.numElements)*this.imgwidth*(-1)){
			this.posactual = 0;
			this.actual = 1-this.photos+1;
			element.setStyle({left:this.posactual + 'px'});	
		}
		this.posactual = this.posactual - this.imgwidth;
		var th = this;
		this.timeoutwait = setTimeout(function(){th.wait()},this.fxduration*1000);
		this.fxscroll = new Effect.Move(element,{x:this.posactual,y:0,mode:'absolute',transition: Effect.Transitions.sinoidal, duration: this.fxduration});
		if (this.mode == 'complete' || this.mode == 'medium'){
			this.activate(container, 0, container.select("div.sipos" + (this.actual+this.photos-1))[0], container.select("div.stpos" + (this.actual+this.photos-1))[0], container.select("div.ttpos" + (this.actual+this.photos-1))[0]);
		}
	}
  },
  movePrev: function(scroller,container,activated) {   
  	if (!this.waiting){
		this.waiting = true;
		this.actual--;
		var element = container.select('.heronew')[0];
		if (this.posactual==0){
			this.posactual = this.originalPosition - ((this.numElements-this.photos)*this.imgwidth);
			this.actual = this.numElements-this.photos;
			element.setStyle({left:this.posactual + 'px'});	
		}
		this.posactual = this.posactual + this.imgwidth;
		var th = this;
		this.timeoutwait = setTimeout(function(){th.wait()},this.fxduration*1000);
		this.fxscroll = new Effect.Move(element,{x:this.posactual,y:0,mode:'absolute',transition: Effect.Transitions.sinoidal, duration: this.fxduration});
		if (this.mode == 'complete' || this.mode == 'medium'){
			if (this.actual<=0)
				this.activate(container, 0, container.select("div.sipos" + (this.numElements+this.actual) + "aux")[0], container.select("div.stpos" + (this.numElements+this.actual))[0], container.select("div.ttpos" + (this.numElements+this.actual))[0]);		
			else
				this.activate(container, 0, container.select("div.sipos" + this.actual)[0], container.select("div.stpos" + this.actual)[0], container.select("div.ttpos" + this.actual)[0]);
		}
	}
  }
}
/**************************    HEROBOXES    *********************************/


/**************************    FORMULARIOS HOME       *********************************/
var select_internet_ac = false;
function toPost_ac(h){
 $('destino').value = h;
 return abuscar_new();
}

function video_ac(id){
	var q = $(id).value;
	if (q == "") q = "humor";
	location.href='http://videos.orange.es/search/?q='+q;
}

function abuscar_new()	{
		document.bcdr.submit();
	}	
	
	
function sendMod(){
 emspy.addImpression('','','boton_ecare','modulo_ecare'); 
 return true;
}

function submit_forms(evt){

	 var child = Event.element(evt);
	 if($(child.id) && $(child.id).href) $(child.id).href="javascript:;";
	 switch (child.id){
	  case "bcdr":
		 if($('buscar') && $('buscar').value != '') toPost_ac('web');
		  else  abuscar_new();
		 break;
	 }
	}	

function functions_search(evt){
 
	 var child = Event.element(evt);
	 //if($(child.id) && $(child.id).href)$(child.id).href="javascript:;";
	 switch(child.id){

		case "searchweb":
		 toPost_ac('web');
		 break;
		 case "searchimg":
		 toPost_ac('imagen');
		 break;
		 case "searchvideo":
		 video_ac('buscar');
		 break;
		 case "searchnews":
		 toPost_ac('news');
		 break;
		 case "boton_buscador2": 
		  if($('buscar')&& $('buscar').value != '') $('boton_buscador').href="http://busca.orange.es/search?origen=home&destino=web&destino2=web&buscar="+$('buscar').value+"&buscar2=";
		  if($('buscar') && $('buscar').value != '') toPost_ac('web');
		  else  abuscar_new();
		 break; 
	}	
	Event.stop(evt);
}

function changeMod_ac(id,radio){
if($(id)) $(id).style.display = "inline";
if(id.indexOf('movil') > -1){
 if($('user_m')) $('user_m').value = "tu teléfono";
 if($('pwd_m')) $('pwd_m').style.display = "none";
 if($('user_pass_m')) $('user_pass_m').style.display = "inline";
 if($('id_care_internet')) $('id_care_internet').style.display = "none";
 select_internet_ac = false;
 }else{
  if($('user_i')) $('user_i').value = "usuario";
  if($('pwd_i')) $('pwd_i').style.display = "none";
  if($('user_pass_i')) $('user_pass_i').style.display = "inline";
  if($('id_care_movil')) $('id_care_movil').style.display = "none";
  select_internet_ac = true;
 }
 
 if($(radio)) $(radio).checked = "checked";
}


function ini_ecare_ac(){
 if(!select_internet_ac){
   changeMod_ac('id_care_movil','movilradiomovil');
 }else{
  changeMod_ac('id_care_internet','internetradiointernet');
 }
}

function click_forms(evt){
  var child = Event.element(evt);
  switch(child.id){
   case('internetradiomovil' ):
	   $('movilradiomovil').checked=true;
	   if( $('id_care_movil') && $('id_care_movil').style.display == "none" ) $('id_care_movil').style.display = "inline";
	   if($('user_m')) $('user_m').value = "tu teléfono";
	   if($('pwd_m')) $('pwd_m').style.display = "none";
	   if($('user_pass_m')) $('user_pass_m').style.display = "inline";
	   if($('id_care_internet')) $('id_care_internet').style.display = "none";
	   select_internet_ac = false;
    break;
	case( 'movilradiomovil'):
	   $(child.id).checked=true;
	   if( $('id_care_movil') && $('id_care_movil').style.display == "none" ) $('id_care_movil').style.display = "inline";
	   if($('user_m')) $('user_m').value = "tu teléfono";
	   if($('pwd_m')) $('pwd_m').style.display = "none";
	   if($('user_pass_m')) $('user_pass_m').style.display = "inline";
	   if($('id_care_internet')) $('id_care_internet').style.display = "none";
	   select_internet_ac = false;
    break;
   case( 'internetradiointernet' ):
	   $(child.id).checked=true;
	   if( $('id_care_internet') && $('id_care_internet').style.display == "none" )$('id_care_internet').style.display = "inline";
	   if($('user_i')) $('user_i').value = "usuario";
	   if($('pwd_i')) $('pwd_i').style.display = "none";
	   if($('user_pass_i')) $('user_pass_i').style.display = "inline";
	   if($('id_care_movil')) $('id_care_movil').style.display = "none";
	   select_internet_ac = true;
   break;
   case( 'movilradiointernet'):
	   $('internetradiointernet').checked=true;
	   if( $('id_care_internet') && $('id_care_internet').style.display == "none" )$('id_care_internet').style.display = "inline";
	   if($('user_i')) $('user_i').value = "usuario";
	   if($('pwd_i')) $('pwd_i').style.display = "none";
	   if($('user_pass_i')) $('user_pass_i').style.display = "inline";
	   if($('id_care_movil')) $('id_care_movil').style.display = "none";
	   select_internet_ac = true;
   break;
  case('user_pass_m'):
	  $('pwd_m').value= '';
	  $('pwd_m').style.display= 'inline';
	  $('user_pass_m').style.display= 'none';
	  $('pwd_m').focus();
   break;
  case('user_pass_i'):
	  $('pwd_i').value= '';
	  $('pwd_i').style.display= 'inline';
	  $('user_pass_i').style.display= 'none';
	  $('pwd_i').focus();
   break;
  case('olvido_m' ):
	   $('id_care_movil').style.display = "none";
	   $('id_care_movil_alerta').style.display = "inline";
  break;
  case('solicita_m'):
	   $('id_care_movil').style.display = "none";
	   $('id_care_movil_alerta').style.display = "inline";
  break;
   case('olvido_i'):
	   $('id_care_internet').style.display = "none";
	   $('id_care_internet_alerta').style.display = "inline";
   break;
   case('solicita_i'):
	   $('id_care_internet').style.display = "none";
	   $('id_care_internet_alerta').style.display = "inline";
   break;
  case('cerrar_alerta_movil'):
    if($('id_care_movil_alerta')) $('id_care_movil_alerta').style.display = "none";
    if( $('id_care_movil')) $('id_care_movil').style.display = "inline";
  break; 
  case('cerrar_alerta_internet'):
    if($('id_care_internet_alerta')) $('id_care_internet_alerta').style.display = "none";
    if($('id_care_internet')) $('id_care_internet').style.display = "inline";
  break;
  case('enviar_m'): $('f_client_m').submit(); break;
  case('enviar_i'): $('f_client_i').submit(); break;
  case('user_m'): $('user_m').value=''; break;
  case('user_i'): $('user_i').value=''; break;
  case('izq_movil') : window.location.href=$('izq_movil').href; break;
  case('drcha_movil') : window.location.href=$('drcha_movil').href; break;
  case('izq_internet') : window.location.href=$('izq_internet').href; break;
  case('drcha_internet') : window.location.href=$('drcha_internet').href; break;
   
   }//switch
Event.stop(evt); //avoid another call related to 'parent_node' itself


}

/*Formulario correo de la parte del menu de la izquierda*/
function ShowFormCorreo(evt){
     var child = Event.element(evt);
	if($(child.id) && $(child.id).href) $('frm_correo').href="javascript:;";
    if($('layer_correo') && $('layer_correo').style.display =="none") Element.show($('layer_correo'));
}	 

function closeFromCorreo(evt){
  	if($('layer_correo')) Element.hide($('layer_correo'));
  	if($("user_movil") ) $("user_movil").value="";
	if($("pass_movil") ) $("pass_movil").value="";
}	 



function checkMobile_ac(evt){
if(document.login){

 if (document.login.user.value.search(/^((\+|00)?34)?6\d{8}$/)==0 || $('select_correo').options[$('select_correo').selectedIndex].value == "amena.com"){
  document.login.action="https://registrate.orange.es/auth/mail";
 }
 
 else{
  document.login.action="http://web.orange.es/LoginWanadoo";
  document.login.usuario.value = document.login.user.value;
 }   
 document.login.submit();
}
 return true;
}
/**************************    FORMULARIOS HOME       *********************************/

/* funcion para el formulario de eshop */

function buscar_filtros(){

	var strCadenaBusqueda = '';
	var id_marca         = document.getElementById('marcas').value;
	var id_precio        = document.getElementById('precios').value;	

	var str_marca         = (document.frmBusquedaMenu.marcas.options[document.frmBusquedaMenu.marcas.selectedIndex ].value == '') ? 'ver todas' : document.frmBusquedaMenu.marcas.options[document.frmBusquedaMenu.marcas.selectedIndex ].text;
	var str_precio        = document.frmBusquedaMenu.precios.options[document.frmBusquedaMenu.precios.selectedIndex ].text;

	// comprobación para que si están vacíos los parámetros, cambiarlos a 0, menos las altas, que no hace falta.
	if (id_marca==''){
		id_marca=0
	}

	document.frmBusquedaMenu.id_marca.value        = id_marca;
	document.frmBusquedaMenu.id_precio.value       = id_precio;

	document.frmBusquedaMenu.str_marca.value        = str_marca;
	document.frmBusquedaMenu.str_precio.value       = str_precio;

	// Para el SEO
	str_precio_seo              = "http://tiendamovil.orange.es/telefonos-moviles.htm?utm_source=orange&utm_medium=autopromo&utm_term=homeorange&utm_campaign=movil";
	str_precio_seo_marca        = "";
	str_precio_seo_precio       = "";
	
	if( str_marca != "ver todas" ) { str_precio_seo_marca = "-" + str_marca.toLowerCase(); }

	if( str_precio != "ver todas" & id_precio > 0) 
	{
             if ( id_precio == 1 ) { str_precio_seo = "de%200%20a%2049"; }
             if ( id_precio == 2 ) { str_precio_seo = "de%2050%20a%20100"; }
             if ( id_precio == 3 ) { str_precio_seo = "mas%20de%20100"; }
             
	     str_precio_seo_precio = "-" + str_precio_seo.toLowerCase(); 
	}

        if( str_precio_seo_marca != "" | str_precio_seo_precio != "" ) 
        {	
             str_precio_seo = "moviles";
             str_precio_seo = str_precio_seo + str_precio_seo_marca;
             str_precio_seo = str_precio_seo + str_precio_seo_precio;
             str_precio_seo = "http://tiendamovil.orange.es/" + str_precio_seo + ".htm?utm_source=orange&utm_medium=autopromo&utm_term=homeorange&utm_campaign=movil";
	}


	document.frmBusquedaMenu.action = str_precio_seo;
	//teniendo en cuenta seo
	document.frmBusquedaMenu.method="post";
	document.frmBusquedaMenu.target="_movilorange";
	document.frmBusquedaMenu.submit();
}
/* funcion para el formulario de eshop */

/*funcion newtoJump*/

			function toJump(event)
			{
				var navegador = window.navigator.userAgent;
				var fl;
				if(navegador.toUpperCase().indexOf('MSIE') != -1)
				{
					var el = window.event.srcElement;
					if( !el || !el.tagName ) return true;
					var tg = (el.tagName == 'A') ? el : el.parentElement;
					if( tg.tagName == 'A')
					{
						fl = getClickTags(tg.rel);
						if(fl) return callImpression(fl,tg.href,tg.target);
					}
				}
				else if( (navegador.toUpperCase().indexOf('SAFARI') != -1) || (navegador.toUpperCase().indexOf('FIREFOX') != -1) )
				{
					var el = event.target;
					if( !el || !el.tagName ) return true;
					var tg = (el.tagName.toLowerCase() == 'a') ? el : el.parentNode;
					var aux_param =(tg)? tg.href : '';
					  
					if( tg.tagName == 'A')
					{
						var linkTarget =event.target.target; // saber si el target es _blank
						var objClicktrought = {};
							
						// recoge los los nombres y valores del clicktrouht en el objeto "objClicktrought"
						for(var i = 0; i < tg.attributes.length; i++)
						{
							var nombreClickTrought = tg.attributes[i].name;
							var valorClickTrought = tg.attributes[i].value;
							objClicktrought[nombreClickTrought] = valorClickTrought;	
						}
						
						if( objClicktrought["rel"] ) fl = getClickTags(objClicktrought["rel"]);
						if(fl) return callImpression(fl,objClicktrought["href"],linkTarget);
					}
				}
				return true;
			}
			
			function getClickTags(str){
				var obj = {};
				var arr = str.split(";");
				
				var j1,j2,j3,j4,a1,a2,a3,a4;
				
				for( var i = 0; i < arr.length; i++ ){
					var tmp = arr[i].split("=");
					obj[tmp[0]] = tmp[1];
				}
				
				return obj;
				
			}
			
			function callImpression(fl, href, target){
			
				if(fl.j1 || fl.j2 || fl.j3 || fl.j4)
				{
					emspy.jump( href , target == '_blank' ? true : false , fl.j1 ? fl.j1 : '' , fl.j2 ? fl.j2 : '' , fl.j3 ? fl.j3 : '' , fl.j4 ? fl.j4 : '' );
				}
				else if(fl.a1 || fl.a2 || fl.a3 || fl.a4)
				{
					emspy.addImpression( fl.a1 ? fl.a1 : '' , fl.a2 ? fl.a2 : '' , fl.a3 ? fl.a3 : '' , fl.a4 ? fl.a4 : '' );                                   
				}
				return true;
			}
			
			
			function newtoJump(){
				return true;
			}
			
/*funcion newtojump*/


document.observe("dom:loaded", function() {
	var query = {};
//	var modulo = {};		
	var contenedores = [];
	
	$$(".pestanasEshop").each(function(gr){
		gr.id = 'tabgr1';
		new introtabs(gr.id);
	})		
	
	  Event.observe('formsecare', 'click', click_forms, false);
	  Event.observe('row_buscador', 'submit', submit_forms, false);
	  Event.observe('row_buscador', 'click', functions_search, false);	
	  Event.observe('nvr_correo', 'click', checkMobile_ac, false);
	  Event.observe('close_frmcorreo', 'click', closeFromCorreo, false);
	  Event.observe('frm_correo', 'click', ShowFormCorreo, false);
	  //Event.observe('row_cabecera', 'click', newtoJump, false);
	  Event.observe('formsecare', 'select', click_forms, false);
	  if($('buscar')){$('buscar').value=""; $('buscar').focus();}
	  if($('pwd_m') && $('pwd_m').style.display != "none"){
	   if($('pwd_m').value == ''){
	   $('pwd_m').style.display = "none";
	   $('user_pass_m').style.display ="inline";
	   }
	  }
	  ini_ecare_ac();
});


/* refresco de la página, se elimina la parte de la cookie que actualizaba el logpage y logindex, ver en pills_home.js */
function rel_rf() {
  self.location.reload();
}
setTimeout("rel_rf()", 300000);
/* refresco de la página */

