var locX=0;
var locY=400;
var imgW=0;
var maxX=0;
var getC=0;
var docW=document.body.clientWidth;
var hldX=0;
var incX=2;
var cStat=1;
imgPoll=new Image();
imgPoll.onload=chkImg;
document.write('<div name="woInvite" id="woInvite" style="position: absolute; top:400; left: 0; z-index: 9" align="center">');
document.write('&nbsp;</div>');
setTimeout("getImg()",1000);
function woMove(){
 if(hldX==0){
  newX=locX+incX;
  if(incX>0){
   if(newX<maxX){
    locX=newX;woDIVs.left=locX;
    setTimeout('woMove()',12);
   } else {
    incX=-2;
    setTimeout('woMove()',1000);
   }
  } else {
   if(locX>0){
    locX=newX;woDIVs.left=locX;
    setTimeout('woMove()',6);
   } else {
    setTimeout('stopInvite()',4000);
   }
 }
 }
}
function getImg(){
 var rTimer=5000;
 if(cStat==1){
  var pUrl="https://www.cellarcentral.com:8443/poll.gif?domain=www.cellarcentral.com&stamp="+(new Date()).getTime();
  if(typeof(sSession)!="undefined"){pUrl+="&u="+sSession;}
  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;
 ofsY=document.body.scrollTop;
 hldX=0;incX=2;locX=0;locY=400;
 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="https://www.cellarcentral.com:8443/invite.gif?domain=www.cellarcentral.com&stamp='+(new Date()).getTime()+'" name="woIImg"</a>';
 woDIVs.top=locY+ofsY;woDIVs.left=locX;
 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://www.cellarcentral.com/chat/chatstart.htm?domain=www.cellarcentral.com","Chat","width=484,height=361");
  this.chatWindow.focus();this.chatWindow.opener=window;
 }
 stopInvite();
}
function anPause(){
 hldX=1;
}
function anResume(){
 hldX=0;
 setTimeout('woMove()',1000);
}


