home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 February / PCpro_2005_02.ISO / files / special / DNA / Dokumentation / FAQ / vms00000.js < prev   
Encoding:
Text File  |  2004-10-19  |  4.5 KB  |  128 lines

  1. if(document.getElementById){
  2.   doc = 'document.getElementById("';
  3.   sty = '").style';
  4.   htm = '';
  5. }
  6. if(document.layers){
  7.   doc = 'document.';
  8.   sty = '';
  9.   htm = '.document';
  10. }
  11. if(document.all){
  12.   doc = 'document.all.';
  13.   sty = '.style';
  14.   htm = '';
  15. }
  16. var currentX = 0;
  17. var currentY = 200;
  18. var inviteImageWidth = 226;
  19. var docWidth, docHeight;
  20. if (document.layers) { docWidth = window.outerWidth; docHeight = window.outerHeight; }
  21. if (document.all) { docWidth = document.body.clientWidth; docHeight = document.body.clientHeight; }
  22. var docXtop = docWidth - 226;
  23. var xAnimationStep = 1;
  24. var xAnimationEvery = Math.round(0.9 * (100000 / (docXtop * 2)));
  25. if (xAnimationEvery < 10) {
  26.   xAnimationEvery = 10;
  27.   var numSteps = 100000 / xAnimationEvery;
  28.   xAnimationStep = Math.round((docXtop * 2) / numSteps);
  29. }
  30. var xIncrementSaved = xAnimationStep;
  31. var xIncrement = xIncrementSaved;
  32. function animationStop() {
  33.   animationDiv = eval(doc + 'theImage' + htm);
  34.   animationDiv.innerHTML = '';
  35.   rpc_setPersonMode('1');
  36. }
  37. function animationStep(){
  38.   newX = currentX + xIncrement;
  39.   if (xIncrement > 0) {
  40.       if (newX < docXtop) {
  41.           currentX = newX;
  42.           animationDivSty.left = currentX;
  43.           setTimeout('animationStep()', xAnimationEvery);
  44.       } else {
  45.           xIncrementSaved = -xIncrementSaved;
  46.           xIncrement = xIncrementSaved;
  47.           setTimeout('animationStep()', xAnimationEvery);
  48.       }
  49.   } else if (xIncrement < 0) {
  50.       if (currentX > 0) {
  51.           currentX = newX;
  52.           animationDivSty.left = currentX;
  53.           setTimeout('animationStep()', xAnimationEvery);
  54.       } else {
  55.           setTimeout('animationStop()', 3000);
  56.       }
  57.   } else {
  58.       setTimeout('animationStep()', 1000);
  59.   }
  60. }
  61. document.write('<div name="theImage" id="theImage" style="position: absolute; top: 200; left: 0; z-index: 999" align="right">');
  62. document.write(' </div>');
  63. var animationDivSty = eval(doc + 'theImage' + sty);
  64. vm_status = 1;
  65. vm_img = new Image();
  66. vm_img.onload = vm_check;
  67. vm_poll();
  68. function vm_poll() {
  69.     vm_img.src = 'https://vm.boldchat.com/bh.vm?pp=10&aid=1669612566&cdid=481302108&vid=1465576347&pvid=1599200595&kill=' + (new Date()).getTime() + '&referrer=' + escape(document.referrer) + '&url=' + escape(document.URL);
  70.     setTimeout('vm_poll()', 10000);
  71. }
  72. function vm_check() {
  73.     if (vm_img!=null) {
  74.         newStatus =  vm_img.height;
  75.         if (newStatus!=vm_status) {
  76.             vm_status = newStatus;
  77.             if (vm_status==2) {
  78.                     vm_openChat();
  79.                 } else if (vm_status==4) {
  80.                     vm_inviteToChat();
  81.                 }
  82.         }
  83.     }
  84. }
  85. function vm_openChat() {
  86.     this.newWindow = window.open('http://vm.boldchat.com/chat/visitor.jsp?type=OIC&cdid=481302108&vid=1465576347&pvid=1599200595', 'Chat', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480'); this.newWindow.focus(); this.newWindow.opener = window;
  87. }
  88. function vm_inviteToChat() {
  89.     xIncrementSaved = xAnimationStep;
  90.     xIncrement = xIncrementSaved;
  91.     currentX = 0; currentY = 200;
  92.     animationDivSty.top = currentY; animationDivSty.left = currentX;
  93.     document.animationDiv = eval(doc + 'theImage' + htm);
  94.     document.animationDiv.innerHTML = '<a href="#" onClick="return vm_onInviteClick(event);" onMouseOver="vm_pause();" onMouseOut="vm_resume();"><img border="0" src="https://secure.netsupportsoftware.com/2003res/images/invitation_2Chat.gif" width="226" height="141"></a>';
  95.     setTimeout('animationStep()', 5000);
  96. }
  97. function vm_onInviteClick(event) {
  98.     imgCloseX = currentX + 164;
  99.     imgCloseY = currentY + 111;
  100.     if (event.x >= imgCloseX && event.x < imgCloseX + 55 && event.y >= imgCloseY && event.y < imgCloseY + 55) {
  101.         animationStop();
  102.     } else {
  103.         this.newWindow = window.open('http://vm.boldchat.com/chat/visitor.jsp?type=OIC&cdid=481302108&vid=1465576347&pvid=1599200595', 'Chat', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480'); this.newWindow.focus(); this.newWindow.opener = window; animationStop();
  104.     }
  105.     return false;
  106. }
  107. function vm_pause() {
  108.     xIncrement = 0;
  109. }
  110. function vm_resume() {
  111.     xIncrement = xIncrementSaved;
  112. }
  113. function rpc_setPersonMode(mode) {
  114.     var p=new Array(3);
  115.     p[0]='1669612566';
  116.     p[1]='1465576347';
  117.     p[2]=mode;
  118.     rpc_execute('boldchat.web_chat_manager', 'setPersonMode', p, new Image());
  119. }
  120. function rpc_execute(name, method, params, rpcImg) {
  121.    url = 'http://vm.boldchat.com/bh.irpc/' + name + '?m=' + method;
  122.    for (i in params) {
  123.        url += '&' + 'p' + i + '=' + params[i];
  124.    }
  125.    url += '&' + (new Date()).getTime();
  126.    rpcImg.src = url;
  127. }
  128.