// Script para el site Bonus


var peticion = false; 
var  testPasado = false; 
try 
{ 
  peticion = new XMLHttpRequest(); 
} 
catch (trymicrosoft) 
{ 
  try 
  { 
    peticion = new ActiveXObject("Msxml2.XMLHTTP"); 
  } 
  catch (othermicrosoft) 
  { 
    try 
    { 
       peticion = new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    catch (failed) 
    { 
      peticion = false; 
    } 
  } 
} 

if (!peticion) 
{
   alert("ERROR AL INICIALIZAR!"); 
}

function showBoletin(id) {

	var contenido = document.getElementById('contenido'); 
	var url_parse="mostrarboletin.php?id="+id;
	contenido.innerHTML="buscando datos..."
	peticion.open("GET", url_parse); 
  peticion.onreadystatechange = function() 
  { 
    	if (peticion.readyState == 4) 
     	{ 
        		//escribimos la respuesta 
         		contenido.innerHTML = peticion.responseText; 
     	} 
  } 
  peticion.send(null);  		
	
}


function BuscarMaestro(pag)
{
	var paginacion = document.getElementById('resultados'); 
	var words = document.getElementById('palabra'); 
	var url_parse="buscador.php?palabra="+words+"&pagina"+pag;

   	paginacion.innerHTML = '<img src="buscando.gif" />'; 
   	//abrimos la url 
    	peticion.open("GET", url_parse); 
    	peticion.onreadystatechange = function() 
    	{ 
        	if (peticion.readyState == 4) 
        	{ 
             		//escribimos la respuesta 
             		paginacion.innerHTML = peticion.responseText; 
        	} 
    	} 
       peticion.send(null);  	
	
}

function MotorBuscar()
{
	envia=document.getElementById("formabuscar");
	envia.action="buscador.php";
	envia.submit();
}

function ValidateFormBonus() {
   var ci = document.getElementById('cedula'); 
   var tj = document.getElementById('tarjeta'); 
   var forma = document.getElementById('formbonus'); 
   
   if(isNaN(tj.value) || tj.value.replace(/ /g, '')=='' ) {
     alert("Por favor s�lo introduzca los n�meros de su tarjeta. Gracias");
     return;
   }
   
   if(ci.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca los n�meros de su c�dula de identidad. Gracias");
      return;
   }
   
   forma.submit();
}


function validaAsistencia() {
   	var nom = document.getElementById('nombre');
   	var emp = document.getElementById('empresa');
   	var cargo = document.getElementById('cargo');
   	var mail = document.getElementById('email');
   	var tel = document.getElementById('telefono');
   	var come = document.getElementById('comentario');
   
   	
   	if(nom.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca su nombre y apellido. Gracias");
      return;
    }
    
    if(emp.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca el nombre de la empresa. Gracias");
      return;
    }
    
    if(cargo.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca su cargo. Gracias");
      return;
    }
    
    if(!isEmailAddress(mail)) {
    	alert("Por favor introduzca un direcci�n de e-mail v�lido. Gracias");
      return;
    }
    
    if(tel.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca su tel�fono(s). Gracias");
      return;
    }
    
    if(come.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca sus comentarios. Gracias");
      return;
    }
    
    var paginacion = document.getElementById('resultado'); 
    
    var qs="nombre="+nom.value+"&emp="+emp.value+"&cargo="+cargo.value+"&mail="+mail.value+"&tel="+tel.value+"&com="+come.value;
	  var url_parse="enviarInfoAsistencia.php?"+qs;
   	paginacion.innerHTML = '<img src="procesando.gif" />'; 
   	//abrimos la url 
    peticion.open("GET", url_parse); 
    peticion.onreadystatechange = function() 
    { 
        	if (peticion.readyState == 4) 
        	{ 
             		//escribimos la respuesta 
             		paginacion.innerHTML = peticion.responseText; 
        	} 
    } 
    peticion.send(null); 
    
}

function validaSolicitud() {
   	var nom = document.getElementById('nombre');
   	var emp = document.getElementById('empresa');
   	var ramo = document.getElementById('ramo');
   	var cargo = document.getElementById('cargo');
   	var mail = document.getElementById('email');
   	var tel = document.getElementById('telefono');
   	var tickets = document.getElementById('tickets');
   	var monto = document.getElementById('monto');
   	var empl = document.getElementById('empleados');
   	var nomina = document.getElementById('nomina');
   	var porc = document.getElementById('porcentaje');
   	var meca = document.getElementById('mecanismo');
   	var tiem = document.getElementById('tiempo');
   	var pago = document.getElementById('formapago');
   	var tras = document.getElementById('traslado');
   	var dist = document.getElementById('distribucion');
   	
   
   	
   	if(nom.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca su nombre y apellido de la persona contacto. Gracias");
      return;
    }
    
    if(ramo.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca el ramo al que pertenece la empresa. Gracias");
      return;
    }
    
    if(emp.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca el nombre de la empresa. Gracias");
      return;
    }
    
    if(cargo.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca su cargo. Gracias");
      return;
    }
    
    if(!isEmailAddress(mail)) {
    	alert("Por favor introduzca un direcci�n de e-mail v�lido. Gracias");
      return;
    }
    
    if(tel.value.replace(/ /g, '')=='') {
   	  alert("Por favor introduzca su tel�fono(s). Gracias");
      return;
    }
    
    if(tickets.value.replace(/ /g, '')=='') {
   	  tickets = 0;
    }
    
    if(monto.value.replace(/ /g, '')=='') {
   	  monto = 0;
    }
    
    if(emp.value.replace(/ /g, '')=='') {
   	  emp = 0;
    }
    
    if(nomina.value.replace(/ /g, '')=='') {
   	  nomina = 0;
    }
    
    if(porc.value.replace(/ /g, '')=='') {
   	  porc = 0;
    }
   
    
    var paginacion = document.getElementById('resultado'); 
    
    var qs="ramo="+ramo.value+"&nom="+nom.value+"&emp="+emp.value+"&cargo="+cargo.value+"&mail="+mail.value+"&tel="+tel.value+"&tickets="+tickets.value;
    qs+="&monto="+monto.value+"&empl="+empl.value+"&nomina="+nomina.value+"&porc="+porc.value+"&meca="+meca.value+"&tiem="+tiem.value;
    qs+="&pago="+pago.value+"&tras="+tras.value+"&dist="+dist.value;
	  var url_parse="enviarInfoSolicitud.php?"+qs;
	  alert(url_parse);
	  //alert(url_parse);
   	/**
   	paginacion.innerHTML = '<img src="procesando.gif" />'; 
   	//abrimos la url 
    peticion.open("GET", url_parse); 
    peticion.onreadystatechange = function() 
    { 
        	if (peticion.readyState == 4) 
        	{ 
             		//escribimos la respuesta 
             		paginacion.innerHTML = peticion.responseText; 
        	} 
    } 
    peticion.send(null); 
    */
    
}


function isEmailAddress(theElement) {

var s = theElement.value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 ) return false;
if (filter.test(s)) {
   return true;
}

}


function enviaEncuesta() {
	
	// inicializar las repuestas posibles
	var pr1op1=0;
  var pr1op2=0;
  var pr1op3=0;
  var pr2op1=0;
  var pr2op2=0;
  var pr2op3=0;
  var pr3op1=0;
  var pr3op2=0;
  var pr3op3=0;
  var pr4op1=0;
  var pr4op2=0;
  var pr4op3=0;
  var pr4op1=0;
  var pr4op2=0;
  var pr4op3=0;
  var pr5op1=0;
  var pr5op2=0;
  var pr5op3=0;
  var pr6op1=0;
  var pr6op2=0;
  var pr6op3=0;
  var pr7op1=0;
  var pr7op2=0;
  var pr7op3=0;
  var pr8op1=0;
  var pr8op2=0;
  var pr8op3=0;
  var pr9op1=0;
  var pr9op2=0;
  var pr9op3=0;
	
	// pregunta 1
  var rp1 =  getRadioValue(document.forma.pr1);
  
  if(rp1=='S') {
  	pr1op1=1;
  } 
  
  if(rp1=='N') {
  	pr1op2=1;
  }
  
  if(rp1=='NC') {
  	pr1op3=1;
  }
  
  // pregunta 2
  var rp2 =  getRadioValue(document.forma.pr2);
  
  if(rp2=='S') {
  	pr2op1=1;
  } 
  
  if(rp2=='N') {
  	pr2op2=1;
  }
  
  if(rp2=='NC') {
  	pr2op3=1;
  }
  
  // pregunta 3
  var rp3 =  getRadioValue(document.forma.pr3);
  
  if(rp3=='S') {
  	pr3op1=1;
  } 
  
  if(rp3=='N') {
  	pr3op2=1;
  }
  
  if(rp3=='NC') {
  	pr3op3=1;
  }
  
  // pregunta 4
  var rp4 =  getRadioValue(document.forma.pr4);
  
  if(rp4=='S') {
  	pr4op1=1;
  } 
  
  if(rp4=='N') {
  	pr4op2=1;
  }
  
  if(rp4=='NC') {
  	pr4op3=1;
  }
 
  // pregunta 5
  var rp5 =  getRadioValue(document.forma.pr5);
  
  if(rp5=='S') {
  	pr5op1=1;
  } 
  
  if(rp5=='N') {
  	pr5op2=1;
  }
  
  if(rp5=='NC') {
  	pr5op3=1;
  }
 
  // pregunta 6
  var rp6 =  getRadioValue(document.forma.pr6);
  
  if(rp6=='S') {
  	pr6op1=1;
  } 
  
  if(rp6=='N') {
  	pr6op2=1;
  }
  
  if(rp6=='NC') {
  	pr6op3=1;
  }
 
  // pregunta 7
  var rp7 =  getRadioValue(document.forma.pr7);
  
  if(rp7=='S') {
  	pr7op1=1;
  } 
  
  if(rp7=='N') {
  	pr7op2=1;
  }
  
  if(rp7=='NC') {
  	pr7op3=1;
  }
 
  // pregunta 8
  var rp8 =  getRadioValue(document.forma.pr8);
  
  if(rp8=='S') {
  	pr8op1=1;
  } 
  
  if(rp8=='N') {
  	pr8op2=1;
  }
  
  if(rp8=='NC') {
  	pr8op3=1;
  }
  
  // pregunta 9
  var rp9 =  getRadioValue(document.forma.pr9);
  
  if(rp9=='S') {
  	pr9op1=1;
  } 
  
  if(rp9=='N') {
  	pr9op2=1;
  }
  
  if(rp9=='NC') {
  	pr9op3=1;
  }
 
  var come = document.getElementById('comentario').value;
  var respuesta = document.getElementById('resultado'); 
   
  var qs="rp1op1="+pr1op1+"&rp1op2="+pr1op2+"&rp1op3="+pr1op3;
  qs+="&rp2op1="+pr2op1+"&rp2op2="+pr2op2+"&rp2op3="+pr2op3;  
  qs+="&rp3op1="+pr3op1+"&rp3op2="+pr3op2+"&rp3op3="+pr3op3;
  qs+="&rp4op1="+pr4op1+"&rp4op2="+pr4op2+"&rp4op3="+pr4op3;
  qs+="&rp5op1="+pr5op1+"&rp5op2="+pr5op2+"&rp5op3="+pr5op3;
  qs+="&rp6op1="+pr6op1+"&rp6op2="+pr6op2+"&rp6op3="+pr6op3;
  qs+="&rp7op1="+pr7op1+"&rp7op2="+pr7op2+"&rp7op3="+pr7op3;
  qs+="&rp8op1="+pr8op1+"&rp8op2="+pr8op2+"&rp8op3="+pr8op3;
  qs+="&rp9op1="+pr9op1+"&rp9op2="+pr9op2+"&rp9op3="+pr9op3;
  qs+="&comen="+come;
  var url_parse="enviarEncuesta.php?"+qs;
  respuesta.innerHTML = "<p class='itemContenido'>Enviando Respuesta...</p>"; 
  //abrimos la url 
  peticion.open("GET", url_parse); 
  peticion.onreadystatechange = function() 
  { 
       	if (peticion.readyState == 4) 
       	{ 
             		//escribimos la respuesta 
             		respuesta.innerHTML = peticion.responseText; 
       	} 
  } 
  peticion.send(null); 
  
}

function getRadioValue(radioObject) {
var value = null;
// Validate parameter value
//*** if (radioObject+"" == "undefined" || radioObject == null)
if (radioObject == null)
   return null;

for (var i=0; i < radioObject.length; i++) {
   if (radioObject[i].checked) {
        value = radioObject[i].value;
        break;
   }
} // end for loop

return value;

} 


function oNoticias(noti)
{
	//alert("hola");
	windows=PopUp('noticias.php?Id='+noti, 'noticias', 450, 550, 1, 0, 1);
}

function PopUp(url, name, width, height, center, resize, scroll, posleft, postop, urllocation) {		
		if (posleft != 0) { 
			var x = posleft;
		}
		if (postop  != 0) { 
			var y = postop;
		}
	
		if (!scroll) { scroll = 0 }
		if (!resize) { resize = 0 }
		if (!urllocation) { urllocation = 0 }
			
		if ((parseInt (navigator.appVersion) >= 4 ) && (center)) {
		  var X = (screen.width  - width ) / 2;
		  var Y = (screen.height - height) / 2;
		}
	
		if (scroll != 0) { scroll = 1 }
	
		var extra = 'width=' + width + ', height=' + height + ', top=' + Y + ', left=' + X + ', resizable=' + resize + ', scrollbars=' + scroll + ', location=' + urllocation + ', directories=no, status=yes, menubar=no, toolbar=no';
		window.open( url, name, extra );
}
	  
function openPopup(url, name, width, heigth) {
       windows=PopUp(url, name, width, heigth, 1, 0);
}

function openPopup2(url, name, width, heigth,scroll) {
    windows=PopUp(url, name, width, heigth, 1, 0, scroll);
}

function myOpen(url) {

if (version == "e4") {
	var xMax = screen.width, yMax = screen.height;
	} 
if (version == "n4") {
	var xMax = screen.availWidth, yMax = screen.availHeight;
	}
if ((version == "e3") || (version == "n3") || (version == "n2") || (version == "other"))	{
	xMax = 640, yMax=480;
	}

	var width=xMax-20;
	var height=yMax-20;
	var X = (xMax - width ) / 2, Y = (yMax - height) / 2;
    	var extra = 'width='+width+',height='+height+', top='+Y+', left='+X+ ', resizable=no, scrollbars=yes, location=yes, directories=no, status=yes, menubar=no, toolbar=no';

	myWindowHandle = window.open(url,'pol',extra);
	if ((version == "e4")||(version == "n4") )
	  myWindowHandle.focus();

	if (!myWindowHandle.opener)
          myWindowHandle.opener = self;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
}

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="index.php?mod=45&accion=69">Solicitud de Cotizaci�n</a>'
menu1[1]='<a href="index.php?mod=45&accion=70">Agentes Autorizados Tebca</a>'
menu1[2]='<a href="http://www.venezolano.com/index.php?mod=contac&action=ubicacion" target="_blank">Agencias BVC</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="http://www.visalatam.com/" target="_blank">Visa</a>'
menu2[1]='<a href="http://www.tusambil.com/" target="_blank">Sambil Venezuela</a>'
		
var menuwidth='80px' //default menu width
var menubgcolor='#ffffff'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="z-index:100;visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"

}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

var count = 0;
// Change the number after delay to change scroll speed. 
// Higher number equals slower scroll.
var delay = 250;
// text between quotes will display in the status window. 
// Leave blank spaces after text.
var text = "Estimados clientes: Les notificamos que por mejoras que estaremos realizando en nuestra plataforma tecnol�gica, nuestro servicio Tebca Online y Bonus Online no estar�n en funcionamiento en el d�a de hoy, durante el horario comprendido entre las 9:00 p.m. y las 12:00 a.m. Les rogamos disculpen los inconvenientes  ";
function  scroll () {
       window.status = text.substring (count, text.length) + text.substring (0, count)
        if (count < text.length)
                count ++;
        else
                count = 0;
        setTimeout ("scroll()", delay);
}

adTime=20;  // seconds ad reminder is shown
chanceAd=1; // ad will be shown 1 in X times (put 1 for everytime)

var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"
adCount=0;
function initAd(){
	if(!ns && !ie && !w3) return;
	if(ie)		adDiv=eval('document.all.sponsorAdDiv.style');
	else if(ns)	adDiv=eval('document.layers["sponsorAdDiv"]');
	else if(w3)	adDiv=eval('document.getElementById("sponsorAdDiv").style');
	randAd=Math.ceil(Math.random()*chanceAd);
        if (ie||w3)
        adDiv.visibility="visible";
        else
        adDiv.visibility ="show";
	if(randAd==1) showAd();
}
function showAd(){
if(adCount<adTime*10){adCount+=1;
	if (ie){documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
	documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;}	
	else if (ns){documentWidth=window.innerWidth/2+window.pageXOffset-20;
	documentHeight=window.innerHeight/2+window.pageYOffset-20;} 
	else if (w3){documentWidth=self.innerWidth/2+window.pageXOffset-20;
	documentHeight=self.innerHeight/2+window.pageYOffset-20;} 
	adDiv.left=documentWidth-200+calunit;adDiv.top =documentHeight-200+calunit;
	setTimeout("showAd()",100);}else closeAd();
}
function closeAd(){
if (ie||w3)
adDiv.display="none";
else
adDiv.visibility ="hide";
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

//onload=initAd;
