/* LIMPIAR BUSCAR ***********************/
function votacion(id_respuesta,id_votacion){
	document.getElementById("poll-answer-"+id_respuesta).checked=true;
	poll_vote(id_votacion);
}
function comprar_tienda(prod_id,cant,name,price){
	document.getElementById("tienda_prod_id").value=prod_id;
	document.getElementById("tienda_cant").value=cant;
	document.getElementById("tienda_name").value=name;
	document.getElementById("tienda_price").value=price;
	document.getElementById("tienda_form").submit();
}

function limpiarBuscar(obj){
	if(obj.value=="Buscar") { obj.value=""; }
}
/****************************************/



/* SUSCRIBIRSE POR EMAIL ****************/
function feed(email){
	if(validaMail(email)){ window.open('http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1778064&email='+email, 'popupwindow', 'scrollbars=yes,width=550,height=520'); }
	else{ alert('Por favor, ingresa una dirección de correo válida.'); }
}
/****************************************/



/* INTERCALAR IMAGENES ******************/
function intercalarImagenes(el){
	var imgs=document.getElementById(el).getElementsByTagName('img');
	
	for(i=0;i<imgs.length;i++){
		if(2%i==0){ imgs[i].className="foto_derecha"; }
		else{ imgs[i].className="foto_izquierda"; }
	}
}
/****************************************/



/* LINK EXTERNOS ************************/
function aExternal() {
   var a,l,i,d=document;
   if (!d.getElementsByTagName) return;
   a = d.getElementsByTagName("a");
	for (i=0;i<a.length;i++) {
		 l = a[i];
		 if (l.getAttribute("href") && l.getAttribute("rel") == "external") l.target = "_blank";
   }
}
/****************************************/




/* TOOLTIP ***************************/
/* CONFIG */
var qTipTag=["span"];
var qTipX = 0;
var qTipY = 5;
/* CONFIG */


tooltip = {
	name : "qTip",
	offsetX : qTipX,
	offsetY : qTipY,
	tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle;

	var anchors=[];
	for(i=0;i<qTipTag.length;i++){
		var els=document.getElementsByTagName(qTipTag[i]);
		for(j=0;j<els.length;j++){
			anchors.push(els[j]);
		}
	}

	for (var i = 0; i < anchors.length; i ++) {
		a = anchors[i];
		sTitle = a.getAttribute("title");
		if(sTitle) {
			a.setAttribute("tiptitle", sTitle);
			a.removeAttribute("title");
			a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
			a.onmouseout = function() {tooltip.hide()};
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX - this.tip.offsetWidth/2) + "px";
	this.tip.style.top = (y - this.offsetY - this.tip.offsetHeight) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}
/***********************************/




/* VALIDAR *************************/
function validaMail(dato){
	var ok=1;
	var es_email=/^(.+\@.+\..+)$/;
	if(!es_email.test(dato)) { ok=0; }
	
	return ok;
}
/***********************************/