// GetWindow.js 1.0 9/26/2007 by J. Bradley Reck
// Reposition image and get window information functions.

// is this IE or Netscape conpatable
var ie=document.all;
var ns6=document.getElementById && !document.all;

function ietruebody(){
  return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
// return the window width
function getWindowX() {
  var wind_width = ie&&!window.opera? ietruebody().clientWidth : window.innerWidth;
return wind_width;
}


// return the window height
function getWindowY() {
  var wind_height = ie&&!window.opera? ietruebody().clientHeight : window.innerHeight;
return wind_height;
}

// get the image size by id
function getImageSize(id) {
  var pic;
  if ( document.getElementById ) {
       pic = document.getElementById(id);
  } else if ( document.layers ) {
       pic = document.layers[id];
   } else if ( document.all ) {
       pic = document.all.item(id);
}

  var Y = pic.offsetHeight;
  var X = pic.offsetWidth;
  var diment = new Array(X,Y);

	if ( ! pic.style )
	{
		py = pic.top;
		px = pic.left;
	}
	else
	{
		py = pic.style.top;
		px = pic.style.left;
	}

return diment;
}

// reposition the object by id
function reposit(id, itemXY, WindXY, PosXY ) {
// item id, item size(x,y), Window size(x,y), window offset(x,y) (from Upper Right)
    var item_X = itemXY[0];
    var item_Y = itemXY[1];
    var w_X = WindXY[0];
    var w_Y = WindXY[1];
    var P_X = PosXY[0];
    var P_Y = PosXY[1];
    //var NX = w_X - (item_X + P_X);
    //var NY = w_Y - (item_Y + P_Y);
	var NX = (w_X - item_X) - P_X;
	var NY = P_Y; 

if ( document.getElementById ) {
        itemid = document.getElementById(id);
   } else if ( document.layers ) {
        itemid = document.layers[id];
   } else if ( document.all ) {
        itemid = document.all.item(id);
   }

	moveObjTo(itemid, NX, NY);

}

function moveObjTo( obj, x, y )
{
	if ( ! obj.style )
	{
		obj.top = y;
		obj.left = x;
	}
	else
	{
		obj.style.top = y + "px";
		obj.style.left = x + "px";
	}
}

function writeit(text,id){	if (document.getElementById)	{		x = document.getElementById(id);		x.innerHTML = '';		x.innerHTML = text;	}	else if (document.all)	{		x = document.all[id];		x.innerHTML = text;	}	else if (document.layers)	{		x = document.layers[id];		text2 = '<P CLASS="testclass">' + text + '</P>';		x.document.open();		x.document.write(text2);		x.document.close();	}}
