/*
 * chat.js, live transfer main class
 *
 *
 */
var domainparts = document.domain.split(".");
if (domainparts.length >= 2) {
  document.domain = domainparts[domainparts.length - 2] + "." + domainparts[domainparts.length - 1];
}

function Chat(account,options){
   this.account =  jQuery.extend({}, account || {});
   this.options = jQuery.extend({}, Chat.DEFAULTS, options || {});
   
   window.onError = null;
   
   //debug
   if(this.options.disconnected==false)
   {
    this.friends = new jQuery.chatFriends(this,{members:account.friends});
   }
   else
    this.friends = null;
    
   this.requesters = [];
   this.requests = [];
   this.channels = [];
   this.selectors = [];
   this.channelDatas = [];
   this.myolduserId = 0;
   this.options.server = window.location.protocol+"//" + Math.abs(this.account.T) % 17 + "." + document.domain;
   this.initialize();
   window.chat = this;   
   
   if(this.options.disconnected==false)
    jQuery(".support").support(this.friends.hasSupport());
}

/*
 *
 *  options.
 *
 */
jQuery.extend(Chat, {
    DEFAULTS: { 
    server: '.devhost.com',
    bi: '/live/bi.html?v='+(new Date().getTime()),
    e:'/events.ashx',
    version : '0.0.1',
    key : false,
    connection : false,
    iframeDiv : false,
	bridgeFrame  :false,
	timer : false,	
	editor : false,	
	current      : false,
	disconnected : false,	
	listWindow   : false,	
	connectWindow: false,	
	status       : false,	
	itimer       :0,
	page         :'',
	context      :'',
	playSound    :true,
	playSoundOnRequest:false,
	supportOnline:false,
	connected    :false,
	support      :false,
	question     :'',
	to           :'',
	to_sellername:'',
	plan         :'',
	connector    :false,
	sellers      :false,
	forced       :false,
	title     :'',
	next :0
    }
});

(function($){
var hassupport = false;
$.fn.support= function(online){
   if(typeof online != 'undefined') 
      hassupport = online;
      
   return $(this).each(function(){
      if(hassupport){
         $(this).addClass("online");
         $(this).find("img").attr('src', '/live/images/online-support.gif');
         $(this).find("a").unbind("click").click(function(){
            chat.addRequest({to:'',context:'support'});
         });
      }else{
         $(this).removeClass("online");
         $(this).find("a").unbind("click").click(function(){
            alert("no agent online, please try again later.");
         });
         $(this).find("img").attr('src', '/live/images/offline-support.gif');
      }
   });
};

Chat.prototype = {
	initialize: function() {
	    //debug new code
	    if(this.options.disconnected==false)
	    {
	        if($(".lt_header").length>0){
	          this.status = new IMStatus("imstatus"); 
	          $("lt_header").show();
	          $("lt_body").show();
	          $("lt_footer").show();
	          $("webim").show();
	        }
	        this.initializeIframe();
	    }
	    else 
	    {
	        $(".lt_header").hide();
	        $(".lt_body").hide();
	        $(".lt_footer").hide();
            if( document.getElementById('comet_iframe'))
                document.body.removeChild(document.getElementById('comet_iframe'));
	    }
	},
	
	logout:function(){window.location.href='http://www.'+document.domain+"/logout.aspx?r="+(new Date().getTime());},
	//supriyo
    disable:function()
    {
        
        this.options.disconnected=true;
        if(this.friends)
        {
            this.friends.options.showmini=true;
            this.friends.clear();
            $('.live-status .sellers').html(" ");
        }
        this.friends = null;
        this.initialize();
    },
    enable:function()
    {
        this.options.disconnected=false;
        this.friends = new jQuery.chatFriends(this,{members:this.account.friends});
        this.initialize();
        jQuery(".support").support(this.friends.hasSupport());
    },
    
	showSupport: function() {
	     if(!chat.support)
	     chat.support = new chatSupport('chatsupprot', {width: 350, height: 200});
	},
	
    noAgent:function(){   chat.support.noAgent();},
	
	removeMember:function(grp,id){
	    for (var i = 0 ; i < this.friends.length ; i++) {
		     if(this.friends[i].G == grp){
		        for(j = 0; j < this.friends[i].M.length; j ++){
		           if(this.friends[i].M[j].UserID == id){
		              this.friends[i].M[j].splice(j,1);
		              return;
		           }
		        }
		     }
	       }
	},
	
	requestPlan:function(plan,to, sellername){ 
	   if(to == this.account.Id){
	       $('#LiveChatLink_'+plan).html("<img src='/im/images/livechat.png' alt='' />");
	       alert('this is your plan');
	       return;
	   }

	   if(this.account.Id > 0)
	       this.addRequest({to:to,plan:plan,context:plan,selldername:sellername,type:1});
	   else	   
         if(typeof this.register != 'undefined' && this.register) alert("Please login first");
         else
             this.register = new $.register({context:plan,plan:plan,inline:false,registered:function(u){
                   chat.account = u;
                   chat.addRequest({to:to,plan:plan,context:plan,selldername:sellername,type:1});
             }});    
	},
	
	removeRegisterwin:function(id,ev){
	    chat.register=false;
	    Windows.close(id, ev);
	    
        // Fix Issue#14: indication which chat window you opened
        if($('#LiveChatLink_'+chat.plan) != null)
           $('#LiveChatLink_'+chat.plan).html("<img src='/im/images/livechat.png' alt='' />");
       // end 
	},
	
	mute:function(e){
	   if(chat.playSound){
	      e.style.marginLeft="-21px";
	   }else
	     e.style.marginLeft="0px";
	     
	   chat.playSound = !chat.playSound;
	},
	
    addRequest:function(options)	{        
        if( chat.account.Id == options.to )  {
	        $('#LiveChatLink_'+chat.plan).html("<img src='/im/images/livechat.png' alt='' />");
	        alert("This is your plan.");
	        return false;
	    }
	   
	   if(chat.requester(options.to)!=null)  {
	        alert("A request has already been sent to the other party");
	        return;
	   }
	   if(!options.forcedRequest)   {
	       for(var i = 0; i< chat.channels.length; i++)       {
	          for(var j = 0; j< chat.channels[i].members.length; j++){
	             if(chat.channels[i].members[j].Id == options.to)
	                return false;
	          }
	       }
	   }
        
        chat.removeSelector(options.to);
	    options.from = this.account.Id;
        tmp = new $.chatRequester(options);
	    chat.requesters.push(tmp);
	    tmp = null;
	},
	
	closeRequest:function(to){
	    var req = this.requester(to)
	    if(req ==undefined) return false;
	    req.close();
	},
 
 	addChannel: function(options) {	
	   if(!options.members) return; 
	   var members = options.members;
	   for(var i=0;i<members.length;i++){
	       this.removeRequester(members[i].Id);
	       this.removeRequest(members[i].Id);
	   } 
	    
          if(options.context.plan){
           this.addLiveChannel(options);
           return ;
        }else{
            if (chat.channel(options.token) == null) {
               var tmp = new $.chatSupportChannel(options);
               chat.channels.push(tmp);
		    }else{
		       chat.channel(options.token).show();
		    }
		}
		
		var self = this;
		if(typeof options.messages != 'undefined'){
		   $(options.messages).each(function(){
		      self.onMessage(this.f,options.token,this.m);
		   });
		}
	},
	
	/*
	* For Buyer::
	* After seller approves request, this function is invoked to "buyer" and "seller"
	*/
	addLiveChannel: function(options) {	
	    if(typeof($.wizard)!='undefined') $.wizard.stopProgress(true);
	    
	    var tmp = this.channel(options.token);
	 	if (!tmp){
            tmp = new chatChannel(options);
            this.channels.push(tmp);
            tmp.editor.typeTimer = setTimeout(function(){tmp.editor.toggleType();},3000);
            tmp.setupTransfer(); 
            if($('#transferlist').length > 0 && options.context.tracker.Status == 9) {
               $('#transferlist').append('<li>'+tmp.toString()+'</li>'); 
            }
            
            $.title("Live Transfer on " + options.context.plan.ID + "!");
		}
	},
	
    forceToChannel:function(id) {
        if (chat.channel(id) == null) {
            var tmp = new chatChannel(id, chat.friends,false,{width: 620, height:520});
            chat.channels.push(tmp);
            tmp.editor.typeTimer = setTimeout(function(){tmp.editor.toggleType();},3000);
        }
    },
    
	removeChannel: function(channelId) {
		if (chat.channel(channelId) != null) {
             chat.channels.splice(chat.indexOfChannel(channelId),1);
		}
	},
	
   selector: function(id) {
	    for (i = 0; i < chat.selectors.length; i++) {
			if (chat.selectors[i].id == id) {
				return chat.selectors[i];
			}
	    }
	    return undefined;
	},
	
	showSelector:function(options){
	   if(chat.requester(options.to)!=undefined){
	      chat.requester(options.to).close();
	   }
	         
	   if (chat.selector(options.to) == undefined) {	
	      var sel = new planSelector(options.to,options.plans,"chat.addRequest",chat.onSelectorClose,{width:420, height: 420});
	      chat.selectors.push(sel);
	   }else{
	      chat.selector(options.to).show();
	   }
	},
	
	onSelectorClose:function(win){
	   var id = win.getId().split('_')[0];
	    chat.removeSelector(id);
	    return true;
	},
	
	removeSelector:function(id){
	   for (i = 0; i < chat.selectors.length; i++) {
			if (this.selectors[i].id == id) {
				this.selectors.splice(i,1);
				return true;
			}
	    }
	},

	channel: function(channelId) {
	    for (i = 0; i < this.channels.length; i++){
	        if (this.channels[i].channel == channelId)
	            return this.channels[i];
	    }
	    return null;
	},
	
	indexOfChannel: function(channelId) {
	    for (i = 0; i < this.channels.length; i++)
	        if (this.channels[i].channel == channelId)
	            return i;
	    return -1;
	},
	
	request:function(id) {
	    for (i = 0; i < this.requests.length; i++) 		{
		    if (this.requests[i].id == id) 
		        return this.requests[i];
	    }
	    return undefined;
	},
	
	requester: function(id) {
	    for (i = 0; i < this.requesters.length; i++) 
			if (chat.requesters[i].id == id) return chat.requesters[i];
	    
	    return null;
	},
	
	indexOfRequester: function(id) {
	    for (i = 0; i < this.requesters.length; i++) 	if (chat.requesters[i].id == id)return i;
	    return -1;
	},

	removeRequester: function(to) {
	   var self = this;
	   $(this.requesters).each(function(i){
	      if($(this).get(0).id == to){
	           self.requesters.splice(i,1);
	           $(this).get(0).close();
	           return ;	         
	      }
	   });
	},	

	channelData: function(channel) {
	    for (i = 0; i < chat.channelDatas.length; i++) 	if (chat.channelDatas[i].channel == channel)return chat.channelDatas[i];
	    return undefined;
	},
	
	popout:function(channel){
	   if (chat.channel(channel) != undefined) {
	       var data = chat.channel(channel).serialize();
	       if(chat.channelData(channel) != undefined)  chat.channelDatas.splice(chat.channelData(channel), 1);
	       chat.channels.splice(chat.indexOfChannel(channel), 1);
	       data.popwin = window.open("/im/pop.htm?channel="+channel,"Transfer","width=650,height=550,top=100,left=200");
	       chat.channelDatas.push(data);
	   }
	},
	
	popin:function(channel){
	    if (chat.channel(channel) != undefined) {
	       var data = chat.channel(channel).serialize();
	       if(chat.channelData(channel) != undefined) {
	        chat.channelData(channel).popwin.close();
	         chat.channelDatas.splice(chat.channelData(channel), 1);
	       }
	      
	       chat.channelDatas.push(data);
	       chat.channels.splice(chat.channel(channel), 1);
	       var tmp = new chatChannel(channel,chat.channelData(channel).members,false, {width: 620, height:530});
           chat.channels.push(tmp);
           tmp.setupTransfer(chat.channelData(channel).plan,chat.channelData(channel).track); 
	   }
	},
	
	popchat:function(){
	   if($("lt_header")){
	   $("lt_header").parentNode.removeChild($("lt_header"));
	   $("lt_body").parentNode.removeChild($("lt_body"));
	   $("lt_footer").parentNode.removeChild($("lt_footer"));
	   window.open("/im/livetransfer.aspx");
	   }
	},
	
	unpop:function(){
	   //$call("/im/pop.aspx");
	},
	
	add: function(channelId, message) {
		if (chat.channel(channelId) == null) {
				//chat.addChannel(channel) ;
				return;
		}
		chat.channel(channelId).add(message);
	},

	sortNames: function(channel) {
		if (chat.channel(channel) != undefined) {
			chat.channel(channel).sortNames();
		}
	},

	onConnecting: function() {
		chat.add('info', '<span class="notice"></span>');
	},
	
	onLeft:function(channelId,userId){
	    var chan = chat.channel(channelId);
	    if(chan != null){
	      var m =chan.member(userId)
	      if(m!=null){
	        chat.onNotice(channelId,m.Name+ " has left.");
	        chan.onLeft(userId);
	      }
	    }
	},
	
	success: function(message) {
        if (message.n == "s") {
            eval(message.c);
        } else if (message.n == "msg") {
            chat.onMessage(message.c.f, message.ci, message.c.m);
        }
    },
    /*
	* onRequest:function(ticket){}
	* After buyer[ticket.from.UserID] initiates chat request, 
	* "seller" receives OnRequest().
	* For seller, chat.requests[] adds another chatRequest object
	*/
	onRequest:function(ticket)	{ 
	    var from = ticket.from;
	    var context = ticket.context;
	    if(from.Id == chat.account.Id && chat.requester(from)!=undefined)    {
	         chat.requester(from).show();
	         chat.requester(from).wait(context.ID); 
	           return;
	    }else {
	       if( chat.friends.indexOf(from.Id) < 0 )
	          chat.friends.add(from.Id,from.Name,1);

	        if(from.Id == chat.account.Id) return;
	        var req = chat.request(from.Id);
	        if ( req == undefined)     {
	 	      var tmp = new $.chatRequest(ticket);
		      chat.requests.push(tmp);
		    }else {
		      req.show();
		    }
		}
	},
	
	removeRequest:function(id){
	   var self = this;
	   $(this.requests).each(function(i){
	      if($(this).get(0).id == id){
	         $(this).get(0).close();
	         return self.requests.splice(i,1);	         
	      }
	   });
	},
	
	onApproved:function(from,channel,plan,tran){
	    chat.addChannel(channel);
	    if(tran) chat.channel(channel).setupTransfer(plan,tran);
	},
	
	onResume:function(from,channel,plan,tran){
	   if(chat.requester(from)){
	       chat.requester(from).close();
	   }
	   chat.addChannel(channel,null,false);
	   chat.channel(channel).setupTransfer(plan,tran);
	},
	
	onRejected:function(by){
	   if(chat.requester(by)!=undefined)chat.requester(by).onRejected();
	   else if(chat.support)chat.support.onRejected();
	},
	
	onFriendSignOn:function(f){ 
	  if(this.friends) {
	     this.friends.onFriendSignOn(f);
	     this.onSellersChanged(this.friends.onlineSellers());
	  }  
     for(var i = chat.channels.length-1; i>=0;i--){
            if (chat.channels[i] != null) {
                if(chat.channels[i].member(f.UserID)) {
                    chat.channels[i].changeStatus(1);
                    chat.onOtherUserMovedFromActiveChannel(chat.channels[i], f);
                }
            }  
      }
        if(f.Role == "admin") $(".support").support(true);
	},
	
	onOtherUserMovedFromActiveChannel: function(objChannel, u){	    
	    if( objChannel.initiated==true){
	        chat.onNotice(objChannel.channel,u.Name+ " has moved to another page.");
	        chat.addRequest( u.UserID, objChannel.plan.ID, u.Name, true );
	    }
	},
	
    onFriendSignOff:function(friendId){ 
    	var f = chat.friends.member(friendId);

	    if(typeof(f)!= 'undefined' && f.Role == 'admin') $(".support").support(false);       
        if (parseInt(friendId)>=0) {
            if(chat.friends)    {
                if($('#divFriendsHidden').length>0) {
                   chat.friends.removemymember(friendId); 
                   chat.onSellersChanged(chat.friends.onlineSellers());
                }   
	            chat.friends.changeStatus(friendId,99);
	        }
	      for(var i = chat.channels.length-1; i>=0;i--)      {
            if (chat.channels[i] != null)            {
                if(chat.channels[i].member(friendId))                 {
                    chat.channels[i].onLeft(friendId);
                }
            }
	      }
	   }
	},
	
	signOff:function(){
	   chat.friends.disable();
	},
	
	onTyping:function(channel,from){
        if(chat.channel(channel)!= null)
	    chat.channel(channel).onTyping(from); 
	},
	
	changeStatus:function(status) {
	   if(status > -1){
	        var r =  (new Date()).getTime();
	       var d = chat.server+'imstatus?key='+chat.account.Id+'&status='+status+"&userid="+chat.userID+"&token="+chat.token+'&r='+r;
		   $.post(d, { asynchronous : true, method : 'get'});
		}
    },
    
    onChannelClosed:function(channel){
       if(chat.channel(channel) != null){
          alert('Your room has been closed, please try again later.');
          chat.channel(channel).disable();
       }
    },
	
   onFriendStatus:function(friendId,status){
	   chat.friends.changeStatus(friendId,status);
	   if(chat.channel(friendId)!=undefined)chat.channel(friendId).changeStatus(status);
	},
	
	onStatus:function(status){
	    if(status == 1){
			$("immystatus").update( ' - Online');
	    }else if(status == 2){
			$("immystatus").update( ' - Away ');
		} else if(status == 3){
			$("immystatus").update( ' -  Busy');
		}else if(status == 4){
		    $("immystatus").update( ' - Idle');
		}else if(status == 99){
		    $("immystatus").update( ' - Offline');
		}
	},

	onMessage: function(from,channel, msg) {
	   msg = unescape(msg);
	   msg = chat.translateTags(msg);
	   $.title ( from+ ": "+msg);
	   if(from == chat.account.Name) 
	        chat.add(channel, '<div class="me">You:</div> <span class="message">'+msg+'</span>&nbsp;');
	   else chat.add(channel, '<div class="from">'+from+':</div> <span class="message">'+msg+'</span>&nbsp;');
	   if(chat.playSound) playSound("msg");
	},
	
	onMessageSent: function(res) {
        var mt = res.msg;
	    mt.Message = unescape(mt.Message);
	    mt.Message = chat.translateTags(mt.Message);
	    chat.add(mt.Channel, '<div class="me">Me:</div> <span class="message">'+mt.Message+'</span>&nbsp;');
	},
	
	translateTags: function(str) {
	   var RegExpCode = [['<spc>1<spc>','\'' ],['<spc>2<spc>','?' ],['<spc>3<spc>','#' ],['<spc>4<spc>','=' ]];
	   $(RegExpCode).each(function($) {
            var code = new RegExp(this[0], 'igm');
            str = str.replace(code, this[1]);
        });
		
		str = str.replace(':)','<img src="/im/images/smilies/smile.gif" />');
		return str;
	},
	
	onJoin:function(channelId,member){
	   if(chat.channel(channelId) != null){
	     if(chat.channel(channelId).member(member.Id) == null){
	         chat.channel(channelId).onJoin(member);
	         chat.onNotice(channelId,member.Name+ " has joined.");
	      }
	   }
	},

	onNotice: function(channel, msg) {
		chat.add(channel, '<span class="notice">Notice : '+msg+'</span>');
	},

	onAction: function(from, msg) {
		chat.add(channel, '<span class="notice">'+from+' <span class="message">'+msg+'</span></span>')
	},
	
	onSellersChanged:function(sels){
	   if(typeof(sellers)!='undefined'&&sellers) sellers.update(sels);
	},
	
	onSupportOnline:function(){
	   chat.supportOnline = true;
	   for(var i=0; i< chat.channels.length;i++){
	      chat.channels[i].updateSupport();
	   }

       jQuery('#cs_support_image').attr("src", '/im/images/online-support.gif');   
	},
	
	onSupportOffline:function(){
	   chat.supportOnline = false;
	   for(var i=0;i<chat.channels.length;i++){
	      chat.channels[i].updateSupport();
	   }
       $('#cs_support_image').attr("src", '/im/images/offline-support.gif');
	},
	
	supportLeft:function(channel){
	   alert("We cannot reach support currently.");
	   chat.onSupportOffline();
	},

	onServerNotice: function(notice) {
		chat.add('info', '<span class="notice">Server notice: '+notice+'</span>');
	},

	onError: function(error) {
		chat.add('info', '<span class="kick">Error: '+error+'</span>');
		if (chat.current != 'info') {
			chat.add(chat.current, '<span class="kick">Error: '+error+'</span>');
		}
	},

	addMember: function(channel, who, operator, voice) {
		if (chat.channel(channel) != undefined) {
			chat.channel(channel).members.add(who, operator, voice);
		}
	},

	setKey: function(channel, key, from) {
		if (chat.channel(channel) != undefined) {
			chat.add(channel, '<span class="notice">'+from+' sets channel key to '+key+'</span>')
			chat.channel(channel).setKey(key, from);
		}
	},
	
	showPlan:function(channel,plan){
	    chat.channel(channel).showPlan(plan);
	},

	renderMembers: function(channel) {
		if (chat.channel(channel) != undefined) {
			chat.channel(channel).members.render();
		}
	},
	
	initializeIframe: function() {
	    var self = this;
        if (navigator.appVersion.indexOf("MSIE") != -1) {
            self.connection = document.createElement('iframe');
            self.connection.setAttribute('id', 'comet_iframe');
            self.connection.setAttribute('name', 'comet_iframe_name');
            self.connection.setAttribute('src', self.options.server + self.options.bi);
            with (self.connection.style) {
                left = top = "-100px";
                height = width = "1px";
                visibility = "hidden";
                display = "none";
                position = "absolute";
            }
            document.body.appendChild(self.connection);
        } else   {
            self.connection = document.createElement('iframe');
            self.connection.setAttribute('id', 'comet_iframe');
            self.connection.setAttribute('name', 'comet_iframe_name');
            self.connection.setAttribute('src', self.options.server + self.options.bi);
            with (self.connection.style) {
                left = top = "-100px";
                height = width = "1px";
                visibility = "hidden";
                display = "none";
                position = "absolute";
            }
            document.body.appendChild(self.connection);
            // for KHTML browsers
            }
//        } else {
//            // For other browser (Firefox...)
//            self.connection = document.createElement('iframe');
//            self.connection.setAttribute('id', 'comet_iframe');
//            with (self.connection.style) {
//                left = top = "-100px";
//                height = width = "1px";
//                visibility = "hidden";
//                display = 'none';
//            }
//            self.iframediv = document.createElement('iframe');
//            self.iframediv.setAttribute('src', self.options.server + self.options.bi);
//            self.connection.appendChild(self.iframediv);
//            document.body.appendChild(self.connection);
//        }
    },

	onUnload: function(e) { 
		if (chat.connection) {
		if(typeof(CollectGarbage)!='undefined'){CollectGarbage();  } 
		  if( $('imheader')){
		  $('imheader').html("Live Transfer");
	      $("immystatus").update( ' - <a href="javascript:void(0);" onclick="chat.connect();return false;">not connected.</a>');
		  $("imsum").hide();
		 }
          chat.connection.setAttribute('src',"javascript:void(0);");
		  document.body.removeChild(chat.connection);
		  chat.connection = null;
		  if(typeof(CollectGarbage)!='undefined') { CollectGarbage();}
		}
		return true;
	},
	
	// on found total buyers
    onFindBuyer:function(amount){
         $.wizard.onFindBuyer(amount);
    },
    
    // on pinging one buyer
    pinging:function(){
           jQuery.wizard.pinging();
    },
    
    isUserOnline:function(uid){
       if(!chat.friends)return false;
       var fs = chat.friends.onlineSellers();
       for(var i = 0; i<fs.length; i++){
          if(fs[i].UserID == uid)
          {
            return true;
          }
       }
       
       return false;
    },
    
    waitSellerPay:function(from,planid){
      if(chat.request(from)!=undefined)chat.request(from).waitSellerPay(planid);
    },
    onResponse:function(from,planid){
       chat.responser = from;
       chat.responsePlan = planid;
    },
    
    onSellerNotAvaliable:function(from){
      if( chat.request(from)!=undefined)chat.request(from).onSellerNotAvaliable();
    },
        
    onPingError:function(msg){
          $.wizard.onPingError(msg);
    },
    
    countRunningChatWindows: function() {
        var count=0;
        for(var i = chat.channels.length-1; i>=0;i--) {
            if (chat.channels[i] != null) {
                if(chat.channels[i].initiated==true)  {
                    count++;
                }
            }
        }
        return count;
  },
  
 removechatplan:function(id,ev){
		var mm="_requestMyApprove";
		channel=id.replace(mm,'');
        channel=parseInt(channel);
        var mischt="";
        for (i = 0; i < chat.requests.length; i++)      {
			if (chat.requests[i].id != channel)			{
			var OldChatReq=chat.requests[i];
			 mischt +=OldChatReq.rendermypanelbymischat();
         
			} 
	 }
	if($('.live-status .opps a').length >=1)	{
        $('.live-status .opps').html($('.live-status .opps a').length+" New Plans Available");
    }
    },
	Arraywin: [],
	mywinCount:0
}
})(jQuery);

jQuery(document).ready(function($){
   if($(".lt_header")){
	    $(".lt_header").hide();
	    $(".lt_body").hide();
	    $(".lt_footer").hide();
   }
});
