//*** This code is copyright 2002-2003 by Gavin Kistner and Refinery Inc.; www.refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
//*** Reuse or modification is free provided you abide by the terms of that license.
//*** (Including the first two lines above in your source code satisfies the conditions.)


// Find the x,y location in pixels for a relatively positioned object
// returns an object with .x and .y properties.
function FindXY(obj){
    //alert(obj);
	var x=0,y=0;
	
	var temp = new Object;
	//alert(obj +' '+ temp)
	while (obj!=null){
	    if(!isNaN(parseInt(obj.offsetLeft)))  {
	       x+= parseInt(obj.offsetLeft);
	    }
	    if(!isNaN(parseInt(obj.scrollLeft)))  {
	        x-=parseInt(obj.scrollLeft);
	    }
		if(!isNaN(parseInt(obj.offsetTop)))  {
	       y+= parseInt(obj.offsetTop);
	    }
	    if(!isNaN(parseInt(obj.scrollTop)))  {
	        y-=parseInt(obj.scrollTop);
	    }
	    
		obj=obj.offsetParent;
	}
	///alert(x);
	//alert(y);
	if (is_mac && is_ie5up ) {
	    x += parseInt( "0" + document.body.currentStyle.marginLeft, 10  );
	    y += parseInt( "0" + document.body.currentStyle.marginTop, 10  );      
	}
	 
	temp.x = x;
	temp.y = y;
	return temp;
}

// Find the x,y location in pixels for a relatively positioned object
// returns an object with .x, .y, .w (width) and .h (height) properties.
function FindXYWH(obj){
	var objXY = FindXY(obj);
	var w= 0;
	var h = 0;
	if (obj!=null) {
	     if(!isNaN(parseInt(obj.offsetWidth)))  {
	         w = parseInt(obj.offsetWidth);
	     }
	     if(!isNaN(parseInt(obj.offsetHeight)))  {
	         h = parseInt(obj.offsetHeight);
	     }

	}
	objXY.w =w;
	objXY.h =h;
	return objXY;
}
