// Obtain the style value of an element.
Function getstyle (ELEM, name ){
If (ELEM. Style [name]) {
Return ELEM. Style [name];
} Else if (ELEM. currentstyle ){
Return ELEM. currentstyle [name];
} Else if (document. defaultview & document. defaultview. getcomputedstyle ){
Name = Name. Replace (/([A-Z])/g, "-$1 ");
Name = Name. tolowercase ();
VaR S = Document. defaultview. getcomputedstyle (ELEM ,"");
Return S & S. getpropertyvalue (name );
} Else {
Return null
}
}
// Obtain the style value of an element.
Function getstyle (ELEM, name ){
If (ELEM. Style [name]) {
Return ELEM. Style [name];
} Else if (ELEM. currentstyle ){
Return ELEM. currentstyle [name];
} Else if (document. defaultview & document. defaultview. getcomputedstyle ){
Name = Name. Replace (/([A-Z])/g, "-$1 ");
Name = Name. tolowercase ();
VaR S = Document. defaultview. getcomputedstyle (ELEM ,"");
Return S & S. getpropertyvalue (name );
} Else {
Return null
}
}
// Obtain the X and Y coordinates of the element relative to the page.
Function pagex (ELEM ){
Return ELEM. offsetparent? (ELEM. offsetleft + pagex (ELEM. offsetparent): ELEM. offsetleft;
}
Function Pagey (ELEM ){
Return ELEM. offsetparent? (ELEM. offsettop + Pagey (ELEM. offsetparent): ELEM. offsettop;
}
// Obtain the X and Y coordinates of the element relative to the parent element.
Function parentx (ELEM ){
Return ELEM. parentnode = ELEM. offsetparent? ELEM. offsetleft: pagex (ELEM)-pagex (ELEM. parentnode );
}
Function parenty (ELEM ){
Return ELEM. parentnode = ELEM. offsetparent? ELEM. offsettop: Pagey (ELEM)-Pagey (ELEM. parentnode );
}
// Obtain the X and Y coordinates of the elements located using CSS.
Function posx (ELEM ){
Return parseint (getstyle (ELEM, "left "));
}
Function posy (ELEM ){
Return parseint (getstyle (ELEM, "TOP "));
}
// Set the element position.
Function setx (ELEM, POS ){
ELEM. style. Left = POS + "PX ";
}
Function sety (ELEM, POS ){
ELEM. style. Top = POS + "PX ";
}
// Add the X and Y coordinates of the elements.
Function addx (ELEM, POS ){
Set (ELEM, (posx (ELEM) + POS ));
}
Function Addy (ELEM, POS ){
Set (ELEM, (posy (ELEM) + POS ));
}
// Obtain the height and width of the element controlled by CSS.
Function getheight (ELEM ){
Return parseint (getstyle (ELEM, "height "));
}
Function getwidth (ELEM ){
Return parseint (getstyle (ELEM, "width "));
}
// Obtain the possible height and width of the element.
Function getfullheight (ELEM ){
If (getstyle (ELEM, "display ")! = "NONE "){
Return getheight (ELEM) | ELEM. offsetheight;
} Else {
VaR old = resetcss (ELEM, {display: "block", visibility: "hidden", position: "absolute "});
VaR H = ELEM. clientheight | getheight (ELEM );
Restorecss (ELEM, old );
Return h;
}
}
Function getfullwidth (ELEM ){
If (getstyle (ELEM, "display ")! = "NONE "){
Return getwidth (ELEM) | ELEM. offsetwidth;
} Else {
VaR old = resetcss (ELEM, {display: "block", visibility: "hidden", position: "absolute "});
VaR W = ELEM. clientwidth | getwidth (ELEM );
Restorecss (ELEM, old );
Return W;
}
}
// Set CSS and save the old CSS
Function resetcss (ELEM, Prop ){
VaR old = {};
For (var I in prop ){
Old [I] = ELEM. Style [I];
ELEM. Style [I] = prop [I];
}
Return old;
}
Function restorecss (ELEM, Prop ){
For (var I in prop ){
ELEM. Style [I] = prop [I];
}
}
// Display and hide
Function show (ELEM ){
ELEM. style. Display = ELEM. $ olddisplay | "";
}
Function hide (ELEM ){
VaR curdisplay = getstyle (ELEM, "display ");
If (curdisplay! = "NONE "){
ELEM. $ olddisplay = curdisplay;
ELEM. style. Display = "NONE ";
}
}
// Set transparency
Function setopacity (ELEM, num ){
If (ELEM. filters ){
ELEM. style. Filter = "alpha (opacity =" + num + ")";
} Else {
ELEM. style. Opacity = num/100;
}
}
// Slide
Function slidedown (ELEM ){
VaR H = getfullheight (ELEM );
ELEM. style. Height = "0px ";
Show (ELEM );
For (VAR I = 0; I <= 100; I + = 5 ){
New Function (){
VaR Pos = I;
SetTimeout (function () {ELEM. style. Height = (POS/100 x H) + "PX" ;}, (Pos * 10 ));
}
}
}
// Gradient
Function fadein (ELEM ){
Show (ELEM );
Setopacity (ELEM, 0 );
For (VAR I = 0; I <= 100; I + = 5 ){
New Function (){
VaR Pos = I;
SetTimeout (function () {setopacity (ELEM, POS) ;}, (Pos + 1) * 10 );
}
}
}
// Obtain the cursor position relative to the entire page.
Function getx (e ){
E = E | window. event;
Return e. pagex | E. clientx + document. Body. scrollleft;
}
Function Gety (e ){
E = E | window. event;
Return e. Pagey | E. clienty + document. Body. scrolltop;
}
// Obtain the cursor position relative to the current element.
Function getelementx (e ){
Return (E & E. layerx) | window. event. offsetx;
}
Function getelementy (e ){
Return (E & E. layery) | window. event. offsety;
}
// Obtain the page height and width
Function getpageheight (){
VaR demo-document.doc umentelement;
Return document. Body. scrollheight | (De & de. scrollheight );
}
Function getpagewidth (){
VaR demo-document.doc umentelement;
Return document. Body. scrollwidth | (De & de. scrollwidth );
}
// Obtain the position of the scroll bar.
Function scrollx (){
VaR demo-document.doc umentelement;
Return self. pagexoffset | (De & de. scrollleft) | document. Body. scrollleft;
}
Function scrolly (){
VaR demo-document.doc umentelement;
Return self. pageyoffset | (De & de. scrolltop) | document. Body. scrolltop;
}
// Obtain the height and width of the view.
Function compute wheight (){
VaR de = document.doc umentelement;
Return self. innerheight | (De & de. offsetheight) | document. Body. offsetheight;
}
Function compute wwidth (){
VaR de = document.doc umentelement;
Return self. innerwidth | (De & de. offsetwidth) | document. Body. offsetwidth;
}
Height: function (){
// Handle ie 6
If ($. browser. MSIE & $. browser. version <7 ){
VaR scrollheight = math. Max (
Document.doc umentelement. scrollheight,
Document. Body. scrollheight
);
VaR offsetheight = math. Max (
Document.doc umentelement. offsetheight,
Document. Body. offsetheight
);
If (scrollheight <offsetheight ){
Return $ (window). Height () + 'px ';
} Else {
Return scrollheight + 'px ';
}
// Handle "good" browsers
} Else {
Return $ (document). Height () + 'px ';
}
},
Width: function (){
// Handle ie 6
If ($. browser. MSIE & $. browser. version <7 ){
VaR scrollwidth = math. Max (
Document.doc umentelement. scrollwidth,
Document. Body. scrollwidth
);
VaR offsetwidth = math. Max (
Document.doc umentelement. offsetwidth,
Document. Body. offsetwidth
);
If (scrollwidth <offsetwidth ){
Return $ (window). Width () + 'px ';
} Else {
Return scrollwidth + 'px ';
}
// Handle "good" browsers
} Else {
Return $ (document). Width () + 'px ';
}
}