var r=''; var ajaxOk=0; var oldValue=''; var estadosObj=new Object(); estadosObj['Aguascalientes']=1;estadosObj['Baja California']=2;estadosObj['Baja California Sur']=3;estadosObj['Campeche']=4;estadosObj['Chiapas']=5;estadosObj['Chihuahua']=6;estadosObj['Coahuila de Zaragoza']=7;estadosObj['Colima']=8;estadosObj['Distrito Federal']=9;estadosObj['Durango']=10;estadosObj['Guanajuato']=11;estadosObj['Guerrero']=12;estadosObj['Hidalgo']=13;estadosObj['Jalisco']=14;estadosObj['Mexico']=15;estadosObj['Michoacan de Ocampo']=16;estadosObj['Morelos']=17;estadosObj['Nayarit']=18;estadosObj['Nuevo Leon']=19;estadosObj['Oaxaca']=20;estadosObj['Puebla']=21;estadosObj['Queretaro de Arteaga']=22;estadosObj['Quintana Roo']=23;estadosObj['San Luis Potosi']=24;estadosObj['Sinaloa']=25;estadosObj['Sonora']=26;estadosObj['Tabasco']=27;estadosObj['Tamaulipas']=28;estadosObj['Tlaxcala']=29;estadosObj['Veracruz Llave']=30;estadosObj['Yucatan']=31;estadosObj['Zacatecas']=32; function getResponse(what) { if(oldValue!=what) { AjaxRequest.get( { 'url':'gateway/gateway.cfm?x=1&edo='+what ,'onSuccess':function(req){ getCPResponse(req);} ,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);} ,'timeout':3000 ,'onTimeout':function(req){ alert('Timed Out!'); } } ); } oldValue=what; } function getCPResponse(req) { r=eval(req.responseText); document.getElementById('ciudad').value=''; document.getElementById('colonia').value=''; document.getElementById('estado')[0].selected=1; document.getElementById('theResDiv').innerHTML=""; if(r&&r.length>0) { document.getElementById('ciudad').value=r[0].ciudad; document.getElementById('estado')[estadosObj[r[0].estado]].selected=1; if(r.length<2){document.getElementById('colonia').value=r[0].asenta;} else{wrt2div(req,'theResDiv');} } } function addOption(selectObject, optionText, optionValue) { var selectObject1=document.getElementById(selectObject); var optionObject = new Option(optionText, optionValue); var optionRank = selectObject1.options.length; selectObject1.options[optionRank]=optionObject; } function removeAllOptions(selectObject) { selectObject=document.getElementById(selectObject); selectObject.options.length=0; } function checkLen(fld) { if(fld.value.length>4) getResponse('&cp='+document.getElementById('cp').value); } function wrt2div(req,theDiv) { r=eval(req.responseText); var res=''; for (var i=0; i'+r[i].asenta+'';} document.getElementById('colonia').value=''; document.getElementById(theDiv).innerHTML=res; mDiv(theDiv); document.getElementById(theDiv).style.display='block'; } function mDiv(theDiv) { document.getElementById(theDiv).style.left=(calculateOffsetLeft(document.getElementById('colonia'))+1)+'px'; document.getElementById(theDiv).style.top=(calculateOffsetTop(document.getElementById('colonia'))+20)+'px'; } function calculateOffsetTop(r){var kb=0;while(r){kb+=r['offsetTop'];r=r.offsetParent}return kb} function calculateOffsetLeft(r){var kb=0;while(r){kb+=r['offsetLeft'];r=r.offsetParent}return kb} function selResults(theText) { document.getElementById('colonia').value=theText; document.getElementById('theResDiv').style.display='none'; } function keypresslistener() { if (navigator.userAgent.indexOf("Safari") > 0) { document.getElementById('colonia').addEventListener("keydown",liveSearchKeyPress,false); } else if (navigator.product == "Gecko") { document.getElementById('colonia').addEventListener("keypress",liveSearchKeyPress,false); } else { document.getElementById('colonia').attachEvent('onkeydown',liveSearchKeyPress); isIE = true; } } function liveSearchKeyPress(event) { if (event.keyCode == 40 ) //KEY DOWN { highlight = document.getElementById("searchhighlight"); if (!highlight){highlight = document.getElementById("theResDiv").firstChild;} else { highlight.removeAttribute("id"); highlight = highlight.nextSibling; } if (highlight){highlight.setAttribute("id","searchhighlight");} if (!isIE){event.preventDefault();} } //KEY UP else if (event.keyCode == 38 ) { highlight = document.getElementById("searchhighlight"); if (!highlight){highlight = document.getElementById("theResDiv").lastChild;} else{ highlight.removeAttribute("id"); highlight = highlight.previousSibling; } if (highlight) {highlight.setAttribute("id","searchhighlight");} if (!isIE) { event.preventDefault();} } //ESC else if (event.keyCode == 13) { highlight = document.getElementById("searchhighlight"); document.getElementById('colonia').value = highlight.innerHTML; if (highlight){highlight.removeAttribute("id");} document.getElementById("theResDiv").style.display = "none"; return false; } } function validate_form (theF) { valid = true; //theF=document.getElementById('addC'); if ( theF.titulo.value==""){alert ( "Es necesario asignar un Titulo al clasificado" );valid=false;} if ( theF.email.value=="" ){alert ( "Es necesario dar una Direccion de Correo para poder contactarte." );valid=false;} if ( theF.estado.options[theF.estado.selectedIndex].value=="0" ){alert ( "Es necesario dar un Estado." );valid=false;} if ( theF.ciudad.value=="" ){alert ( "Es necesario dar una Ciudad." );valid=false;} //if ( theF.descripcion.value=="" ){alert ( "Es necesario dar una Descripcion." );valid=false;} // Aqui el codigo para validar que este seleccionada una opcion del Tipo de Clasificado. var el=document.forms[0].elements; for(var i=0;i2)getBR(theFld.value, selected); } function go2(event){window.location.href==event.data.liga}; function getBR(sp,parent) { if(ajaxOK) { $.ajax( { url: "gateway/busquedaAjax.cfz?sp="+sp+'&parent='+parent, cache: false, success: function(html) { $("#resultadoBR").html(html); $(".r").hover( function(){$(this).css({backgroundColor:"#5a7dde",color:"white"});}, function(){$(this).css({backgroundColor:"#ffcf31",color:"black"});} ); $(".r").bind("click", function(){location.href=$(this).attr("l")}); aCo=$('busqueda').offset();//aBuscar Offset aCh=$('busqueda').height();//aBuscar Height $("#resultadoBR").css("top",100); $("#resultadoBR").css("left",650); $("#resultadoBR").show("slow"); Nifty("div#resultadoBR","big transparent bottom"); } } ); } } function hideBR() { $("#resultadoBR").hide("slow") } function testAjax(page) { $.ajax( { url: "gateway/qv.cfm?chkAjax=1", cache: true, success: function(html){ajaxOK=1; if(page=="QV")$("a.QVLink").show();} } ); } function reportarClas(id) { var repC=$("#repC").val(); $.ajax( { url: "gateway/reportaClas.cfm?id="+id+"&tipo="+$(":radio:checked").val()+"&com="+repC, cache: false, success: function(html){$("div#cluetip").hide();} } ); }