// Var temp = Document. getelementbyid ("test_2 ");
// Temp. style. Position = "absolute ";
// Temp. style. Top = pos. Y + "PX ";
// Temp. style. Left = pos. x + "PX ";
// Get the X and Y position of the object. The accept object does not receive the ID.
Function getelementpos (EL ){
VaR UA = navigator. useragent. tolowercase ();
VaR isopera = (UA. indexof ('Opera ')! =-1 );
VaR isie = (UA. indexof ('msie ')! =-1 &&! Isopera); // not opera Spoof
If (El. parentnode = NULL | El. style. Display = 'None '){
Return false;
}
VaR parent = NULL;
VaR Pos = [];
VaR box;
If (El. getboundingclientrect) {// IE
Box = El. getboundingclientrect ();
VaR scrolltop = math.max(document.doc umentelement. scrolltop, document. Body. scrolltop );
VaR scrollleft = math.max(document.doc umentelement. scrollleft, document. Body. scrollleft );
Return {X: box. Left + scrollleft, Y: box. Top + scrolltop };
} Else if (document. getboxobjectfor) {// Gecko
Box = Document. getboxobjectfor (EL );
VaR borderleft = (El. style. borderleftwidth )? Parseint (El. style. borderleftwidth): 0;
VaR bordertop = (El. style. bordertopwidth )? Parseint (El. style. bordertopwidth): 0;
Pos = [box. X-borderleft, box. Y-bordertop];
} Else {// safari & Opera
Pos = [El. offsetleft, El. offsettop];
Parent = El. offsetparent;
If (parent! = El ){
While (parent ){
Pos [0] + = parent. offsetleft;
Pos [1] + = parent. offsettop;
Parent = parent. offsetparent;
}
}
If (UA. indexof ('Opera ')! =-1 | (UA. indexof ('safari ')! =-1 & El. style. Position = 'absolute ')){
Pos [0]-= Document. Body. offsetleft;
Pos [1]-= Document. Body. offsettop;
}
}
If (El. parentnode) {parent = El. parentnode ;}
Else {parent = NULL ;}
While (parent & parent. tagname! = 'Body' & parent. tagname! = 'Html ') {// account for any scrolled ancestors
Pos [0]-= parent. scrollleft;
Pos [1]-= parent. scrolltop;
If (parent. parentnode) {parent = parent. parentnode ;}
Else {parent = NULL ;}
}
Return {X: POS [0], Y: POS [1]};
}