var dropboxleft=400
var dropboxtop=100
var dropspeed=10
var dropwait=300000
if(typeof(cscontrol) != 'undefined' && iamhome == true)
  dropwait = 30000

var displaymode="oncepersession" //always|oncepersession|#(1/# times)
if (parseInt(displaymode)!=NaN)
var random_num=Math.floor(Math.random()*displaymode)
var ie=document.all
var dom=document.getElementById
function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
function xClientHeight()
{
  var v=0,d=document,w=window;
  if((!d.compatMode || d.compatMode == 'CSS1Compat') && !w.opera && d.documentElement && d.documentElement.clientHeight)
    {v=d.documentElement.clientHeight;}
  else if(d.body && d.body.clientHeight)
    {v=d.body.clientHeight;}
  else if(xDef(w.innerWidth,w.innerHeight,d.width)) {
    v=w.innerHeight;
    if(d.width>w.innerWidth) v-=16;
  }
  return v;
}

function xClientWidth()
{
  var v=0,d=document,w=window;
  if(d.compatMode == 'CSS1Compat' && !w.opera && d.documentElement && d.documentElement.clientWidth)
    {v=d.documentElement.clientWidth;}
  else if(d.body && d.body.clientWidth)
    {v=d.body.clientWidth;}
  else if(xDef(w.innerWidth,w.innerHeight,d.height)) {
    v=w.innerWidth;
    if(d.height>w.innerHeight) v-=16;
  }
  return v;
}
function ei(a_szId)
{ if(a_szId == null)
{ return null;}
if('string' != typeof(a_szId))
{ return a_szId;}
if(document.getElementById && document.getElementById(a_szId))
{ return document.getElementById(a_szId);}
else if (document.all && document.all(a_szId))
{ return document.all(a_szId);}
else if (document.layers && document.layers[a_szId])
{ return document.layers[a_szId];}
else
{ return null;}
}
function initboxv2(){
if(xGetCookie("droppedinv2")=='')
{
   xSetCookie('droppedinv2','yes');
}
if (!dom&&!ie)
return
crossboxcover=ei('dropinboxv2cover')
if(!crossboxcover)
{
 alert('dropinboxv2cover not found');
 return;
}
crossbox=ei('dropinboxv2')
if(!crossbox)
{
alert('dropinboxv2 not found');
return;
}

scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossbox.height=crossbox.offsetHeight
crossboxcover.style.height=parseInt(crossbox.height)+"px"
crossbox.style.top=crossbox.height*(-1)+"px"
crossboxcover.style.top=(xClientHeight()/2)-(crossbox.offsetHeight/2)+"px"
crossboxcover.style.left=(xClientWidth()/2)-(crossbox.offsetWidth/2)+"px"
crossboxcover.style.top=dropboxtop+"px"
crossboxcover.style.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropinv2()",50)
}

function dropinv2(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossbox.style.top)<0){
crossboxcover.style.top=scroll_top+dropboxtop+"px"
crossbox.style.top=parseInt(crossbox.style.top)+dropspeed+"px"
}
else{
clearInterval(dropstart)
crossbox.style.top=0
}
}

function dismissboxv2(){
if (window.dropstart) clearInterval(dropstart)
crossboxcover.style.visibility="hidden"
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function xSetCookie(name, value, expire, path)
{
  document.cookie = name + "=" + escape(value) +
                    ((!expire) ? "" : ("; expires=" + expire.toGMTString())) +
                    "; path=" + ((!path) ? "/" : path);
}

function xGetCookie(name)
{
  var value='', search=name+"=";
  if (document.cookie.length > 0) {
    var offset = document.cookie.indexOf(search);
    if (offset != -1) {
      offset += search.length;
      var end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      value = unescape(document.cookie.substring(offset, end));
    }
  }
  return value;
}

if ((displaymode=="oncepersession" && xGetCookie("droppedinv2")=='') || displaymode=="always" || (parseInt(displaymode)!=NaN && random_num==0))
{
   window.setTimeout('initboxv2()', dropwait)
}

function isEmailValid(a_oInput)
{ var szValue = a_oInput.value; if(0 == szValue.toLowerCase().search(/^[a-z0-9]+[a-z0-9._-]*@((([a-z0-9][a-z0-9-]*[a-z0-9][.])*([a-z][a-z0-9-]*[a-z0-9][.])+[a-z]{2,6})|(([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})))$/) )

{ return true;}

return false;}

function validateForm(a_oe)
{
for(i in a_oe.elements)
{
if('text'==a_oe.elements[i].type && ''==a_oe.elements[i].value)
{
alert('Please enter your '+a_oe.elements[i].id+' before submitting.')
return false;         
}
if('email'==a_oe.elements[i].id || 'Email1'==a_oe.elements[i].id)
{
   if(false == isEmailValid(a_oe.elements[i]))
   {
      alert('Please enter a valid email address before submitting.');
      return false;
   }
}

}

var now = new Date();
var expireDate = new Date(now.getTime() + (365*86400000));
xSetCookie('droppedinv2','yes', expireDate);

return true;
}

