
// class="pestana_tit activo"
/*var indiceActivo = 0;

function cambia(indice)
{
	eval("document.getElementById('pestana_link_" + indiceActivo + "').className = 'pestana_tit';");
	eval("document.getElementById('pestana_link_" + indice + "').className = 'pestana_tit activo';");
	
	eval("document.getElementById('pestana_content_" + indiceActivo + "').style.display = 'none';");
	eval("document.getElementById('pestana_content_" + indice + "').style.display = 'block';");
	
	indiceActivo = indice;
}


*/
/*ENCUESTA*/
function is_client(){
   var f= document.getElementById('f_encuesta');
   if(f && f.es_cliente.options[f.es_cliente.selectedIndex].value == 'si')
   {
    document.getElementById('clasi').style.display= "inline";
    document.getElementById('motivoc').style.display= "inline";
    document.getElementById('motivonc').style.display= "none";
   }else{
    document.getElementById('clasi').style.display= "none";
    document.getElementById('motivoc').style.display= "none";
    document.getElementById('motivonc').style.display= "inline";
   }
 }
 
 
 function is_mejora(){
    var f= document.getElementById('f_encuesta');
    if(f && f.mejorar.options[f.mejorar.selectedIndex].value == 'otro')
    {
     document.getElementById('mejorastxa').style.display= "inline";
    }else{
     document.getElementById('mejorastxa').style.display= "none";
    }
 }
 
 function cerrar_encuesta(div){
  cerrarLayer(div);
  if($('f_encuesta')) Form.reset('f_encuesta');
  if($('motivonc')) $('motivonc').style.display="none";
  if(!c_ck_get("mr_encuesta") || c_ck_get("mr_encuesta") != 'yes'){
   var futdate = new Date()		//Get the current time and date
   var expdate = futdate.getTime()  //Get the milliseconds since Jan 1, 1970
   expdate += 30*24*60*60*1000;  //expires in 1 month(milliseconds)
   futdate.setTime(expdate);
   c_ck_set("mr_encuesta",'yes',futdate,"/",".orange.es");
  }
 }
 
 function addElement (id){
  var aux = document.createElement('span'); 
  aux.id="ad_"+id; 
   aux.className = "motivo";
  aux.innerHTML= ' '+$(id).title; 
  return aux;
 }
 
 function validateForm(){
  var send = true;
  if($('es_cliente').value == ""){
  var aux = addElement ('es_cliente');
  Insertion.After($('es_cliente'), aux);
  send= false; }

  if($('motivoc').style.display != 'none' && $('motivoc').value == ""){
  var aux = addElement ('motivoc');
  Insertion.After($('motivoc'), aux);
  send= false; }

  if($('motivonc').style.display != 'none' && $('motivonc').value == ""){
  var aux = addElement ('motivonc');
  Insertion.After($('motivonc'), aux);
  send= false; }

  if( $('buscado').value == ""){
  var aux = addElement ('buscado');
  Insertion.After($('buscado'), aux);
  send= false; }

  if($('satisfaccion').value == ""){
  var aux = addElement ('satisfaccion');
  Insertion.After($('satisfaccion'), aux);
  send= false; }

  if($('general').value == ""){
  var aux = addElement ('general');
  Insertion.After($('general'), aux);
  send= false; }


  if($('grado').value == ""){
  var aux = addElement ('grado');
  Insertion.After($('grado'), aux);
  send= false; }


  if($('mejorar').value == ""){
  var aux = addElement ('mejorar');
  Insertion.After($('mejorar'), aux);
  send= false; }

  if($('clasi').style.display != 'none' && $('en_tarifas').value == ""){
  var aux = addElement ('en_tarifas');
  Insertion.After($('en_tarifas'), aux);
  send= false; }

  if($('clasi').style.display != 'none' && $('en_sexo').value == ""){
  var aux = addElement ('en_sexo');
  Insertion.After($('en_sexo'), aux);
  send= false; }

  if($('mejoras').value != ""){
   var auxi = $('mejoras').value.replace(/\n/gi,'. ');
   auxi = auxi.replace(/\r/gi,'. ');
   $('mejoras').value = auxi;
  }

  return send;
 }

 
 function enviar_encuesta(){
 if(validateForm()){ 
  if(!c_ck_get("mr_encuesta") || c_ck_get("mr_encuesta") != 'yes'){
   var futdate = new Date()		//Get the current time and date
   var expdate = futdate.getTime()  //Get the milliseconds since Jan 1, 1970
   expdate += 30*24*60*60*1000;  //expires in 1 month(milliseconds)
   futdate.setTime(expdate);
   c_ck_set("mr_encuesta",'yes',futdate,"/");
   
   var urlPagina = "" + document.location;
   var buscarBarra = urlPagina.split("/");
   if(buscarBarra.length < 5) var procedencia ="home";
   else var procedencia ="otros";
   
   $('f_encuesta').procedencia.value = procedencia;
   $('f_encuesta').urlenc.value = urlPagina;

   $('f_encuesta').action = "http://movil.orange.es/encuestas/encuestanew.php";
   
   $('f_encuesta').request({
     onComplete: function(){ $('tit_enc').innerHTML ="";$('ppl_encuesta').innerHTML =""; $('ppl_encuesta').innerHTML="Gracias por tu colaboración"; }
   })
  }else{
     return false;
  } 
  }
 }




/*ENCUESTA*/


var lnkCounter = 0;

function lanzarLayer (id_layer)
{
	if (lnkCounter == 0) // Sustituye enlaces con # para evitar desplazamiento página
	{
		var tb = document.getElementsByTagName('a');
		for(var i = 0; i < tb.length; i++){
			if( tb[i].href.indexOf('#') != -1 )	{ tb[i].href = 'javascript:;'; lnkCounter ++; }
		}			
	}
    var div = ""+id_layer;
	var frm = $(div).select('[id="f_encuesta"]');
    if(frm && frm.length == 0)
    {
	 $$('select').invoke('hide');	
    }

	startLoading(id_layer);  
}
 
function cerrarLayer (id_layer)
{
  $$('select').invoke('show')
  activeLayers--;
   Element.hide("" + id_layer);
   if (activeLayers < 1) { Element.hide("popup") } 
   if( $(id_layer + "section_0") != null ) abrirLayer((id_layer + "section_0"),6,id_layer);
 }


/*-------------------------------------------------------------
FUNCIONES DE POSICIONAMIENTO DEL LAYER
---------------------------------------------------------------*/

function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

function getPageScroll()
{
    var yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
    }
    arrayPageScroll = new Array("", yScroll);
    return arrayPageScroll;
}

function startLoading(idCapa)
{ 
	var pageSize = this.getPageSize();
	var layerPos = (pageSize[0]-620)/2;
	var pageScroll = this.getPageScroll()[1];
	var altoPag = pageSize[1];
	
	Element.setStyle(String(idCapa),{top: pageScroll + 20 + "px", left: layerPos + "px", width: "620" });  
	Element.show("" + idCapa);	
	var altoCapa = pageScroll + parseInt($("" + idCapa).offsetHeight) + 20;	
	if (altoCapa > altoPag) altoPag = altoCapa;
	Element.setStyle("popup",{height: altoPag + "px", width: "100%", display: "block" });
	activeLayers ++;
}

var activeLayers = 0;

document.write('<div id="popup" style="position:absolute;display:none; z-index:8;top:0px;left:0px;" class="transp"></div>');

