function menu(valor){
document.getElementById('solapa0').className = 'Au_Ficha_Autos_Off';
document.getElementById('solapa1').className = 'Au_Ficha_4x4_Off';
document.getElementById('solapa2').className = 'Au_Ficha_Motos_Off';
document.getElementById('solapa3').className = 'Au_Ficha_Camiones_Off';
document.getElementById('solapa4').className = 'Au_Ficha_Maquinas_Off';
document.getElementById('solapa5').className = 'Au_Ficha_Embarcaciones_Off';
if (valor==0){
document.getElementById('solapa0').className = 'Au_Ficha_Autos_On';
document.getElementById('solapa1').className = 'Au_Ficha_4x4_Off_2';
document.getElementById('seccion').innerHTML = 'Autos y Station Wagons';
document.getElementById('selecttipo').selectedIndex = 0 }
if (valor==1){
document.getElementById('solapa1').className = 'Au_Ficha_4x4_On';
document.getElementById('solapa2').className = 'Au_Ficha_Motos_Off_2';
document.getElementById('seccion').innerHTML = '4x4 y Pick Up';
document.getElementById('selecttipo').selectedIndex = 1}
if (valor==2){
document.getElementById('solapa2').className = 'Au_Ficha_Motos_On';
document.getElementById('solapa3').className = 'Au_Ficha_Camiones_Off_2';
document.getElementById('seccion').innerHTML = 'Motocicletas';
document.getElementById('selecttipo').selectedIndex = 2 }
if (valor==3){
document.getElementById('solapa3').className = 'Au_Ficha_Camiones_On';
document.getElementById('solapa4').className = 'Au_Ficha_Maquinas_Off_2';
document.getElementById('seccion').innerHTML = 'Camiones y Buses';
document.getElementById('selecttipo').selectedIndex = 3}
if (valor==4){
document.getElementById('solapa4').className = 'Au_Ficha_Maquinas_On';
document.getElementById('solapa5').className = 'Au_Ficha_Embarcaciones_Off_2';
document.getElementById('seccion').innerHTML = 'Maquinas, motores y accesorios';
document.getElementById('selecttipo').selectedIndex = 4}
if (valor==5){
document.getElementById('solapa5').className = 'Au_Ficha_Embarcaciones_On';
document.getElementById('seccion').innerHTML = 'Embarcaciones';
document.getElementById('selecttipo').selectedIndex = 5}}

function menu_in(valor){
document.getElementById('solapa0').className = 'In_Ficha_Casas_Off';
document.getElementById('solapa1').className = 'In_Ficha_Deptos_Off';
document.getElementById('solapa2').className = 'In_Ficha_Locales_Off';
document.getElementById('solapa3').className = 'In_Ficha_Terrenos_Off';
document.getElementById('solapa4').className = 'In_Ficha_Otros_Off';
if (valor==0){
document.getElementById('solapa0').className = 'In_Ficha_Casas_On';
document.getElementById('solapa1').className = 'In_Ficha_Deptos_Off_2';
document.getElementById('seccion').innerHTML = 'Casas';
document.getElementById('selecttipo').selectedIndex = 0 }
if (valor==1){
document.getElementById('solapa1').className = 'In_Ficha_Deptos_On';
document.getElementById('solapa2').className = 'In_Ficha_Locales_Off_2';
document.getElementById('seccion').innerHTML = 'Departamentos';
document.getElementById('selecttipo').selectedIndex = 1}
if (valor==2){
document.getElementById('solapa2').className = 'In_Ficha_Locales_On';
document.getElementById('solapa3').className = 'In_Ficha_Terrenos_Off_2';
document.getElementById('seccion').innerHTML = 'Locales';
document.getElementById('selecttipo').selectedIndex = 2 }
if (valor==3){
document.getElementById('solapa3').className = 'In_Ficha_Terrenos_On';
document.getElementById('solapa4').className = 'In_Ficha_Otros_Off_2';
document.getElementById('seccion').innerHTML = 'Terrenos y Propiedades';
document.getElementById('selecttipo').selectedIndex = 3}
if (valor==4){
document.getElementById('solapa4').className = 'In_Ficha_Otros_On';
document.getElementById('seccion').innerHTML = 'Otros Inmuebles';
document.getElementById('selecttipo').selectedIndex = 4}}

function menu_em(valor){
document.getElementById('solapa0').className = 'Em_Ficha_Profesionales_Off';
document.getElementById('solapa1').className = 'Em_Ficha_Oficios_Off';
document.getElementById('solapa2').className = 'Em_Ficha_SD_Off';
if (valor==0){
document.getElementById('solapa0').className = 'Em_Ficha_Profesionales_On';
document.getElementById('solapa1').className = 'Em_Ficha_Oficios_Off_2';
document.getElementById('seccion').innerHTML = 'Profesionales';
document.getElementById('selecttipo').selectedIndex = 0 }
if (valor==1){
document.getElementById('solapa1').className = 'Em_Ficha_Oficios_On';
document.getElementById('solapa2').className = 'Em_Ficha_SD_Off_2';
document.getElementById('seccion').innerHTML = 'Oficios';
document.getElementById('selecttipo').selectedIndex = 1}
if (valor==2){
document.getElementById('solapa2').className = 'Em_Ficha_SD_On';
document.getElementById('seccion').innerHTML = 'Servicios Dom&eacute;sticos';
document.getElementById('selecttipo').selectedIndex = 2 }}

function autossobre(){
/*document.getElementById('autoslink').className = 'Cl-Au-Tt-Tb';*/
document.getElementById('inlink').className = 'Cl-In-Tt-Tb-Off';
/*document.getElementById('emlink').className = 'Cl-Em-Tt-Tb-Off';*/
document.getElementById('oplink').className = 'Cl-Op-Tt-Tb-Off';}

function inmsobre(){
/*document.getElementById('autoslink').className = 'Cl-Au-Tt-Tb-Off';*/
document.getElementById('inlink').className = 'Cl-In-Tt-Tb';
/*document.getElementById('emlink').className = 'Cl-Em-Tt-Tb-Off';*/
document.getElementById('oplink').className = 'Cl-Op-Tt-Tb-Off';}

function emsobre(){
/*document.getElementById('autoslink').className = 'Cl-Au-Tt-Tb-Off';*/
document.getElementById('inlink').className = 'Cl-In-Tt-Tb-Off';
/*document.getElementById('emlink').className = 'Cl-Em-Tt-Tb';*/
document.getElementById('oplink').className = 'Cl-Op-Tt-Tb-Off';}

function opsobre(){
/*document.getElementById('autoslink').className = 'Cl-Au-Tt-Tb-Off';*/
document.getElementById('inlink').className = 'Cl-In-Tt-Tb-Off';
/*document.getElementById('emlink').className = 'Cl-Em-Tt-Tb-Off';*/
document.getElementById('oplink').className = 'Cl-Op-Tt-Tb';}

function programa(){
document.getElementById('divfondo').style.display="block";
document.getElementById('sobrediv').style.display="block"
document.getElementById('html').style.overflow="hidden"}

function programa1(){
document.getElementById('divfondo').style.display="block";
document.getElementById('sobrediv2').style.display="block"
document.getElementById('html').style.overflow="hidden"}

function salirprogramas(){
document.getElementById('divfondo').style.display="none";
document.getElementById('sobrediv').style.display="none";
document.getElementById('html').style.overflow="auto";
document.getElementById('html').style.overflowX ="hidden"}

function salirprogramas1(){
document.getElementById('divfondo').style.display="none";
document.getElementById('sobrediv2').style.display="none";
document.getElementById('html').style.overflow="auto";
document.getElementById('html').style.overflowX ="hidden"}

/*Fecha*/
function aparece (valor){document.getElementById(valor).style.display="block";}
function desa (valor){document.getElementById(valor).style.display="none";}

var empezar = false 
var retardo 
var ocultar 

function ocultardiv2(valor){document.getElementById(valor).style.display="none";} 
function mostrardiv(valor){document.getElementById(valor).style.display="block";} 

/*Cartelito Foto Viñeta*/

function FotoV(){
if(document.getElementById('CheckFotoV').checked == true){
if((document.getElementById('select1').selectedIndex == 1) && ((document.getElementById('select2').selectedIndex == 1)||(document.getElementById('select2').selectedIndex == 2))){
document.getElementById('FotoVineta').style.display="block"}
else{document.getElementById('FotoVineta').style.display="none"}
document.getElementById('tablaimgen2').style.display="block"
document.getElementById('tablaFotoV').className=''
document.getElementById('gratisspan').style.visibility="hidden"
document.getElementById('textotabla').innerHTML = 'Esta im&aacute;gen ser&aacute; utilizada para la b&uacute;squeda en internet y ser&aacute; publicada en el papel.';
document.seleccion.AviFotVin.value=1}
else{document.getElementById('FotoVineta').style.display="none"
document.getElementById('tablaFotoV').className='Pub_MgBt11'
document.getElementById('tablaimgen2').style.display="none"
document.getElementById('gratisspan').style.visibility="visible"
document.seleccion.AviFotVin.value=0
}}


function FotoV2(){
if(document.getElementById('CheckFotoV').checked == true){
document.getElementById('tablaimgen2').style.display="block"
document.getElementById('tablaFotoV').className=''
document.getElementById('gratisspan').style.visibility="hidden"
document.getElementById('textotabla').innerHTML = 'Esta im&aacute;gen ser&aacute; utilizada para la b&uacute;squeda en internet y ser&aacute; publicada en el papel.';
document.seleccion.AviFotVin.value=1;}
else{document.getElementById('tablaFotoV').className='Pub_MgBt11'
document.getElementById('tablaimgen2').style.display="none"
document.getElementById('gratisspan').style.visibility="visible"
document.seleccion.AviFotVin.value=0
}}


function fotogratis(){
	//xmlConsultarEstadoFotoWeb.asp
	var iIndex=document.seleccion.cmbOpera.selectedIndex;
	var idSubSeccion=document.seleccion.cmbOpera.options[iIndex].value;
	var urlAsp="/macro/xmlConsultarEstadoFotoWeb.asp?id="+idSubSeccion;
	var miObjetoAjaxCombo = false;
	var iPriEle=0;
	miObjetoAjaxCombo=InstanciaAjax();
	miObjetoAjaxCombo.open("GET",urlAsp,true);
	miObjetoAjaxCombo.onreadystatechange=function() {

	if (miObjetoAjaxCombo.readyState==4)
	{
		info=miObjetoAjaxCombo.responseXML;//guardo en la variable info el xml
		var estFotoWeb	= info.getElementsByTagName('bln_FotoWeb').item(iPriEle).firstChild.nodeValue;
		if(estFotoWeb==1){
		document.getElementById('FotoVineta').style.display="none"
		document.getElementById('tablaimgen2').style.display="block"
		document.getElementById('tablaFotoV').className=''
		document.getElementById('gratisspan').style.visibility="visible"
		document.getElementById('CheckFotoV').checked = false
		document.getElementById('rangoprecioast').style.display="block"
		document.getElementById('Pub_Fecha').style.top="1218px"
		document.getElementById('rangoprecio').innerHTML = 'Este dato es obligatorio para la venta de autos, 4x4 y pick up.<br>No se cobra por el dato, ni se incluye en el aviso. '
		document.getElementById('textotabla').innerHTML = 'Esta im&aacute;gen ser&aacute; utilizada para la b&uacute;squeda en internet y no ser&aacute; publicada en el papel.';}
		else{document.getElementById('FotoVineta').style.display="none"
		document.getElementById('tablaimgen2').style.display="none"
		document.getElementById('tablaFotoV').className=''
		document.getElementById('gratisspan').style.visibility="visible"
		document.getElementById('CheckFotoV').checked = false
		document.getElementById('rangoprecioast').style.display="none"
		document.getElementById('Pub_Fecha').style.top="1204px"
		document.getElementById('rangoprecio').innerHTML = 'No se cobra por el dato, ni se incluye en el aviso.'
		document.getElementById('textotabla').innerHTML = 'Esta im&aacute;gen ser&aacute; utilizada para la b&uacute;squeda en internet y ser&aacute; publicada en el papel.';}
	//if(document.getElementById('select1').selectedIndex == 1){document.getElementById('valor2rango').innerHTML="Rango de venta"}
	//if(document.getElementById('select1').selectedIndex == 2){document.getElementById('valor2rango').innerHTML="Rango de alquiler"}
	}
	}
miObjetoAjaxCombo.send(null);	
}

function calcularfin(){
	if(document.seleccion.Mode.value == 1)
	{
	 document.getElementById('botonescalcular').style.display="none"
	 document.getElementById('costodelaviso').style.display="block"
	}
}
	
function checkpublicar2(){
if(document.getElementById('checkfactureno').checked == true)
{document.getElementById('Aufacturacion').style.display="none";
document.getElementById('Auboletas').style.display="block";}
else
{document.getElementById('Aufacturacion').style.display="block";
document.getElementById('Auboletas').style.display="none";}
}

function CheckDestD(valor){
if(document.getElementById('DestD').checked == true){document.getElementById(valor).style.display="block";}
else{document.getElementById(valor).style.display="none"}}

function Fdia(){
	if (document.getElementById('dia').value=="Ingresar el día")
	{document.getElementById('dia').value=""}
}

function infotogratis(){
if(((document.getElementById('select1').selectedIndex == 1)||(document.getElementById('select1').selectedIndex == 3)) && ((document.getElementById('select2').selectedIndex == 1)||(document.getElementById('select2').selectedIndex == 2))){
document.getElementById('FotoVineta').style.display="none"
document.getElementById('tablaimgen2').style.display="block"
document.getElementById('tablaFotoV').className=''
document.getElementById('gratisspan').style.visibility="visible"
document.getElementById('CheckFotoV').checked = false
document.getElementById('rangoprecioast').style.display="block"
document.getElementById('Pub_Fecha').style.top="1281px"
document.getElementById('rangoprecio').innerHTML = 'Este dato es obligatorio para la venta de Casas y Departamentos.<br>No se cobra por el dato, ni se incluye en el aviso. '
document.getElementById('textotabla').innerHTML = 'Esta im&aacute;gen ser&aacute; utilizada para la b&uacute;squeda en internet y no ser&aacute; publicada en el papel.';}
else{document.getElementById('FotoVineta').style.display="none"
document.getElementById('tablaimgen2').style.display="none"
document.getElementById('tablaFotoV').className=''
document.getElementById('gratisspan').style.visibility="visible"
document.getElementById('CheckFotoV').checked = false
document.getElementById('rangoprecioast').style.display="none"
document.getElementById('Pub_Fecha').style.top="1267px"
document.getElementById('rangoprecio').innerHTML = 'No se cobra por el dato, ni se incluye en el aviso.'
document.getElementById('textotabla').innerHTML = 'Esta im&aacute;gen ser&aacute; utilizada para la b&uacute;squeda en internet y ser&aacute; publicada en el papel.';}
if(document.getElementById('select1').selectedIndex == 1){document.getElementById('valor2rango').innerHTML="Rango de venta"}
if(document.getElementById('select1').selectedIndex == 2){document.getElementById('valor2rango').innerHTML=""}
if(document.getElementById('select1').selectedIndex == 3){document.getElementById('valor2rango').innerHTML="Rango de alquiler"}
}

/*Solo num: gvidalp@msn.com*/
function acceptNum(evt){
	var nav4 = window.Event ? true : false;
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
	var key = nav4 ? evt.which : evt.keyCode;
	return (key <= 13 || (key >= 48 && key <= 57));
}
/*Solo txt: gvidalp@msn.com*/
function acceptTxt(evt){
	var nav4 = window.Event ? true : false;
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
	var key = nav4 ? evt.which : evt.keyCode;
	return (key != 13);
}
/*Nada txt: gvidalp@msn.com*/
function disabledTxt(evt){
	var nav4 = window.Event ? true : false;
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
	var key = nav4 ? evt.which : evt.keyCode;
	return (key == 0);
}
/*Solo star: gvidalp@msn.com*/
function chkEstrella(estrella){
	if (estrella == 1){document.seleccion.chkEstrellaDos.checked=false;}
	if (estrella == 2){document.seleccion.chkEstrellaUno.checked=false;}
	if (estrella == 3){document.seleccion.chkEncSim.checked=false;}
	if (estrella == 4){document.seleccion.chkEncDbl.checked=false;}
}
/*Solo fch: gvidalp@msn.com*/
function fSelecdDias(){
	var strFecha='';
	var i=0;
	for (i = 0; i < document.seleccion.chkCal.length; i++)
	{	if (document.seleccion.chkCal[i].checked)
		{strVerFec = new Date(document.seleccion.chkCal[i].value)
		strFecha += strVerFec.getDate() + '/' + (strVerFec.getMonth()+1) + '/' + strVerFec.getFullYear() + "; ";}
	}
	document.seleccion.txtFecPub.value=strFecha;
}

/*Solo fch: gvidalp@msn.com*/
function MM_openBrWindow(xurl,xstatus,xwidth,xheight)
{	var argumentos= "toolbar=no,scrollbars=no,resizable=no,height=" + xheight + ",width=" + xwidth + ",status=" + xstatus;
	remote=window.open(xurl,'NewWindow',argumentos);
	if (remote != null)
	{if (remote.opener == null){ remote.opener = self;}
	}
}

function ValidaVin()
{	//Valida si hay alguna viñeta seleccionada
	var i=0,est=false;
	for(i=0;i<document.vineta.chkVin.length;i++)
	{if(document.vineta.chkVin[i].checked) est=true;}
	return est;
}

/*Solo Viñeta-On: gvidalp@msn.com*/
function AceptaVin()
{	if(!ValidaVin()){alert('Seleccione una viñeta');return;}
	for(i=0;i<window.document.vineta.chkVin.length;i++)
  {	if(document.vineta.chkVin[i].checked)
		{window.opener.document.seleccion.AviCodVin.value=window.document.vineta.chkVin[i].value;}
	}
	window.close();
}

/*Solo Viñeta-Off: gvidalp@msn.com*/
function CancelaVin()
{	if(!ValidaVin())
	{	window.opener.document.seleccion.AviCodVin.value="";
		window.opener.document.seleccion.chkVineta.checked=false;}
	window.close();
}

/*Solo Viñeta-Off: gvidalp@msn.com*/
function valida_longitud(CantCaract)
{  var num_caracteres = document.frmMail.txtMailMen.value.length
   if (num_caracteres >= CantCaract)
	 {document.frmMail.txtMailMen.value = document.frmMail.txtMailMen.value.slice(0,CantCaract);}
}

/*Verifica Valor q no sea "": gvidalp@msn.com*/
function val_NumDoc(NumDoc, TipEnt)
{ String.prototype.trim= function() //Agrega la función trim al objeto String
	{return this.replace(/(^\s*)|(\s*$)/g,"");} //elimina espacios a izquierda y derecha
	if (NumDoc.trim()==""){alert("Ingrese un numero de documento valido");return false;}
	//alert(TipEnt);
	var NumDoc2 = NumDoc.trim();
	//alert(NumDoc2.length);
	switch(TipEnt)
	{
	case 0: if(NumDoc2.length!=8){alert("El DNI debe tener 8 digitos");return false;}
	break;
	case 1: if(NumDoc2.length!=11){alert("El RUC debe tener 11 digitos");return false;} else {return valruc(NumDoc);}
	break;
	}

	return true;

return true;
}

/*Verifica Ruc Valido "": gvidalp@msn.com*/
function valruc(valor){
  valor = trim(valor)
  //if ( esnumero( valor ) ) {
    if ( valor.length == 8 ){
      suma = 0
      for (i=0; i<valor.length-1;i++){
        digito = valor.charAt(i) - '0';
        if ( i==0 ) suma += (digito*2)
        else suma += (digito*(valor.length-i))
      }
      resto = suma % 11;
      if ( resto == 1) resto = 11;
      if ( resto + ( valor.charAt( valor.length-1 ) - '0' ) == 11 ){
        return true
      }
    } else if ( valor.length == 11 ){
      suma = 0
      x = 6
      for (i=0; i<valor.length-1;i++)
      {
        if ( i == 4 ) x = 8
        digito = valor.charAt(i) - '0';
        x--
        if ( i==0 ) suma += (digito*x)
        else suma += (digito*x)
      }
      resto = suma % 11;
      resto = 11 - resto
      
      if ( resto >= 10) resto = resto - 10;
      if ( resto == valor.charAt( valor.length-1 ) - '0' ){return true}      
    }
//  }
  alert("El número de RUC ingresado no es válido, por favor verifique.");
  return false
}

function trim(cadena){
  cadena2 = "";
  len = cadena.length;
  for ( var i=0; i <= len ; i++ ) if ( cadena.charAt(i) != " " ){cadena2+=cadena.charAt(i);	}
  return cadena2;
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


/* date */
function fecha(){
	// date vars
		var date = new Date();
		var d  = date.getDate();
			var day = (d < 10) ? '0' + d : d;
		var m = date.getMonth();
			var months = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Setiembre', 'Octubre', 'Noviembre', 'Diciembre'];
			var month = months[m];
		var yy = date.getYear();
			var year = (yy < 1000) ? yy + 1900 : yy;
		var today = day + ' de ' + month + ' del ' + year;

	// exec
		document.write(today);
}