// JavaScript Document


//Pop-under window II- By JavaScript Kit
//Credit notice must stay intact for use
//Visit http://javascriptkit.com for this script

//specify URLs to randomly select from and pop-under
var popunder=new Array()
var win2;
var win3;


popunder[0]="http://www.avantel.com.co/segundos/sabermas.html"
popunder[1]="http://www.clubavantel.com"

//specify popunder window features
//set 1 to enable a particular feature, 0 to disable
var winfeatures="width=800,height=510,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"

//Pop-under only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause popunder to load every time page is loaded
var once_per_session=1

///No editing beyond here required/////

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}


//-----------------------------------Función para detectar el bloqueo de ventanas emergenes
function DetectaBloqueoPops()
{
  var popup
  try
  {
    //Se crea una nueva ventana para probar si esta o no activo
    // el bloqueador de ventanas emergentes.
    //Si esta activo, se lanza el error, de lo contrario sólo se cierra la ventana creada
    if(!(popup = window.open('about:blank','_blank','left=-100,top=1000,width=1,height=1,toolbar=0,status=0,resizable=0,directories=0,location=0')))
      throw "ErrPop"
    msj = "La ventana se creó con éxito"
    popup.close()
  }
  catch(err)
  {
    //Se captura el error, si fue por motivo de bloqueo, se muestra el mensaje de advertencia
    //Si no fue por bloque, entonces se muestra la descripción del error ocurrido.
    if(err=="ErrPop"){
      msj = "El Bloqueo de ventanas esta activo y este aplicativo requiere que no este activo el bloqueo para las direcciones *.avantel.com.co\nPara permitir ventanas emergentes de Avantel, realice los siguientes pasos:\n\t1. Ir al menu 'Herramientas'\n\t2. El submenu 'opciones de internet'.\n\t3. El Tab 'Privacidad'\n\t4. Clic en el boton 'Configuración'\n\t5. Agregar '*.avantel.com.co'."
      msj2 = "<span style='font-weight:bold; text-align:left; width:100%'>El Bloqueo de ventanas esta activo y este aplicativo requiere que no este activo el bloqueo para las direcciones *.avantel.com.co<br />Para permitir ventanas emergentes de Avantel, realice los siguientes pasos:<br />1. Ir al menu 'Herramientas'<br />2. El submenu 'opciones de internet'.<br />3. El Tab 'Privacidad'<br />4. Clic en el boton 'Configuración'<br />5. Agregar. '*.avantel.com.co'</span>"
	  
	}else
    {
      msj="Hubo un erro en la página.nn"
      msj+="Descripción del error: " + err.description + "nn"
     }
	 try{document.getElementById('salida').innerHTML=msj2;}catch(error){}
     alert(msj);	
  }
}

function loadornot(){
if (get_cookie('popunder')==''){
  loadpopunder()
  document.cookie="popunder=yes"
}
}

function loadpopunder(){
try{
  //win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"",winfeatures)
  //win2=window.open(popunder[0],"",winfeatures)
  //win2.blur()
  win3=window.open(popunder[1],"",winfeatures)  
  win3.blur()
  window.focus()
}catch(error){}
}


function loadpopunder2(){
try{
win2=window.open(popunder[0],"",winfeatures)
//win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"",winfeatures)
//wn2.blur()
//window.focus()
}catch(error){}
}

function abrir(){
try{   
   if(win2.closed){
	loadpopunder2();		
   }else{
	win2.focus()	
   }
}catch(error){
  loadpopunder2();
}
}

if (once_per_session==0)
loadpopunder()
else
loadornot()

//DetectaBloqueoPops();
