var IM_Windows=new String();var Presences=new String();var BuddyDetails=new String();var BuddyWindow=null;Presences.UserIDs=new Array();var OnlineBuddy="blOnlineBuddy";var OfflineBuddy="blOfflineBuddy";var OnlineBuddylist="blOnlineBuddylist";var OfflineBuddylist="blOfflineBuddylist";var TopToolbarPrototype="blTopToolbarPrototype";var TopToolbar="blTopToolbar";var DisplayName="blDisplayName";var FontList="fontsList";var FontSizeList="fontSizeList";var FontColorList="fontColorList";var SmileyList="smileyList";var StatusList="statusList";var CurStatus="curStatus";var CustomStatus="customStatus";function setFont(aa){window.CurrentMessageWindow.setFont(aa);}
function setFontSize(ba){window.CurrentMessageWindow.setFontSize(ba);}
function setFontColor(ca){window.CurrentMessageWindow.setFontColor(ca);}
function setBold(){window.CurrentMessageWindow.setBold();}
function setBold(){window.CurrentMessageWindow.setBold();}
function setItalic(){window.CurrentMessageWindow.setItalic();}
function setUnderline(){window.CurrentMessageWindow.setUnderline();}
function InsertText(da){window.CurrentMessageWindow.InsertText(da);}
function ShowProfile(ea){var fa="";var ga="";RemoveProfile();if(ea.status!="offline")fa=$(OnlineBuddy).innerHTML;else fa=$(OfflineBuddy).innerHTML;if(ea.customStatus=="")ga=ea.nickname;else ga=ea.nickname+" - "+ea.customStatus;fa=ReplaceAll(fa,"_ID_",ea.userID);fa=ReplaceAll(fa,"_Name_",ga);if(ea.status=="online")new Insertion.Bottom($(OnlineBuddylist),fa);else new Insertion.Bottom($(OfflineBuddylist),fa);}
function RemoveProfile(ha){if($(ha+"_blItem")!=null)$(ha+"_blItem").remove();}
function CreateMessageWindow(ia){var ja=BuddyWindow.UserID;var ka=BuddyWindow.Presence.nickname;if(IM_Windows["UserID_"+ia]==null){var la=Presences["UserID_"+ia].nickname;IM_Windows["UserID_"+ia]=new CWTMessageWindow("Window_"+ia,"PT_IM_MB",ja,ia,ka,la,"MessageB","MessageB");}}
function ShowMessageWindow(ma){IM_Windows["UserID_"+ma].Window.toFront();IM_Windows["UserID_"+ma].Window.show();}
var onClickOnlineBuddy=function(na){onMouseoutOnlineBuddy(null);CreateMessageWindow(na);ShowMessageWindow(na);};function setStatus(oa,pa,qa){BuddyWindow.setStatus(oa,pa,qa);}
function Block(ra){BuddyWindow.Block(ra);}
var MOD_X=0;var MOD_Y=0;var MOD_UserID=null;function onMouseoverOnlineBuddy(sa,ta){MOD_UserID=ta;MOD_X=Event.pointerX(sa);MOD_Y=Event.pointerY(sa);setTimeout("OpenBuddyDetails();",1000);}
function OpenBuddyDetails(){if(MOD_UserID==null)return;if(BuddyDetails["UserID_"+MOD_UserID]==undefined){BuddyDetails["UserID_"+MOD_UserID]=new CWTBuddyDetail("blBuddyDetail",MOD_UserID,MOD_X,MOD_Y);}
BuddyDetails["UserID_"+MOD_UserID].Window.show();BuddyDetails["UserID_"+MOD_UserID].Window.toFront();MOD_UserID=null;}
var onMouseoutOnlineBuddy=function(ua){MOD_UserID=null;Presences.UserIDs.each(function(va){if(BuddyDetails["UserID_"+va]!=null)BuddyDetails["UserID_"+va].Window.hide();});};function CWTMessageWindow(wa,xa,ya,za,Aa,Ba,Ca,Da){this.MessageA=Ca;this.MessageB=Da;this.BuddyName=Aa;this.ToBuddyName=Ba;this.UserID=ya;this.ToUserID=za;this.WindowID=wa;this.Window=new Window(wa,{className:"dialog",width:320,height:335,top:100,left:250,zIndex:200,resizable:true,title:Ba,draggable:true,detachable:true,minWidth:320,minHeight:150,showEffectOptions:{duration:0},hideEffectOptions:{duration:0}});var Ea=$(xa).innerHTML;Ea=ReplaceAll(Ea,"_Name_",wa);this.Window.getContent().innerHTML=Ea;this.Font="Arial";this.setFont=function(Fa){$(this.WindowID+'_sendBox').style.fontFamily=Fa;$(FontList).style.display="none";$(this.WindowID+'_sendBox').focus();};this.setFontSize=function(Ga){$(this.WindowID+'_sendBox').style.fontSize=Ga;$(FontSizeList).style.display="none";$(this.WindowID+'_sendBox').focus();};this.setFontColor=function(Ha){$(this.WindowID+'_sendBox').style.color=Ha;$(FontColorList).style.display="none";$(this.WindowID+'_sendBox').focus();};this.setBold=function(){if($(this.WindowID+'_sendBox').style.fontWeight=="normal")$(this.WindowID+'_sendBox').style.fontWeight="bold";else$(this.WindowID+'_sendBox').style.fontWeight="normal";$(this.WindowID+'_sendBox').focus();};this.setItalic=function(){if($(this.WindowID+'_sendBox').style.fontStyle=="normal")$(this.WindowID+'_sendBox').style.fontStyle="italic";else$(this.WindowID+'_sendBox').style.fontStyle="normal";$(this.WindowID+'_sendBox').focus();};this.setUnderline=function(){if($(this.WindowID+'_sendBox').style.textDecoration=="none")$(this.WindowID+'_sendBox').style.textDecoration="underline";else$(this.WindowID+'_sendBox').style.textDecoration="none";$(this.WindowID+'_sendBox').focus();};this.InsertText=function(Ia){$(this.WindowID+'_sendBox').value=$(wa+'_sendBox').value+Ia;$(SmileyList).style.display="none";$(this.WindowID+'_sendBox').focus();};this.Resize=function(){$(this.WindowID+'_rcvd').style.height=(this.Window.getSize().height-128)+'px';$(this.WindowID+'_rcvd').style.width=(this.Window.getSize().width-10)+'px';$(this.WindowID+'_toolbar').style.top=(this.Window.getSize().height-95)+'px';$(this.WindowID+'_toolbar').style.width=(this.Window.getSize().width-10)+'px';$(this.WindowID+'_setFont').style.top=(this.Window.getSize().height-85)+'px';$(this.WindowID+'_setFontSize').style.top=(this.Window.getSize().height-85)+'px';$(this.WindowID+'_setFontColor').style.top=(this.Window.getSize().height-85)+'px';$(this.WindowID+'_setFontColorColor').style.backgroundColor='#000';$(this.WindowID+'_insertEmoticon').style.top=(this.Window.getSize().height-85)+'px';$(this.WindowID+'_sendBox').style.top=(this.Window.getSize().height-65)+'px';$(this.WindowID+'_sendBox').style.left='2px';$(this.WindowID+'_sendBox').style.width=(this.Window.getSize().width-16)+'px';$(this.WindowID+'_sendBox').style.fontWeight='400';$(this.WindowID+'_sendBox').style.fontStyle='normal';$(this.WindowID+'_sendBox').style.textDecoration='none';};$(this.WindowID+'_setFontColor').onclick=function(){window.CurrentMessageWindow=this.Parent;if($(FontColorList).style.display!="block"){$(FontColorList).style.display="block";$(FontColorList).style.left=(parseInt(this.Parent.Window.getLocation()['left'])+parseInt(this.offsetLeft))+'px';$(FontColorList).style.top=(parseInt(this.Parent.Window.getLocation()['top'])+parseInt(this.Parent.Window.getSize()['height'])-46)+'px';$(FontColorList).style.zIndex=Windows.maxZIndex+20;}
else{$(FontSizeList).style.display="none";}};$(this.WindowID+'_setFontColor').Parent=this;$(this.WindowID+'_insertEmoticon').onclick=function(){window.CurrentMessageWindow=this.Parent;if($(SmileyList).style.display!="block"){$(SmileyList).style.display="block";$(SmileyList).style.left=(parseInt(this.Parent.Window.getLocation()['left'])+parseInt(this.offsetLeft))+'px';$(SmileyList).style.top=(parseInt(this.Parent.Window.getLocation()['top'])+parseInt(this.Parent.Window.getSize()['height'])-46)+'px';$(SmileyList).style.zIndex=Windows.maxZIndex+20;}
else{$(SmileyList).style.display="none";}};$(this.WindowID+'_insertEmoticon').Parent=this;$(this.WindowID+'_setFont').onclick=function(){window.CurrentMessageWindow=this.Parent;if($(FontList).style.display!="block"){$(FontList).style.display="block";$(FontList).style.left=(parseInt(this.Parent.Window.getLocation()['left'])+parseInt(this.offsetLeft))+'px';$(FontList).style.top=(parseInt(this.Parent.Window.getLocation()['top'])+parseInt(this.Parent.Window.getSize()['height'])-46)+'px';$(FontList).style.zIndex=Windows.maxZIndex+100;}
else{$(FontList).style.display="none";}};$(this.WindowID+'_setFont').Parent=this;$(this.WindowID+'_setFontSize').onclick=function(){window.CurrentMessageWindow=this.Parent;if($(FontSizeList).style.display!="block"){$(FontSizeList).style.display="block";$(FontSizeList).style.left=(parseInt(this.Parent.Window.getLocation()['left'])+parseInt(this.offsetLeft))+'px';$(FontSizeList).style.top=(parseInt(this.Parent.Window.getLocation()['top'])+parseInt(this.Parent.Window.getSize()['height'])-46)+'px';$(FontSizeList).style.zIndex=Windows.maxZIndex+20;}
else{$(FontSizeList).style.display="none";}};$(this.WindowID+'_setFontSize').Parent=this;$(this.WindowID+'_sendBox').Parent=this;Event.observe(this.WindowID+'_sendBox','keydown',function(Ja){var Ka=Event.element(Ja);window.CurrentMessageWindow=Ka.Parent;switch(Ja.keyCode){case Event.KEY_RETURN:var La=Ka.value;var Ma=$(Ka.Parent.WindowID+'_sendBox').style.fontFamily;var Na=$(Ka.Parent.WindowID+'_sendBox').style.fontSize;var Oa=$(Ka.Parent.WindowID+'_sendBox').style.color;var Pa=$(Ka.Parent.WindowID+'_sendBox').style.fontWeight;var Qa=$(Ka.Parent.WindowID+'_sendBox').style.textDecoration;var Ra=$(Ka.Parent.WindowID+'_sendBox').style.fontStyle;var Sa=new Date();var Ta="["+Sa.getHours()+":"+Sa.getMinutes()+"]";var Ua=Ka.Parent.BuddyName;var Va="font-size: "+Na+"; font-family: "+Ma+"; color: "+Oa;if(Qa!="none")Va=Va+"; text-decoration: "+Qa;if(Ra!="normal")Va=Va+"; font-style: "+Ra;if(Pa!="normal")Va=Va+"; font-weight: "+Pa;var Ea=" <span class='userB'>  <B> "+Ua+Ta+"</B> </span>"+" <span style='"+Va+"' >"+La+"</span> <br></br>";Ka.value="";Ka.Parent.WriteMessage(Ka.Parent.ToUserID,Ea);Ka.Parent.SendMessage(Ea);return false;}});this.WriteMessage=function(Wa,Xa){$(this.WindowID+'_rcvd').innerHTML=$(this.WindowID+'_rcvd').innerHTML+Xa;$(this.WindowID+'_rcvd').scrollTop=$(this.WindowID+'_rcvd').scrollHeight;ShowMessageWindow(Wa);};this.SendMessage=function(Ya){Chat.addMessage(Ya,this.ToUserID);};this.Resize();}
function CWTBuddyWindow(Za,$a){BuddyWindow=this;var ab=new BrowserDimension();this.Window=new Window("BuddiesWindow",{className:"dialog",width:210,height:350,zIndex:300,resizable:true,top:0,left:ab.Width-225,title:"Arkadaşlarım",draggable:true,closable:false,maximizable:false,detachable:false,minWidth:205,minHeight:150,showEffectOptions:{duration:0},hideEffectOptions:{duration:0}});IM_Windows.BuddyWindow=this;var bb=$(Za).innerHTML;this.Window.getContent().innerHTML=bb;this.Window.getContent().oncontextmenu=function(){return false;};this.Window.show();this.Presences=new String();this.DisplayName=DisplayName;this.ListContainer=$a;this.onClickCurStatus=function(){if($(StatusList).style.display!="block"){$(StatusList).style.display="block";$(StatusList).style.left=(parseInt(BuddyWindow.Window.getLocation()['left'])+5)+'px';$(StatusList).style.top=(parseInt(BuddyWindow.Window.getLocation()['top'])+28)+'px';$(StatusList).style.zIndex=Windows.maxZIndex+20;}
else{$(StatusList).style.display="none";}};$(CurStatus).onclick=this.onClickCurStatus;this.setStatus=function(cb,db,eb){var bb=$(TopToolbarPrototype).innerHTML;bb=ReplaceAll(bb,"_Status_",eb);$(TopToolbar).innerHTML=bb;$(CurStatus).onclick=this.onClickCurStatus;$(StatusList).style.display='none';if(cb=="online"){this.Logon();$('lfImage').style.display='none';$('lnImage').style.display='block';}else if(cb=="offline"){this.Logoff();$('lnImage').style.display='none';$('lfImage').style.display='block';}else{Chat.setStatus(BuddyWindow.NullCallBack,cb,db);$('lfImage').style.display='none';$('lnImage').style.display='block';}};this.NullCallBack=function(){};this.getMyPresenceCallBack=function(fb){BuddyWindow.Presence=fb;$(DisplayName).innerHTML='&nbsp;&nbsp;'+fb.nickname;};this.getPresencesCallBack=function(gb){this.Presences=gb;var i=0;$(OnlineBuddylist).innerHTML="";$(OfflineBuddylist).innerHTML="";gb.each(function(hb){Presences["UserID_"+hb.userID]=hb;Presences.UserIDs[i++]=hb.userID;ShowProfile(hb);});};this.logonCallBack=function(ib){if(ib){Chat.getMyPresence(BuddyWindow.getMyPresenceCallBack);Chat.getPresences(BuddyWindow.getPresencesCallBack);}else alert("Girilemedi");};this.STEP_START=2;this.STEP_END=5;this.NRC=0;this.STEP=this.STEP_START;this.Logon=function(){Chat.logon(this.logonCallBack);this.Executer=new PeriodicalExecuter(function(pe){if(BuddyWindow.NRC==0){BuddyWindow.NRC++;BuddyWindow.Ping();}
else if(BuddyWindow.NRC<BuddyWindow.STEP){BuddyWindow.NRC++;}else{BuddyWindow.NRC=0;if(BuddyWindow.STEP<BuddyWindow.STEP_END)BuddyWindow.STEP++;}},4);};this.logoffCallBack=function(){Chat.getMyPresence(BuddyWindow.getMyPresenceCallBack);Chat.getPresences(BuddyWindow.getPresencesCallBack);};this.Logoff=function(){this.Executer.stop();Chat.logoff(BuddyWindow.logoffCallBack);};this.Block=function(jb){Chat.block(BuddyWindow.NullCallBack,jb);onMouseoutOnlineBuddy(null);};this.RefreshPresences=function(){Chat.getPresences(BuddyWindow.getPresencesCallBack);};this.AddMessage=function(kb){if(kb.messageType=="S"){playIn();Chat.getPresences(BuddyWindow.getPresencesCallBack);}else if(kb.messageType=="L"){BuddyWindow.RefreshPresences();}else if(kb.messageType=="P"){playIn();Popup(kb.description);}else{playIn();CreateMessageWindow(kb.fromUserID);IM_Windows["UserID_"+kb.fromUserID].WriteMessage(kb.fromUserID,kb.description);}};this.Ping=function(){Chat.ping(function(lb){lb.each(function(mb){BuddyWindow.AddMessage(mb);});BuddyWindow.NRC=0;BuddyWindow.STEP=BuddyWindow.STEP_START;});};}
function Popup(nb){var ob=new BrowserDimension();var Cn=$('im_popup');var Ms=$('im_popup_msg');Ms.innerHTML=nb;Cn.style.top=ob.CenterHeight-Cn.style.height/2-50;Cn.style.left=ob.CenterWidth-Cn.style.width/2-50;Cn.style.display="block";Grow('im_popup');}
function CWTBuddyDetail(pb,qb,X,Y){this.Window=new Window("BuddyDetailsWindow_"+qb,{className:"dialog",width:240,height:100,zIndex:500,resizable:false,top:Y,left:X-250,title:"Profil",draggable:true,closable:false,maximizable:false,minimizable:false,detachable:false,minWidth:205,minHeight:150,showEffectOptions:{duration:0},hideEffectOptions:{duration:0}});this.UserID=qb;this.PrototypeWindow=pb;var rb=$(pb).innerHTML;rb=ReplaceAll(rb,"_ID_",qb);rb=ReplaceAll(rb,"_Name_",Presences["UserID_"+qb].nickname);this.Window.getContent().innerHTML=rb;this.Window.show();this.Window.toFront();}
function WindowObserver(){this.onDestroy=function(){};this.onStartResize=function(){};this.onStartMove=function(){$(StatusList).style.display="none";$(FontSizeList).style.display="none";$(SmileyList).style.display="none";$(FontList).style.display="none";$(FontSizeList).style.display="none";};this.onResize=function(){};this.onMove=function(){};this.onEndResize=function(){};this.onEndMove=function(){};this.onFocus=function(){};this.onBeforeShow=function(){};this.onShow=function(){};this.onHide=function(){};this.onMinimize=function(){};this.onMaximize=function(){};this.onClose=function(){};}
Windows.addObserver(new WindowObserver());function CIM(){if(BuddyWindow==null){BuddyWindow=new CWTBuddyWindow("buddyWindowPrototype","blContainer");}}
function DIM(){if(BuddyWindow!=null){BuddyWindow.Window.destroy();BuddyWindow=null;}}