// JavaScript Document /** * Ajax Class * Designer: Stephen Liang **/ var AjaxKtClass = function() { this.xmlHttp = false; this.url = ""; this.updateFun = null; this.Create = function(url, updateFun) { /*@cc_on @*/ /*@if(@_jscript_version >= 5) try{ this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e2){ this.xmlHttp = false; } } @end @*/ if(!this.xmlHttp&&typeof XMLHttpRequest != 'undefined'){ this.xmlHttp = new XMLHttpRequest(); } this.url = url; this.updateFun = updateFun; } this.Open = function() { this.xmlHttp.open("GET", this.url, true); this.xmlHttp.onreadystatechange = this.updateFun; this.xmlHttp.send(null); } this.Open2 = function(url) { this.xmlHttp.open("GET", url, true); this.xmlHttp.onreadystatechange = this.updateFun; this.xmlHttp.send(null); } this.Open3 = function(param) { this.xmlHttp.open("GET", this.url + param, true); this.xmlHttp.onreadystatechange = this.updateFun; this.xmlHttp.send(null); } this.UpdateDiv = function(div) { if(this.xmlHttp.readyState == 4){ var content=this.xmlHttp.responseText; if(content!='') document.getElementById(div).innerHTML = content; } } } var ajaxObj = new AjaxKtClass(); function AjaxUpdate(){ ajaxObj.UpdateDiv("content");} function load_home() { ajaxObj.Create("response.php", AjaxUpdate); ajaxObj.Open3("?action=load_home"); document.getElementById("content").style.background="url(img/bg_home.jpg) no-repeat"; } function load_service(id) { ajaxObj.Create("response.php", AjaxUpdate); ajaxObj.Open3("?action=load_service&id="+id); document.getElementById("content").style.background="url(img/bg_"+id+".jpg) no-repeat"; } function load_workers(id) { ajaxObj.Create("response.php", AjaxUpdate); ajaxObj.Open3("?action=load_workers&id="+id); document.getElementById("content").style.background="url(img/bg_workers.jpg) no-repeat"; } function load_gallery() { ajaxObj.Create("response.php", AjaxUpdate); ajaxObj.Open3("?action=load_gallery"); document.getElementById("content").style.background="url(img/bg_gallery.jpg) no-repeat"; } function load_page(id) { ajaxObj.Create("response.php", AjaxUpdate); ajaxObj.Open3("?action=load_page&id="+id); document.getElementById("content").style.background="url(img/bg_"+id+".jpg) no-repeat"; } function load_news(id) { ajaxObj.Create("response.php", AjaxUpdate); ajaxObj.Open3("?action=load_news&id="+id); document.getElementById("content").style.background="url(img/bg_workers.jpg) no-repeat"; } function change_image(img) { document.gallery_image.src=img; }