var width;  // Change the # value with the size of the ad also leave buffer space so the window doesn't chase the ad
var height;   // Change the # value with the size of the ad also leave buffer space so the window doesn't chase the ad

var x1;
var y1;

var position;

(document.getElementById && !document.all) ? dom = true : dom = false;

function typeStart(x,y,id,pos) {
  width = x;
  height = y;
  position = pos;
  if(pos == 'left') {
    x1 = 0;
    y1 = getHeight() - height;
  } else {
    x1 = getWidth() - width;
    y1 = getHeight() - height;
  }
  if (dom) {
    document.write('<div id="logoBox" style="position:absolute; left:' + (window.innerWidth-x1) + 'px; visibility:visible">') }
  if (document.all) {
    document.write('<div id="logoBox" style="position:absolute; left:' + (document.documentElement.clientWidth-x1) + 'px; visibility:visible">') }
 }

function typeEnd() {
  if (document.all || dom) { document.write('</div>') }
 }

function placeIt() {
  if (dom) {document.getElementById("logoBox").style.top = window.pageYOffset + y1 + "px"; document.getElementById("logoBox").style.left = window.pageXOffset + x1 + "px";}
  if (document.all) {document.all["logoBox"].style.top = document.documentElement.scrollTop + y1 + "px"; document.all["logoBox"].style.left = document.documentElement.scrollLeft + x1 + "px";}
  window.setTimeout("placeIt()", 10);
 }

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
  placeIt();
});

function resizeWindow() {
  if(position == 'left') {
    x1 = 0;
    y1 = getHeight() - height;
  } else {
    x1 = getWidth() - width;
    y1 = getHeight() - height;
  }
	placeIt();
}

function getHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function getWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}