var http = false; if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); if (http.overrideMimeType) { http.overrideMimeType('text/html'); } } function Tampilkan(mode) { http.abort(); http.open("GET", "//" + mode + "&ajax=1", true); http.onreadystatechange=function() { if(http.readyState==4 && http.status==200) { document.getElementById('result').innerHTML = http.responseText; document.getElementById('vmode').innerHTML = '
'; } } http.send(null); } function Eksekusi(url, bid) { http.abort(); http.open("GET", url, true); http.onreadystatechange=function() { if(http.readyState==4 && http.status==200) { document.getElementById(bid).innerHTML = http.responseText; } } http.send(null); } function Login(url, params, bid) { http.onreadystatechange=function() { if(http.readyState==4 && http.status==200) { result = http.responseText; if(result.indexOf('/home')!=-1) { window.alert("WELCOME BACK!"); window.location.href = result; } else { reloadCaptcha('result'); document.getElementById(bid).innerHTML = result; } } } http.open('POST', url, true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.send(params); } function Kirim(url, params, bid) { http.onreadystatechange=function() { if(http.readyState==4 && http.status==200) { result = http.responseText; document.getElementById(bid).innerHTML = result; } } http.open('POST', url, true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.send(params); } function ajaxPost(url, params, idp) { http.onreadystatechange=function() { if(http.readyState==4 && http.status==200) { hasil = http.responseText; if(hasil!='' && hasil!='undefined') showCart(hasil); } } http.open('POST', url, true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.send(params); } var win = null; function NewWindow(mypage,myname,w,h,scroll) { LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+ h +',width=' + w +',top='+ TopPosition +',left='+ LeftPosition +',scrollbars='+ scroll +',resizable' win = window.open(mypage,myname,settings) } function openmypage(w,h,u,t) { ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", u, t, "width="+w+"px,height="+h+"px,left=300px,top=100px,resize=1,scrolling=1"); ajaxwin.moveTo('middle', 'middle'); } function delCategory(idcat) { Eksekusi('category&action=delcategory&idcat=' + idcat, 'd' + idcat); window.setTimeout('ajaxwin.hide()', 0); } function delGroup(idgroup, p) { Eksekusi('menu&action=delgroup&idgroup=' + idgroup, p + idgroup); window.setTimeout('ajaxwin.hide()', 0); window.location.href='menu'; } function delMenu(idmenu) { Eksekusi('menu&action=delmenu&idmenu=' + idmenu, 'd' + idmenu); window.setTimeout('ajaxwin.hide()', 0); window.location.href='menu'; } function reloadCaptcha(id) { var acak=Math.floor(Math.random()*1001); document.getElementById(id).innerHTML = ''; } function clearPenggunaNameField() { document.getElementById('login').value = ""; } function clearPasswordField() { document.getElementById('password').value = ""; } function updateTotalPrice() { var itemBox = document.getElementById('shopping_cart_items'); var totalPrice = 0; if(document.getElementById('shopping_cart_totalprice')) { for(var no=1;no0) { document.getElementById('shopping_cart_totalprice').innerHTML = '
Total: ' + Rupiah(totalPrice.toFixed(0)) + '
'; } else { document.getElementById('shopping_cart').visibility = 'hidden'; document.getElementById('shopping_cart_totalprice').innerHTML = ''; } } } function get_radio_value(a,b) { for (var i=0; i < a; i++) { if (b[i].checked) { var rad_val = b[i].value; } } return rad_val; } function Rupiah(ttotal) { ttotal += ""; stotal = ""; rp = 'Rp '; while(ttotal.length>3) { stotal = "." + ttotal.substr(ttotal.length - 3, 3) + stotal; ttotal = ttotal.substring(0, ttotal.length - 3); } stotal = ttotal + stotal; hsl = rp+stotal; return hsl; } function sack(file) { this.xmlhttp = null; this.resetData = function() { this.method = "POST"; this.queryStringSeparator = "?"; this.argumentSeparator = "&"; this.URLString = ""; this.encodeURIString = true; this.execute = false; this.element = null; this.elementObj = null; this.requestFile = file; this.vars = new Object(); this.responseStatus = new Array(2); }; this.resetFunctions = function() { this.onLoading = function() { }; this.onLoaded = function() { }; this.onInteractive = function() { }; this.onCompletion = function() { }; this.onError = function() { }; this.onFail = function() { }; }; this.reset = function() { this.resetFunctions(); this.resetData(); }; this.createAJAX = function() { try { this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e1) { try { this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { this.xmlhttp = null; } } if (! this.xmlhttp) { if (typeof XMLHttpRequest != "undefined") { this.xmlhttp = new XMLHttpRequest(); } else { this.failed = true; } } }; this.setVar = function(name, value){ this.vars[name] = Array(value, false); }; this.encVar = function(name, value, returnvars) { if (true == returnvars) { return Array(encodeURIComponent(name), encodeURIComponent(value)); } else { this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true); } } this.processURLString = function(string, encode) { encoded = encodeURIComponent(this.argumentSeparator); regexp = new RegExp(this.argumentSeparator + "|" + encoded); varArray = string.split(regexp); for (i = 0; i < varArray.length; i++){ urlVars = varArray[i].split("="); if (true == encode){ this.encVar(urlVars[0], urlVars[1]); } else { this.setVar(urlVars[0], urlVars[1]); } } } this.createURLString = function(urlstring) { if (this.encodeURIString && this.URLString.length) { this.processURLString(this.URLString, true); } if (urlstring) { if (this.URLString.length) { this.URLString += this.argumentSeparator + urlstring; } else { this.URLString = urlstring; } } // prevents caching of URLString this.setVar("rndval", new Date().getTime()); urlstringtemp = new Array(); for (key in this.vars) { if (false == this.vars[key][1] && true == this.encodeURIString) { encoded = this.encVar(key, this.vars[key][0], true); delete this.vars[key]; this.vars[encoded[0]] = Array(encoded[1], true); key = encoded[0]; } urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0]; } if (urlstring){ this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator); } else { this.URLString += urlstringtemp.join(this.argumentSeparator); } } this.runResponse = function() { eval(this.response); } this.runAJAX = function(urlstring) { if (this.failed) { this.onFail(); } else { this.createURLString(urlstring); if (this.element) { this.elementObj = document.getElementById(this.element); } if (this.xmlhttp) { var self = this; if (this.method == "GET") { totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString; this.xmlhttp.open(this.method, totalurlstring, true); } else { this.xmlhttp.open(this.method, this.requestFile, true); try { this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") } catch (e) { } } this.xmlhttp.onreadystatechange = function() { switch (self.xmlhttp.readyState) { case 1: self.onLoading(); break; case 2: self.onLoaded(); break; case 3: self.onInteractive(); break; case 4: self.response = self.xmlhttp.responseText; self.responseXML = self.xmlhttp.responseXML; self.responseStatus[0] = self.xmlhttp.status; self.responseStatus[1] = self.xmlhttp.statusText; if (self.execute) { self.runResponse(); } if (self.elementObj) { elemNodeName = self.elementObj.nodeName; elemNodeName = elemNodeName.toLowerCase(); if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea") { self.elementObj.value = self.response; } else { self.elementObj.innerHTML = self.response; } } if (self.responseStatus[0] == "200") { self.onCompletion(); } else { self.onError(); } self.URLString = ""; /* These lines were added by Alf Magne Kalleland ref. info on the sack home page. It prevents memory leakage in IE */ delete self.xmlhttp['onreadystatechange']; self.xmlhttp=null; self.responseStatus=null; self.response=null; self.responseXML=null; break; } }; this.xmlhttp.send(this.URLString); } } }; this.reset(); this.createAJAX(); } function checkForm() { $("#sponsor").blur(function() { $("#sponsorbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow"); $.post("/index.php?mode=user&action=ajax&id=form",{ sponsor_user:$(this).val() } ,function(data) { if(data=='no') { $("#sponsorbox").fadeTo(200,0.1,function() { $(this).html('Sponsor tidak valid!').addClass('messageboxerror').fadeTo(900,1); }); } else { $("#sponsorbox").fadeTo(200,0.1,function() { $(this).html('Sponsor valid!').addClass('messageboxok').fadeTo(900,1); }); } }); }); $("#username").blur(function() { $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow"); $.post("/index.php?mode=user&action=ajax&id=form",{ user_name:$(this).val() } ,function(data) { if(data=='no') { $("#msgbox").fadeTo(200,0.1,function() { $(this).html('Username tidak tersedia!').addClass('messageboxerror').fadeTo(900,1); }); } else { $("#msgbox").fadeTo(200,0.1,function() { $(this).html('Nama User!').addClass('messageboxok').fadeTo(900,1); }); } }); }); $("#password").blur(function() { $("#pasbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow"); $.post("/index.php?mode=user&action=ajax&id=form",{ pass_id:$(this).val() } ,function(data) { if(data<1) { $("#pasbox").fadeTo(200,0.1,function() { $(this).html('Kata Sandi baru terlalu pendek Gunakan minimal 6 karakter!').addClass('messageboxerror').fadeTo(900,1); }); } else { $("#pasbox").fadeTo(200,0.1,function() { $(this).html('Kata Sandi: '+ data +'!').addClass('messageboxok').fadeTo(900,1); }); } }); }); $("#nama").blur(function() { $("#nambox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow"); $.post("/index.php?mode=user&action=ajax&id=form",{ nama_lkp:$(this).val() } ,function(data) { if(data=='no') { $("#nambox").fadeTo(200,0.1,function() { $(this).html('Nama lengkap tidak valid!').addClass('messageboxerror').fadeTo(900,1); }); } else { $("#nambox").fadeTo(200,0.1,function() { $(this).html('OK').addClass('messageboxok').fadeTo(900,1); }); } }); }); $("#email").blur(function() { $("#emlbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow"); $.post("/index.php?mode=user&action=ajax&id=form",{ emailid:$(this).val() } ,function(data) { if(data=='no') { $("#emlbox").fadeTo(200,0.1,function() { $(this).html('Alamat email tidak valid!').addClass('messageboxerror').fadeTo(900,1); }); } else { $("#emlbox").fadeTo(200,0.1,function() { $(this).html('OK').addClass('messageboxok').fadeTo(900,1); }); } }); }); } var _CONTENTS_WIDTH=520; var _CONTENTS_HEIGHT=390; var _DEF_CONTENTS_WIDTH=520; var _DEF_CONTENTS_HEIGHT=390;