
cargar_var = function(txt){
	v = txt.split("|");
	eval(v[0] +"=v[1]");
};

callServiceText = function (p_name,p_data,fx,async){
	var v_async = false;
	if(async)v_async = async;
	$.ajax({						
		type: "POST",
		dataType:"text",
		async:v_async,
		data:p_data,
		url: p_name,
		success: fx,
		cache:false
	});
};

callServiceJSON = function (p_name,p_data,fx,async,c){
	var v_async = false;
	if(async)v_async = async;
	if(! c)c=10;
	if (c>0)
		$.ajax({						
			type: "POST",
			dataType:"json",
			data:p_data,
			url: p_name,
			async:v_async,
			success: function (json){
				fx(json);
				//ocultas el div
			},
			cache:false,
			error: function (request, status, error) {
					//reintentando...
					callServiceJSON (p_name,p_data,fx,async,c--);
				}
		});
	else{
		// ocultar div plubicar error hoy con alert	
		alert("Error en "+ p_name);
	}
};


calculador = function(){

	var codigoOrigen = $("#select_desde").val();
	var codigoDestino = $("#select_hasta").val();
	var km = 0;
	

	if (codigoOrigen != codigoDestino){
		km = distancias[codigoOrigen][codigoDestino];
	}
	$("#km").html(km + " km");
	
};

addClassActive = function(link){
	$("#subMenu li a").removeClass("active");
	$("."+link).addClass("active");
};

templatePrevioEstadistica = 	'<div class="item">'
							+     '<img src="${path}" alt="${titulo}" width="247" height="111"/>'
							+	  '<p><a href="estadisticas-detalle.html?id=${id}">${resumen}</a></p>'
							+   '</div>';	

templateMuestraEstadistica =    '<h2>${titulo}</h2>'
							 + 	'<p><strong>${resumen}</strong></p>'
							 +	'<div id="estadisticas">'
							 +   	'<img src="${path}" alt="estadistica"/>'
							 +		'<p><a href="${pathDownload}" class="download">download</a></p>'
							 +  '</div>';	
							 
templatePrevio = '<div class="item">'+
  		   '<img src="${path}"  height="72" width="96"/>'+
  		   '<span>${fecha}</span>'+
           '<h3>${titulo}</h3>'+
           '<p>${resumen}</p>'+
           '<p class="link"><a href="${cat}-detalle.html?id=${id}">ver m&aacute;s</a></p>'+   
           '</div>';

templateMuestra='<div class="top"><p><a href="${cat}.html" class="link">Volver</a>${link2}</p></div>'+
'<img src="${path}" id="img_masc" width="400px" height="240px"  /><div><h2>${titulo}</h2>${cuerpo}</div>';

								 

function gup( name ){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
