// JavaScript Document

<script language='Javascript'>
var locX=0;
var locY=150;
var imgW=0;
var maxX=0;
var getC=0;
var docW=document.body.clientWidth;
var hldX=0;
var incX=1;
var cStat=1;
imgPoll=new Image();
imgPoll.onload=chkImg;
function woAfterLoad(){
 var tmpDiv=document.createElement('DIV');
 tmpDiv.setAttribute('name', 'woInvite');
 tmpDiv.setAttribute('id', 'woInvite');
 tmpDiv.setAttribute('align', 'right');
 tmpDiv.style.position='absolute';
 tmpDiv.style.top=150;
 tmpDiv.style.left=0;
 tmpDiv.style.zIndex=999;
 document.body.appendChild(tmpDiv);
 setTimeout('getImg()',1000);
}
function woMove(){
 if(hldX==0){
  newX=locX+incX;
  if(incX>0){
   if(newX<maxX){
    locX=newX;woDIVs.left=locX+'px';
    setTimeout('woMove()',12);
   } else {
    incX=-1;
    setTimeout('woMove()',1000);
   }
  } else {
   if(locX>0){
    locX=newX;woDIVs.left=locX+'px';
    setTimeout('woMove()',6);
   } else {
    setTimeout('stopInvite()',4000);
   }
 }
 }
}
function getImg(){
 var rTimer=5000;
 if(cStat==1){
  var pUrl="http://87.102.101.97:8080/poll.gif?domain=www.offsiteit.co.uk&stamp="+(new Date()).getTime();
  if(typeof(sWOSession)!="undefined"){pUrl+="&u="+sWOSession;}
  imgPoll.src=pUrl;
 }
 getC++;
 if(getC>6)rTimer=10000;
 if(getC>20)rTimer=15000;
 if(getC>30)rTimer=0;
 if(rTimer>0)setTimeout("getImg()",rTimer);
}
function chkImg(){
 if(imgPoll!=null){
  nStat=imgPoll.width;
  if(nStat!=cStat){
   cStat=nStat;
   if(cStat==3)startChat();
   if(cStat==2)startInvite();
   if(cStat==1)stopInvite();
  }
 }
}
function getIImgw(){
 imgW=woIMG.width;maxX=docW-imgW;
}
function startInvite(){
 var ofsY;
 if(document.documentElement && document.documentElement.scrollTop){
  ofsY=document.documentElement.scrollTop;
 } else {
  ofsY=document.body.scrollTop;
 }
 hldX=0;incX=1;locX=0;locY=150;
 woDIVs=document.getElementById('woInvite').style;
 woDIVh=document.getElementById('woInvite');
 woDIVh.innerHTML='<a href="javascript:void(0);" onclick="return startChat(event);" onMouseOver="anPause()" onMouseOut="anResume()"><img border="0" src="http://87.102.101.97:8080/invite.gif?domain=www.offsiteit.co.uk&stamp='+(new Date()).getTime()+'" name="woIImg"</a>';
 woDIVs.top=(locY+ofsY)+'px';woDIVs.left=locX+'px';
 setTimeout('woMove()',3000);
 woIMG=document.images.woIImg;
 woIMG.onload=getIImgw;
}
function stopInvite(){
 cStat=1;woDIVh.innerHTML="";
 setTimeout("getImg()",10000);
}
function startChat(event){
 clsX=locX+imgW-12;
 clsY=locY+12;
 if(event.clientX<clsX || event.clientY>clsY){
  this.chatWindow=window.open("http://server03.onsite-it-support.co.uk/chat/?domain=www.offsiteit.co.uk","Chat","width=484,height=361");
  this.chatWindow.focus();this.chatWindow.opener=window;
 }
 stopInvite();
}
function anPause(){
 hldX=1;
}
function anResume(){
 hldX=0;
 setTimeout('woMove()',1000);
}
var woOldOnload=window.onload;
if(typeof woOldOnload=='function'){
 if (! (String(woOldOnload).indexOf('woAfterLoad') > 0))
 {
   var woRunOnload = woOldOnload;
   window.onload=function(){woRunOnload();woAfterLoad();};
 }
} else {
 window.onload=woAfterLoad;
}

</script>
