function MM_swapImgRestore(){var i,x,a=document.MM_sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)x.src=x.oSrc;}
function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments;for(i=0;i<a.length;i++)if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function MM_swapImage(){var i,j=0,x,a=MM_swapImage.arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc)x.oSrc=x.src;x.src=a[i+2];}}

function addSuscriber()
{
  var val = document.getElementById("suscriberemail").value;
  var p = val.indexOf('@');
  if ((p < 1 || p==(val.length-1)) && document.getElementById("suscriberemail").value != '')
  {
    alert('Por favor entre una dirección de correo válida');
    return;
  }
  http_request = getRequest();


  http_request.open('POST','/TSRating/addsuscriber.php?a=a', false);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

  var parameters = "email=" + encodeURI( document.getElementById("suscriberemail").value );

  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
  var text = http_request.responseText;
  text = text.replace(/%26/g, "&");
  alert(text);
}

function getRequest(){http_request=false;if(window.XMLHttpRequest){http_request=new XMLHttpRequest();if(http_request.overrideMimeType){http_request.overrideMimeType('text/html');}}else if(window.ActiveXObject){try{http_request=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{http_request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}if(!http_request){alert('Cannot create XMLHTTP instance');return false;}return http_request;}


function vote(id,value,p1,p2,p3)
{
  url = id;
  http_request = getRequest();
  http_request.open("GET", '/updaterankings.php?path='+encodeURI(url)+'&action=vote&value='+value, false);
  http_request.send(null);
  var text = http_request.responseText;
  text = text.replace(/%26/g, "&");
  updateIMG(text,id,p1,parseInt(p2),parseInt(p3));

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.oSrc = x.src;
}

function updateIMG(text,id,p1,p2,p3)
{
	arraytmp = text.split(";");
	var nv = document.getElementById(id+"numvotes");
    nv.innerHTML = (parseInt(arraytmp[2])+parseInt(p3))+" votos";
	rank = (parseInt(arraytmp[1])+parseInt(p2))/(parseInt(arraytmp[2])+parseInt(p3));
	var img = new Array();
	for (i=1;i<6;i++)
      img[i] = document.getElementById(id+"-"+i);
    var t = "/TSRating/images/star"; 
    img[1].src = t+((rank > 0.5)?"":"g")+".gif";
    img[2].src = t+((rank > 1.5)?"":"g")+".gif";
    img[3].src = t+((rank > 2.5)?"":"g")+".gif";
    img[4].src = t+((rank > 3.5)?"":"g")+".gif";
    img[5].src = t+((rank > 4.5)?"":"g")+".gif";
}
var myid = "";
var mypageview = "";
var myp1 = "";
var myp2 = "";
var myp3 = "";
function addUR(id,pageview,p1,p2,p3)
{
	if (myid!="") myid += ",";
	myid += id;
	if (mypageview!="") mypageview += ",";
	mypageview += pageview;
	if (myp1!="") myp1 += ",";
	myp1 += p1;
	if (myp2!="") myp2 += ",";
	myp2 += p2;
	if (myp3!="") myp3 += ",";
	myp3 += p3;
}
function myupdateRankings()
{
updateRankings(myid,mypageview,myp1,myp2,myp3);
}

 function validateEmail()
 {
  var val = document.fsuscribe.email.value;
  var p = val.indexOf('@');
  if ((p < 1 || p==(val.length-1)))
  {
    alert('Por favor, entre una dirección email válida.');
    return false;
  }
  else
    return true;
 }

function hdw_URLEncode (clearString) {var output = '';var x = 0;clearString = clearString.toString();var regex = /(^[a-zA-Z0-9_.]*)/;while (x < clearString.length) {var match = regex.exec(clearString.substr(x));if (match != null && match.length > 1 && match[1] != '') {output += match[1];x += match[1].length;} else {if (clearString[x] == ' ')output += '+';else {var charCode = clearString.charCodeAt(x);var hexVal = charCode.toString(16);output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();}x++;}}return output;}function addbookmark(title, url) {if (window.sidebar) {window.sidebar.addPanel(title, url, "");} else if(window.opera && window.print) {var elem = document.createElement('a');elem.setAttribute('href',url);elem.setAttribute('title',title);elem.setAttribute('rel','sidebar');elem.click();} else if(document.all) {window.external.AddFavorite(url, title);}}function tde_Bookmark_TraverseNodes(nodes){var str = "";if (nodes != null)for (var i = 0; i < nodes.length; i++)str = str + tde_Bookmark_Traverse (nodes.item(i));return str;}function tde_Bookmark_Traverse(node){if (node.nodeType == 3)return node.data;if (node.childNodes != null)for (var i = 0; i < node.childNodes.length; i++)return tde_Bookmark_Traverse( node.childNodes.item( i ) );return "";}function autoDetectTitle(){return tde_Bookmark_TraverseNodes (document.getElementsByTagName( "title" ));}function hdw_gobookmark(item,u_title,target,u_url){
 var jumpto = ""; if (u_title == "") u_title = autoDetectTitle(); if (u_url == "") u_url = document.location; title = hdw_URLEncode(u_title); url = hdw_URLEncode(u_url); switch (item) { case "digg": jumpto = "http://digg.com/submit?url="+url+"&title="+title; break; case "reddit": jumpto = "http://reddit.com/submit?url="+url+"&title="+title; break; case "del.icio.us": jumpto = "http://del.icio.us/post?url="+url+"&title="+title; break; case "ma.gnolia": jumpto = "http://ma.gnolia.com/bookmarklet/add?url="+url+"&title="+title; break; case "stumbleupon": jumpto = "http://www.stumbleupon.com/submit?url="+url+"&title="+title; break; case "facebook": jumpto = "http://www.facebook.com/sharer.php?u="+url; break; case "twitter": jumpto = "http://twitter.com/home?status="+url; break; case "google": jumpto = "http://www.google.com/bookmarks/mark?op=edit&bkmk="+url+"&title="+title; break; case "yahoo myweb": jumpto = "http://myweb2.search.yahoo.com/myresults/bookmarklet?u="+url+"&t="+title; break; case "furl": jumpto = "http://furl.net/storeIt.jsp?u="+url+"&t="+title; break; case "blinklist": jumpto = "http://blinklist.com/index.php?Action=Blink/addblink.php&Url="+url+"&Title="+title; break; case "technorati": jumpto = "http://www.technorati.com/faves?add="+url; break; case "mixx": jumpto = "http://www.mixx.com/submit?page_url="+url; break; case "live": jumpto = "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url="+url+"&top=1"; break; case "myspace": jumpto = "http://www.myspace.com/Modules/PostTo/Pages/?l=3&u="+url+"&t="+title; break; case "yahoo bookmarks": jumpto = "http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u="+url+"&t="+title; break; case "n4g": jumpto = "http://www.n4g.com/tips.aspx?url="+url+"&title="+title; break; case "mister-wong": jumpto = "http://www.mister-wong.com/index.php?action=addurl&bm_url="+url+"&bm_description="+title; break; case "blogmarks": jumpto = "http://blogmarks.net/my/new.php?mini=1&url="+url+"&title="+title; break; case "slashdot": jumpto = "http://slashdot.org/bookmark.pl?url="+url+"&title="+title; break; case "fresqui": jumpto = "http://ocio.fresqui.com/post?url="+url+"&title="+title; break; case "care2": jumpto = "http://www.care2.com/news/compose?share[link_url]="+url+"&share[title]="+title; break; case "kirtsy": jumpto = "http://www.kirtsy.com/login.php?return=/submit.php?url="+url; break; case "sphinn": jumpto = "http://sphinn.com/login.php?return=/submit.php?url="+url; break; case "hugg": jumpto = "http://www.hugg.com/node/add/storylink?edit[title]="+title+"&edit[url]="+url; break; case "meneame": jumpto = "http://meneame.net/login.php?return=/submit.php?url="+url; break; case "faves": jumpto = "http://faves.com/Authoring.aspx?u="+url+"&t="+title; break; case "newsvine": jumpto = "http://www.newsvine.com/_tools/seed&save?popoff=0&u="+url+"&h="+title; break; case "propeller": jumpto = "http://www.propeller.com/signin/?next=/story/submit/%3FU%3D"+hdw_URLEncode(url)+"%26T%3D"+hdw_URLEncode(title); break; case "friendfeed": jumpto = "https://friendfeed.com/account/login?next=%2F%3Furl%3D"+hdw_URLEncode(url)+"%26title%3D"+hdw_URLEncode(title); break; case "funp": jumpto = "http://funp.com/account/loginpage.php?url=%2Fpush%2Fsubmit%2F%3Ftitle%3D"+hdw_URLEncode(title)+"%26url%3D"+hdw_URLEncode(url)+"%26via%3Dtools&msg=%E6%82%A8%E6%BA%96%E5%82%99%E8%B2%BC%E4%B8%80%E7%AF%87%E6%96%87%E7%AB%A0&tips=post"; break; case "diigo": jumpto = "https://secure.diigo.com/sign-in?referInfo=%2Fpost%3Furl%3D"+hdw_URLEncode(url)+"%26title%3D"+hdw_URLEncode(title); break; case "oknotizie": jumpto = "http://oknotizie.alice.it/login.html.php?uri=%2Fpost%3Furl%3D"+hdw_URLEncode(url)+"%26title%3D"+hdw_URLEncode(title); break; case "simpy": jumpto = "http://www.simpy.com/simpy/Login.do?_doneURI=%2Fsimpy%2FLinkAdd.do%3Fhref%3D"+hdw_URLEncode(url)+"%26title%3D"+hdw_URLEncode(title); break; default: jumpto = "";try {addbookmark(u_title, u_url);}catch(e){} return; } if (target == "") document.location = jumpto; else window.open(jumpto,target);}
