//JS Document

function getSize() {
	
	// Window Size

    if (self.innerHeight) { // Everyone but IE
    	myWidth = window.innerWidth;
    	myHeight = window.innerHeight;
    	myScroll = window.pageYOffset;
    } else if (document.documentElement && document.documentElement.clientHeight) { // IE6 Strict
    	myWidth = document.documentElement.clientWidth;
    	myHeight = document.documentElement.clientHeight;
    	myScroll = document.documentElement.scrollTop;
    } else if (document.body) { // Other IE, such as IE7
    	myWidth = document.body.clientWidth;
    	myHeight = document.body.clientHeight;
    	myScroll = document.body.scrollTop;
    }

    // Page size w/offscreen areas

    if (window.innerHeight && window.scrollMaxY) {	
    	myScrollWidth = document.body.scrollWidth;
    	myScrollHeight = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac
    	myScrollWidth = document.body.scrollWidth;
    	myScrollHeight = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    	myScrollWidth = document.body.offsetWidth;
    	myScrollHeight = document.body.offsetHeight;
    }
}
	
function findPosX(obj) {
  var curleft = 0;
  if(obj.offsetParent)
      while(1) {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}

function findPosY(obj) {
  var curtop = 0;
  if(obj.offsetParent)
      while(1) {
        curtop += obj.offsetTop;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}

function clearDrop() {
	alert('Clearing')
    var inBody = document.getElementsByTagName('body').item(0);
    var sDrop = $('sDrop');
    inBody.removeChild(sDrop);

}

function searchDrop() {
		
    var inBody = document.getElementsByTagName('body').item(0);

    var sDrop = document.createElement("div");
    sDrop.setAttribute('id', 'sDrop');
    sDrop.className = 'searchDrop';
    inBody.appendChild(sDrop);
    adjustSearchSpot();

}

function adjustSearchSpot() {
    
    getSize();
    $('sDrop').style.left = (findPosX($('eDrop')) - 67)+'px';
    $('sDrop').style.top = (findPosY($('eDrop')) + 18)+'px';
    setTimeout("adjustSearchSpot()", 20);
}

function inputFocus(id, def) {
	if ($(id).value == def) {
		$(id).value = '';
	}
}

function inputBlur(id, def) {
	if (($(id).value == '') || ($(id).value == def)) {
		$(id).value = def;
		//$(id).className = '';
	} else {
		//$(id).className = 'set';
	}
}

function preloadImages(ar) {
	if (document.images) {
		for(var i = 0; i < ar.length; i++) {
			pic = new Image(); 
	  		pic.src = ar[i]; 	
		}
	}
}
