var openWindows=new Array(1000);var loadNewMessagesWithAjax=true;var objRCCParent="";function closeRCCChild(){objRCCParent=setInterval("checkRCCParent()",500)}function checkRCCParent(){if(window.opener){if(window.opener.closed){clearInterval(objRCCParent);self.close()}}else{clearInterval(objRCCParent);self.close()}}function openRemoteControl(){var g=parseInt(screen.width);var a=parseInt(screen.height);var h="300";var b="450";if(g<="800"&&a<="600"){h="200";b="350"}var f=(g-h-40);var d=(a-(a-70));var c=config.a_url+"remote_control/";var j="AmcmsRemoteControl";try{self.wino=window.open(c,j,"width="+h+",height="+b+",top="+d+",left="+f+",scrollbars=0,resizable=1,menubar=0,location=0,toolbar=0,status=1,directories=0");self.setTimeout(function(){try{if(!self.wino){console.log("couldn't open child window",strURL)}}catch(k){}},200)}catch(i){console.log("error while trying to open child window",c)}}function openPrivateChat(m,f,k){var h=screen.width;var b=screen.height;var i="370";var c="370";if(h<="800"&&b<="600"){i="300";c="300"}var g=(50+(k*15));var e=(100+(k*10));f=f!=""?"&"+f:"";var d=config.a_url+"remote_control_chat/?mid="+m+f;var j="AmcmsRemoteControlChat"+m.trim();if(openWindows&&openWindows[j]&&!openWindows[j].closed){if(loadNewMessagesWithAjax||openWindows[j].frames.iReceiver){var a=config.a_url+"receivers/remote_control_chat_append.php";var l="mid="+m;if(loadNewMessagesWithAjax){if(openWindows[j].mcmsAjax){openWindows[j].mcmsAjax.loadUrl(a,"get",l,"alert")}else{setTimeout("openWindows['"+j+"'].mcmsAjax.loadUrl('"+a+"', 'get', '"+l+"', 'alert');",2000)}}else{openWindows[j].frames.iReceiver.document.location.href=config.a_url+"receivers/remote_control_chat_append.php?mid="+m+""}}}else{openWindows[j]=window.open(d,j,"width="+i+",height="+c+",top="+e+",left="+g+",scrollbars=0,resizable=1,menubar=0,location=0,toolbar=0,status=1,directories=0")}if(f=="&typing"){setTimeout("if(openWindows['"+j+"'] && !openWindows['"+j+"'].closed) openWindows['"+j+"'].resetStatusText('"+global_usr_for_typing+"');",120000)}}function openRemoteControlChatRequests(){if(window.opener&&!window.opener.closed){if(window.opener.remoteControlChatRequests){for(var a=0;a<window.opener.remoteControlChatRequests.length;a++){if(window.opener.remoteControlChatRequests[a]!=""){openPrivateChat(window.opener.remoteControlChatRequests[a],"",a);if(window.opener.document.getElementById("blinkRemoteControlChat")){var b=parseInt(window.opener.document.getElementById("blinkRemoteControlChat").innerHTML);window.opener.document.getElementById("blinkRemoteControlChat").innerHTML=(b>0)?b-1:0;if(window.opener.document.getElementById("blinkRemoteControlChatImg")){window.opener.document.getElementById("blinkRemoteControlChatImg").src=config.a_url+"inc/gfx/icon_header_remote_p.gif"}window.opener.remoteControlChatRequests[a]=""}}}}}}function onMessageSubmit(a){var b="";if(document.getElementById("remoteControlChatHistory")){var b=document.getElementById("frmRCCMessage")?document.getElementById("frmRCCMessage").value:"";if(b.length>0){append_message(b.htmlEntities(),sess_username,true,"","append");scrollChatHistory();setChatFocus()}}}function message_length(){var b=document.getElementById("frmRCCMessage")?document.getElementById("frmRCCMessage").value:"";var a=parseInt(b.length);if(document.getElementById("frmMsgLength")){document.getElementById("frmMsgLength").innerHTML=(2000-a)}if(a>=2000){if(document.getElementById("frmRCCMessage")){document.getElementById("frmRCCMessage").value=document.getElementById("frmRCCMessage").value.substr(0,2000)}}}var printed_messages=new Array();function append_message(c,e,b,d,a){a=(a!=undefined&&a!="undefined")?a:"";if(printed_messages[a]==undefined||printed_messages[a]=="undefined"){if(a!="append"){printed_messages[a]=true}b=(b=="undefined"||b==undefined)?true:b;d=(d!="undefined"&&d!=undefined)?d:"";c=c.replace(/\r/g,"");if(b){c=c.replace(/\n/g,"<br/>")}c=c.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");c=c.replace(/\ /g,"&nbsp;");if(c.length>0){if(document.getElementById("remoteControlChatHistory")){if(d==""){c=c.replace(/&nbsp;/g," ");
document.getElementById("remoteControlChatHistory").innerHTML+="<b>"+e+"</b> s&auml;ger:<br/>"+c+"<br/>"}else{if(d=="notify"){document.getElementById("remoteControlChatHistory").innerHTML+="<br/><span style='color: gray;'><b>MEDDELANDE</b><br/>"+c+"</span><br/>"}}}}}else{}}var toggle_mode=0;var objInt="";function blink_window(){objInt=setInterval('toggle_title("'+toggle_mode+'")',1000)}function stop_blink(){clearInterval(objInt)}function toggle_title(){if(toggle_mode==0){if(typeof(parent.document)!="undefined"&&typeof(parent.document)!="unknown"&&typeof(parent.document.title)=="string"){parent.document.title="[NYTT MEDDELANDE]";toggle_mode=1}}else{if(typeof(parent.document)!="undefined"&&typeof(parent.document)!="unknown"&&typeof(parent.document.title)=="string"){document.title="[-]";toggle_mode=0}}}function scrollChatHistory(){if(document.getElementById("remoteControlChatHistory")){document.getElementById("remoteControlChatHistory").scrollTop=10000000}}function setChatFocus(){if(document.getElementById("frmRCCMessage")){document.getElementById("frmRCCMessage").focus()}}var oldWidth=0;var oldHeight=0;function resizeContent(){if(document&&document.documentElement&&document.documentElement.clientWidth){var b=document.documentElement.clientWidth?parseInt(document.documentElement.clientWidth):0;var a=document.documentElement.clientHeight?parseInt(document.documentElement.clientHeight):0}else{if(document&&document.body&&document.body.clientWidth){var b=document.body.clientWidth?parseInt(document.body.clientWidth):0;var a=document.body.clientHeight?parseInt(document.body.clientHeight):0}else{var b=0;var a=0}}if(!document.getElementById("remoteControlChatHistory")){b=b-3;a=a-3}else{b=b;a=a}if(b!=oldWidth||a!=oldHeight){if(document.getElementById("remoteControlArea")){document.getElementById("remoteControlArea").style.width=b+"px"}if(document.getElementById("remoteControlArea")){document.getElementById("remoteControlArea").style.height=a+"px"}if(document.getElementById("frmPersonalMessage")){document.getElementById("frmPersonalMessage").style.width=((b-25)>=0?(b-25):0)-63+"px"}if(document.getElementById("remoteControlFriendsList")){document.getElementById("remoteControlFriendsList").style.width=b+"px"}if(document.getElementById("remoteControlFriendsList")){document.getElementById("remoteControlFriendsList").style.height=((a-140)>=0?(a-140):0)+"px"}if(document.getElementById("remoteControlFriendsList_content")){document.getElementById("remoteControlFriendsList_content").style.width=((b-25)>=0?(b-25):0)+"px"}if(document.getElementById("remoteControlFriendsList_content")){document.getElementById("remoteControlFriendsList_content").style.height=((a-140)>=0?(a-140):0)+"px"}if(document.getElementById("footerAd")){document.getElementById("footerAd").style.width=((b-25)>=0?(b-25):0)-13+"px"}if(document.getElementById("remoteControlChatHistory")&&document.getElementById("remoteControlChatHistoryParent")){document.getElementById("remoteControlChatHistory").style.width=((b-22)>=0?(b-22):0)-150+"px";document.getElementById("remoteControlChatHistoryParent").style.width=((b-22)>=0?(b-22):0)-150+"px";var c=200;document.getElementById("remoteControlChatHistory").style.height=((a-c)>=0?(a-c):0)+"px";document.getElementById("remoteControlChatHistoryParent").style.height=((a-c)>=0?(a-c):0)+"px";document.getElementById("rightColumnPictures").style.height=((a-c)>=0?(a-c+20):0)+"px"}oldWidth=b;oldHeight=a;scrollChatHistory();window.scroll(1000000,0)}}var windowRemoteControlMain=true;var objRemoteControlSpawnWindow="";function openSite(a){if(window.opener&&!window.opener.closed&&window.opener.frames.appFrame){window.opener.frames.appFrame.document.location.href=a}else{if(objRemoteControlSpawnWindow!=""&&!objRemoteControlSpawnWindow.closed){objRemoteControlSpawnWindow.frames.appFrame.document.location.href=a}else{objRemoteControlSpawnWindow=window.open(config.a_url+"?go="+a,"remoteControlSpawn")}}}var has_sent=false;function startTypingStatusCheck(){setInterval("send_typing_status(document.getElementById('frmRCCMessage'))",500)
}function send_typing_status(c){if(c.value.length>0&&!has_sent){has_sent=true;var b="../sock__remote_control/typing_status_send.php";var a="mid="+receiver_mid+"&action=typing";mcmsAjax.loadUrl(b,"GET",a,"alert")}if(c.value.length==0&&has_sent){has_sent=false;var b="../sock__remote_control/typing_status_send.php";var a="mid="+receiver_mid+"&action=not_typing";mcmsAjax.loadUrl(b,"GET",a,"alert")}}function resetStatusText(a){if(document.getElementById("statusBar")){document.getElementById("statusBar").innerHTML="["+objDate.getHours()+":"+objDate.getMinutes()+":"+objDate.getSeconds()+"] <b>"+a+"</b> &auml;r online!"}}var global_usr_for_typing="";function set_typing_status(mid,usr,status){var winName="AmcmsRemoteControlChat"+mid.trim();if(openWindows&&(!openWindows[winName]||(openWindows[winName]&&openWindows[winName].closed))){if(status=="typing"){global_usr_for_typing=usr;openPrivateChat(mid,status.replace(/_/g,""),1)}}if(openWindows&&openWindows[winName]&&!openWindows[winName].closed){var objDate=new Date();if(status=="typing"){if(openWindows[winName]){if(openWindows[winName].document.getElementById("statusBar")){openWindows[winName].document.getElementById("statusBar").innerHTML="["+objDate.getHours()+":"+objDate.getMinutes()+":"+objDate.getSeconds()+"] <b>"+usr+"</b> skriver ett meddelande.";if(eval("openWindows['"+winName+"'] != undefined && openWindows['"+winName+"'] != 'undefined'")){if(eval("openWindows['"+winName+"'].resetStatusText != undefined && openWindows['"+winName+"'].resetStatusText != 'undefined'")){setTimeout("if(openWindows['"+winName+"']) openWindows['"+winName+"'].resetStatusText('"+usr+"');",120000)}}}}}else{if(status=="not_typing"){if(openWindows[winName]){if(openWindows[winName].document.getElementById("statusBar")){openWindows[winName].document.getElementById("statusBar").innerHTML="["+objDate.getHours()+":"+objDate.getMinutes()+":"+objDate.getSeconds()+"] <b>"+usr+"</b> &auml;r online!"}}}}}}function KeyCheck(d){var c=d||window.event;var b=(window.event)?event.keyCode:d.keyCode;var a=c.shiftKey;if(c.shiftKey&&b==13){if(document.getElementById("frmRCCMessage")){}}else{if(b==13){onMessageSubmit(receiver_mid);document.forms.frmChatArea.submit();return false}}}function KeyCheckMain(d){var c=d||window.event;var b=(window.event)?event.keyCode:d.keyCode;var a=c.shiftKey;if(b==116){}}var start_pos_y=0;var cur_pos_y=0;var c_enabled=false;var objDate=new Date();last_move=objDate.getTime()*1000;function startEventListeners(a){if(a=="main"){document.onkeydown=KeyCheckMain}else{document.onkeydown=KeyCheck}}function resizeOnMouseDown(a){c_enabled=true;if(c_enabled){if(!document.all){start_pos_y=parseInt(a.screenY)}else{start_pos_y=parseInt(event.clientY)}}}function resizeOnMouseMove(a){if(c_enabled){objDate=new Date();var c=objDate.getTime()*1000;if((c-last_move)>1){if(!document.all){cur_pos_y=parseInt(a.screenY)}else{cur_pos_y=parseInt(event.clientY)}var b=parseInt(document.getElementById("frmRCCMessage").style.height);if(cur_pos_y<start_pos_y){document.getElementById("frmRCCMessage").style.height=b-((start_pos_y-cur_pos_y)/100)+"px"}else{document.getElementById("frmRCCMessage").style.height=b+((cur_pos_y-start_pos_y)*100)+"px"}}}}function resizeOnMouseUp(){c_enabled=false}var max_friends2=1000;var hUsernames2=new Array(max_friends2);var hUsernamesOffline2=new Array(max_friends2);var hMids2=new Array(max_friends2);var hMidsOffline2=new Array(max_friends2);var hPersonalMessage2=new Array(max_friends2);var hPersonalMessageOffline2=new Array(max_friends2);function init_buddies2(){if(document.getElementById("polareOnlineList")){var d=str_friends.split(",");var b="";var c=Array();for(var a=0;a<d.length;a++){c=d[a].split("|");if(c[0]!=""&&c[1]!=""){append_buddy2(c[0],c[1],c[2],false)}}}if(document.getElementById("polareOfflineList")){var d=str_friends_offline.split(",");var b="";var c=Array();for(var a=0;a<d.length;a++){c=d[a].split("|");if(c[0]!=""&&c[1]!=""){append_buddy2(c[0],c[1],c[2],true)}}}}function refresh_buddies2(){var b="";
var d="";var c="";for(var a=max_friends2;a>-1;a--){if(hUsernames2[a]!=""&&hUsernames2[a]!="undefined"&&hUsernames2[a]!=undefined){d=((hPersonalMessage2[a]!=undefined&&hPersonalMessage2[a]!="undefined"&&hPersonalMessage2[a]!="")?"- "+(base64_decode(hPersonalMessage2[a])):"");d=htmlspecialchars(d);b+='<table cellspacing="0" cellpadding="0" border="0" width="100%">';b+="	<tr>";b+='		<td valign="top" style="width: 16px;">';b+='			<div style="padding-top: 3px;"><img src="'+config.a_url+'inc/gfx/icon_remote_member.gif" style="width: 11px; height: 16px;" /></div>';b+="		</td>";b+='		<td valign="top" style="cursor: pointer; -moz-user-select: none;" onselectstart="return false;" ondblclick="openPrivateChat(\''+hMids2[a]+"', 'request', '"+a+"');\" onmouseover=\"this.style.backgroundColor='#e1e1e1';\" onmouseout=\"this.style.backgroundColor='white';\">";b+='			<div style="padding: 3px 3px 3px 3px">';b+="				"+hUsernames2[a]+' <font color="gray">'+d+"</font>";b+="			</div>";b+="		</td>";b+="	</tr>";b+="</table>"}}document.getElementById("polareOnlineList").innerHTML=b;b="";for(var a=max_friends2;a>-1;a--){if(hUsernamesOffline2[a]!=""&&hUsernamesOffline2[a]!="undefined"&&hUsernamesOffline2[a]!=undefined){c=((hPersonalMessageOffline2[a]!=undefined&&hPersonalMessageOffline2[a]!="undefined"&&hPersonalMessageOffline2[a]!="")?"- "+(base64_decode(hPersonalMessageOffline2[a])):"");c=htmlspecialchars(c);b+='<table cellspacing="0" cellpadding="0" border="0" width="100%">';b+="	<tr>";b+='		<td valign="top" style="width: 16px;">';b+='			<div style="padding-top: 3px;"><img src="'+config.a_url+'inc/gfx/icon_remote_member.gif" style="width: 11px; height: 16px;" /></div>';b+="		</td>";b+='		<td valign="top" style="cursor: pointer; -moz-user-select: none;" onselectstart="return false;" ondblclick="openPrivateChat(\''+hMidsOffline2[a]+"', 'request', '"+a+"');\" onmouseover=\"this.style.backgroundColor='#e1e1e1';\" onmouseout=\"this.style.backgroundColor='white';\">";b+='			<div style="padding: 3px 3px 3px 3px">';b+="				"+hUsernamesOffline2[a]+' <font color="gray"> '+c+"</font>";b+="			</div>";b+="		</td>";b+="	</tr>";b+="</table>"}}document.getElementById("polareOfflineList").innerHTML=b;return false}function append_buddy2(d,e,b,c){b=b.replace(/^\s+|\s+$/g,"");b=b=="IA=="?"":b;if(c!=undefined&&c!="undefined"&&c==true){for(var a=0;a<max_friends2;a++){if(hUsernamesOffline2[a]==""||hUsernamesOffline2[a]=="undefined"||hUsernamesOffline2[a]==undefined){hUsernamesOffline2[a]=d;hMidsOffline2[a]=e;hPersonalMessageOffline2[a]=b;break}}}else{for(var a=0;a<max_friends2;a++){if(hUsernames2[a]==""||hUsernames2[a]=="undefined"||hUsernames2[a]==undefined){hUsernames2[a]=d;hMids2[a]=e;hPersonalMessage2[a]=b;break}}}refresh_buddies2();return false}function remove_buddy2(c,d,b){if(b!=undefined&&b!="undefined"&&b==true){for(var a=max_friends2;a>-1;a--){if(hUsernamesOffline2[a]!=""&&hUsernamesOffline2[a]!="undefined"&&hUsernamesOffline2[a]!=undefined){if(hUsernamesOffline2[a].toLowerCase()==c.toLowerCase()){hUsernamesOffline2[a]="";hMidsOffline2[a]="";hPersonalMessageOffline2[a]=""}}}}else{for(var a=max_friends2;a>-1;a--){if(hUsernames2[a]!=""&&hUsernames2[a]!="undefined"&&hUsernames2[a]!=undefined){if(hUsernames2[a].toLowerCase()==c.toLowerCase()){hUsernames2[a]="";hMids2[a]="";hPersonalMessage2[a]=""}}}}refresh_buddies2();return false};
