
function getXML(sufijo,Vars,nFunction){
try{
	    jQuery.ajax({
				url: "php/02/resources/getMxM-XML.php",
				async:true,
				data:Vars,
				contentType: "text/xml; charset=utf-8",
				dataType: "xml",
				global: true,
				ifModified: false,
				processData:true,
				error: function(objeto, quepaso, otroobj){
					  //alert("La comunicacion ha fallado, intente de nuevo: "+quepaso+"; fallo provocado por: "+sufijo+"; "+Vars+"; "+" Linea del error: "+nFunction);
				},
				success: function(xml){
							  switch(nFunction){
									case 0:
									case 1:
									case 2:
										 getMenu(sufijo,xml,nFunction);
									break;
							  }
				},
				timeout: 30000,
				type: "GET"
	    });
} catch (e) {
	alert(e.description);
}
}

function getMenu(sufijo,xml,n){
try{	
		var i = 1;
		if ($("status",xml).text() == "2") return;
		    $("nota",xml).each(function(id) {
		    var nota = $("nota",xml).get(id);
		    var nidnota = $("idnota",nota).text(); 
		    $("#tdH"+sufijo+"_"+i).text($("hora",nota).text());
		    $("#tdT"+sufijo+"_"+i+" span a").text($("titulo",nota).text());
		    $("#tdT"+sufijo+"_"+i+" span a").attr("href",$("url",nota).text());
		    
		    $("#tdT"+sufijo+"_"+i+" .textDetail h1").text($("titulo",nota).text());
		    $("#Img"+sufijo+"_"+i).attr("src",'http://www.diariopresente.com.mx/images/'+$("image",nota).text());
		    $("#in"+sufijo+"_"+i).text($("intronota",nota).text());
		    $("#hf"+sufijo+"_"+i).attr("href",$("url",nota).text());
		    //alert($("hora",nota).text());
		    i++;
		});
} catch (e) {
  alert(e.description);
}
			
}

function lydpost(URL, PARAMS) {
	var temp=document.createElement("form");
	temp.action=URL;
	temp.method="GET";
	temp.style.display="none";
	for(var x in PARAMS) {
		var opt=document.createElement("textarea");
		opt.name=x;
		opt.value=PARAMS[x];
		temp.appendChild(opt);
	}
	document.body.appendChild(temp);
	temp.submit();
	return temp;
}

$(document).ready(function(){
					  
		 $("#searchSingle").click(function(){
			var val = $("input#buscar").val();				
			if (val!=""){
			   //lydpost("http://www.diariopresente.com.mx/busqueda_panel.php", {titulo:val});
			   lydpost("http://www.diariopresente.com.mx/search-info/"+val+".i1.0/", {titulo:val});
			   
			}else{
				alert("Debe escribir la frase que desea buscar.");
			}
		 });
		 
		 $("#searchExtend").click(function(){
			lydpost("http://www.diariopresente.com.mx/busqueda_avanzada.php", {param:'null'});
		 });
		 
		 $("#aSearchTop").click(function(){
			lydpost("http://www.diariopresente.com.mx/php/02/resources/transform.php", {t:tipo,c:$("input[name='searchInput']").val(),ty:0});
		 });
		 
		 if ($("#lblgenOtherChar").length){	 
			$("#lblgenOtherChar").click(function(){
				$("#imgCaptcha").attr("src", 
								  "http://www.diariopresente.com.mx/"+
								  "php/02/resources/captcha.php?url="+
								  "http://www.diariopresente.com.mx/"+
								  +"images/02/web/bgcaptcha.gif"+'&rnd=' + 
								  Math.random());
			});
		 }
/*
		 if ($("#frmRegistry").length){	 
			setValidFormReg();
		 }
*/		 



});

/*

function setValidFormReg(){
	
$("#frmRegistry").validationEngine('attach', {
	  		   onValidationComplete: function(form, status){
			   if (status){	   
				   $('p.caption-bg').show();
				   var chk=$("#chk1").attr("checked")?1:0;
				   var dataString = 'str='+ $("#txtUser").val() + 
								'_devch_' + $("#txtPass1").val() + 
								'_devch_' + $('#txtEMail').val()+
								'_devch_-' +
								'_devch_-' +
								'_devch_' + $('#txtCaptcha').val()+
								'_devch_0'+
								'_devch_0'+
								'_devch_'+chk+
								'&id=4';
						jQuery.ajax({
							async:true,
                				contentType: "application/json; charset=utf-8",
                				dataType: 'json',
							global: true,
							ifModified: false,
							processData:true,
							timeout: 30000,
						  	type: "GET",
						  	url: sRegNewURL,
						  	data: dataString,
						  success: function(json) {
						  		 $('p.caption-bg').hide();
								 if (json[0].id == 1){
								 	$("input#txtUser").val('');
								 	$("input#txtPass1").val('');
								 	$("input#txtEMail").val('');
									$('input#txtCaptcha').val("Imagen");
									//alert(json[0].msg);
									$('p.success-bg').html("<span>"+json[0].msg+"</span>")
												  .show('slow').delay(10000).fadeOut('slow', 
												   function() {
															$("#frmRegistry").reset();
															$("#imgCaptcha").attr("src", 
															"http://www.diariopresente.com.mx/"+
															"php/02/resources/captcha.php?url="+
															"http://www.diariopresente.com.mx/"+
															+"images/02/web/bgcaptcha.gif"+'&rnd=' + 
															Math.random());
												   });
								}else{
									$('p.error-bg').html("<span>"+json[0].msg+"</span>").show('slow').delay(5000)
																			  .fadeOut('slow'); 
								}
	
					  	},
					     failure : function() { alert("Error PHP"); }
					     });  
			     }
				},
			     failure : function() {}
});

}

*/

