// 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','

please wait while your note is deleted

'); hidePop(); } // HIDE DIV function hidestuff(id) { document.getElementById(id).style.display = "none"; } // SHOW DIV function showstuff(id) { document.getElementById(id).style.display = "block"; } // CHANGE ICON WHEN ADDED TO BLOCKED, FAV OR CONTACT LIST function setIcon(id){ document.getElementById(id).src = '../gfx/icon_'+id+'_1.png'; } // VALIDATE SEND NOTE // ERROR AT SENDING WITH INITIAL TEXT // ERROR AT SENDING WITH EMPTY FIELD function validatenote() { var theMessage = ""; var noErrors = theMessage if(!/\S/.test(document.getElementById('note').value)){ theMessage = theMessage + "\n Please enter a note"; } if(document.getElementById('note').value == "Type note here"){ theMessage = theMessage + "\n Please enter a note"; } if (theMessage == noErrors) { doSetNote = new ajaxObject(baselink+'inc/setnote.php', processResponse, 'notefield'); doSetNote.update(document.getElementById('setnote'),'POST'); processWait(doSetNote,'notefield','

please wait while your note is added

'); return true; } else { showPop('error',theMessage); return false; } } // LINK BACK FROM POPUP TO OPENER function remote(url){ window.opener.location=url } // OPEN PHOTO POPUP function showPhoto(profid,photid,nick,premium){ window.open('../prof/photo.php?id='+profid+'&img='+photid+'&prof='+nick+'&premium='+premium+'','photo','height=700,width=570,top=25,right=25,scrollbars=no,menubar=no'); } // VALIDATE SEND MESSAGE // ERROR AT SENDING WITH INITIAL TEXT // ERROR AT SENDING WITH EMPTY FIELD function validatemsg() { var theMessage = ""; var noErrors = theMessage if(!/\S/.test(document.getElementById('msg').value)){ theMessage = theMessage + "\n Please enter a message"; } if(document.getElementById('msg').value == "Type message here"){ theMessage = theMessage + "\n Please enter a message"; } if (theMessage == noErrors) { doSendMsg = new ajaxObject(baselink+'mail/mailSend.php', processResponse, 'msgfield'); doSendMsg.update(document.getElementById('sendmsg'),'POST'); processWait(doSendMsg,'msgfield','

please wait while your message is sent

'); return true; } else { showPop('error',theMessage); return false; } } function closeMsg(){ setTimeout ('hidestuff(\'sendmsg\')', 750 ); } // CLEAR TEXT WHEN CLICKING IN MESSAGE FIELD function clearText(field) { if (document.getElementById(field).value == 'Type note here') document.getElementById(field).value = ''; if (document.getElementById(field).value == 'Type message here') document.getElementById(field).value = ''; } // LIMIT TEXT IN MESSAGE AND NOTE FIELDS function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } // LOAD MESSAGE FORM function loadmsgform(){ document.getElementById('msgfield').innerHTML = ""; document.getElementById('countmsg').value = '1000'; } // SET ACTIONS function setFav(id) { doSetFav = new ajaxObject(baselink+'inc/setaction.php', processResponse, 'set'); doSetFav.update('action=setfav&id='+id+'','GET'); } function setBlock(id) { dosetBlock = new ajaxObject(baselink+'inc/setaction.php', processResponse, 'set'); dosetBlock.update('action=setblock&id='+id+'','GET'); } function setContact(id) { doSetContact = new ajaxObject(baselink+'inc/setaction.php', processResponse, 'set'); doSetContact.update('action=setcontact&id='+id+'','GET'); }