$(document).ready(function () {
	msClick();
});

function msClick() {
	$("li.ms a").click(function (ev) {
		var dt, nc, ot, pos, qs, id, url, prm;
		dt  = new Date();
		nc  = dt.getTime();
		ot  = this;
		pos = this.href.indexOf("#");
		id  = this.href.substr(pos+1);
		url = sMSURL + "ajax-miseleccion.aspx";
		$(ot).parent().css("visibility", "hidden");
		jQuery.ajax({
			type   : "GET",
			url    : url,
			data   : "id="+id+"&nc="+nc,
			cache  : false,
			success: function (data) {
				switch(data) {
					case "On"  : 
						$(ot).html(sMSRem).parent().css("visibility", "visible").attr("class", "ms msok").attr("id", "es"); 
						if(typeof(pageTracker)=="object") {
							var action = "n/d", inmu = $("h1").html().replace(/<(\/)?(\w)+>/g, "");
							if(location.href.indexOf("/viviendas/")>-1)       action = "Click_Viviendas";
							if(location.href.indexOf("/otros-inmuebles/")>-1) action = "Click_Otros_Inmuebles";
							if(location.href.indexOf("/obra-nueva/")>-1)      action = "Click_Pomociones";
							pageTracker._trackEvent("Selección", action, inmu);
						}
						break;
					case "Off" :
						$(ot).html(sMSSel).parent().css("visibility", "visible").attr("class", "ms msko").attr("id", "si"); 
						break;
				}
			}
		});
		return false;
	});
}
