﻿// JavaScript Document [chis]


// Variables
var v_campobusqueda,v_calidaddelservicio,v_layercalidad;


// promolayer
function cierralayer(){
	document.getElementById('promolayer').style.display="none";
}


// calidad
function layercalidad(){
	v_layercalidad.className='visible';
	v_layercalidad.style.display='block';
	return false;
}
function ocultame(divaocultar){document.getElementById(divaocultar).style.display='none';}


// funcion popup MM_openBrWindow
function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;  
    var myTop = (screen.height-myHeight)/2; 
    features+=(features!='')?',':''; 
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


// estoyenmessenger: si navegamos desde el messenger abrimos enlaces nyp en popup
var estoyenmessenger='no';
function messenger(enlace){if(estoyenmessenger=='messenger'){MM_openBrWindow(enlace,'','',screen.width,screen.height,'true');}else{document.location.href=enlace;}}
function flot(url){MM_openBrWindow(url,'info','scrollbars=yes','500','320','true');}



// funcion popup asignacion tamaños
function popup(){;
	var ancho_popup=this.rel.split('x')[0]; //capturamos el primer valor del atributo rel del enlace
	var altura_popup=this.rel.split('x')[1]; //capturamos el segundo valor del atributo rel del enlace
	var url_popup=this.href; //capturamos el atributo href del enlace
	MM_openBrWindow(url_popup,'movistar','scrollbars=yes,resizable=yes',ancho_popup,altura_popup,'true');
	return false;
}




// resultado de las busquedas
function buscamos(){
	var palabras= document.getElementsByTagName('form')[0].getElementsByTagName('input')[1].value;
	var miurl="http://www.movistar.es/busquedas/resultado.html?cx=007015020189759892766%3Aj3qoyktmq9q&cof=FORID%3A10&q="+palabras+"&sa=Comenzar+la+b%C3%BAsqueda&num=4";
	if(palabras!=""){
		MM_openBrWindow(miurl,'legal','scrollbars=yes,resizable=yes','900','700','true');
		return false;
	}else{
		v_campobusqueda.value="Buscar";
		return false;}
}

function vaciarbusqueda(){v_campobusqueda.value="";}



// onload
function preparamoselescenario(){
	
	// capa calidaddelservicio
	if (document.getElementById('calidaddelservicio')){
		v_calidaddelservicio=document.getElementById('calidaddelservicio');
		v_layercalidad=document.getElementById('layercalidad');
		v_layercalidad.style.display='none';
		v_calidaddelservicio.onclick=layercalidad;
	}
	
	// campo de busquedas
	if (document.getElementById('buscar_texto')){
		v_campobusqueda=document.getElementById('buscar_texto');
		v_campobusqueda.value="Buscar";
		v_campobusqueda.onfocus=vaciarbusqueda;
		v_campobusqueda.onblur=buscamos;
	}
	document.getElementsByTagName('form')[0].onsubmit=buscamos;
	document.getElementById('buscar_submit').onclick=buscamos;

	// Asigna popup
	var v_enlaces_popup=document.getElementsByTagName('a');
	var v_n_enlaces_popup=v_enlaces_popup.length;
	for(i=0; i<v_n_enlaces_popup; i++){
		if(v_enlaces_popup[i].className=='popup'){
			v_enlaces_popup[i].title=v_enlaces_popup[i].title+' (abre en ventana emergente)';
			v_enlaces_popup[i].onclick=popup;
		}
	}


	// Atencion en Linea
	// faq genericas y de tarjeta
	if(document.getElementById('preguntas')){
		var nfaq=document.getElementById('preguntas').getElementsByTagName('dt').length;
		//alert(nfaq);
		for(i=1; i<=nfaq; i++){
			document.getElementById("rfaq"+i).className='rfaq_none';
			document.getElementById("vfaq"+i).className="vfaq_none";
			var copyfaq=document.getElementById("faq"+i).innerHTML;
			if(copyfaq.split('<strong>')[1]!=undefined){
				var copyfaqsinstrong=copyfaq.split('</strong>')[0].split('<strong>')[1];
			}else{
				var copyfaqsinstrong=copyfaq.split('</STRONG>')[0].split('<STRONG>')[1];
			}
			
			document.getElementById("faq"+i).innerHTML='<a href="javascript:void(0);" title="Mostar/Ocultar: '+copyfaqsinstrong+'">'+copyfaq+'</a>';
			document.getElementById("faq"+i).onclick=veoveo;
		}
	}
	//  faq de contrato
	if(document.getElementById('cpreguntas')){
		var ncfaq=document.getElementById('cpreguntas').getElementsByTagName('dt').length;
		for(i=1; i<=ncfaq; i++){
			document.getElementById("crfaq"+i).className='rfaq_none';
			document.getElementById("cvfaq"+i).className="vfaq_none";
			var copyfaq=document.getElementById("cfaq"+i).innerHTML;
			if(copyfaq.split('<strong>')[1]!=undefined){
				var copyfaqsinstrong=copyfaq.split('</strong>')[0].split('<strong>')[1];
			}else{
				var copyfaqsinstrong=copyfaq.split('</STRONG>')[0].split('<STRONG>')[1];
			}
			document.getElementById("cfaq"+i).innerHTML='<a href="javascript:void(0);" title="Mostar/Ocultar: '+copyfaqsinstrong+'">'+copyfaq+'</a>';
			document.getElementById("cfaq"+i).onclick=veoveo;
		}
	}

	
}

window.onload = preparamoselescenario;