//                  SCRIPT INTERAMENTE CREATO DA ROSSI46GO
//                        MESSAGGIO PERSONALE PAZZO 1.0

//var orario;
var online;
var offline;
var nchat;
var nomecontatto;
var chat;

function ContaContatti(){
	online=0;
	offline=0;
	var Contacts = Messenger.MyContacts; 
	for(var e = new Enumerator(Contacts); !e.atEnd(); e.moveNext()){
		item = e.item();
		if(item.Status != 1 && item.Status != 0){
		online++;
		}
		offline++;
		}
}

function ContaChat(){
	nchat=Messenger.CurrentChats.Count;
	if (nchat=="0"){
		nchat="[c=4]"+nchat+"[/c] ";
	}else{
		nchat="[c=9]" + nchat + "[/c] ";
	}
}


function OnEvent_Timer(timer1){
	var inizio="[a=1][c=0]";
	var fine="[/a][/c]";
	var barra="|";
	var messpers;
	ContaChat();
	ContaContatti(); 
	messpers= inizio + " Chats Abertos : " + nchat + barra;
	messpers+= " Online/Offline : " + "[c=9]" + online + "[/c]/[c=4]" + offline +"[/c] "+ barra;
	if(nomecontatto=="[c=4]Nimguem[/c] ")
		messpers+= " Conversando com : " + nomecontatto + fine;
	else
		messpers+= " Conversando com : " +"[c=9]" + nomecontatto + "[/c]"+ fine;
	Messenger.MyPersonalMessage=messpers;
	MsgPlus.AddTimer("timer1",500);
}

function OnEvent_Signin(Email){
	nomecontatto="[c=4]Nimguem[/c] ";
	MsgPlus.AddTimer("timer1",500);
}

function OnEvent_Initialize(MessengerStart){
	nomecontatto="[c=4]Nimguem[/c] ";
	MsgPlus.AddTimer("timer1",500);
}

function Amp(){
	nomecontatto="[c=4]Nimguem[/c] ";
	MsgPlus.AddTimer("timer1",500);
}

function Dmp(){
	MsgPlus.CancelTimer("timer1");
	Messenger.MyPersonalMessage="";
}

function OnEvent_ChatWndSendMessage(ChatWnd,message){
	if(message == '/Amp'){
	       Amp();	
           return "";
     }
     if(message == '/Dmp'){
		  Dmp();
           return "";
     }
    	return message;
}

function OnEvent_MenuClicked(MenuItemId,Location,ChatWnd) {
   switch(MenuItemId) {
      case 'Amp':       		
         Amp();
       break;
       case 'Dmp':
        Dmp();		
        break;
   }
}

function OnEvent_ChatWndReceiveMessage(ChatWnd,Origin,Message,MessageKind){
	var backup;
	chat=ChatWnd;
	contatto=ChatWnd.Contacts;
	if(contatto.Count == 1) {
			var e = new Enumerator(contatto);
			var Cnt = e.item();
			nomecontatto = Cnt.Email.split("@");
			nomecontatto = nomecontatto[0];
	}

}

function OnEvent_ChatWndDestroyed(ChatWnd){
	if(chat.Handle==ChatWnd.Handle){
		nomecontatto="[c=4]Nimguem[/c] ";
	}
}

function OnEvent_ChatWndCreated(ChatWnd){
	var contatto;
	chat=ChatWnd;
	contatto=ChatWnd.Contacts;
	if(contatto.Count == 1) {
			var e = new Enumerator(contatto);
			var Cnt = e.item();
			nomecontatto = Cnt.Email.split("@");
			nomecontatto = nomecontatto[0];
	}

}

