function toggleLayer(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else
		if (document.layers) {
			// this is the way nn4 works
			var style2 = document.layers[whichLayer].style;
			style2.display = style2.display? "":"block";
		}
}

function hideLayer(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"none";
	}
	else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"none";
	}
	else
		if (document.layers) {
			// this is the way nn4 works
			var style2 = document.layers[whichLayer].style;
			style2.display = style2.display? "":"none";
		}
}

function refrescar(value){

	window.location.href = "/login.php?idafil=" + value
}

function refrescar_tarot(value){

	window.location.href = "/login_tarot.php?idafil=" + value


}

function refrescar_permiso(value){

	window.location.href = "/private_zone/permisos/index.htm?idusuario=" + value
}

function refrescar_banner(value){

	window.location.href = "/private_zone/webcams/banners.htm?tipo=" + value


}

function refrescar_captura(value){

	if (value != '') {

		window.location.href = "/private_zone/webcams/capturas.htm?tipo=" + value

	}


}

function ctexto(elem){
	document.form.ctexto.value=elem
}
function cfondo(elem){
	document.form.cfondo.value=elem
}
function cnumero(elem){
	document.form.ctelefono.value=elem
}

var hexadecimal = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");

function rgb2hex(R, G, B) {
        if (R > 255 || G > 255 || B > 255) {
            alert('Las cifras no pueden ser mayores que 255');
            return false;
        }
        if (R < 0 || G < 0 || B < 0) {
            alert('Las cifras no pueden ser menores que 0');
            return false;
        }
        var Rrest = R % 16;
        var R = (R - Rrest) / 16;
        var Grest = G % 16;
        var G = (G - Grest) / 16;
        var Brest = B % 16;
        var B = (B - Brest) / 16;
        var red = hexadecimal[R] + hexadecimal[Rrest];
        var green = hexadecimal[G] + hexadecimal[Grest];
        var blue = hexadecimal[B] + hexadecimal[Brest];

        return '#'+red+green+blue;
}

function indexOf (what) {
        var i = new Number();

        for (i=0 ; i < hexadecimal.length ; i++) {
            if (hexadecimal[i] == what.toUpperCase()) {
                return i;
            }
        }
        return 0;
}

function muestra_color(objeto, color) {

        if (!color) {
            color = getColor(objeto);
        }
        document.form.sample.style.background = color;
}

function hex2rgb(RGB) {
        var valor = new Array;
        var cifras = new Array;

        RGB = RGB.replace("#","");
        valor[0] = parseInt(indexOf(RGB.substr(0,1)));
        valor[1] = parseInt(indexOf(RGB.substr(1,1)));
        valor[2] = parseInt(indexOf(RGB.substr(2,1)));
        valor[3] = parseInt(indexOf(RGB.substr(3,1)));
        valor[4] = parseInt(indexOf(RGB.substr(4,1)));
        valor[5] = parseInt(indexOf(RGB.substr(5,1)));

        cifras[0] = valor[0] * 16 + valor[1];
        cifras[1] = valor[2] * 16 + valor[3];
        cifras[2] = valor[4] * 16 + valor[5];

        return Array(cifras[0], cifras[1], cifras[2]);
}

function chkColorImg(color) {

        if (color == 'red') {
            return true;
        } else {
            return false;
        }
}

function getColor(objeto) {
        if (document.layers) {
            eval('var hex = window.document.layers[objeto].bgColor');
        } else if (document.all) {
            eval('var hex = window.document.all[objeto].style.background');
        }
        return hex;
}

function colores(inicio) {
        var index = document.form.sel.value;
        if (!index) {
            alert('Haga click sobre el campo a cambiar y posteriormente seleccione el color en la paleta');
            return;
        }
        document.form.elements[index].value = inicio;
        document.form.elements[index].style.background = inicio;

        var RGB = new Array();
        RGB = hex2rgb(inicio);

        if (((RGB[0] + RGB[1] + RGB[2]) / 3) >= 85) {
            document.form.elements[index].style.color = '#000000';
        } else {
            document.form.elements[index].style.color = '#FFFFFF';
        }
        document.form.sel.value = inicio;

}

function paleta() {
        var i = j = 0;
        var R = G = B = 0;
        var paso = 51;

        document.write('<table border=0 cellspacing=0 cellpadding=0>');
        for (G = 0; G <= 255 ; G = G + paso) {
            document.write('<tr>');
            for (R = 0; R <= 255 ; R = R + paso) {
                for (B = 0; B <= 255 ; B = B + paso) {
                    color = rgb2hex(R,G,B);
                    document.write('<td class="pixel" id="r'+R+'g'+G+'b'+B+'" style="background: '+color+';" onMouseOver="javascript: return muestra_color(\'r'+R+'g'+G+'b'+B+'\',\''+color+'\');" onClick="javascript: colores(\''+color+'\');">&nbsp;&nbsp;&nbsp;</td>');
                }
            }
            document.write("</tr>\n");
        }
        document.write('</table>');
}


function mostrar_imagen(obj, imagen){

	obj.style.backgroundImage = "url('"+imagen+"')";
}

function mostrar_player(obj, datos){

	var a_datos = datos.split("-");
	var imagen = "http://www.recursoweb.com/images/player_swf/" + a_datos[1];
	if (a_datos[1])	obj.style.backgroundImage = "url('"+imagen+"')";
	else obj.style.backgroundImage = "url('http://www.recursoweb.com/images/player_swf/no_player.jpg')";
}

function Form_ListadoResp(text) {
	myAlert2(text, '/private_zone/webcams/salas_iframe.htm');
}

function CheckForm_Listado(f, pagina) {

	var msg          = '';
    var empty_fields = "";
    var errors       = "";
    var obliga       = 0;
    var conrepes     = 1;
    var selecciondos = '';

    // Inicializa los valores del formulario

	 if (esVacio(f.ctxtchica.value) || f.ctxtchica.value==null || f.ctxtchica.value== ""){

      	empty_fields += "\nColor Chic@" ;

    }

    if (esVacio(f.ctxtacceso.value) || f.ctxtacceso.value==null || f.ctxtacceso.value== ""){

    	empty_fields += "\nColor Acceso" ;

    }

    if (esVacio(f.cfondo.value) || f.cfondo.value==null || f.cfondo.value== ""){

    	empty_fields += "\nColor Fondo" ;

    }

    if (esVacio(f.dominio.value) || f.dominio.value==null || f.dominio.value== ""){

    	empty_fields += "\nDominio" ;

    }

    if (esVacio(f.ctxttelefono.value) || f.ctxttelefono.value==null || f.ctxttelefono.value== ""){

    	empty_fields += "\nColor Nº Telefono" ;

    }

    // Formamos el mensaje de error.
    if (errors=="" && empty_fields=="") {

    	if (pagina != 'previsualizar') {

    		AjaxSendForm('form', pagina, Form_ListadoResp);

    	} else {
    		var ctxtchica  = f.ctxtchica.value.replace("#","");
    		var ctxtacceso = f.ctxtacceso.value.replace("#","");
    		var cfondo 	   = f.cfondo.value.replace("#","");
    		var ctxttelefono   = f.ctxttelefono.value.replace("#","");

    		if (typeof(f.player_swf) != "undefined") {

    			var a_datos = f.player_swf.value.split("-");
    			var player_tipo  = a_datos[0];

    		} else {

    			var player_tipo  = '';
    			var player_color = '';

    		}


    		if (typeof(f.cplayer) != "undefined") var player_color   = f.cplayer.value.replace("#","");
    		else var player_color   = '';

    		if (f.fpago[0].checked) var fpago = f.fpago[0].value;
    		else var fpago = f.fpago[1].value;

    		var URL = 'http://videochat.paraisowebcam.com/listado_salas.htm?preview=1&tipo=' + f.tipo.value + '&alias=' + f.alias_popup.value + '&filas=' + f.filas.value +'&columnas=' + f.columnas.value + '&ctxtchica=' + ctxtchica + '&ctxttelefono=' + ctxttelefono + '&ctxtacceso=' + ctxtacceso + '&cfondo=' + cfondo + '&plantilla=' + f.plantilla.value + '&webcam=' + f.webcam.value + '&fpago=' + fpago + '&id_listado=' + f.idlistado.value + '&player_tipo=' + player_tipo + '&player_color=' + player_color + '&tamanyo=' + f.tamanyo.value;
   			window.open(URL,"ventana1","width=750,height=900,scrollbars=YES,resizable=YES")
    	}

    } else{

      msg = "Se han detectado errores en el formulario.\n\n";

      if (errors) {

          msg += "- Los siguientes campos tienen valores erroneos :\n"+ errors;

      }

      if (empty_fields) {

          msg += "\n- Los siguientes campos obligatorios estan vacios:\n"+ empty_fields;

      }

      if (msg != '') {
      	alert('-'+ msg +'-');
      }
    }
}

function CheckForm_Listado2(f, pagina, urlsalas) {

	var msg          = '';
    var empty_fields = "";
    var errors       = "";
    var obliga       = 0;
    var conrepes     = 1;
    var selecciondos = '';

    // Inicializa los valores del formulario

	 if (esVacio(f.ctxtchica.value) || f.ctxtchica.value==null || f.ctxtchica.value== ""){

      	empty_fields += "\nColor Chic@" ;

    }

    if (esVacio(f.ctxtacceso.value) || f.ctxtacceso.value==null || f.ctxtacceso.value== ""){

    	empty_fields += "\nColor Acceso" ;

    }

    if (esVacio(f.cfondo.value) || f.cfondo.value==null || f.cfondo.value== ""){

    	empty_fields += "\nColor Fondo" ;

    }

    if (esVacio(f.dominio.value) || f.dominio.value==null || f.dominio.value== ""){

    	empty_fields += "\nDominio" ;

    }

    if (esVacio(f.ctxttelefono.value) || f.ctxttelefono.value==null || f.ctxttelefono.value== ""){

    	empty_fields += "\nColor Nº Telefono" ;

    }

    // Formamos el mensaje de error.
    if (errors=="" && empty_fields=="") {

    	if (pagina != 'previsualizar') {

    		AjaxSendForm('form', pagina, Form_ListadoResp);

    	} else {
    		var ctxtchica  = f.ctxtchica.value.replace("#","");
    		var ctxtacceso = f.ctxtacceso.value.replace("#","");
    		var cfondo 	   = f.cfondo.value.replace("#","");
    		var ctxttelefono   = f.ctxttelefono.value.replace("#","");

    		if (typeof(f.player_swf) != "undefined") {

    			var a_datos = f.player_swf.value.split("-");
    			var player_tipo  = a_datos[0];

    		} else {

    			var player_tipo  = '';
    			var player_color = '';

    		}


    		if (typeof(f.cplayer) != "undefined") var player_color   = f.cplayer.value.replace("#","");
    		else var player_color   = '';

    		if (f.fpago[0].checked) var fpago = f.fpago[0].value;
    		else var fpago = f.fpago[1].value;

    		var URL = urlsalas + '?preview=1&tipo=' + f.tipo.value + '&alias=' + f.alias_popup.value + '&filas=' + f.filas.value +'&columnas=' + f.columnas.value + '&ctxtchica=' + ctxtchica + '&ctxttelefono=' + ctxttelefono + '&ctxtacceso=' + ctxtacceso + '&cfondo=' + cfondo + '&plantilla=' + f.plantilla.value + '&webcam=' + f.webcam.value + '&fpago=' + fpago + '&id_listado=' + f.idlistado.value + '&player_tipo=' + player_tipo + '&player_color=' + player_color + '&tamanyo=' + f.tamanyo.value;
   			window.open(URL,"ventana1","width=750,height=900,scrollbars=YES,resizable=YES")
    	}

    } else{

      msg = "Se han detectado errores en el formulario.\n\n";

      if (errors) {

          msg += "- Los siguientes campos tienen valores erroneos :\n"+ errors;

      }

      if (empty_fields) {

          msg += "\n- Los siguientes campos obligatorios estan vacios:\n"+ empty_fields;

      }

      if (msg != '') {
      	alert('-'+ msg +'-');
      }
    }
}

function Form_Listado_SWFResp(text) {
	myAlert2(text, '/private_zone/webcams/salas_swf.htm');
}

function CheckForm_Listado_SWF(f, pagina) {

	var msg          = '';
    var empty_fields = "";
    var errors       = "";
    var obliga       = 0;
    var conrepes     = 1;
    var selecciondos = '';

    // Inicializa los valores del formulario

	 if (esVacio(f.ctxtcolor.value) || f.ctxtcolor.value==null || f.ctxtcolor.value== ""){

      	empty_fields += "\nColor Chic@" ;

    }

    if (esVacio(f.ctxtcolor2.value) || f.ctxtcolor2.value==null || f.ctxtcolor2.value== ""){

    	empty_fields += "\nColor Texto Entrar" ;

    }

    if (esVacio(f.cfondo.value) || f.cfondo.value==null || f.cfondo.value== ""){

    	empty_fields += "\nColor Fondo" ;

    }

    if (esVacio(f.dominio.value) || f.dominio.value==null || f.dominio.value== ""){

    	empty_fields += "\nDominio" ;

    }

    if (esVacio(f.cbgcolor.value) || f.cbgcolor.value==null || f.cbgcolor.value== ""){

    	empty_fields += "\nColor Fondo Cajita" ;

    }

    // Formamos el mensaje de error.
    if (errors=="" && empty_fields=="") {

    	if (pagina != 'previsualizar') {

    		AjaxSendForm('form', pagina, Form_Listado_SWFResp);

    	} else {
    		var ctxtcolor  = f.ctxtcolor.value.replace("#","");
    		var ctxtcolor2 = f.ctxtcolor2.value.replace("#","");
    		var cfondo 	   = f.cfondo.value.replace("#","");
    		var cbgcolor   = f.cbgcolor.value.replace("#","");

    		if (f.fpago[0].checked) var fpago = f.fpago[0].value;
    		else var fpago = f.fpago[1].value;

    		var URL = 'http://videochat.paraisowebcam.com/listado_salas_swf.htm?preview=1&tipo=' + f.tipo.value + '&alias=' + f.alias_popup.value + '&filas=' + f.filas.value +'&columnas=' + f.columnas.value + '&ctxtcolor=' + ctxtcolor + '&ctxtcolor2=' + ctxtcolor2 + '&cfondo=' + cfondo + '&cbgcolor=' + cbgcolor + '&marco=' + f.marco.value + '&fpago=' + fpago + '&id_listado=' + f.idlistado.value;
   			window.open(URL,"ventana1","width=750,height=900,scrollbars=YES,resizable=YES")
    	}

    } else{

      msg = "Se han detectado errores en el formulario.\n\n";

      if (errors) {

          msg += "- Los siguientes campos tienen valores erroneos :"+ errors;

      }

      if (empty_fields) {

          msg += "\n- Los siguientes campos obligatorios estan vacios:"+ empty_fields;

      }
      if (msg != '') {
      	alert(msg);
      }
    }
}



function esVacio(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

function CheckForm_Datos(f, pagina) {

	var msg;
    var empty_fields = "";
    var errors = "";
    var obliga=0;
    var conrepes=1;
    var selecciondos='';

    // Inicializa los valores del formulario

	 if (esVacio(f.nombre.value) || f.nombre.value==null || f.nombre.value== ""){

      	empty_fields += "\nNombre empresa" ;

    }

    if (esVacio(f.cif.value) || f.cif.value==null || f.cif.value== ""){

    	empty_fields += "\nCIF" ;

    }

    if (esVacio(f.contacto.value) || f.contacto.value==null || f.contacto.value== ""){

    	empty_fields += "\nPersona de Contacto" ;

    }

    if (esVacio(f.domicilio.value) || f.domicilio.value==null || f.domicilio.value== ""){

    	empty_fields += "\nDomicilio" ;

    }

    if (esVacio(f.poblacion.value) || f.poblacion.value==null || f.poblacion.value== ""){

    	empty_fields += "\nPoblacion" ;

    }

    if (esVacio(f.provincia.value) || f.provincia.value==null || f.provincia.value== ""){

    	empty_fields += "\nProvincia" ;

    }

    if (esVacio(f.pais.value) || f.pais.value==null || f.pais.value== ""){

    	empty_fields += "\nPais" ;

    }

    if (esVacio(f.email.value) || f.email.value==null || f.email.value== ""){

    	empty_fields += "\nEmail" ;

    }

    if (esVacio(f.web.value) || f.web.value==null || f.web.value== ""){

    	empty_fields += "\nWeb" ;

    }

    if (esVacio(f.password2.value) || f.password2.value==null || f.password2.value== ""){

    	empty_fields += "\nPassword" ;

    }

    // Formamos el mensaje de error.
    if (errors=="" && empty_fields=="") {

    		AjaxSendForm('datos', pagina, myAlert);

    }else{

      msg = "Se han detectado errores en el formulario.\n\n";

      if (errors) {

          msg += "- Los siguientes campos tienen valores erroneos :"+ errors;

      }

      if (empty_fields) {

          msg += "\n- Los siguientes campos obligatorios estan vacios:"+ empty_fields;

      }
      alert(msg);
    }
}

function registroResp(text) {
	if (text != 'Gracias por registrarse, utilice el login y password para acceder a su intranet') {
		myAlert(text);
	} else {
		myAlert(text, '/');
		//setTimeout("window.location.href = '/'", 200);
	}
}

function ticketResp(text) {
	var iniText = text.substring(0,11);
	//if (text != 'Atenderemos su ticket lo antes posible.<br><br>Recibirá un email con los detalles del mismo.') {
	if (iniText != 'Atenderemos') {
		myAlert(text);
	} else {
		myAlert(text, '/private_zone/support/index.htm');
		//setTimeout("window.location.href = '/'", 200);
	}
}

function ticketRespXPagos(text) {
	var iniText = text.substring(0,11);
	if (iniText != 'Atenderemos') {
		myAlert(text);
	} else {
		myAlert(text, '/private_zone/support/list.htm');
	}
}

function imprimir_pagina (pagina){

	var URL = pagina;

   window.open(URL,"ventana1","width=490,height=720,scrollbars=AUTO,resizable=NO")
}

function imprimir_pagina_tarot (pagina){

	var URL = pagina;

   window.open(URL,"ventana1","width=550,height=720,scrollbars=AUTO,resizable=NO")
}

function abrir_ventana (pagina, imagen){

	var URL = pagina + '?imagen=' + imagen;

   window.open(URL,"ventana1","width=490,height=250,scrollbars=AUTO,resizable=NO")
}


function abrir_player (pagina, size){

	var URL = pagina + '?size=' + size;
	var a_size = size.split("x");
	var ancho  = a_size[0];
	var alto   = parseInt(a_size[1]);

   window.open(URL,"ventana1","width="+ancho+",height="+alto+",scrollbars=AUTO,resizable=NO")
}


function myAlert(text, url) {
	var html = '';
	html += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"list_pair\">\n";
	html += "\t<tr style=\"height:20px\"><td></td></tr>\n";
	html += "\t<tr>\n";
	html += "\t\t<td colspan=\"2\" align=\"center\">" + text + "</td>\n";
	html += "\t</tr>\n";
	html += "\t<tr style=\"height:20px\"><td></td></tr>\n";
	html += "\t<tr>\n";
	html += "\t\t<td colspan=\"2\" align=\"center\">\n";
	if (!url) {
		html += "\t\t\t<input class=\"buttons\" name=\"ModalboxYes\" type=\"button\" id=\"ModalboxYes\" value=\"Aceptar\" onclick=\"javascript:Modalbox.hide()\">\n";
	} else {
		html += "\t\t\t<input class=\"buttons\" name=\"ModalboxYes\" type=\"button\" id=\"ModalboxYes\" value=\"Aceptar\" onclick=\"javascript:Modalbox.hide(); window.location.href='" + url + "'\">\n";
	}
	html += "\t\t</td>\n";
	html += "\t</tr>\n";
	html += "\t<tr style=\"height:20px\"><td></td></tr>\n";
	html += "</table>\n";

	Modalbox.show(html, {title: '¡¡Atención!!', width: 250});
}

function myAlert2(text, url) {
	alert(text);
	window.location = url;
}

function changeTypeTicket(type) {
	window.location.href = "list.htm?admin=1&type=" + type;
}

function verFAQ_viejo_borraremos(faq, estado, faqresp) {

	var form = document.getElementById('formFaqs');
	var vars = {};
	for (i=0; i<form.length; i++) {
		var name = form.elements[i].name;
		if (name.substring(0,6) == 'hidden') {
			form.elements[i].value = 'oculto';
			number = name.substring(6);
			var myfaq = document.getElementById('faq' + number);
			myfaq.innerHTML = '';
		}
	}

	var faq     = document.getElementById(faq);
	var estado  = document.getElementById(estado);
	var resp    = document.getElementById(faqresp);

	if (estado.value == 'oculto') {
		estado.value  = 'visible';
		faq.innerHTML = "<div class='list_odd' style='width:100%'>" + resp.value + "</div>";
	} else {
		estado.value  = 'oculto';
		faq.innerHTML = '';
	}
}

function printStats(html) {
	var divHtml       = document.getElementById('divStats');
	divHtml.innerHTML = html;
}


function CheckForm_Marca_Blanca(f, pagina) {

	var msg;
    var empty_fields = "";
    var errors = "";
    var obliga=0;
    var conrepes=1;
    var selecciondos='';

    // Inicializa los valores del formulario

	 if (esVacio(f.alias_popup.value) || f.alias_popup.value==null || f.alias_popup.value== ""){

      	empty_fields += "\nSeleccione un Alias" ;

    }

    if (esVacio(f.tipo.value) || f.tipo.value==null || f.tipo.value== ""){

    	empty_fields += "\nSeleccione un Tipo de Web" ;

    }


    // Formamos el mensaje de error.
    if (errors=="" && empty_fields=="") {

    	if (pagina != 'previsualizar') {

    		AjaxSendForm('form', pagina, myAlert('Insertado Correctamente', '/private_zone/webcams/marca_blanca.htm'));

    	} else {

    		var background  				= f.background.value.replace("#","");
    		var background_caja_listado 	= f.background_caja_listado.value.replace("#","");
    		var background_titulo_listado 	= f.background_titulo_listado.value.replace("#","");
    		var background_header		 	= f.background_header.value.replace("#","");
    		var txt_header				 	= f.txt_header.value.replace("#","");
    		var txt_header_p			 	= f.txt_header_p.value.replace("#","");
    		var txt_titulo_listado		 	= f.txt_titulo_listado.value.replace("#","");
    		var txt_conectada			 	= f.txt_conectada.value.replace("#","");
    		var txt_menu				 	= f.txt_menu.value.replace("#","");
    		var txt_titulo				 	= f.txt_titulo.value.replace("#","");
    		var txt						 	= f.txt.value.replace("#","");

   			var URL = 'http://' + f.tipo.value + '/?actualizar=1&background=' + background + '&background-caja-listado=' + background_caja_listado + '&background-titulo-listado=' + background_titulo_listado +'&background-header=' + background_header + '&txt-header=' + txt_header + '&txt-header-p=' + txt_header_p + '&txt-titulo-listado=' + txt_titulo_listado + '&txt-conectada=' + txt_conectada + '&txt-menu=' + txt_menu  + '&txt-titulo=' + txt_titulo  + '&txt=' + txt;

   			window.open(URL,"ventana1","width=850,height=900,scrollbars=YES,resizable=YES")
    	}

    } else{

      msg = "Se han detectado errores en el formulario.\n\n";

      if (errors) {

          msg += "- Los siguientes campos tienen valores erroneos :"+ errors;

      }

      if (empty_fields) {

          msg += "\n- Los siguientes campos obligatorios estan vacios:"+ empty_fields;

      }
      alert(msg);
    }
}


function CheckForm_Marca_Blanca_WAP(f, pagina) {

	var msg;
    var empty_fields = "";
    var errors = "";
    var obliga=0;
    var conrepes=1;
    var selecciondos='';

    // Inicializa los valores del formulario

	 if (esVacio(f.alias_popup.value) || f.alias_popup.value==null || f.alias_popup.value== ""){

      	empty_fields += "\nSeleccione un Alias" ;

    }

    // Formamos el mensaje de error.
    if (errors=="" && empty_fields=="") {

    	if (pagina != 'previsualizar') {

    		AjaxSendForm('form', pagina, myAlert('Insertado Correctamente', '/private_zone/contenido_wap/marca_blanca.htm'));

    	} else {

    		var background  				= f.color_fondo.value.replace("#","");
    		var color_titulo			 	= f.color_titulo.value.replace("#","");
    		var color_txt				 	= f.color_txt.value.replace("#","");
    		var color_txt_2				 	= f.color_txt_2.value.replace("#","");
    		var color_destacado			 	= f.color_destacado.value.replace("#","");

   			var URL = 'http://todoporno.mobi/?phone_brand=NOKIA&idphone=367&actualizar=1&tpl=afiliado&color_fondo=' + background + '&color_titulo=' + color_titulo + '&color_txt=' + color_txt +'&color_txt_2=' + color_txt_2 + '&color_destacado=' + color_destacado;
    		//alert(URL);
   			window.open(URL,"ventana1","width=242,height=300,scrollbars=YES,resizable=YES")
    	}

    } else{

      msg = "Se han detectado errores en el formulario.\n\n";

      if (errors) {

          msg += "- Los siguientes campos tienen valores erroneos :"+ errors;

      }

      if (empty_fields) {

          msg += "\n- Los siguientes campos obligatorios estan vacios:"+ empty_fields;

      }
      alert(msg);
    }
}

var TieneFoco = true;
var ventana;
var cont=0;

function DaFoco() { if (TieneFoco == true)	setTimeout("ventana.focus()",100); }

function redimensiona_ventana(ancho, alto) {
	ventana.resizeTo(ancho+12,alto+28);
	ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
}

function abre_foto(foto,titulo) {
	// Si descomentamos esta linea, la ventana se cierra y se abre cada vez (no es necesario si utilizamos el onLoad="opener.daFoco()" en el poput)
	//if(cont==1){ventana.close();ventana=null}
	if(titulo==null){titulo='www.recursoweb.com'}
	var danch = (screen.availWidth / 2)-(400/2);
	var dalt = (screen.availHeight / 2)-(200/2);
	ventana=window.open('','ventana','resizable=yes,scrollbars=no,width=400,height=200,top='+ dalt +',left='+ danch)
	ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden;" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onLoad="opener.DaFoco()" onUnload="opener.cont=0" onFocus="opener.redimensiona_ventana(fotillo.width, fotillo.height)"><img name="fotillo" alt="Pulsa para cerrar" src="' + foto + '" onLoad="opener.redimensiona_ventana(this.width, this.height)" onClick="window.close()" style="cursor:hand">');
	ventana.document.close();
	cont++;
}

function mostrar_marco(marco) {

	document.getElementById(marco).style.display = 'block'

	if (marco != 'marco1') document.getElementById('marco1').style.display = 'none';
	if (marco != 'marco2') document.getElementById('marco2').style.display = 'none';
	if (marco != 'marco3') document.getElementById('marco3').style.display = 'none';
	if (marco != 'marco4') document.getElementById('marco4').style.display = 'none';
	if (marco != 'marco5') document.getElementById('marco5').style.display = 'none';
	if (marco != 'marco6') document.getElementById('marco6').style.display = 'none';

}

function change_numfactura (pagina, num){

	var URL = pagina + '?num=' + num;

   window.open(URL,"ventana1","width=350,height=150,scrollbars=AUTO,resizable=NO")
}


function Form_ListadoResp2(text) {
	myAlert2(text, '/private_zone/webcams_tarot/salas_iframe.htm');
}

function CheckForm_Listado_Tarot(f, pagina) {

	var msg          = '';
    var empty_fields = "";
    var errors       = "";
    var obliga       = 0;
    var conrepes     = 1;
    var selecciondos = '';

    // Inicializa los valores del formulario
    if (esVacio(f.ccaja.value) || f.ccaja.value==null || f.ccaja.value== ""){
    	empty_fields += "\nColor Caja" ;
    }
    
    if (esVacio(f.cfondo.value) || f.cfondo.value==null || f.cfondo.value== ""){
    	empty_fields += "\nColor Fondo" ;
    }
    
    if (esVacio(f.ctitulo.value) || f.ctitulo.value==null || f.ctitulo.value== ""){
    	empty_fields += "\nColor Nombre Tarotista" ;
    }
    
    if (esVacio(f.ctxt.value) || f.ctxt.value==null || f.ctxt.value== ""){
    	empty_fields += "\nColor Texto" ;
    }

    if (esVacio(f.dominio.value) || f.dominio.value==null || f.dominio.value== ""){
    	empty_fields += "\nDominio" ;
    }

    // Formamos el mensaje de error.
    if (errors=="" && empty_fields=="") {

    	if (pagina != 'previsualizar') {

    		AjaxSendForm('form', pagina, Form_ListadoResp2);

    	} else {
    		var ccaja  	= f.ccaja.value.replace("#","");
    		var ctxt	= f.ctxt.value.replace("#","");
    		var cfondo 	= f.cfondo.value.replace("#","");
    		var ctitulo = f.ctitulo.value.replace("#","");

    		if (f.fpago[0].checked) var fpago = f.fpago[0].value;
    		else var fpago = f.fpago[1].value;

    		var URL = 'http://salas.sponsortarot.com/listado_tarotistas.htm?preview=1&alias=' + f.alias_popup.value + '&filas=' + f.filas.value +'&columnas=' + f.columnas.value + '&ctxt=' + ctxt + '&ctitulo=' + ctitulo + '&ccaja=' + ccaja + '&cfondo=' + cfondo + '&fpago=' + fpago + '&id_listado=' + f.idlistado.value;
   			window.open(URL,"ventana1","width=750,height=900,scrollbars=YES,resizable=YES")
    	}

    } else{

      msg = "Se han detectado errores en el formulario.\n\n";

      if (errors) {

          msg += "- Los siguientes campos tienen valores erroneos :\n"+ errors;

      }

      if (empty_fields) {

          msg += "\n- Los siguientes campos obligatorios estan vacios:\n"+ empty_fields;

      }

      if (msg != '') {
      	alert('-'+ msg +'-');
      }
    }
}

function validateEmail(e){

	reg = /^[-_a-zA-Z0-9]+@[-_a-zA-Z0-9]+\.[a-zA-Z]+$/;
	return reg.test(e); // TRUE si es correcto, FALSE en caso contrario

}

function validar_contact()
{
	var ko      = 0;
	var asunto  = document.getElementById('asunto');
	var mensaje = document.getElementById('mensaje');
	var email   = document.getElementById('email');
	if (asunto.value == '') {
		ko = 1;
		alert("Indicanos el asunto del mensaje, por favor");
		asunto.focus();
		return false;
	}
	if (mensaje.value == '') {
		ko = 1;
		alert("Necesitamos saber cual es el problema, no has escrito nada");
		mensaje.focus();
		return false;
	}
	if (!validateEmail(email.value)) {
		ko = 1;
		alert("Email no válido");
		email.focus();
		return false;
	}
	if (ko == 1) {
		return false;
	} else {
		//form.submit();
		return true;
	}
}