<!--

function SearchText(w) {

	var u;
	u = '/directorio/buscar';
	u += '?t=' + escape2(w);
	
	location.href = u;
	return false;
		
}

function SearchTextForum(w) {

	var u;
	u = '/foro/buscar';
	u += '?t=' + escape2(w);
	
	location.href = u;
	return false;
		
}

function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURIComponentNew(s) {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}

function escape2(fld)
{
	if (fld == "") return '';
	var encodedField = "";
	var s = fld;
	if (typeof encodeURIComponent == "function")
	{
		// Use JavaScript built-in function
		// IE 5.5+ and Netscape 6+ and Mozilla
		encodedField = encodeURIComponent(s);
	}
	else 
	{
		// Need to mimic the JavaScript version
		// Netscape 4 and IE 4 and IE 5.0
		encodedField = encodeURIComponentNew(s);
	}
	return encodeURIComponentNew(fld);
}

// --------------------------------------------------------------------------

var MD_Rating_VoteComplete = false;
var MD_Rating_InitLevel = 3;
var MD_Rating_Id = 0;

function MD_Rating(starNum, act, httpRsp) {

	var i;

	if(act == 'ov') {
		for(i=0;i<=5;i++) {
			if(document.getElementById('MD_Rating_StarDiv_'+i)) {
				if(i<=starNum) {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'slt';
				} else {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'nrm';
				}
			}
		}
	}
	
	if(act == 'ou') {
		MD_Rating(0, 'init_stars');
	}
	
	if(act == 'init') {
		MD_Rating_InitLevel = starNum;
		MD_Rating(0, 'init_stars');
	}
	
	if(act == 'set_id') {
		MD_Rating_Id = starNum;
	}
	
	if(act == 'init_stars') {
		for(i=0;i<=5;i++) {
			if(document.getElementById('MD_Rating_StarDiv_'+i)) {
				if(i<=MD_Rating_InitLevel) {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'slt';
				} else {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'nrm';
				}
			}
		}
	}
	
	if(act == 'reset') {
		for(i=0;i<=5;i++) {
			if(document.getElementById('MD_Rating_StarDiv_'+i)) {
				document.getElementById('MD_Rating_StarDiv_'+i).className = 'slt';
			}
		}
	}
	
	if(act == 'load_on') {
		document.getElementById('MD_Rating_LoadImgDiv').innerHTML = '<img src="/app/do/img/star_load_anim.gif" width="18" height="18" />';
	}
	
	if(act == 'load_off') {
		document.getElementById('MD_Rating_LoadImgDiv').innerHTML = '';
	}
	
	if(act == 'set') {
		for(i=0;i<=5;i++) {
			if(document.getElementById('MD_Rating_StarDiv_'+i)) {
				if(i <= starNum) {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'slt';
				} else {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'nrm';
				}
			}
		}
	}
	
	if(act == 'ck') {
		if(MD_Rating_VoteComplete) {
			alert('Solo se permite un voto al dia por cada negocio.');
			return false;
		}
		var RatingHttp = MD_GetHttpObj(true);
		var RatingUrl = '';
		RatingUrl = '/app/do/';
		RatingUrl += 'xml/';	
		RatingUrl += 'imagerating.aspx';
		RatingUrl += '?item_id=' + escape(MD_Rating_Id);
		RatingUrl += '&score=' + escape(starNum);
		RatingUrl += '&t=' + escape(new Date().toString());

		if(RatingHttp) {
			RatingHttp.onreadystatechange = function() { MD_Rating(0, 'httprsp', RatingHttp); };
			RatingHttp.open('GET', RatingUrl, true);
			RatingHttp.send(null);
			MD_Rating(0, 'load_on');
			MD_Rating(starNum, 'set');
		}
	}

	if(act == 'httprsp') {
		if (httpRsp.readyState == 4) {
			if (httpRsp.status == 200) {		
				MD_Rating_VoteComplete = true;
				MD_Rating(0, 'load_off');
				alert(httpRsp.responseText);
				httpRsp = null;
			} else {
				MD_Rating(0, 'load_off');
				MD_Rating(0, 'reset');
				alert('Su voto no pudo ser registrado.');
				httpRsp = null;
			}
		}
	}

}

// --------------------------------------------------------------------------

function MD_RatingFFoto(starNum, act, httpRsp) {

	var i;

	if(act == 'ov') {
		for(i=0;i<=5;i++) {
			if(document.getElementById('MD_Rating_StarDiv_'+i)) {
				if(i<=starNum) {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'slt';
				} else {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'nrm';
				}
			}
		}
	}
	
	if(act == 'ou') {
		MD_Rating(0, 'init_stars');
	}
	
	if(act == 'init') {
		MD_Rating_InitLevel = starNum;
		MD_Rating(0, 'init_stars');
	}
	
	if(act == 'set_id') {
		MD_Rating_Id = starNum;
	}
	
	if(act == 'init_stars') {
		for(i=0;i<=5;i++) {
			if(document.getElementById('MD_Rating_StarDiv_'+i)) {
				if(i<=MD_Rating_InitLevel) {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'slt';
				} else {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'nrm';
				}
			}
		}
	}
	
	if(act == 'reset') {
		for(i=0;i<=5;i++) {
			if(document.getElementById('MD_Rating_StarDiv_'+i)) {
				document.getElementById('MD_Rating_StarDiv_'+i).className = 'slt';
			}
		}
	}
	
	if(act == 'load_on') {
		document.getElementById('MD_Rating_LoadImgDiv').innerHTML = '<img src="/app/do/img/star_load_anim.gif" width="18" height="18" />';
	}
	
	if(act == 'load_off') {
		document.getElementById('MD_Rating_LoadImgDiv').innerHTML = '';
	}
	
	if(act == 'set') {
		for(i=0;i<=5;i++) {
			if(document.getElementById('MD_Rating_StarDiv_'+i)) {
				if(i <= starNum) {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'slt';
				} else {
					document.getElementById('MD_Rating_StarDiv_'+i).className = 'nrm';
				}
			}
		}
	}
	
	if(act == 'ck') {
		if(MD_Rating_VoteComplete) {
			alert('Solo se permite un voto al dia por cada negocio.');
			return false;
		}
		var RatingHttp = MD_GetHttpObj(true);
		var RatingUrl = '';
		RatingUrl = '/app/do/';
		RatingUrl += 'xml/';	
		RatingUrl += 'fotorating.aspx';
		RatingUrl += '?item_id=' + escape(MD_Rating_Id);
		RatingUrl += '&score=' + escape(starNum);
		RatingUrl += '&t=' + escape(new Date().toString());

		if(RatingHttp) {
			RatingHttp.onreadystatechange = function() { MD_Rating(0, 'httprsp', RatingHttp); };
			RatingHttp.open('GET', RatingUrl, true);
			RatingHttp.send(null);
			MD_Rating(0, 'load_on');
			MD_Rating(starNum, 'set');
		}
	}

	if(act == 'httprsp') {
		if (httpRsp.readyState == 4) {
			if (httpRsp.status == 200) {		
				MD_Rating_VoteComplete = true;
				MD_Rating(0, 'load_off');
				alert(httpRsp.responseText);
				httpRsp = null;
			} else {
				MD_Rating(0, 'load_off');
				MD_Rating(0, 'reset');
				alert('Su voto no pudo ser registrado.');
				httpRsp = null;
			}
		}
	}

}

// --------------------------------------------------------------------------

function MD_GetHttpObj(textMode) {
	try {	
		var returnObj;
		if(window.XMLHttpRequest) { 
			returnObj = new XMLHttpRequest();
			if (returnObj.overrideMimeType) {
				if(textMode) {
					returnObj.overrideMimeType('text/plain');
				} else {
					returnObj.overrideMimeType('text/xml');
				}
			}
		} else if(window.ActiveXObject) {
			try {
				returnObj = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					returnObj = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
	} catch(e) {
		returnObj = false;
	}	
	return returnObj;
}

// --------------------------------------------------------------------------

function MD_Comment(act, httpRsp) {
	
	if(act == 'load_off') {
		document.getElementById('MD_Comments_LoadImgDiv').innerHTML = '';
	}
	
	if(act == 'load_on') {
		document.getElementById('MD_Comments_LoadImgDiv').innerHTML = '<img src="/app/do/img/star_load_anim.gif" width="18" height="18" />';
	}
	
	if(act == 'post') {

		var t_Name = document.getElementById('tfNm').value;
		var t_Email = document.getElementById('tfEm').value;
		var t_Text = document.getElementById('tfMs').value;

		if(t_Name == '') { alert('Por favor digite su nombre.'); return; }
		//if(t_Email == '') { alert('Por favor digite su email.'); return; }
		if(t_Text == '') { alert('Por favor digite el texto del comentario.'); return; }

		var CommentHttp = MD_GetHttpObj(true);
		var CommentUrl = '';
		CommentUrl = '/app/do/';
		CommentUrl += 'xml/';	
		CommentUrl += 'comments.aspx';
		CommentUrl += '?item_id=' + escape(MD_Rating_Id);
		CommentUrl += '&name=' + escape2(t_Name);
		CommentUrl += '&email=' + escape2(t_Email);
		CommentUrl += '&text=' + escape2(t_Text);
		CommentUrl += '&t=' + escape(new Date().toString());

		if(CommentHttp) {
			CommentHttp.onreadystatechange = function() { MD_Comment('httprsp', CommentHttp); };
			CommentHttp.open('GET', CommentUrl, true);
			CommentHttp.send(null);
			MD_Comment('load_on');
		}
		
	}

	if(act == 'httprsp') {
		if (httpRsp.readyState == 4) {
			if (httpRsp.status == 200) {		
				MD_Comment('load_off');
				alert(httpRsp.responseText)
				if(httpRsp.responseText.indexOf('Gracias') != -1) {
					document.getElementById('tfNm').value = '';
					document.getElementById('tfEm').value = '';
					document.getElementById('tfMs').value = '';
					httpRsp = null;
					location.href = location.href + '#comments';
				}
				httpRsp = null;
			} else {
				MD_Comment('load_off');
				alert('Su voto no pudo ser registrado.');
				httpRsp = null;
			}
		}
	}

}

// --------------------------------------------------------------------------

function MD_CommentNews(act, httpRsp) {
		
	if(act == 'load_off') {
		document.getElementById('MD_Comments_LoadImgDiv').innerHTML = '';
	}
	
	if(act == 'load_on') {
		document.getElementById('MD_Comments_LoadImgDiv').innerHTML = '<img src="/app/do/img/star_load_anim.gif" width="18" height="18" />';
	}
	
	if(act == 'post') {

		var t_Name = document.getElementById('tfNm').value;
		var t_Email = document.getElementById('tfEm').value;
		var t_Text = document.getElementById('tfMs').value;

		if(t_Name == '') { alert('Por favor digite su nombre.'); return; }
		//if(t_Email == '') { alert('Por favor digite su email.'); return; }
		if(t_Text == '') { alert('Por favor digite el texto del comentario.'); return; }

		var CommentHttp = MD_GetHttpObj(true);
		var CommentUrl = '';
		CommentUrl = '/app/do/';
		CommentUrl += 'xml/';	
		CommentUrl += 'commentsnews.aspx';
		CommentUrl += '?item_id=' + escape(MD_Rating_Id);
		CommentUrl += '&name=' + escape2(t_Name);
		CommentUrl += '&email=' + escape2(t_Email);
		CommentUrl += '&text=' + escape2(t_Text);
		CommentUrl += '&t=' + escape(new Date().toString());

		if(CommentHttp) {
			CommentHttp.onreadystatechange = function() { MD_Comment('httprsp', CommentHttp); };
			CommentHttp.open('GET', CommentUrl, true);
			CommentHttp.send(null);
			MD_Comment('load_on');
		}
		
	}

	if(act == 'httprsp') {
		if (httpRsp.readyState == 4) {
			if (httpRsp.status == 200) {		
				MD_Comment('load_off');
				alert(httpRsp.responseText)
				if(httpRsp.responseText.indexOf('Gracias') != -1) {
					document.getElementById('tfNm').value = '';
					document.getElementById('tfEm').value = '';
					document.getElementById('tfMs').value = '';
					httpRsp = null;
					location.href = location.href + '#comments';
				}
				httpRsp = null;
			} else {
				MD_Comment('load_off');
				alert('Su voto no pudo ser registrado.');
				httpRsp = null;
			}
		}
	}

}

// --------------------------------------------------------------------------

function MD_CommentFFoto(act, httpRsp) {
		
	if(act == 'load_off') {
		document.getElementById('MD_Comments_LoadImgDiv').innerHTML = '';
	}
	
	if(act == 'load_on') {
		document.getElementById('MD_Comments_LoadImgDiv').innerHTML = '<img src="/app/do/img/star_load_anim.gif" width="18" height="18" />';
	}
	
	if(act == 'post') {

		var t_Name = document.getElementById('tfNm').value;
		var t_Email = document.getElementById('tfEm').value;
		var t_Text = document.getElementById('tfMs').value;

		if(t_Name == '') { alert('Por favor digite su nombre.'); return; }
		//if(t_Email == '') { alert('Por favor digite su email.'); return; }
		if(t_Text == '') { alert('Por favor digite el texto del comentario.'); return; }

		var CommentHttp = MD_GetHttpObj(true);
		var CommentUrl = '';
		CommentUrl = '/app/do/';
		CommentUrl += 'xml/';	
		CommentUrl += 'commentsfotos.aspx';
		CommentUrl += '?item_id=' + escape(MD_Rating_Id);
		CommentUrl += '&name=' + escape2(t_Name);
		CommentUrl += '&email=' + escape2(t_Email);
		CommentUrl += '&text=' + escape2(t_Text);
		CommentUrl += '&t=' + escape(new Date().toString());

		if(CommentHttp) {
			CommentHttp.onreadystatechange = function() { MD_Comment('httprsp', CommentHttp); };
			CommentHttp.open('GET', CommentUrl, true);
			CommentHttp.send(null);
			MD_Comment('load_on');
		}
		
	}

	if(act == 'httprsp') {
		if (httpRsp.readyState == 4) {
			if (httpRsp.status == 200) {		
				MD_Comment('load_off');
				alert(httpRsp.responseText)
				if(httpRsp.responseText.indexOf('Gracias') != -1) {
					document.getElementById('tfNm').value = '';
					document.getElementById('tfEm').value = '';
					document.getElementById('tfMs').value = '';
					httpRsp = null;
					location.href = location.href + '#comments';
				}
				httpRsp = null;
			} else {
				MD_Comment('load_off');
				alert('Su voto no pudo ser registrado.');
				httpRsp = null;
			}
		}
	}

}

-->

