﻿   
//<!--

var mousex = 0;
var mousey = 0;
var popped=0;
var neg=0;
var PopWidth=509, PopHeight=500;
var myWidth = 0, myHeight = 0;
var myTop=0,myLeft=0;
function falsefunc() { return false; } // used to block cascading events

function init()
{
  document.onmousemove = update; // update(event) implied on NS, update(null) implied on IE
  update();
}
function GetWindowSize()
{
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }   
    myTop=myHeight/2-PopHeight/2;
    if (myTop<30) {myTop=32}
    myLeft=myWidth/2-PopWidth/2;
    if (myLeft<0){ myLeft=5}
    myPop=document.getElementById('dropin')
    myPop.style.position = "absolute";
    myPop.style.left = (myLeft).toString(10) + 'px';
    myPop.style.top  = (myTop).toString(10) + 'px';
}
function GetChatWindowSize()
{
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }   
    myTop=myHeight/2-PopHeight/2;
    if (myTop<30) {myTop=32}
    myLeft=myWidth/2-PopWidth/2;
    if (myLeft<0){ myLeft=5}
    myPop=document.getElementById('chatwindow')
    myPop.style.position = "absolute";
    myPop.style.left = (myLeft).toString(10) + 'px';
    myPop.style.top  = (myTop).toString(10) + 'px';
}
function getMouseXY(e) // works on IE6,FF,Moz,Opera7
{ 
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = e.pageX;
      mousey = e.pageY;
      algor = '[e.pageX]';
      if (e.clientX || e.clientY) algor += ' [e.clientX] '
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      mousex = e.clientX + document.body.scrollLeft;
      mousey = e.clientY + document.body.scrollTop;
      algor = '[e.clientX]';
      if (e.pageX || e.pageY) algor += ' [e.pageX] '
    }  
  }
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "0";
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}
function update(e)
{
  getMouseXY(e); // NS is passing (event), while IE is passing (null)
  if (mousey<1) 
    {
        neg=1
    } 
  else 
    {
        if (mousey>30 ) 
        {
            neg=0
        }
    }
	if (mousey<30  && neg==0)	
	{
	   popped=getCookie("popup")
    if (popped==0) {
        setCookie("popup","1",120);
	    popped=1;
	    PopupMe2();
	   
	}
	}
  //document.getElementById('span_mousex').innerHTML = mousex;
  //document.getElementById('span_mousey').innerHTML = mousey;
}
function grab(context)
{
  document.onmousedown = falsefunc; // in NS this prevents cascading of events, thus disabling text selection
  dragobj = context;
  dragobj.style.zIndex = 100; // move it to the top
  document.onmousemove = drag;
  document.onmouseup = drop;
  grabx = mousex;
  graby = mousey;
  elex = orix = dragobj.offsetLeft;
  eley = oriy = dragobj.offsetTop;
  update();
}

function drag(e) // parameter passing is important for NS family 
{
  if (dragobj)
  {
    elex = orix + (mousex-grabx);
    eley = oriy + (mousey-graby);
    dragobj.style.position = "absolute";
    dragobj.style.left = (elex).toString(10) + 'px';
    dragobj.style.top  = (eley).toString(10) + 'px';
  }
  update(e);
  return false; // in IE this prevents cascading of events, thus text selection is disabled
}

function drop()
{
  if (dragobj)
  {
    dragobj.style.zIndex = 0;
    dragobj = null;
  }
  update();
  document.onmousemove = update;
  document.onmouseup = null;
  document.onmousedown = null;   // re-enables text selection on NS
}
var ie=document.all;
var dom=document.getElementById;
var ns4=document.layers;
var calunits=document.layers? "" : "px";
var bouncelimit;
var bouncing=0;
var direction="up";
var usedropin=1;

function PopupLiveChat(){

GetChatWindowSize();
if (!dom&&!ie&&!ns4)
    {
 
    }
    else
    {
    bouncelimit=32 //(must be divisible by 8)
    crossobj=(dom)?document.getElementById("chatwindow").style : ie? document.all.dropin : document.dropin
    // crossframe=(dom)?document.getElementById("cframe") : ie? document.all.cframe : document.cframe
    //  crossframe.src="linktext.htm" //link for pop up window
   
    crossobj.visibility=(dom||ie)? "visible" : "show"
    
    }
 
}
function PopupChat(){
//create grey out area
//var cvr = document.getElementById("cover")
//cvr.style.display = "block"
//if (document.body.style.overflow = "hidden") 
//    {
//	cvr.style.width = "100%"
//	cvr.style.height = "100%"
//	}
//hide video
//vid=(dom)?document.getElementById("video1").style : ie? document.all.video1 : document.video1
//vid.visibility="hidden"
GetChatWindowSize();
if (!dom&&!ie&&!ns4)
    {
 
    }
    else
    {
    bouncelimit=32 //(must be divisible by 8)
    crossobj=(dom)?document.getElementById("chatwindow").style : ie? document.all.dropin : document.dropin
    // crossframe=(dom)?document.getElementById("cframe") : ie? document.all.cframe : document.cframe
    //  crossframe.src="linktext.htm" //link for pop up window
   
    crossobj.visibility=(dom||ie)? "visible" : "show"
    
    }
 
}
function PopupMe2(){
//create grey out area

var cvr = document.getElementById("cover")
scroll(0,0)
cvr.style.display = "block"
if (document.body.style.overflow = "hidden") 
    {
	cvr.style.width = "100%"
	cvr.style.height = "100%"
	}

GetWindowSize();
if (!dom&&!ie&&!ns4)
    {
    window.open("popup.htm", "", "scrollbars=1")
    }
    else
    {
    bouncelimit=32 //(must be divisible by 8)
    crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
    // crossframe=(dom)?document.getElementById("cframe") : ie? document.all.cframe : document.cframe
    //  crossframe.src="linktext.htm" //link for pop up window
   
    if(usedropin)
       {
      // scroll_top=(ie)? truebody().scrollTop : window.pageYOffset    
       scroll_top=myTop; 
       crossobj.top=0+calunits
       }
    crossobj.visibility=(dom||ie)? "visible" : "show"
    if(usedropin)
        {        
        dropstart=setInterval("dropin()",50)
        }
    }
 
}
function dropin()
{
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<myTop)
    {
     crossobj.top=parseInt(crossobj.top)+10+calunits
     //if (parseInt(crossobj.top)>myTop+scroll_top)
     //   {
     //   crossobj.top=myTop+scroll_top
     //   }
    }
    else
    {
    clearInterval(dropstart)
    if (bouncing==1)
        {
        bouncestart=setInterval("bouncein()",50)
        }
    }
}
function bouncein()
{
    crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
    if (bouncelimit<0)
        bouncelimit+=8
        bouncelimit=bouncelimit*-1
        if (bouncelimit==0)
        {
        clearInterval(bouncestart)
        }
}

function dismissbox()
{
    //popped=0;        
    document.body.style.overflow = "auto"
  // vid.visibility=(dom||ie)? "visible" : "show"
   var cvr = document.getElementById("cover")
   cvr.style.display = "none";
    if (window.bouncestart) clearInterval(bouncestart)    
    crossobj.visibility="hidden"
    //open popunder window
   // pWindowOpen();
     
}
function Closechat()
{
    popped=0;        
    //document.body.style.overflow = "auto"
    //vid.visibility=(dom||ie)? "visible" : "show"
    //var cvr = document.getElementById("cover")
    //cvr.style.display = "none";
    if (window.bouncestart) clearInterval(bouncestart)    
    crossobj.visibility="hidden"
    //open popunder window
    
     
}

function truebody()
{
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}


function pShowModalDialog() {
   fyicenterVal = window.showModalDialog('popup.htm',window,
      'dialogLeft:100px; dialogTop:100px; dialogWidth:510px; dialogHeight:422px; status:no;');
}
function pWindowOpen() {
   fyicenterWin = window.open('popup.htm','Popup',
      'toolbar=no,scrollbars=no,resizeable=no,width=510,height=422,screenX=300,screenY=300');  
     fyicenterWin.blur();
     // window.focus();
      
      }

function moveObjRight() 
{
if (parseInt(crossobj.left)<100)
    {
     crossobj.left=parseInt(crossobj.left)+40+calunits
     if (parseInt(crossobj.left)>100)
        {
        crossobj.top=100}
        }
    else
    {
    clearInterval(dropstart)
    //bouncestart=setInterval("bouncein()",50)
    }
}



//-->
    