function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function paginadoListado(mipagina) {
	var ff=window.document.bava;
	ff.pagina.value=mipagina;
	ff.submit();
}

function ZoomG(ruta,sPicURL) { 
	window.open("/zoom.php?Dir="+ruta+"&Doc="+sPicURL,"","resizable=1,HEIGHT=200,WIDTH=200");
}

function VPrint(idioma) {
	window.open("/vprint.html?Idioma="+idioma, "","resizable=1,SCROLLBARS=YES,HEIGHT=600,WIDTH=745");
}

function PopUp(idioma,pagina,parametros){
	parametros = "Idioma="+idioma+"&Pagina="+pagina+"&"+parametros;
	window.open("/popup.php?"+parametros, "","resizable=1,SCROLLBARS=YES,HEIGHT=600,WIDTH=745");
}

function Documento(idioma,pagina,parametros){
	parametros = "Idioma="+idioma+"&Pagina="+pagina+"&"+parametros;
	window.open("/documento.php?"+parametros, "","resizable=1,SCROLLBARS=YES,HEIGHT=600,WIDTH=745");
}


var H_Replace =(window.onload)? window.onload : function(){};
window.onload = function(){ H_Replace; SimpleSwapSetup(); H_Replace; H4_Replace_Setup('h5'); }

function SimpleSwap(el, which) {
    el.src = el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup() {
    var x = document.getElementsByTagName("img");
    for (var i = 0; i < x.length; i++) {
        var oversrc = x[i].getAttribute("oversrc");
        if (!oversrc) {
            continue;
        }
        x[i].oversrc_img = new Image;
        x[i].oversrc_img.src = oversrc;
        x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
        x[i].onmouseout = new Function("SimpleSwap(this);");
        x[i].setAttribute("origsrc", x[i].src);
    }
}

function H4_Replace_Setup(etiqueta) {
    var x = document.getElementsByTagName(etiqueta);
    for (var i = 0; i < x.length; i++) {
        var texto = x[i].innerHTML;
        if (!texto) {
            continue;
        }
        mi_id = x[i].id = etiqueta+"_"+i;
        H1_x_Div(x[i]);

	link = x[i].getAttribute("href");
	width = str_replace("px","",getStyle(mi_id,'width'));
	height = str_replace("px","",getStyle(mi_id,'height'));
	
        H4_Flash(x[i].id,x[i].className,texto,width,height,link);

    }
}

function H1_x_Div(x){
	var replace = document.createElement('div');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id)
		{
			var y = replace.cloneNode(true);
			x[i].replaceChild(y,x[i].firstChild);
		}
	}
}

function H4_Flash(id,estilo,texto,width,height,link) {
	var so = new SWFObject("/media/Flash/"+estilo+".swf", "f"+id, width, height, "8", "#FFFFFF");
	so.addVariable("mitexto", texto);
	so.addVariable("miid", id);
	so.addVariable("miurl", link);
	so.addParam("wmode", "transparent");
	so.addParam("menu", "false");
	so.write(id);
}

function getStyle(el,styleProp){
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

function str_replace(busca, repla, orig){
	str 	= new String(orig);
	rExp	= "/"+busca+"/g";
	rExp	= eval(rExp);
	newS	= String(repla);
	str = new String(str.replace(rExp, newS));
	return str;
}

function url_nula() {
	void(0);
}

function stristr( haystack, needle) {
    var pos = 0;
    haystack += '';
    pos = haystack.toLowerCase().indexOf( (needle+'').toLowerCase() );
    if( pos == -1 ){
    	return false;
    }
    else{
	return true;
    }
}

function strtr (str, from, to) {
    
    var fr = '', i = 0, j = 0, lenStr = 0, lenFrom = 0, tmpStrictForIn = false, fromTypeStr = '', toTypeStr = '', istr = '';    var tmpFrom = [];
    var tmpTo = [];
    var ret = '';
    var match = false;
    if (typeof from === 'object') {
        tmpStrictForIn = this.ini_set('phpjs.strictForIn', false); // Not thread-safe; temporarily set to true
        from = this.krsort(from);        this.ini_set('phpjs.strictForIn', tmpStrictForIn);
 
        for (fr in from) {
            if (from.hasOwnProperty(fr)) {
                tmpFrom.push(fr);                tmpTo.push(from[fr]);
            }
        }
 
        from = tmpFrom;
        to = tmpTo;
    }
    
    lenStr  = str.length;
    lenFrom = from.length;
    fromTypeStr = typeof from === 'string';
    toTypeStr = typeof to === 'string';
 
    for (i = 0; i < lenStr; i++) {        match = false;
        if (fromTypeStr) {
            istr = str.charAt(i);
            for (j = 0; j < lenFrom; j++) {
                if (istr == from.charAt(j)) {                    match = true;
                    break;
                }
            }
        }        else {
            for (j = 0; j < lenFrom; j++) {
                if (str.substr(i, from[j].length) == from[j]) {
                    match = true;
                    // Fast forward                    i = (i + from[j].length)-1;
                    break;
                }
            }
        }        if (match) {
            ret += toTypeStr ? to.charAt(j) : to[j];
        } else {
            ret += str.charAt(i);
        }    }
 
    return ret;
}

function getRadio(ctrl){
	for(i=0;i<ctrl.length;i++)
		if(ctrl[i].checked) return ctrl[i].value;
}

function elimina_acentos(cadena){
	tofind = "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ,;.:-_´¨+*`[]'¡?¿ºª!·$%&/()=?¿|@#~’";
	replac = "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn                                   ";
	return(strtr(cadena,tofind,replac));
}

function Arregla_Rewrite(texto) {
	texto = elimina_acentos(texto);
	texto = str_replace('"',"",texto);
	texto = str_replace("  "," ",texto);
	texto = str_replace("  "," ",texto);
	texto = str_replace("  "," ",texto);
	texto = str_replace("  "," ",texto);
	texto = str_replace(" ","_",texto);
	return texto;
}

function vaciar(dato){
	dato.value = "";
}

function comprobarEmail(texto){

	var mailres = true;            
	var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
	var arroba = texto.indexOf("@",0);
	
	if ((texto.lastIndexOf("@")) != arroba) arroba = -1;
	
	var punto = texto.lastIndexOf(".");      
	for (var contador = 0 ; contador < texto.length ; contador++){
		if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
			mailres = false;
			 break;
		}
	}

	if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
		mailres = true;
	else
		mailres = false;

	return mailres;
}

function dateStatus(date) {
	var max = new Date("2037","11","31");
	if (max.getTime() < date.getTime()) {
		return true;
	}
}

function mostrarElemento(elemento){

	if(window.document.getElementById(elemento).style.display == "block"){
		window.document.getElementById(elemento).style.display = "none";
	}
	else{
		window.document.getElementById(elemento).style.display = "block";
	}
}


function cambiaSinopsis(elemento,si,no){

	if(window.document.getElementById(elemento).innerHTML == si){
		window.document.getElementById(elemento).innerHTML = no;
	}
	else{
		window.document.getElementById(elemento).innerHTML = si;
	}
}

var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.

var defaultimageheight = 40;	// maximum image size.
var defaultimagewidth = 40;	// maximum image size.

var timer;

function gettrailobj(){
if (document.getElementById)
return document.getElementById("preview_div").style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("preview_div")
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hidetrail(){	
	gettrailobj().display= "none";
	document.onmousemove=""
	gettrailobj().left="-3500px"
	clearTimeout(timer);
}

function showtrail(imagename,title,width,height){
	i = imagename
	t = title
	w = width
	h = height
	timer = setTimeout("show('"+i+"',t,w,h);",200);
	followmouse;
}
function show(imagename,title,width,height){
 
    	var oWidth = width;
    	var oHeight = height;
    	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500)) {
		( width == 0 ) ? width = defaultimagewidth: '';
		( height == 0 ) ? height = defaultimageheight: '';
			
		width+=30
		height+=30
		defaultimageheight = height
		defaultimagewidth = width
	
		document.onmousemove=followmouse_2; 

		
		newHTML = '<div class="border_preview" style="width:'+  width +'px;height:'+ height +'px"><div id="loader_container"><div id="loader"><div align="center">Cargando imagen '+title+' ...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
		//newHTML = newHTML + '<h2 class="title_h2">' + ' '+title + '</h2>'
		
    		newHTML = newHTML + '<div class="preview_temp_load"><img onload="javascript:remove_loading();" src="' + imagename + '" border="0" width="'+oWidth+'" height="'+oHeight+'"></div>';
		newHTML = newHTML + '</div>'; 
		
		if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1 ){
			newHTML = newHTML+'<iframe src="about:blank" scrolling="no" frameborder="0" width="'+width+'" height="'+height+'"></iframe>';
		}		

		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="block";
	}
}


function followmouse_2(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = e.pageX - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){
			ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	
	//xcoord = docwidth/2; 
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = e.pageX - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){
			ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}


var t_id = setInterval(animate,20);
var pos=0;
var dir=2;
var len=0;

function animate(){
	var elem = document.getElementById('progress');
	if(elem != null) {
		if (pos==0) len += dir;
		if (len>32 || pos>79) pos += dir;
		if (pos>79) len -= dir;
		if (pos>79 && len==0) pos=0;
		elem.style.left = pos;
		elem.style.width = len;
	}
}

function remove_loading() {
	this.clearInterval(t_id);
	var targelem = document.getElementById('loader_container');
	targelem.style.display='none';
	targelem.style.visibility='hidden';
	var t_id = setInterval(animate,60);
}

function replaceSubstring(inputString, fromString, toString) {
   var temp = inputString;
   if (fromString == '') {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1){
      while (temp.indexOf(fromString) != -1){
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   }
   else{
      var midStrings = new Array('~', '`', '_', '^', '#');
      var midStringLen = 1;
      var midString = '';
      while (midString == '') {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = '';
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      }
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   }
   return temp;
}

function CambiaCategorias(idioma,pagina,categoria,id){

	categoria = Arregla_Rewrite(categoria);

	if(id>0){
		location.href = "/" + idioma + "/libros/nov/" + categoria + "/" + id + ".html";
	}
	else{
		location.href = "/" + idioma + "_" + pagina + ".html";
	}

}

function CambiaProductos(idioma,pagina,categoria,id){

	categoria = Arregla_Rewrite(categoria);

	if(id>0){
		location.href = "/" + idioma + "/productos/cat/" + categoria + "/" + id + ".html";
	}
	else{
		location.href = "/" + idioma + "_" + pagina + ".html";
	}

}

function CambiaFormato(idioma,pagina,categoria,formato,id){

	categoria = Arregla_Rewrite(categoria);
	
	if(formato == "Precio_Imp") formato = "impresa";
	if(formato == "Precio_Dig") formato = "digital";
	
	if(formato != "Id"){
	
		location.href = "/" + idioma + "/" + pagina + "/" + formato + "/" + categoria + "/" + id + ".html";
	}
	else{
		location.href = "/" + idioma + "/" + pagina + "/" + categoria + "/" + id + ".html";
	}

}

function validarNIF(nif) {
	nif = replaceSubstring(nif,' ','');
	nif = replaceSubstring(nif,'-','');
	nif = replaceSubstring(nif,'.','');
	if(nif.length!=9){
		return false;
	}
	else{
		if(!(CalculaNif(nif) || CalculaCif(nif) || CalculaNie(nif))) {
			return false;
		}
		else {
			return true;
		}
	}
}
function CalculaNie(nif){
	var letras = 'TRWAGMYFPDXBNJZSQVHLCKE';
	var letraNie = nif.substring(0,1);
	var dni = nif.substring(1,8);
	var letraNif = nif.substring(8,9);
	var letraAux;
	var letraInicio='X';
	var numero = dni%23;
	letraAux = letras.substring(numero,numero+1);
	if ((letraAux == letraNif.toUpperCase()) && (letraInicio==letraNie.toUpperCase())){
		return true;
	}
	else{
		return false;
	}
}
function CalculaNif(nif){
	var letras = 'TRWAGMYFPDXBNJZSQVHLCKE';
	var dni    = nif.substring(0,8);
	var letraNif = nif.substring(8,9);
	var letraAux;
	var numero = dni%23;
	letraAux = letras.substring(numero,numero+1);
	if(letraAux == letraNif.toUpperCase()){
		return true;
	}
	else{
		return false;
	}
}
function CalculaCif(elCIF){
	var resul = false;
	var temp = elCIF.toUpperCase();
	if (!/^[A-Za-z0-9]{9}$/.test(temp)) {
		resul = false;
	}
	else {
		if (!/^[ABCDEFGHKLMNPQS]/.test(temp)) {
			resul = false;
		}
		else {
			resul = ValidaCIF(temp);
		}
	}
	return resul;
}
function ValidaCIF(elCIF){
	var resul = false;
	var v1 = new Array(0,2,4,6,8,1,3,5,7,9);
	var letrascif = 'ABCDEFGHIJ';
	var temp = 0;
	var temp1;
	for(i=2;i<=6;i+=2){
		temp = temp + v1[parseInt(elCIF.substr(i-1,1))];
		temp = temp + parseInt(elCIF.substr(i,1));
	}
	temp = temp + v1[parseInt(elCIF.substr(7,1))];
	temp = (10 - ( temp % 10));
	if( temp == 10 ) {
		if ((elCIF.substring(8,9)=='J') || (elCIF.substring(8,9)=='0')) {
			resul = true;
		}
		else {
			resul = false;
		}
	}
	else {
		if ((elCIF.substring(8,9)==temp) || (elCIF.substring(8,9)==letrascif.substring(temp-1,temp))) {
			resul = true;
		}
		else {
			resul = false;
		}
	}
	return resul;
}

function GeneraDatos(ff,pagina,campo,campoProvincia,campoPoblacion){

	if(campoProvincia == "Provincia_Fac"){
		pais = ff.Pais_Fac.value;
		codigo = ff.CodigoPostal_Fac.value;
	}
	else if(campoProvincia == "Provincia_Env"){
		pais = ff.Pais_Env.value;
		codigo = ff.CodigoPostal_Env.value;
	}
	else{
		pais = ff.Pais.value;
		codigo = ff.CodigoPostal.value;
	}
	if(codigo == ""){ codigo = 0; }

	var myConn2 = new XHConn();
	if (!myConn2) alert("XMLHTTP not available. Try a newer/better browser.");

	window.document.getElementById("cargando"+campo).style.display = "inline";

	if(pais == 199){

		var GeneraDatosFunc = function (oXML) {
			if (oXML.responseText!=""){
				datos = oXML.responseText;
				auxer = datos.split(";");
				window.document.getElementById("Provincia"+campo).innerHTML = auxer[0];
				window.document.getElementById("Poblacion"+campo).innerHTML = auxer[1];
			}
		};
		AGD(1,codigo,pagina,campoProvincia,campoPoblacion);
		

	}
	else{
		var GeneraDatosFunc = function (oXML) {
			if (oXML.responseText!=""){
				datos = oXML.responseText;
				auxer = datos.split(";");
				window.document.getElementById("Provincia"+campo).innerHTML = auxer[0];
				window.document.getElementById("Poblacion"+campo).innerHTML = auxer[1];
			}
		};
		AGD(2,codigo,pagina,campoProvincia,campoPoblacion);
	}

	window.document.getElementById("cargando"+campo).style.display = "none";

	function AGD(tipo,codigo,pagina,campoProvincia,campoPoblacion) {
		myConn2.connect("/inc/incAjaxPoblaciones.php", "GET", "Tipo="+tipo+"&CodigoPostal="+codigo+"&Pagina="+pagina+"&CampoProvincia="+campoProvincia+"&CampoPoblacion="+campoPoblacion, GeneraDatosFunc);
	}

}

function MostrarForm(formulario){
	window.document.getElementById(formulario).style.display = "block";
}


/* Cargar el botón de instalación de Digital Editions  Versión 1.7 */


	// ********************
	// Stub function provided to support operation
	// independent of DigitalEditionsDetection.js
	// ********************
	function ShowADE_DivLayer()
	{
		// This example does not use DigitalEditionsDetection.js
		// Therefore this stub is needed
		return;
	}

	// ********************
	// Stub function provided to support operation for SWF Version
	// This is called when sendSWFVersion = "true"
	// and the script at setG_strSWFVersion() detects a fresh string
	// ********************
	function ShowSWFVersion_DivLayer()
	{
		// We do the version in this example therefore this is needed
		if (G_bUpdateSWFVersion)
		{
			G_bUpdateSWFVersion = false;
			var element = document.getElementById("swfVersionDiv");

			if (G_strSWFVersion.length > 0)
			{
				element.innerHTML = "<hr/>Adobe Digital Editions SWF Version:<br/><br/>" + G_strSWFVersion;
				// kick in the pants to be sure to display
				element.style.display = "block";
			}
			else
			{
				element.style.display = "none";
			}
		}
		return;
	}

	// ********************
	// Stub function provided to support send_ADE_SWF_ButtonPush()
	// That anchor function will call the stub
	// This way, the anchor function is always defined, and various
	// implementations can provide the stub where needed
	// ********************
	function ADE_SWF_ButtonPush_action()
	{
		// Copy and enable this function into your
		// implementations where sendButtonPush = "true"

		//  NOTE: When sendButtonPush = "true", then even if contentURL is set, it will not
		//  be sent to ADE after it is launched.  When sendButtonPush = "true", all that happens
		//  after ADE is launched is that the JS Callback is made, and that is it.

		// We dont do this, but stub is provided anyway
		return;
	}

	function doOnLoad()
	{
		// Please reference ADEBadgeLauncher.js for full documentation

		//  HTML Section params:
		//  =========================
		// HTMLdivID - id of the <div> which will hold the SWF
		// HTMLobjectID - desired ID for the HTML <object> that contains the SWF (may be null - default is ADEBadgeLauncherInstance)


		// *******************************
		// FOR installerDivLayer1
		// *******************************

		//  HTML Section params:
		//  =========================
		var HTMLdivID = "installerDivLayer1"; 
		var HTMLobjectID = "ADEBadgeInstallerInstance1";

		//  Flash SWF parameters:
		//  =========================
		var autoInstall = false; 
		var autoLaunch = false;
		var badFlashRedirectURL	= null; // "http://my.domain.com/flashhelp";  // null; // can be null

		var sendSWFVersion = true;
		var sendButtonPush = false;  // if true, only call the JS function - contentURL would be ignored if used

		ADEBadgeInstallerInstance(HTMLdivID, HTMLobjectID,  autoInstall, autoLaunch, badFlashRedirectURL, sendSWFVersion, sendButtonPush);

		// *******************************
		// THIS SECTION SHOWING THE USE OF THE DEFAULTS
		// *******************************

	 /**** installerDivLayer2 commented for now ****	

		//  HTML Section params:
		//  =========================
		HTMLdivID = "installerDivLayer2"; 
		HTMLobjectID = "ADEBadgeInstallerInstance2";

		SetADEBadgeInstallerDefaults(autoInstall, autoLaunch, badFlashRedirectURL, sendSWFVersion, sendButtonPush);

		// simpler API
		ADEBadgeInstallerInstanceWithDefs(HTMLdivID, HTMLobjectID);

	**** installerDivLayer2 commented for now ****/

	}
	


/* Cargar el botón de instalación de Digital Editions  Versión 1.6 */

function ADE_Instalador() {


	var qs = new Querystring();

	var so = new SWFObject("/media/Flash/ade_web_library.swf", "subtitulo", 315, 220, "7", "#FFFFFF");
	so.addParam("wmode", "opaque");
	so.addParam("menu", "false");

	so.addVariable("min_major_version", "7");
	so.addVariable("min_minor_version", "0");
	so.addVariable("min_rev_version", "0");
	so.addVariable("min_build_version", "0");

	so.addVariable("MMredirectURL", document.location.href);
	so.addVariable("userAgent", navigator.userAgent);
	so.addVariable("ADEVersion", "2");  // "2" means ADE 1.5

	var ap = qs.get("autoPrompt", "false");
	so.addVariable("autoPrompt", ap);

	so.addVariable("badgeJSLauncher", "true");
	so.addVariable("file", "");
	so.addVariable("contentURL", "");

	so.write('div_ADE_Instalador');

}



/* Client-side access to querystring name=value pairs
	Version 1.3
	28 May 2008
	
	License (Simplified BSD):
	http://adamv.com/dev/javascript/qslicense.txt
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}


function GeneraTiendas(ff,campo,cliente){

	var pais = ff.Pais.value;
	var codigo = ff.CodigoPostal.value;
	
	if((pais == 199 || pais == 5) && (codigo != "" && codigo != "0")){

		var myConn2 = new XHConn();
		if (!myConn2) alert("XMLHTTP not available. Try a newer/better browser.");
	
		var GeneraTiendasFunc = function (oXML) {
			if (oXML.responseText!=""){
				datos = oXML.responseText;
				window.document.getElementById(campo).innerHTML = datos;
			}
		
		};
		
	
		var poblacion = ff.Poblacion.value;
		var provincia = ff.Tienda_Provincia.value;
		
		AGT(campo,cliente,poblacion,provincia);
			
	}
	
	function AGT(campo,cliente,poblacion,provincia) {
		myConn2.connect("/inc/incAjaxTiendas.php", "GET", "Cliente="+cliente+"&Campo="+campo+"&Poblacion="+poblacion+"&Provincia="+provincia, GeneraTiendasFunc);
	}
}

function CambiaProvincia(ff,campo,cliente){

	var pais = ff.Pais.value;
	var codigo = ff.CodigoPostal.value;
	codigo = codigo.substr(0,2);
	codigo = parseInt(codigo,10);
		
	if((codigo > 0 && codigo < 54) && (pais == 199 || pais == 5)){
		ff.Tienda_Provincia.disabled = false;
		ff.Tienda_Calle.disabled = false;
		ff.Tienda_Provincia.value = codigo;
		GeneraTiendas(ff,campo,cliente);
	}
	else{
		ff.Tienda_Provincia.disabled = true;
		ff.Tienda_Calle.disabled = true;
	}

}
