var xmlHttp; var timeoutAddDownload; var DownloadProxy = new Object(); function getXMLHttpRequest() { try{ return new XMLHttpRequest(); }catch(e){} try{ return new ActiveXObject('Msxm12.XMLHTTP'); }catch(e){} try{ return new ActiveXObject('Microsoft.XMLHTTP'); }catch(e){} } function handler_getDownload() { var resp; var html; if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { html = ""; try{resp = eval("(" + xmlHttp.responseText + ")");}catch(e){document.getElementById("id_getDownload").innerHTML = html; return false;} if (!isNaN(parseInt(resp.contentData.result))) { html = parseInt(resp.contentData.result).toString() + " download"; } document.getElementById("id_getDownload").innerHTML = html; } } } function handler_addDownload() { if (xmlHttp.readyState == 4) { if (timeoutAddDownload) { clearTimeout(timeoutAddDownload); document.location.href = document.getElementById("imgAddDownload").href; } } } function handler_timeoutAddDownload() { if (timeoutAddDownload) { clearTimeout(timeoutAddDownload); document.location.href = document.getElementById("imgAddDownload").href; } } DownloadProxy.addClick = function(content_id) { var url_addClick = "/tecnologia/click/click.jsp?id=" + content_id; xmlHttp = getXMLHttpRequest(); if (xmlHttp) { xmlHttp.onreadystatechange = function () {}; xmlHttp.open("GET", url_addClick , true); xmlHttp.send(null); } } DownloadProxy.addDownload = function(content_id) { var url_addDownload = "/tecnologia/download/add_download.jsp?id=" + content_id; xmlHttp = getXMLHttpRequest(); if (xmlHttp) { xmlHttp.onreadystatechange = handler_addDownload; xmlHttp.open("GET", url_addDownload , true); xmlHttp.send(null); timeoutAddDownload = setTimeout("handler_timeoutAddDownload();", 1000); } return false; } DownloadProxy.getDownload = function(content_id) { var url_getDownload = "/tecnologia/download/get_download.jsp?id=" + content_id; xmlHttp = getXMLHttpRequest(); if (xmlHttp) { xmlHttp.onreadystatechange = handler_getDownload; xmlHttp.open("GET", url_getDownload, true); xmlHttp.send(null); } }