// JavaScript Document
var baselink = "http://waterboys.com/";
// AJAX object
var responseDiv = "";
function ajaxObject(url, callbackFunction, responseDiv) {
responseDiv = responseDiv;
var that=this;
this.updating = false;
this.abort = function() {
if (that.updating) {
that.updating=false;
that.AJAX.abort();
that.AJAX=null;
}
}
this.update = function(passData,postMethod) {
if (that.updating) { return false; }
that.AJAX = null;
if (window.XMLHttpRequest) {
that.AJAX=new XMLHttpRequest();
} else {
that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
}
if (that.AJAX==null) {
return false;
} else {
that.AJAX.onreadystatechange = function() {
if (that.AJAX.readyState==4) {
that.updating=false;
that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML,responseDiv);
that.AJAX=null;
}
}
that.updating = new Date();
if (/post/i.test(postMethod)) {
// encode all POST data
var str = "";
for(var i = 0;i < passData.elements.length;i++) {
switch(passData.elements[i].type){
case "text":
case "textarea":
case "password":
if (!passData.elements[i].disabled) str += passData.elements[i].name + "=" + encodeURIComponent(passData.elements[i].value) + "&";
break;
case "hidden":
// hidden cannot be disabled
str += passData.elements[i].name + "=" + encodeURIComponent(passData.elements[i].value) + "&";
break;
case "checkbox":
case "radio":
if(passData.elements[i].checked && !passData.elements[i].disabled) str += passData.elements[i].name + "=" + encodeURIComponent(passData.elements[i].value) + "&";
break;
case "select-one":
if (!passData.elements[i].disabled) str += passData.elements[i].name + "=" + encodeURIComponent(passData.elements[i].options[passData.elements[i].selectedIndex].value) + "&";
break;
case "select-multiple":
if (!passData.elements[i].disabled){
for (var j = 0; j < passData.elements[i].length; j++){
var optElem = passData.elements[i].options[j];
if (optElem.selected == true){
str += passData.elements[i].name + "[]" + "=" + encodeURIComponent(optElem.value) + "&";
}
}
}
break;
}
}
// strip final &
str = str.substr(0,(str.length - 1));
// end secure
var uri=urlCall+'?'+that.updating.getTime();
that.AJAX.open("POST", uri, true);
that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
that.AJAX.setRequestHeader("Content-Length", str.length);
that.AJAX.send(str);
} else {
var uri=urlCall+'?'+passData+'×tamp='+(that.updating.getTime());
that.AJAX.open("GET", uri, true);
that.AJAX.send(null);
}
return true;
}
}
var urlCall = url;
this.callback = callbackFunction || function () { };
}
// processData process ajaxObject response: optional
// ajaxObject processes task and ignores response when processData is not used
// different functions can be made to serve different purposes
function processResponse(responseText, responseStatus, responseXML, responseDiv) {
if (responseStatus==200 || responseStatus==304) {
parent.top.document.getElementById(''+responseDiv+'').innerHTML=responseText;
} else {
//showPop('connection');
}
}
// use when waiting needs to be shown , and timeout
function processWait(request,div,action){
if (request.updating) {
parent.top.document.getElementById('' + div + '').innerHTML = '' + action + '';
} else {
alert('this object is idle');
}
}
function showPop(type,txt,url) {
var type2 = type;
var header;
var txt2;
if(type2 == "delnote"){
header = 'Alert';
txt2 = ''+txt+'
';
} else if(type2 == "block"){
header = 'Alert';
txt2 = ''+txt+'
';
} else if(type2 == "success"){
header = 'Success!';
txt2 = txt;
} else if(type2 == "warning"){
header = 'Warning';
txt2 = 'test';
} else if(type2 == "error"){
header = 'Pissfuck!';
txt2 = txt;
} else {
header = 'Pissfuck!';
txt2 = txt;
}
document.getElementById('pop').style.display = "block";
document.getElementById('pop_content').style.display = "block";
document.getElementById('pop_text').innerHTML= txt2;
document.getElementById('pop_header').innerHTML = header;
}
// CLOSE ERROR
function hidePop() {
document.getElementById('pop').style.display = "none";
document.getElementById('pop_content').style.display = "none";
}
// VALIDATE DELETE NOTE
function delNote(profid) {
doDelNote = new ajaxObject(baselink+'inc/delnote.php', processResponse, 'notefield');
doDelNote.update('del='+profid+'','GET');
processWait(doDelNote,'notefield','