var xc_name='';
var xc_city='';
var xc_st='';
var xscratch1='';
var xscratch2='';
var xclientid='';
var xURL = "http://thevdex.com/";
var player=null;     
var doDone='';                                                                            
var xtra=0;
var cur_opacity=0;
var end_opacity=50;
increase_opacity_by=2;
adblock_timeout=100;

var home1 = new Image(140,39);
home1.src = 'images/homegrey.jpg';
var home2 = new Image(140,39);
home2.src = 'images/homered.jpg';
var search1 = new Image(140,39);
search1.src = 'images/gsearchbut.jpg';
var search2 = new Image(140,39);
search2.src = 'images/rsearchbut.jpg';
var getstarted1 = new Image(140,39);
getstarted1.src = 'images/ggetstarted.jpg';
var getstarted2 = new Image(140,39);
getstarted2.src = 'images/rgetstarted.jpg';
var busown1 = new Image(140,39);
busown1.src = 'images/gbusown.jpg';
var busown2 = new Image(140,39);
busown2.src = 'images/rbusown.jpg';
var vdexopp1 = new Image(140,39);
vdexopp1.src = 'images/gopportunities.jpg';
var vdexopp2 = new Image(140,39);
vdexopp2.src = 'images/ropportunities.jpg';
var contact1 = new Image(140,39);
contact1.src = 'images/gcontact.jpg';
var  contact2 = new Image(140,39);
contact2.src = 'images/rcontact.jpg';

function mouseOn(lk) {
  imageOn = eval(lk + "2.src");
  a=document.getElementById(lk);
  a.src = imageOn;
}
function mouseOff(lk) {
  imageOff = eval(lk + "1.src");
  a-document.getElementById(lk);
  a.src = imageOff;
}

function doOver() {
var thisPage ="http://thevdex.com/" + self.location.pathname;
top.location = thisPage;
window.location.reload();
}

function getAbsX(elt) {
  return parseInt(elt.x) ? elt.x: getAbsPos(elt,"Left");
}

function getAbsY(elt) {
  return parseInt(elt.y) ? elt.y: getAbsPos(elt,"Top");
}

function getAbsPos(elt,which) {
  iPos = 0;
  while (elt != null) {
    iPos += elt["offset" + which];
    elt = elt.offsetParent;
  }
  return iPos;
}

function pageWidth() {return window.innerwidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth: null;}

function pageHeight() {return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;}

function doSize() {
/*
  if (doDone !='Y') {
  pwidth=pageWidth();
  pheight=pageHeight();
  if (c=document.getElementById('mycustomscroll')) {
  }else{
    c=document.getElementById('textscroller');
  }
    mcs=pwidth-370;
    if (pwidth >= 1200) {
     mcs=mcs-520;
    }else if (pwidth >= 1000) {
     mcs=mcs-400;
    }else{
     mcs=mcs-280;
    }
    if (mcs > 400) {
      xtra=mcs-400;
      mcs=400;
    }
    c.style.width=mcs+'px';
//  window.resizeBy(0,0);
if (ie >= 1) {
}else{
window.onresize=doOver;
}


  hgt = pageHeight();
  hgt = hgt -32;
  if (hgt <= 650) {
    ft=650;
    hgt=620;
  }else{
    ft=hgt;
  }
  c=document.getElementById('footer');
  c.style["top"]=ft + 'px';
  hgt = hgt - 205;
  c=document.getElementById('sidebar1');
  c.style.height=hgt + 'px';
  c=document.getElementById('sidebar2');
  c.style.height=hgt + 'px';
  c=document.getElementById('mainContent');
  c.style.height=hgt + 'px';
  if (hgt > 400) {
    if(c=document.getElementById('lpic4')) {
      c.style.visibility='visible';
    }
    if (c=document.getElementById('rpic4')) {
      c.style.visibility='visible';
    }
  }
  if (hgt > 520) {
    if (c=document.getElementById('lpic5')) {
      c.style.visibility='visible';
    }
    if (c=document.getElementById('rpic5')) {
      c.style.visibility='visible';
    }
  }

  c=document.getElementById('sidebar2');
  d=getAbsPos(c,"Left");
  e=c.offsetWidth;
  cc=document.getElementById('measure');
  dd=getAbsPos(cc,"Left");
  mLeft = dd-162;
  f=d-(dd+30);
  if (g=document.getElementById('adblock')) {
  if (f >= 100) {
//    g.style.visibility='visible';
    g.style.left=mLeft + 'px';
    g.style.width=f + 'px';
    if (adblock_timeout >0) {
      cur_opacity=0;
      g.style.opacity = cur_opacity / 100;
      g.style.filter = "alpha(opacity=" + cur_opacity + ")";
      timer = setTimeout("increase_opacity()",adblock_timeout);
    }else{
      g.style.opacity - end_opacity /100;
      g.style.filter = "alpha(opacity=" + end_opacity + ")";;
    }
//    g.style.width=f + 'px';
//    g.style.visibility='visible';
  }
  }
  }
  doDone='Y';
*/
}

function increase_opacity() { 
  g=document.getElementById('adblock');
  cur_opacity += increase_opacity_by;
  g.style.opacity = cur_opacity / 100;
  g.style.filter = "alpha(opacity=" + cur_opacity + ")";
  if (cur_opacity < end_opacity) {
    timer = setTimeout("increase_opacity()",adblock_timeout);
  }
}

function playerReady(obj) {
    player =  document.getElementById(obj.id);
    player.addModelListener('STATE', 'stateMonitor');
}

function stateMonitor(obj) {
  a=obj.newstate;
  if (obj.newstate == 'PAUSED' || obj.newstate == 'COMPLETED' || obj.newstate == 'IDLE') {
    if (ie) {
      setTimeout('scrollOn()',500);
    }else{
      scrollOn();
    }
  }else{
    copyspeed=0;
    slidespeed=0;
  }
}


function scrollOn() {
  copyspeed=1;
  slidespeed=1;
}

function scrollOff() {
  copyspeed=0;
  slidespeed=0;
}


function procRequest (prog,module,data,typ) {
        prog = prog + ".php";
        xurl = xURL + prog;
        if (typ == 1) {
          xdataout = data.value;
        }else{
          xdataout = data;
        }

        xurl = xurl + "?m=" + module + "&d=" + xdataout;
        // Create new JS element
        var xjsel = document.createElement('SCRIPT');
        xjsel.type = 'text/javascript';
        xjsel.src = xurl;

        // Append JS element (therefore executing the 'AJAX' type call)
        document.body.appendChild (xjsel);
}
function addScratch1(c) {
  xscratch1=c;
}
function addScratch2(c) {
  xscratch2=c;
}
function addCname(c) {
  xc_name=c;
}
function addCcity(c) {
  xc_city=c;
}
function addCst(c) {
  xc_st=c;
} 
function doProc (prog,module,data,typ) {
        prog = prog + ".php";
        xurl = xURL + prog;

        xd=clientid + "|" + xscratch1 + "|" + xscratch2 + "|" + xc_name + "|" + xc_city + "|" + xc_st;
                                                                                
        xurl = xurl + "?m=" + module + "&d=" + xd;
                                                                                
        // Create new JS element
        var xjsel = document.createElement('SCRIPT');
        xjsel.type = 'text/javascript';
        xjsel.src = xurl;
                                                                                
        // Append JS element (therefore executing the 'AJAX' type call)
        document.body.appendChild (xjsel);
}

function animate(elementID, newLeft, newTop, newWidth,
      newHeight, time, callback)
{
  var el = document.getElementById(elementID);
  if(el == null)
    return;
                                                                                          
  var cLeft = parseInt(el.style.left);
  var cTop = parseInt(el.style.top);
  var cWidth = parseInt(el.style.width);
  var cHeight = parseInt(el.style.height);
                                                                                          
  var totalFrames = 1;
  if(time> 0)
    totalFrames = time/40;
                                                                                          
  var fLeft = newLeft - cLeft;
  if(fLeft != 0)
    fLeft /= totalFrames;
                                                                                          
  var fTop = newTop - cTop;
  if(fTop != 0)
    fTop /= totalFrames;
                                                                                          
  var fWidth = newWidth - cWidth;
  if(fWidth != 0)
    fWidth /= totalFrames;
                                                                                          
  var fHeight = newHeight - cHeight;
  if(fHeight != 0)
    fHeight /= totalFrames;
                                                                                          
  doFrame(elementID, cLeft, newLeft, fLeft,
      cTop, newTop, fTop, cWidth, newWidth, fWidth,
      cHeight, newHeight, fHeight, callback);
}

function doFrame(eID, cLeft, nLeft, fLeft,
      cTop, nTop, fTop, cWidth, nWidth, fWidth,
      cHeight, nHeight, fHeight, callback)
{
   var el = document.getElementById(eID);
   if(el == null)
     return;
                                                                                          
  cLeft = moveSingleVal(cLeft, nLeft, fLeft);
  cTop = moveSingleVal(cTop, nTop, fTop);
  cWidth = moveSingleVal(cWidth, nWidth, fWidth);
  cHeight = moveSingleVal(cHeight, nHeight, fHeight);
                                                                                          
  el.style.left = Math.round(cLeft) + 'px';
  el.style.top = Math.round(cTop) + 'px';
  el.style.width = Math.round(cWidth) + 'px';
  el.style.height = Math.round(cHeight) + 'px';
                                                                                          
  if(cLeft == nLeft && cTop == nTop && cHeight == nHeight
    && cWidth == nWidth)
  {
    if(callback != null)
      callback();
    return;
  }
                                                                                          
  setTimeout( 'doFrame("'+eID+'",'+cLeft+','+nLeft+','+fLeft+','
    +cTop+','+nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+','
    +cHeight+','+nHeight+','+fHeight+','+callback+')', 40);
}
                                                                                          
function moveSingleVal(currentVal, finalVal, frameAmt)
{
  if(frameAmt == 0 || currentVal == finalVal)
    return finalVal;
                                                                                          
  currentVal += frameAmt;
  if((frameAmt> 0 && currentVal>= finalVal)
    || (frameAmt <0 && currentVal <= finalVal))
  {
    return finalVal;
  }
  return currentVal;
}

