function urlencode(string) { return encodeURIComponent(string); } function ajax() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function endswith(string, end) { return string.substr(string.length-end.length, end.length) == end; } function ajax_and_refresh(url,finished) { var a = ajax(); a.onreadystatechange=function() { if(a.readyState!=4) return; if(a.status!=200) return; if(finished) finished(a.responseText); window.location = window.location; } a.open("GET",url,true); a.send(null); } function doajax(url,finished) { var a = ajax(); a.onreadystatechange=function() { if(a.readyState!=4) return; if(a.status!=200) return; if(finished) finished(a.responseText); } a.open("GET",url,true); a.send(null); } function showpopup(parent,text,z,time) { var a = document.createElement('div'); a.className = 'popup'; a.name = 'gran_popup'; a.innerHTML = '
'+text+'
'; if(z) a.style.zIndex = z; document.getElementById(parent).parentNode.appendChild(a); var t=3000; if(time) t = time; setTimeout(function(){a.parentNode.removeChild(a);},t); } function clearpopups() { var popups = document.getElementsByName('gran_popup'); for(var i=0; i < popups.length; i++) { popups[i].parentNode.removeChild(popups[i]); } } this.onmousedown = function(e) { clearpopups(); }; function show(id) { var e = document.getElementById(id); if(e) { e.style.visibility = 'visible'; e.style.display = ''; } } function hide(id) { var e = document.getElementById(id); if(e) { e.style.visibility = 'hidden'; e.style.display = 'none'; } } function toggle_show(id) { var e = document.getElementById(id); if(e) { if(e.style.visibility != 'hidden') { e.style.visibility = 'hidden'; e.style.display = 'none'; } else { e.style.visibility = 'visible'; e.style.display = ''; } } } function popup(url,bgcolor) { try { var e=document.getElementById('popup_content'); doajax(url,function(response) { var a = ''; var b = ''; if(bgcolor) { a = '
'; b = '
'; } e.innerHTML = a + response + b; show('popup'); e.focus(); }); } catch(e) { alert(e); } } function trim(str, chars) { if(chars) return ltrim(rtrim(str, chars), chars); return ltrim(rtrim(str, ' '), ' '); } function ltrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); } function rtrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); } function popup(url,width,height) { mywindow = window.open (url,"mywindow","location=0,status=0,scrollbars=1,width="+width+",height="+height); //mywindow.moveTo(0,0); }