  function findPos(el) {
        x = 0; y = 0; var temp
        if(el.offsetParent) {
              temp = el
              while(temp.offsetParent) {
                    temp = temp.offsetParent;
                    x += temp.offsetLeft
                    y += temp.offsetTop;
              }
        }
        x += el.offsetLeft
        y += el.offsetTop
        w = el.offsetWidth;// ? el.offsetWidth : parseInt(el.style.width);
        h = el.offsetHeight;// ? el.offsetHeight : parseInt(el.style.height);
        return [x, y, w, h]
  }

function defValue(e) {
  tmpVar = '';
  var tmpVar = this.getAttribute('dv');
  if(!tmpVar)tmpVar = this.dv;
  if(tmpVar) {
    var cn = this.className;
    if(cn.indexOf(' a') != -1) cn = cn.substring(0, cn.indexOf(' a'));
    if(e.type == 'focus') {
      this.className = cn + ' a';
      if(this.value == tmpVar) this.value = '';
    }
    if(e.type == 'blur') {
      if(this.value == '') {
        this.value = tmpVar;
        this.className = cn;
      }
    }
  }
}

function initDefaultValues() {
  var inpArr = ['INPUT', 'TEXTAREA']
  for(var t in inpArr) {
    var inp = document.getElementsByTagName(inpArr[t]);
  for(var i = 0; i < inp.length; i++) {
    tmpVar = null;
    var tmpVar = inp[i].getAttribute('dv');
    if(!tmpVar)tmpVar = inp[i].dv;
    if(tmpVar) {
      tagAddEvent(inp[i], 'focus', defValue);
      tagAddEvent(inp[i], 'blur', defValue);
      if(inp[i].value == '') inp[i].value = tmpVar;
    }
  }
  }
}

function tagAddEvent(whichObject, eventType, functionName) { 
  if(whichObject.attachEvent) {
    whichObject['e' + eventType + functionName] = functionName; 
    whichObject[eventType + functionName] = function(){whichObject['e' + eventType + functionName]( window.event );} 
		whichObject.attachEvent('on' + eventType, whichObject[eventType + functionName]);
  } else {
    whichObject.addEventListener(eventType, functionName, false);
  } 	    
} 

function imageSwap(obj, tag, wait) {
  this.obj = obj;
  this.tag = tag;
  this.wait = wait ? wait : 5000;
  this.imageArr = [];
  this.img = 0;
  this.opened = 0;
  this.timeOut = null;
  this.alpha = 0;
  this.holder = [];
  this.h = 1;  
}

imageSwap.prototype.init = function() {
  this.tag = document.getElementById(this.tag);
  for(var i = 1; i <= 2; i++) {
    var div = document.createElement('DIV');
    div.style.position = 'relative';
    if(i == 2) {
      div.style.marginTop = -this.tag.offsetHeight + 'px';
      div.style.visibility = 'hidden';
    }
    this.tag.appendChild(div);
    this.holder[i] = div;
  }
  this.timeOut = setTimeout(this.obj + '.nextImage()', this.wait);
}

imageSwap.prototype.nextImage = function() {
  clearTimeout(this.timeOut);
  this.img++;
  if(!this.imageArr[this.img]) this.img = 0;
  this.h = this.h == 1 ? 2 : 1;
  var tmpImage = new Image();
  tmpImage.obj = this.obj;
  tmpImage.onload = function() {
    tmpImage.onload = null;
    eval(this.obj + '.imageLoaded()');
  }
  tmpImage.src = this.imageArr[this.img];
}

imageSwap.prototype.imageLoaded = function() {
  this.holder[this.h].style.backgroundImage = "url('" + this.imageArr[this.img] + "')";
  this.holder[this.h].style.visibility = 'visible';
  this.holder[this.h].style.opacity = 0;
  this.holder[this.h].style.filter = 'alpha(opacity:0)';
  this.holder[this.h].style.zIndex = 100;
  this.holder[this.h == 1 ? 2 : 1].style.zIndex = 99;
  this.swapImage();
}

imageSwap.prototype.swapImage = function() {
  this.alpha += 10;
  this.holder[this.h].style.opacity = this.alpha / 100;
  this.holder[this.h].style.filter = 'alpha(opacity:' + this.alpha +')';
  if(this.alpha < 100) {
    this.timeOut = setTimeout(this.obj + '.swapImage()', 50);
  } else {
    this.alpha = 0;
    this.timeOut = setTimeout(this.obj + '.nextImage()', this.wait);
  }           
}

function flashHeight(h) {
  document.getElementById('banner').style.height = h + 'px';
}

function check(obj) {
  var inp = obj.getElementsByTagName('INPUT')[0];
  inp.value = inp.value == '1' ? '0' : '1';
  obj.className = 'check' + (inp.value == '1' ? ' on' : '');
}

