var mblAdsServed = null;
var mblAdCnt = null;
var mblAdDivID = null;
var mblAdMax = null;
var sendmgsxml = null;
var cptr = null;
var lastMsgID = null;
var fwarnings = null;
var mutexml = null;
var readxml = null;
var winxml = null;
var synchCon = null;
var refresh = null;
var wzChanID = null;
var wzChanName = null;
var urlroot = null;
var ifrm = null;
var wzUserID = null;
var talkTimer = null;
var talkmode = null;
var imgSize = null;
var nDispRecs = null;
var listLength = null;
var chatMsgEL = null;
var chatMsgELC = null;
var chatELTimer = null;
var zoomImgEL = null;
var pvcInFocus = null;
var showGoogleAd = null;
var rollMsgs = null;
var rollCnt = null;
var rollRefresh = null;
var rollnNew = null;
var rollTimer = null;
var isRolling = null;
var chanHasChanged = null;
// end chat engine core declarations..
var chanReload = 1; var mkyUState = {
muid : ''
}
var actv_msgNum = 0;
var actv_msgs = [
"
" +
"
" + actv_msgs[actv_msgNum] + "...
";
actv_msgNum += 1;
if (actv_msgNum <= actv_msgs.length){
setTimeout('showMainLoadProgress()',8*100);
}
else {
spot.style.display = 'none';
}
}
}
function getSpinner(msg){
return "
";
}
function getInvitePg(group,muid){
var url = 'https://www.bitmonky.com/whzon/adMgr/joinMyChan.php?grp='+group+'&muid='+muid+'&rfm=webr';
window.open(url,'mkyGrpInvite');
}
function testYouTubeIFail(vidId,img=null){
var divxml = getHttpConnection();
var currentTime = new Date();
var ranTime = currentTime.getMilliseconds();
inUrl = img.src;
divxml.open("GET", inUrl,true);
divxml.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 404) {
console.log('YT Video: '+vidId+' Marked For Delete');
logYouTubeImgFail(vidId,img);
}
};
divxml.send(null);
}
function logYouTubeImgFail(vidId,img){
if (img){
img.style.display = 'none';
}
var divxml = getHttpConnection();
var currentTime = new Date();
var ranTime = currentTime.getMilliseconds();
inUrl = '/whzon/mbr/vidView/logYouTubeImgFail.php?vidID=' + vidId + '&xm=' + ranTime ;
divxml.open("GET", inUrl,true);
divxml.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log('YT Video: '+vidId+' Marked For Delete');
return;
}
};
divxml.send(null);
}
function checkUrlExists(url){
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status!=404;
}
function checkImgURL(url,id){
if (checkUrlExists(url)){
return true;
}
adImgFail(id,1);
}
var emAlertTimer = null;
var emAlertcon = null;
var pvcDeclcon = null;
emAlertcon = getHttpConnection();
pvcDeclcon = getHttpConnection();
setTimeout('roomEmPopAlert()',15*1000);
/*
window.addEventListener('load',function(){
var el = document.getElementById('pvChatAlertSpotCon');
if (el){
el.style.zIndex = 999999;
dragDIVListen(el, function(distX,distY){
var ex = pxToInt(percentToPx(el.style.left,'left'));
var ey = pxToInt(percentToPx(el.style.top,'top'));
el.style.top = ey + distY + 'px';
el.style.left = ex + distX + 'px';
});
el.style.display = 'none';
}
}, false);
*/
function dragDIVListen(el, callback){
console.log('drag pre listing');
var touchsurface = el,
startX,
startY,
distX,
distY,
dragDiv = callback || function(distX,distY){}
document.onmousedown = function(e){
e = e || window.event;
startX = e.clientX;
startY = e.clientY;
}
document.onmouseup = function(e){
startX = null;
e.preventDefault();
}
document.onmousemove = function(e){
e = e || window.event;
if (startX){
distX = e.clientX - startX; // get horizontal dist traveled by finger while in contact with surface
distY = e.clientY - startY; // get vertical dist traveled by finger while in contact with surface
dragDiv(distX,distY);
startX = e.clientX;
startY = e.clientY;
}
}
}
function percentToPx(str,cord){
if (str.indexOf('%') < 0) {return str;}
str = str.replace('%','');
var si = parseInt(str);
var d = window.innerHeight;
if (cord == 'left'){
d = window.innerWidth;
}
return (si/100.0) * d + 'px';
}
function pxToInt(str){
str = str.replace('px','');
var si = parseInt(str);
return si;
}
function swipedetect(el, callback){
var touchsurface = el,
swipedir,
startX,
startY,
distX,
distY,
threshold = 150, //required min distance traveled to be considered swipe
restraint = 100, // maximum distance allowed at the same time in perpendicular direction
allowedTime = 300, // maximum time allowed to travel that distance
elapsedTime,
startTime,
handleswipe = callback || function(swipedir){}
touchsurface.addEventListener('touchstart', function(e){
var touchobj = e.changedTouches[0]
swipedir = 'none'
dist = 0
startX = touchobj.pageX
startY = touchobj.pageY
startTime = new Date().getTime() // record time when finger first makes contact with surface
//e.preventDefault()
}, false)
touchsurface.addEventListener('touchmove', function(e){
//e.preventDefault() // prevent scrolling when inside DIV
}, false)
touchsurface.addEventListener('touchend', function(e){
var touchobj = e.changedTouches[0]
distX = touchobj.pageX - startX // get horizontal dist traveled by finger while in contact with surface
distY = touchobj.pageY - startY // get vertical dist traveled by finger while in contact with surface
elapsedTime = new Date().getTime() - startTime // get time elapsed
if (elapsedTime <= allowedTime){ // first condition for awipe met
if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint){ // 2nd condition for horizontal swipe met
swipedir = (distX < 0)? 'left' : 'right' // if dist traveled is negative, it indicates left swipe
}
else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint){ // 2nd condition for vertical swipe met
swipedir = (distY < 0)? 'up' : 'down' // if dist traveled is negative, it indicates up swipe
}
}
handleswipe(swipedir)
//e.preventDefault()
}, false)
}
function roomAcceptAtM(atm){
//hideTop();
showChatWidget(null,null,atm);
roomDeclineAtM(atm.msgID,atm.mbrID);
}
function roomDeclineAtM(id,uid){
var xm = new Date();
var url = '/whzon/mblp/mail/atAlertDecline.php?wzID=' + sID + '&fmsgID=' + id + '&xm=' + xm.getTime();
pvcDeclcon.open("GET", url,true);
pvcDeclcon.onreadystatechange = doRoomDeclineEM;
pvcDeclcon.send(null);
}
function doRoomDeclinePVC(){
if (pvcDeclcon.readyState == 4){
if (pvcDeclcon.status == 200) {
var cdiv = document.getElementById("pvChatAlertSpotCon");
if (cdiv) {cdiv.style.display = 'none';}
var gdiv = document.getElementById("pvChatAlertSpot");
gdiv.innerHTML = "";
dbug('innerHTML set to By RoomDelcinePVC : ' + gdiv.innerHTML);
}
}
}
var lastAtmID = null;
function showAtMemberNotice(atm){
var gdiv = document.getElementById("pvChatAlertSpot");
if (gdiv != null ) {
if (atm.msgID != lastAtmID){
lastAtmID = atm.msgID;
var snd = new Audio("/sounds/quiteTone.wav");
if (snd.currentTime == 0){
snd.play();
}
}
var mtype = 2;
var pimg = 'getMbrImg.php';
var bgc = '#333333'
var cdiv = document.getElementById("pvChatAlertSpotCon");
if (cdiv) {cdiv.style.display = 'inline-block';}
gdiv.innerHTML = "
";
}
}
function roomEmPopAlert(){
return;
if (sID == '0'){
dbug('cancel emAlert room');
return;
}
if (emAlertTimer) {clearTimeout(emAlertTimer)};
var xm = new Date();
var url = '/whzon/mblp/emAlertRoom.php?wzID=' + sID + '&xm=' + xm.getMilliseconds();
emAlertcon.timeout = 22*1000;
emAlertcon.ontimeout = roomEmPopAlert;
emAlertcon.onerror = function(){
emAlertTimer = setTimeout('roomEmPopAlert()',22*1000);
};
emAlertcon.open("GET", url, true);
emAlertcon.onreadystatechange = doRoomEmPopAlert;
emAlertcon.send(null);
}
function excRoomEmPopAlert(j){
eAlert = j.emAlerts;
console.log(eAlert);
if(eAlert.msgID == 0){
return;
}
var gdiv = document.getElementById("pvChatAlertSpot");
if (gdiv != null ) {
if (eAlert){
var mtype = eAlert.msgType;
var pimg = 'getMbrImg.php';
var bgc = '#222222';
if (mtype == 2){
console.log(eAlert);
showAtMemberNotice(eAlert);
return;
}
if (mtype == 1){
pimg = 'getDProfThm.php';
bgc = 'fireBrick'
}
var cdiv = document.getElementById("pvChatAlertSpotCon");
if (cdiv) {cdiv.style.display = 'inline-block';}
gdiv.innerHTML = "
";
}
else {
/*
var cdiv = document.getElementById("pvChatAlertSpotCon");
if (cdiv) {cdiv.style.display = 'none';}
gdiv.innerHTML = "";
*/
}
}
}
function doRoomEmPopAlert(){
if (emAlertcon.readyState == 4){
emAlertTimer = setTimeout(roomEmPopAlert, 22*1000);
if(emAlertcon.status == 200){
var jdata = emAlertcon.responseText;
var eAlert = null;
if (jdata == 'NF') {
return;
}
try {eAlert = JSON.parse(jdata); }
catch(err) {
eAlert = null;
}
var gdiv = document.getElementById("pvChatAlertSpot");
if (gdiv != null ) {
if (eAlert){
var mtype = eAlert.msgType;
var pimg = 'getMbrImg.php';
var bgc = '#222222';
if (mtype == 2){
console.log(eAlert);
showAtMemberNotice(eAlert);
return;
}
if (mtype == 1){
pimg = 'getDProfThm.php';
bgc = 'fireBrick'
}
var cdiv = document.getElementById("pvChatAlertSpotCon");
if (cdiv) {cdiv.style.display = 'inline-block';}
gdiv.innerHTML = "
";
}
else {
/*
var cdiv = document.getElementById("pvChatAlertSpotCon");
if (cdiv) {cdiv.style.display = 'none';}
gdiv.innerHTML = "";
*/
}
}
}
}
}
// ****************************************
// Public Chat Widget Controls
// ****************************************
function showChatWidgetSpace(){
//hideTop();
var space = document.getElementById('chatWidgetSpace');
if (space){
space.style.display = 'block';
}
}
function hideChatWidgetSpace(){
var space = document.getElementById('chatWidgetSpace');
if (space){
space.style.display = 'none';
}
}
function atMChangeChannel(atm){
atm = JSON.parse(decodeURIComponent(atm));
wzChangeChannel(atm.chanID);
//doShowChatRoom();
showChatWidget(null,null,atm);
}
function hideChatWidget() {
hideChatWidgetSpace();
var chatW = document.getElementById('chatWidget');
if (chatW) {
chatW.style.display = "none";
}
}
function showChatWidget(name,id,atm=null) {
console.log('showChatWidget');
if (atm){
name = atm.nic;
id = atm.mbrID;
var toChanID = document.getElementById('postToChan');
if (toChanID){
toChanID.value = atm.chanID;
}
}
var gto = id;
if (!gto){gto = 0;}
//hidePVChatWidget();
//hidePVDChatWidget();
showChatWidgetSpace();
//hideMoreWidget();
var chatW = document.getElementById('chatWidget');
var chatT = document.getElementById('chatWidgetT');
if (chatW) {
wzAPI_closeMenu();
//chatW.style.width = "98%";
if (chatT){
chatT.style.width = "98%";
}
chatW.style.display = 'block';
chatW.style.zIndex = 20;
var chatb = document.getElementById("chatWidgetBox");
var cimg = document.getElementById('chatWhoImg');
var cmsg = document.getElementById('chatWhoMsg');
if (cmsg){
if (atm){
var clink = "
";
cmsg.innerHTML = '
' + doEmotes(atm.msg) + clink + '
';
}
else {
cmsg.innerHTML = '';
}
}
if (cimg && gto){
if (wzChanID == 302057){
cimg.src = '//image.bitmonky.com/getDProfThm.php?id=' + gto;
}
else {
cimg.src = '//image.bitmonky.com/getMbrImg.php?id=' + gto;
}
}
if (chatb){
chatb.value = '';
if (name){
chatb.value = '@' + name + ' - ';
}
//chatb.focus();
}
var goPV = document.getElementById("goPrivate");
dbug('div goPrivate found');
if (goPV){
goPV.onclick = function() {
if (wzChanID == 302057){
wzPopDChat(gto);
}
else {
wzPopChat(gto);
}
dbug('wzPop installed');
};
}
var goMor = document.getElementById("goMoreWid");
dbug('div goMore found');
if (goMor){
goMor.value = ' More ';
goMor.style.display = 'none';
goMor.onclick = function() {
doWidgetShowMore(gto);
dbug('wzMore installed');
};
}
}
return false;
}
function roomAcceptEM(id,uid,mtype){
var cdiv = document.getElementById("pvChatAlertSpotCon");
if (cdiv) {cdiv.style.display = 'none';}
var gdiv = document.getElementById("pvChatAlertSpot");
gdiv.innerHTML = "";
if(mtype == 0){
wzGetPage('/whzon/mbr/mail/replyForm.php?wzID=' + sID + '&fmsgID=' + id + '&fwzUserID=' + uid);
}
else {
wzGetPage('/whzon/apps/dating/mail/replyForm.php?wzID=' + sID + '&fmsgID=' + id + '&fwzUserID=' + uid);
}
}
function roomDeclineEM(id,uid){
var xm = new Date();
var url = '/whzon/mblp/mail/emAlertDecline.php?wzID=' + sID + '&fmsgID=' + id + '&xm=' + xm.getTime();
pvcDeclcon.open("GET", url,true);
pvcDeclcon.onreadystatechange = doRoomDeclineEM;
pvcDeclcon.send(null);
}
function roomAcceptAtM(atm){
//hideTop();
showChatWidget(null,null,atm);
roomDeclineAtM(atm.msgID,atm.mbrID);
}
function roomDeclineAtM(id,uid){
var xm = new Date();
var url = '/whzon/mblp/mail/atAlertDecline.php?wzID=' + sID + '&fmsgID=' + id + '&xm=' + xm.getTime();
pvcDeclcon.open("GET", url,true);
pvcDeclcon.onreadystatechange = doRoomDeclineEM;
pvcDeclcon.send(null);
}
function doRoomDeclineEM(){
if (pvcDeclcon.readyState == 4){
if (pvcDeclcon.status == 200) {
var cdiv = document.getElementById("pvChatAlertSpotCon");
if (cdiv) {cdiv.style.display = 'none';}
var gdiv = document.getElementById("pvChatAlertSpot");
gdiv.innerHTML = "";
}
}
}
window.addEventListener('load',function(){
var el = document.getElementById('videoChatWindow');
if (el){
el.style.zIndex = 999999;
dragDIVListen(el, function(distX,distY){
var ex = pxToInt(percentToPx(el.style.left,'left'));
var ey = pxToInt(percentToPx(el.style.top,'top'));
el.style.top = ey + distY + 'px';
el.style.left = ex + distX + 'px';
});
el.style.display = 'none';
}
}, false);
function openVideoChatFrame(url,width,height){
var gdiv = document.getElementById("videoChatFrame");
if (gdiv != null ) {
var cdiv = document.getElementById("videoChatWindow");
if (cdiv) {cdiv.style.display = 'inline-block';}
var htm = '';
htm += "
";
htm += "