function ajax(url, ret, params, disable_loading){ // AJAX v1.3 // Coded by HANT // 30.05.2006 // Support: IE5,6,7 , Firefox, Opera // var _ajax; // remove this if(disable_loading!=true){ show("loading"); } // end of remove this function db(){ if(_ajax.readyState == 4 && _ajax.status == 200){ // remove this if(disable_loading!=true){ hide("loading"); } // end of remove this if(ret!=false){ ret(_ajax.responseText); } } } if(window.XMLHttpRequest){ _ajax = new XMLHttpRequest(); _ajax.onreadystatechange = db; }else{ _ajax = new ActiveXObject("Microsoft.XMLHTTP"); _ajax.onreadystatechange = db; } _ajax.open((params ? "POST" : "GET"), url, true); _ajax.setRequestHeader("Cache-control", "no-cache"); if(params){ _ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); _ajax.setRequestHeader("Content-length", params.length); } _ajax.send(params ? params : null); } // POP-Up function function popup(url,w,h){ var left = Math.ceil(screen.width-w)/2; var top = Math.ceil(screen.height-h)/2; var rand_name = ""+Math.random(); rand_name = rand_name.split("."); window.open(url, rand_name[1], 'toolbar=0,location=0,statusbar=0,menubar=0,resizable=0,width='+w+',height='+h+',left = '+left+',top = '+top+',scrollbars=yes'); } // end of pop-up function show_content(url){ popup(url, 680, 550); } // GET Function function get(get_url, where){ ajax(get_url, get_result); function get_result(str){ document.getElementById(where).innerHTML = str; } }// end of get // POST Function function post(post_url, post_vars){ ajax(post_url, false, post_vars); }// end of post function show(id) { var item = null; item = document.getElementById(id); item.style.display = ""; } function hide(id){ var item = null; item = document.getElementById(id); item.style.display = "none"; } function scrollup(){ for(var i=0; i<300; i++){ window.scrollBy(0,-5); } } function scrolldown(){ for(var i=0; i<20; i++){ window.scrollBy(0,50); } } function rand(min, max){ return Math.round((Math.random()*(max-min))+min) } function center_div(id,w,h){ var left = Math.ceil(screen.width-w)/2; var top = Math.ceil(screen.height-h)/2; document.getElementById(id).style.left = left; document.getElementById(id).style.left = top; } function js_in_array(the_needle, the_haystack){ var the_hay = the_haystack.toString(); if(the_hay == ''){ return false; } var the_pattern = new RegExp(the_needle, 'g'); var matched = the_pattern.test(the_haystack); return matched; }