var xmlhttp; var original_values = new Array(); function updatenumber(span_num){ xmlhttp=GetXmlHttpObject(); var properties_id = document.getElementsByTagName("span")[span_num].className.substring(19) * 1; url = "click_for_number.php?"; url = url + "affiliate_id=" + track_number_views[properties_id]['affiliate_id']; url = url + "&domain_id=" + track_number_views[properties_id]['domain_id']; url = url + "&sid=" + Math.random(); //to prevent cached results display_number(properties_id); xmlhttp.open("GET",url,true); xmlhttp.send(null); return false; } function display_number(properties_id){ for(var i = 0; i < document.getElementsByTagName("span").length; i++){ if(document.getElementsByTagName("span")[i].className == null){ continue; } if((document.getElementsByTagName("span")[i].className.substring(19) * 1) == properties_id){ document.getElementsByTagName("span")[i].innerHTML = original_values[i]; document.getElementsByTagName("span")[i].style.color = '#000000'; document.getElementsByTagName("span")[i].style.textDecoration = 'none'; document.getElementsByTagName("span")[i].style.cursor = 'text'; } } } function GetXmlHttpObject(){ var xmlhttp; if(window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); }else if(window.ActiveXObject){ // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); }else{ //if we can't make the request, just show the number. display_number(); } } window.onload=function(){ for(var i = 0; i < document.getElementsByTagName("span").length; i++){ if(document.getElementsByTagName("span")[i].className == null){ continue; } if(document.getElementsByTagName("span")[i].className.substring(0, 18) == 'track_number_views'){ original_values[i] = document.getElementsByTagName("span")[i].innerHTML; var this_tag_num = document.getElementsByTagName("span")[i].className.substring(19) * 1; document.getElementsByTagName("span")[i].innerHTML = track_number_views[this_tag_num]['link_title']; document.getElementsByTagName("span")[i].style.color = track_number_views[this_tag_num]['link_color']; if(track_number_views[this_tag_num]['link_underline']){ document.getElementsByTagName("span")[i].style.textDecoration = 'underline'; document.getElementsByTagName("span")[i].style.cursor = 'pointer'; } document.getElementsByTagName("span")[i].idx = i; document.getElementsByTagName("span")[i].onclick = function(){ updatenumber(this.idx); } } } }