function breakLongWordsForAjax(txt,max) { var length = txt.length; var result = ""; var count=0; if(length <= max+3) { return txt; } for(i=0; i< length; i++) { if(txt.substring(i,i+1)==" " || txt.substring(i,i+1)=="<" || txt.substring(i,i+1)=="\n") { count=0; } else if(count>max && count+3< length) { result=result+" "; count=0; } result=result+txt.substring(i,i+1); count++; } return result; } function ajaxObj(url,param,panel,funcp) { var http = null; if (window.XMLHttpRequest) http = new XMLHttpRequest(); else if(window.ActiveXObject) http = new ActiveXObject("Microsoft.XMLHTTP"); else return; http.onreadystatechange = function() { if(http.readyState ==4 ) { if(http.responseText.indexOf("connection error")>=0) window.location.href="error.php"; else funcp(panel,http.responseText); } } http.open("POST",url,true); http.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); http.setRequestHeader("Content-Length",param.length); http.setRequestHeader("Connection","close"); http.send(param); } function getPotentialPeepsList(param,panel) { new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,panel,responseGetPeepsList); } function getMyPeepsList(param,panel) { new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,panel,responseGetPeepsList); } function responseGetPeepsList(panel,response) { document.getElementById(panel).innerHTML=response; } function sendShareProfile() { var sp_screenname = document.shareprofileform.sp_screenname.value; var sp_phone = document.shareprofileform.sp_phone.value; var sp_email = document.shareprofileform.sp_email.value; var sp_note = urlencode(document.shareprofileform.sp_note.value); var sp_userid = document.shareprofileform.sp_userid.value; var sp_vkey = document.shareprofileform.sp_vkey.value; var param = "task=shareprofile&screenname="+sp_screenname+"&phone="+sp_phone+"&email="+sp_email+"¬e="+sp_note+"&userid="+sp_userid+"&vkey="+sp_vkey; new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,"shareprofilepanelerrorpanel",responseSendShareProfile); } function responseSendShareProfile(panel,response) { if(response=="success") { g_sharepopup.hidePopUp(); document.getElementById("msgbox").innerHTML="Share profile successful."; g_msgboxpopup.showPopUp(); }else{ document.getElementById(panel).innerHTML=response; } } function saveEditMsgBox() { document.getElementById("editmsgboxerrorpanel").innerHTML="saving..."; var sp_msg = document.getElementById("edittextbox").value; var sp_vkey = document.getElementById("hiddenvkey").value; var sp_type = document.getElementById("hiddenedittype").value; sp_msg = sp_msg.replace("&","/amp/"); sp_msg = urlencode(sp_msg); var param = "task=editmsgbox&msg="+sp_msg+"&type="+sp_type+"&vkey="+sp_vkey; new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,"editmsgboxerrorpanel",responseEditMsgBox); } function saveAlertMsgBox(hasPromo) { document.getElementById("editalertboxerrorpanel").innerHTML="saving..."; var i = 0; var alertString = ""; var total = 6; if(hasPromo=="false") total = 4; for ( i = 0 ; i < total; i++ ) { if(i!=1) { if(document.getElementById("alertcheck_"+i).checked) alertString = alertString + "1"; else alertString = alertString + "0"; }else alertString=alertString+"0"; } var sp_vkey = document.getElementById("hiddenalertvkey").value; var param = "task=editalertbox&alert="+alertString+"&vkey="+sp_vkey; new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,"editalertboxerrorpanel",responseAlertMsgBox); } function responseAlertMsgBox(panel,response) { if(response=="success") { var alertArray = new Array(); alertArray[0] = "When someone sends me a message."; alertArray[1] = ""; alertArray[2] = "When I get a potential peeps."; alertArray[3] = "As a daily summary of my daily activity."; alertArray[4] = "Send Promo alerts through Email."; alertArray[5] = "Send Promo alerts through SMS."; alertArray[6] = "You don't have any alerts. " g_alertboxpopup.hidePopUp(); document.getElementById("editalertboxerrorpanel").innerHTML = ""; var i = 0; var alertString = ""; var alertDetails = ""; var total = 6; if(document.getElementById("hiddenalert").value.length==4) total = 4; for ( i = 0 ; i < total; i++ ) { if(i!=1) { if(document.getElementById("alertcheck_"+i).checked) { alertString = alertString + "1"; alertDetails = alertDetails + "- "+ alertArray[i] + "
"; } else alertString = alertString + "0"; }else alertString=alertString+"0"; } document.getElementById("hiddenalert").value = alertString; document.getElementById("msgbox").innerHTML="Profile successfully updated."; g_msgboxpopup.showPopUp(); if(alertDetails.length==0) alertDetails = alertArray[6]; document.getElementById("alertDetails").innerHTML=alertDetails; }else document.getElementById(panel).innerHTML=response; } function responseEditMsgBox(panel, response) { if(response=="success") { g_editboxpopup.hidePopUp(); document.getElementById("msgbox").innerHTML="Profile successfully updated."; var msg = document.getElementById("edittextbox").value; document.getElementById("hidden"+document.getElementById("hiddenedittype").value).value = msg; var msg = breakLongWordsForAjax(document.getElementById("edittextbox").value,24); while(msg.indexOf("<")>0) msg = msg.replace("<","<"); while(msg.indexOf(">")>0) msg = msg.replace(">",">"); while(msg.indexOf("\n")>0) msg = msg.replace("\n","
"); document.getElementById("pnl"+document.getElementById("hiddenedittype").value).innerHTML = msg; g_msgboxpopup.showPopUp(); }else { document.getElementById(panel).innerHTML=response; } } function checkValidateEmail(email) { if(!validateEmail(email)) { document.getElementById("validateemail").innerHTML="Email is invalid."; }else { email = email.replace("+","%2B"); var param = "task=validateemail&email="+email; new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,"none",responseValidateEmail); } } function checkValidateMobile(mobile) { if(!isNumeric(mobile)) document.getElementById("validatemobile").innerHTML="Mobile Number should only contain numeric digits."; else if(mobile.length>0 && mobile.length<10) document.getElementById("validatemobile").innerHTML="Mobile Number should be 10 digits."; else { var param = "task=validatemobile&mobi="+mobile; new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,"none",responseValidateMobile); } } function checkValidateUserName(username) { var param = "task=validateusername&user="+username; new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,"none",responseValidateUserName); } function responseValidateEmail(panel,response) { if(response=="available") { document.getElementById("validateemail").innerHTML = "available"; }else{ document.getElementById("validateemail").innerHTML = response; } } function responseValidateMobile(panel,response) { if(response=="available") { document.getElementById("validatemobile").innerHTML="available"; }else { document.getElementById("validatemobile").innerHTML=response; } } function responseValidateUserName(panel,response) { if(response=="available") { document.getElementById("validateusername").innerHTML="available"; }else { document.getElementById("validateusername").innerHTML=response; } } function getSearchUserList(param,panel) { new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,panel,responseGetPeepsList); } function getPromoLeaderList(param,panel) { new ajaxObj("http://www.peepsnation.mobi/function/ajaxfunction.php",param,panel,responseGetPromoLeaderList); } function responseGetPromoLeaderList(panel,response) { document.getElementById(panel).innerHTML=response; }