var chatWindowNum;
var numChatWindows;
chatWindowNum = 0;
numChatWindows = 0;
var usi;
var chatWindowsIDs = new Array();
var emoticonsMatches = new Array();
    emoticonsMatches.push(':\)');
    emoticonsMatches.push(':\(');
    emoticonsMatches.push('יאללה');
    emoticonsMatches.push('יאלה');
    emoticonsMatches.push('yalla');

var emoticonsReplaces = new Array();
    emoticonsReplaces.push('<img src="http://p1.yalla.co.il/yf/emoticon_smile.png" align="absmiddle"/>');
    emoticonsReplaces.push('<img src="http://p1.yalla.co.il/yf/emoticon_unhappy.png" align="absmiddle"/>');
    emoticonsReplaces.push('<img src="http://p1.yalla.co.il/yf/yalaicon.jpg" align="absmiddle"/>');
    emoticonsReplaces.push('<img src="http://p1.yalla.co.il/yf/yalaicon.jpg" align="absmiddle"/>');
    emoticonsReplaces.push('<img src="http://p1.yalla.co.il/yf/yalaicon.jpg" align="absmiddle"/>');
    emoticonsReplaces.push('<img src="http://p1.yalla.co.il/yf/yalaicon.jpg" align="absmiddle"/>');
var firstChatWindow;
var lastChatWindow;
var titleTimer;

if(!Array.indexOf){
    Array.prototype.indexOf = function(obj){
        for(var i=0; i<this.length; i++){
            if(this[i]==obj){
                return i;
            }
        }
        return -1;
    }
}

function onlineUsersBox() {
    if (document.getElementById('onlineUsers').style.display == 'none') {
        document.getElementById('onlineUsers').style.display = 'block';
        if (document.getElementById('appsWindow').style.display == 'block') {
            document.getElementById('appsWindow').style.display = 'none';
            clearTimeout(updateInfoWindow);
        }
        ajaxOp('/ajax.yalla.php',1,'a=13&s='+sid,'oullo',0,0,0);
    } else {
        document.getElementById('onlineUsers').style.display = 'none';
        clearTimeout(updateUsersList);
    }
}

function openChatWindow(uid,ir,un,us,pt) {
    if (!document.getElementById('chatWindow_'+uid)) {
        if (false) {
            document.getElementById(chatWindowsIDs[(chatWindowsIDs.length-3)]).style.display = 'none';
            document.getElementById('windowsArrowLeft').style.display = 'block';
            
            firstChatWindow = chatWindowsIDs.length-2;
            lastChatWindow = chatWindowsIDs.length;
        }
        if (numChatWindows > 2) {
            alert ("קיימת הגבלה ל-3 חלונות");
        } else {
            if (document.getElementById('onlineUsers')) {
                document.getElementById('onlineUsers').style.display = 'none';
            }
            
            if (document.getElementById('chatWindow_'+uid)) {
                if (document.getElementById('chatWindow_'+uid).style.display == 'none') {
                    document.getElementById('chatWindow_'+uid).style.display = 'block';
                    
                    numChatWindows++;
                }
            } else {
                numChatWindows++;
                
                if (us == 1) {
                    usi = 'green';
                } else if (us == 2) {
                    usi = 'orange';
                } else {
                    usi = 'black';
                }
                
                if (pt == '' || pt == undefined) {
                    pt = 'לא ידוע';   
                }
                
                if (document.getElementById('contactBanner')) {
                    document.getElementById('contactBanner').style.display = 'none';
                }
                
                chatWindowHTML = '';
                /*
                chatWindowHTML = chatWindowHTML + '<div style="float: left; width: 200px; background-color: #FFF; border: 1px solid #D7D7D7; font-size: 12px; font-family: arial; color: #0C3262; padding: 1px; height: 250px; text-align: left; position: relative; margin-top: -231px; margin-left: 5px; border-bottom: 0px; font-size: 12px; font-family: arial; direction: rtl" id="chatWindow_'+uid+'"><div style="width: 100%; position: absolute; top: 0; left: 0">';
                chatWindowHTML = chatWindowHTML + '<div style="position: relative; width: 100%; height: 21px; background-color: #017FB9; color: #FFF; text-align: right; cursor: pointer" id="chatWindowTop_'+uid+'">';
                chatWindowHTML = chatWindowHTML + '<div style="padding: 3px; float: right; width: 150px" onclick="hideChatWindow(\''+uid+'\')" id="chatWindowTopContainer_'+uid+'"><img src="http://p1.yalla.co.il/yf/bullet_'+usi+'.png" align="absmiddle" style="margin-top: -1px" id="chatUserStatus_'+uid+'"/> <b>'+un+'</b></div>';
                chatWindowHTML = chatWindowHTML + '<div style="padding-left: 3px; float: left; font-size: 13px; margin-top: 1px; cursor: pointer" onmouseover="this.style.fontWeight=\'bold\'" onmouseout="this.style.fontWeight=\'normal\';" onclick="closeChatWindow(\''+uid+'\')">x</div>';
                chatWindowHTML = chatWindowHTML + '<div style="padding-left: 3px; float: left; font-size: 13px; margin-top: 6px; cursor: pointer" onclick="openFloatChatWindow(\''+uid+'\',1)" id="floatChatButton_'+uid+'"><img src="http://p1.yalla.co.il/yf/chatfloat.png"/></div>';
                chatWindowHTML = chatWindowHTML + '<div style="padding-left: 5px; float: left; font-size: 12px; margin-top: 0px; cursor: pointer" onclick="hideChatWindow(\''+uid+'\')" id="chatMinimizeButton_'+uid+'">_</div>';
                chatWindowHTML = chatWindowHTML + '</div>';
                if (ut > 0) {
                    chatWindowHTML = chatWindowHTML + '<div style="position: relative; width: 100%; height: 21px; background-color: #CADDEF; color: #333; text-align: right" onmouseover="this.style.backgroundColor=\'#EAEAEA\'" onmouseout="this.style.backgroundColor=\'#CADDEF\'">';
                    chatWindowHTML = chatWindowHTML + '<div style="padding: 3px; float: right; font-size: 11px; width: 175px; cursor: pointer" title="'+pt+'" alt="'+pt+'" id="chatViewTitle_'+uid+'" onclick="">צופה בעמוד: <span id="chatWindowView_'+uid+'">'+pt+'</span></div>';
                    chatWindowHTML = chatWindowHTML + '<div style="padding-left: 1px; padding-top: 1px; float: left; font-size: 11px; width: 17px" id="viewTime_'+uid+'"></div>';
                    chatWindowHTML = chatWindowHTML + '</div>';
                    
                    textDivHeight = '186px';
                } else {
                    textDivHeight = '207px';
                }
                chatWindowHTML = chatWindowHTML + '<div style="float: right; text-align: right; width: 130px; color: #000; overflow: auto; margin-right: 10px; margin-top: 10px; display: none" id="chatPic_'+uid+'"><img src="http://www.yalla.co.il/yala/uploads/u192/product/1265560968-1.jpg"/></div>';
                chatWindowHTML = chatWindowHTML + '<div style="float: right; text-align: right; width: 100%; color: #000; height: '+textDivHeight+'; overflow: auto;" onclick="document.getElementById(\'chatWindowTop_'+uid+'\').style.backgroundColor=\'#017FB9\'; document.getElementById(\'msgTextBox_'+uid+'\').focus(); setOriginTitle();" id="chatBoxTextWrapper_'+uid+'"><div style="padding: 1px; float: right" id="chatBoxText_'+uid+'"><font style="color: #BDBDBD">אין לתת את פרטי האשראי בצ\'אט!</font></div><div style="clear: both; display: none; float: right" id="msgloader_'+uid+'"></div></div>';
                chatWindowHTML = chatWindowHTML + '<div style="clear: both; float: right; text-align: right; width: 100%; color: #000; height: 21px; border-top: 1px solid #E0E0E0" id="msgTextBoxWrapper_'+uid+'"><input type="text" style="width: 196px; height: 17px; border: 0px" onkeydown="if (event.keyCode == 13) { insertChatText(\''+uid+'\',this.value); this.value=\'\'; }" onfocus="document.getElementById(\'chatWindowTop_'+uid+'\').style.backgroundColor=\'#017FB9\'; setOriginTitle();" onclick="document.getElementById(\'chatWindowTop_'+uid+'\').style.backgroundColor=\'#017FB9\'; setOriginTitle();" id="msgTextBox_'+uid+'"/></div>';
                chatWindowHTML = chatWindowHTML + '</div></div>';
                */
                
                chatWindowHTML = chatWindowHTML + '<div style="float: left; width: 200px; background-color: #FFF; border: 1px solid #D7D7D7; font-size: 12px; font-family: arial; color: #0C3262; height: 250px; text-align: left; position: relative; margin-top: -231px; margin-left: 5px; border-bottom: 0px; font-size: 12px; font-family: arial; direction: rtl" id="chatWindow_'+uid+'">';
                chatWindowHTML = chatWindowHTML + ' <div style="width: 100%; position: absolute; top: 0; left: 0">';
                chatWindowHTML = chatWindowHTML + '  <div style="position: relative; width: 100%; height: 21px; background-color: #017FB9; color: #FFF; text-align: right; cursor: pointer" id="chatWindowTop_'+uid+'">';
                chatWindowHTML = chatWindowHTML + '   <div style="float: right; margin-top: 3px; width: 150px" onclick="hideChatWindow(\''+uid+'\')" id="chatWindowTopContainer_'+uid+'"><img src="http://p1.yalla.co.il/m/pixel.gif" class="chatsprite bullet_'+usi+'" align="absmiddle" style="margin-top: -1px" id="chatUserStatus_'+uid+'"/> <b>'+un+'</b></div>';
                chatWindowHTML = chatWindowHTML + '   <div style="float: left; font-size: 13px; margin-left: 3px; margin-top: 1px; cursor: pointer" onmouseover="this.style.fontWeight=\'bold\'" onmouseout="this.style.fontWeight=\'normal\';" onclick="closeChatWindow(\''+uid+'\')">x</div>';
                chatWindowHTML = chatWindowHTML + '   <div style="float: left; font-size: 13px; margin-left: 4px; margin-top: 6px; cursor: pointer" onclick="openFloatChatWindow(\''+uid+'\',1)" id="floatChatButton_'+uid+'"><img src="http://p1.yalla.co.il/yf/chatfloat.png"/></div>';
                chatWindowHTML = chatWindowHTML + '   <div style="float: left; font-size: 12px; margin-left: 4px; margin-top: 0px; cursor: pointer" onclick="hideChatWindow(\''+uid+'\')" id="chatMinimizeButton_'+uid+'">_</div>';
                chatWindowHTML = chatWindowHTML + '  </div>';
                if (ut > 0) {
                    chatWindowHTML = chatWindowHTML + '  <div style="position: relative; width: 100%; height: 21px; background-color: #CADDEF; color: #333; text-align: right" onmouseover="this.style.backgroundColor=\'#EAEAEA\'" onmouseout="this.style.backgroundColor=\'#CADDEF\'">';
                    chatWindowHTML = chatWindowHTML + '   <div style="float: right; font-size: 11px; width: 175px; margin-right: 3px; margin-top: 3px; cursor: pointer" title="'+pt+'" alt="'+pt+'" id="chatViewTitle_'+uid+'" onclick="">צופה בעמוד: <span id="chatWindowView_'+uid+'">'+pt+'</span></div>';
                    chatWindowHTML = chatWindowHTML + '   <div style="float: left; font-size: 11px; width: 17px; margin-left: 3px; margin-top: 2px"><img src="http://p1.yalla.co.il/m/pixel.gif" class="" align="absmiddle" id="viewTime_'+uid+'"/></div>';
                    chatWindowHTML = chatWindowHTML + '  </div>';
                    
                    textDivHeight = '186px';
                } else {
                    textDivHeight = '207px';
                }
                chatWindowHTML = chatWindowHTML + '  <div style="float: right; text-align: right; width: 100%">';
                chatWindowHTML = chatWindowHTML + '   <div style="float: right; text-align: right; width: 130px; color: #000; overflow: auto; display: none; margin-top: 10px; margin-right: 10px" id="chatPic_'+uid+'"><img src="'+chatPic+'"/></div>';
                chatWindowHTML = chatWindowHTML + '   <div style="float: right; text-align: right; width: 100%; color: #000; height: '+textDivHeight+'; overflow: auto;" onclick="document.getElementById(\'chatWindowTop_'+uid+'\').style.backgroundColor=\'#017FB9\'; document.getElementById(\'msgTextBox_'+uid+'\').focus(); setOriginTitle();" id="chatBoxTextWrapper_'+uid+'"><div style="float: right; padding: 2px" id="chatBoxText_'+uid+'"><font style="color: #BDBDBD">אין לתת את פרטי האשראי בצ\'אט!</font></div><div style="clear: both; display: none; float: right" id="msgloader_'+uid+'"></div></div>';
                chatWindowHTML = chatWindowHTML + '  </div>';
                chatWindowHTML = chatWindowHTML + '  <div style="float: left; width: 100%; text-align: left"><div style="text-align: right; width: 100%; color: #000; height: 21px; border-top: 1px solid #E0E0E0" id="msgTextBoxWrapper_'+uid+'"><input type="text" style="width: 196px; height: 17px; border: 0px" onkeydown="if (event.keyCode == 13) { insertChatText(\''+uid+'\',this.value); this.value=\'\'; }" onfocus="document.getElementById(\'chatWindowTop_'+uid+'\').style.backgroundColor=\'#017FB9\'; setOriginTitle();" onclick="document.getElementById(\'chatWindowTop_'+uid+'\').style.backgroundColor=\'#017FB9\'; setOriginTitle();" id="msgTextBox_'+uid+'"/></div></div>';
                chatWindowHTML = chatWindowHTML + ' </div>';
                chatWindowHTML = chatWindowHTML + '</div>';
                
                document.getElementById('chatBar').innerHTML = document.getElementById('chatBar').innerHTML + chatWindowHTML;
                
                document.getElementById('msgTextBox_'+uid).focus();
                
                chatWindowsIDs.push('chatWindow_'+uid);
            }
            if (ir != 1) {
                ajaxOp('/ajax.yalla.php',1,'a=14&cw='+uid+'&s='+sid,'oullo',0,0,0);
                ajaxOp('/ajax.yalla.php',1,'a=17&cw='+uid+'&s='+sid,'oullo',0,0,0);
            }
        }
    } else {
        if (document.getElementById('onlineUsers')) {
            document.getElementById('onlineUsers').style.display = 'none';
        }
    }
}

function closeChatWindow(cwid) {
    document.getElementById('chatBar').removeChild(document.getElementById('chatWindow_'+cwid));
    numChatWindows--;
    chatWindowID = chatWindowsIDs.indexOf('chatWindow_'+cwid);
    if (chatWindowsIDs.length > 3) {
        if (document.getElementById(chatWindowsIDs[lastChatWindow+1])) {
            document.getElementById(chatWindowsIDs[lastChatWindow+1]).style.display = 'block';
        } else {
            document.getElementById(chatWindowsIDs[firstChatWindow-1]).style.display = 'block';
        }
    }
    chatWindowsIDs.splice(chatWindowID,1);
    ajaxOp('/ajax.yalla.php',1,'a=16&cw='+cwid+'&s='+sid,'oullo',0,0,0);
    
    if (document.getElementById('contactBanner')) {
        document.getElementById('contactBanner').style.display = 'block';   
    }
}

function hideChatWindow(cwid,ir) {
    if (document.getElementById('chatWindow_'+cwid).style.height == '21px') {
        document.getElementById('chatWindow_'+cwid).style.marginTop = '-231px';
        document.getElementById('chatWindow_'+cwid).style.paddingBottom = '1px';
        document.getElementById('chatWindow_'+cwid).style.height = '250px';
        document.getElementById('chatWindowTop_'+cwid+'').style.backgroundColor = '#017FB9';
        document.getElementById('msgTextBox_'+cwid).focus();
        if (document.title != originTitle) {
            setOriginTitle();
        }
        if (ir != 1) {
            ajaxOp('/ajax.yalla.php',1,'a=18&cw='+cwid+'&cs=1&s='+sid,'oullo',0,0,0);
        }
    } else {
        document.getElementById('chatWindow_'+cwid).style.height = '21px';
        document.getElementById('chatWindow_'+cwid).style.marginTop = '-1px';
        document.getElementById('chatWindow_'+cwid).style.paddingBottom = '0px';
        document.getElementById('chatWindowTop_'+cwid+'').style.backgroundColor = '#017FB9';
        if (document.title != originTitle) {
            setOriginTitle();
        }
        if (ir != 1) {
            ajaxOp('/ajax.yalla.php',1,'a=18&cw='+cwid+'&cs=0&s='+sid,'oullo',0,0,0);
        }
    }
}

function insertChatText(ctbid,cv) {
    if (cv != '') {
        currentTime = new Date();
        getNowHours = currentTime.getHours();
        getNowMinutes = currentTime.getMinutes();
        getNowSeconds = currentTime.getSeconds();
        if (getNowHours < 10) {
            getNowHours = "0"+getNowHours;
        }
        if (getNowMinutes < 10) {
            getNowMinutes = "0"+getNowMinutes;
        }
        if (getNowSeconds < 10) {
            getNowSeconds = "0"+getNowSeconds;
        }
        getNowTime = getNowHours+':'+getNowMinutes+':'+getNowSeconds;
        
        var cvr = cv;
        
        for (var i = 0; i < emoticonsMatches.length; i++) {
            cvr = cvr.replace(emoticonsMatches[i], emoticonsReplaces[i]);
        }
        
        document.getElementById('chatBoxText_'+ctbid).innerHTML = document.getElementById('chatBoxText_'+ctbid).innerHTML + '<br/><b>אני</b> <font style="font-size: 11px; color: #C4C4C4">'+getNowTime+'</font><br/>'+cvr;
        document.getElementById('chatBoxText_'+ctbid).parentNode.scrollTop = document.getElementById('chatBoxText_'+ctbid).parentNode.scrollHeight;
        ajaxOp('/ajax.yalla.php',1,'a=15&cw='+ctbid+'&mt='+cv+'&cwi='+ctbid+'&s='+sid,'msgloader'+ctbid,0,0,0);
    }
}

function playMSGSound() {
    //var msgSound = eval("document.soundBox");
    //msgSound.Play();
}

function changeTitle(ts,mf) {
    if (ts == 0) {
        document.title = originTitle;
        titleTimer = setTimeout('changeTitle(1,\''+mf+'\')', 2000);
    } else {
        document.title = mf;
        titleTimer = setTimeout('changeTitle(0,\''+mf+'\')', 2000);
    }
}

function setOriginTitle() {
    document.title = originTitle;
    clearTimeout(titleTimer);
}

function appsFunctions(s) {
    if (s == 0 && document.getElementById('appsWindow').style.display == 'none') {
        document.getElementById('appsButton').style.backgroundColor='#DDECF8';
    } else if (s == 1 && document.getElementById('appsWindow').style.display == 'none') {
        document.getElementById('appsButton').style.backgroundColor='#E0E0E0';
    } else if (s == 2 && document.getElementById('appsWindow').style.display == 'none') {
        document.getElementById('appsButton').style.backgroundColor='#FFF';
        
        if (document.getElementById('onlineUsers').style.display == 'block') {
            document.getElementById('onlineUsers').style.display = 'none';
            clearTimeout(updateUsersList);
        }
        
        document.getElementById('appsWindow').style.display = 'block';
        
        ajaxOp('/ajax.yalla.php',1,'a=19&s='+sid,'oullo',0,0,0);
    } else if (s == 2 && document.getElementById('appsWindow').style.display == 'block') {
        document.getElementById('appsButton').style.backgroundColor='#E0E0E0';
        document.getElementById('appsWindow').style.display = 'none';
        
        clearTimeout(updateInfoWindow);
    }
}

function slideChatWindows(d) {
    if (d == 0) {
        if (lastChatWindow <= chatWindowsIDs.length-1 && lastChatWindow > 2) {
            document.getElementById(chatWindowsIDs[lastChatWindow]).style.display = 'none';
            document.getElementById(chatWindowsIDs[firstChatWindow-1]).style.display = 'block';
            lastChatWindow -= 1;
            firstChatWindow -= 1;
        }
        
        if (lastChatWindow >= chatWindowsIDs.length-2) {
            document.getElementById('windowsArrowLeft').style.display = 'none';
            document.getElementById('windowsArrowRight').style.display = 'block';
        } else {
            document.getElementById('windowsArrowRight').style.display = 'block';
        }
        
    } else {
        if (lastChatWindow <= chatWindowsIDs.length-2) {
            document.getElementById(chatWindowsIDs[firstChatWindow]).style.display = 'none';
            document.getElementById(chatWindowsIDs[lastChatWindow+1]).style.display = 'block';
            lastChatWindow += 1;
            firstChatWindow += 1;
        }
        
        if (lastChatWindow >= chatWindowsIDs.length-2) {
            document.getElementById('windowsArrowRight').style.display = 'none';
            document.getElementById('windowsArrowLeft').style.display = 'block';
        } else {
            document.getElementById('windowsArrowLeft').style.display = 'block';
        }
    }
    
    if (chatWindowsIDs.length <= 3) {
        document.getElementById('windowsArrowRight').style.display = 'none';
        document.getElementById('windowsArrowLeft').style.display = 'none';
    }
}

function openFloatChatWindow(cid,s) {
    window.open('/popChat.php?sid='+sid+'&uid='+cid+'&usi=green','_blank','width=300,height=400,location=0,scrollbars=0,toolbar=0,resizable=0');
    closeChatWindow(cid);
    /*
    if (s == 1) {
        //document.getElementById('chatWindow_'+cid).className = 'dragme';
        cws = document.getElementById('chatWindow_'+cid).style;
        cws.position = 'absolute';
        cws.bottom = '100px';
        cws.left = '100px';
        cws.cssFloat = '';
        cws.width = '500px';
        cws.height = '350px';
        cws.border = '1px solid #000';
        
        cwtw = document.getElementById('chatBoxTextWrapper_'+cid).style;
        cwtw.width = '340px';
        if (ut > 0) {
            cwtw.height = '250px';
        } else {
            cwtw.height = '270px';  
        }
        cwtw.margin = '10px 0px 0px 10px';
        cwtw.cssFloat = 'left';
        cwtw.border = '1px solid #000';
        
        mtw = document.getElementById('msgTextBoxWrapper_'+cid).style;
        mtw.width = '340px';
        mtw.margin = '10px 0px 0px 10px';
        mtw.cssFloat = 'left';
        mtw.border = '1px solid #000';
        //mtw.left = '10px';
        //mtw.bottom = '-30px';
        //mtw.position = 'absolute';
        
        mt = document.getElementById('msgTextBox_'+cid).style;
        mt.width = '338px';
        
        cp = document.getElementById('chatPic_'+cid).style;
        cp.display = 'block';
        
        document.getElementById('chatWindowTopContainer_'+cid).style.width = '450px';
        
        document.getElementById('floatChatButton_'+cid).style.display = 'none';
        
        document.getElementById('chatWindowTopContainer_'+cid).onclick = function () { openFloatChatWindow(cid,0); }
        document.getElementById('chatMinimizeButton_'+cid).onclick = function () { openFloatChatWindow(cid,0); }
        document.getElementById('floatChatButton_'+cid).onclick = function () { openFloatChatWindow(cid,0); }
    } else {
        //document.getElementById('chatWindow_'+cid).className = '';
        cws = document.getElementById('chatWindow_'+cid).style;
        cws.position = 'relative';
        cws.bottom = '0px';
        cws.left = '0px';
        cws.cssFloat = 'left';
        cws.width = '200px';
        cws.height = '250px';
        cws.border = '1px solid #D7D7D7';
        cws.borderBottom = '0px';
        
        cwtw = document.getElementById('chatBoxTextWrapper_'+cid).style;
        cwtw.width = '100%';
        if (ut > 0) {
            cwtw.height = '186px';
        } else {
            cwtw.height = '207px';  
        }
        cwtw.margin = '0px';
        cwtw.cssFloat = 'right';
        cwtw.border = '0px';
        
        mtw = document.getElementById('msgTextBoxWrapper_'+cid).style;
        mtw.width = '100%';
        mtw.margin = '0px';
        mtw.cssFloat = 'right';
        mtw.border = '0px';
        mtw.borderTop = '1px solid #E0E0E0';
        
        mt = document.getElementById('msgTextBox_'+cid).style;
        mt.width = '196px';
        
        cp = document.getElementById('chatPic_'+cid).style;
        cp.display = 'none';
        
        document.getElementById('floatChatButton_'+cid).style.display = 'block';
        
        document.getElementById('chatWindowTopContainer_'+cid).style.width = '150px';
        
        document.getElementById('chatWindowTopContainer_'+cid).onclick = function () { hideChatWindow(cid); }
        document.getElementById('chatMinimizeButton_'+cid).onclick = function () { hideChatWindow(cid); }
        document.getElementById('floatChatButton_'+cid).onclick = function () { openFloatChatWindow(cid,1); }
    }
    */
}

var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;

function movemouse(e)
{
  if (isdrag)
  {
    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    return false;
  }
}

function selectmouse(e) 
{
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  while (fobj.tagName != topelement && fobj.className != "dragme")
  {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }

  if (fobj.className=="dragme")
  {
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
    return false;
  }
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
