//================================================================
// Find the x &/or y position of an element
//================================================================
function findPos(obj, which)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	if (which == 'left') {
		return [curleft];
	} else {
		return [curtop];
	}
}

//================================================================
// Dynamically create a div
// e.g. Usage: creatediv(id, html, width, height, left, top)
//================================================================
function creatediv(id, html, width, height, left, top, zindex) {

   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', id);
   
   style = 'position: absolute;';
   if (zindex) style += 'z-index: '+ zindex +';' ;
   if (left) style += 'Left: '+ left +'px;' ;
   if (top) style += 'Top: '+ top +'px;' ;
   
   
   newdiv.setAttribute('style', style);
   
   if (html) {
       newdiv.innerHTML = html;
   } else {
       newdiv.innerHTML = '';
   }
   
   //newdiv.style.background = "#FFFFFF";
   //newdiv.style.border = '1px solid black';
   
   //newdiv.style.visibility = visibility;
   document.body.appendChild(newdiv);

} 

function findPageDimensions (which) {
  var myWidth = 0;
  var myHeight = 0;

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  if (which == 'height') return myHeight;
  if (which == 'width') return myWidth;
  
}