//CONFIG: Vars that Set Element Positioning
var xs_StartPositionTopButton = 85;
var xs_StartPositionTopBanner = -129;
var xs_MovePositionTop=xs_StartPositionTopBanner;//used to be 91
var xs_BannerWidthPhysical = 320;
var xs_BannerWidthMiddle = xs_BannerWidthPhysical/2;
var xs_pHeightPhysical = 211;
var xs_pHeightClipped=211;
//VARS: Supporting VARs for flags, etc
var xs_updown=1;
var xs_endpt=0;
var xs_ranonce=0;
var xs_pDivSeen=0;
var xs_pTuck=0;
var ua=navigator.userAgent.toLowerCase()
var isflex;
var isGroupA = false;

function xsGetCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1){endstr = document.cookie.length;}
   return unescape(document.cookie.substring(offset, endstr));
}

function xsGetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
   var j = i + alen;
   if (document.cookie.substring(i, j) == arg) return xsGetCookieVal (j);
   i = document.cookie.indexOf(" ", i) + 1;
   if (i == 0) break; }
   return null;
}
function xsSetCookie (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}

function fnSetGroupA(value)
{
    isGroupA = value;
}

var xs_exp = new Date(); xs_exp.setTime(xs_exp.getTime()+(48*60*60*1000));
function xs_pdEx(){        
   if(isflex=="yes"){
        setTimeout("flexing()",500);
   }
   var xs_pDiv2 = document.getElementById("xs_pDiv2");
   var xs_pDiv = document.getElementById("xs_pDiv");
   var xs_popval = GetCookieDictionary('apc','pv');
   xsSetCookie('seenexp', "", xs_exp, "/");
   var xs_ctest = (String(xs_popval) == "1" ? true : null);   
   if ((xs_pDiv2))
   {
      if((!xs_ranonce)&&(xs_ctest)){
         //BRANCH: Occurs with ONLOAD event...sets up the DIVs
         xs_pDiv2.style.left=xs_pDiv.style.left= ((document.body.offsetWidth/2)-xs_BannerWidthMiddle); 
         xs_pDiv2.style.top=xs_StartPositionTopButton;
         xs_pDiv.style.top=xs_StartPositionTopBanner; 
         xs_pd();
      }else{
         //BRANCH: Occurs with ONRESIZE event
         if(xs_pTuck == 1){
            if (xs_pDivSeen != 1){
               xs_pDiv.style.clip="rect(0," + xs_BannerWidthPhysical + "," + xs_pHeightPhysical + ",0)";
               xs_pDiv.style.display="";
               xs_pDiv.style.top=xs_StartPositionTopBanner;
            }
            xs_endpt=(document.body.offsetWidth/2)-xs_BannerWidthMiddle;  
            xs_tuck();
         }//end if
      }//end if
   }
}//end function

function xs_pd(){
   var xs_pDiv = document.getElementById("xs_pDiv");
   var xs_pDiv2 = document.getElementById("xs_pDiv2");
   if (isGroupA)
   {
        xs_pDiv2.style.top = 115;
   }
   xs_ranonce=1;
   if (((xs_pHeightClipped<xs_pHeightPhysical)&&(xs_updown==0)) || ((xs_pHeightClipped>3)&&(xs_updown==1))) {
      //BRANCH: Movement
      if(xs_pHeightClipped==xs_pHeightPhysical){xs_pDiv.style.display=""}
      (xs_updown==0)?xs_pHeightClipped+=3:xs_pHeightClipped-=3;
      (xs_updown==0)?xs_MovePositionTop-=3:xs_MovePositionTop+=3;
      xs_pDiv.style.clip="rect(" + xs_pHeightClipped + ",auto," + xs_pHeightPhysical + ",auto)";
      xs_pDiv.style.top=xs_MovePositionTop;
      setTimeout("xs_pd();",20);
   }else{
      if (xs_updown==1){
         //BRANCH: All the way DOWN position
         xs_pDiv.style.clip="rect(0,auto," + xs_pHeightPhysical + ",auto)";//width of actual drop down
         xs_pDiv.style.top=xs_MovePositionTop;//this is the space from the top of the page to the top of the banner
         xs_updown=0;
         xs_pDiv2.style.display='';
         setTimeout("xs_pd();",4500);
      }else{
         //BRANCH: All the way UP position
         xs_pDiv.style.display='none';
         xs_pDivSeen = 1;
         xs_endpt=(document.body.offsetWidth/2)-xs_BannerWidthMiddle;
         xs_tuck();
      }
   }
}
function xs_tuck(){
   var xs_pDiv2 = document.getElementById("xs_pDiv2");
   if(xs_endpt<(document.body.offsetWidth-355)){
      xs_endpt+=5;
      xs_pDiv2.style.left=xs_endpt; 
      setTimeout("xs_tuck();",20);
   }else{
      xs_pTuck = 1
   }
}