//Gets the style value of the 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
}
}
//Gets the x and y coordinates of the element relative to this 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;
}
//Gets 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);
}
//Gets the x and y coordinates of elements that are positioned using CSS.
function PosX (elem) {
Return parseint (GetStyle (Elem, "left");
}
function PosY (elem) {
Return parseint (GetStyle (Elem, "top");
}
//Set element position.
function SetX (elem,pos) {
elem.style.left=pos+ "px";
}
function Sety (elem,pos) {
elem.style.top=pos+ "px";
}
//add element x and y coordinates.
function Addx (elem,pos) {
Set (Elem, (PosX (elem) +pos));
}
function AddY (elem,pos) {
Set (Elem, (PosY (elem) +pos));
}
//Get elements using CSS to control the height and width of the size
function GetHeight (elem) {
Return parseint (GetStyle (elem, "height"));
}
function GetWidth (elem) {
Return parseint (GetStyle (Elem, "width"));
}
//Get element possible, full height and width
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];
}
}
//Show 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;
}
}
//Sliding
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*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);
}
}
}
//Gets the position of the mouse cursor 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;
}
//Gets the position of the mouse cursor 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;
}
//Gets the height and width of the page
function Getpageheight () {
var de=document.documentelement;
return Document.body.scrollheight| | (De&&de.scrollheight);
}
function Getpagewidth () {
var de=document.documentelement;
return document.body.scrollwidth| | (De&&de.scrollwidth);
}
//Gets the position of the scroll bar.
function Scrollx () {
var de=document.documentelement;
return self.pagexoffset| | (De&&de.scrollleft) | | Document.body.scrollLeft;
}
function scrolly () {
var de=document.documentelement;
return self.pageyoffset| | (de&&de.scrolltop) | | Document.body.scrollTop;
}
//Gets the height and width of the viewport.
function windowheight () {
var de = document.documentelement;
return self.innerheight| | (de && de.offsetheight) | | Document.body.offsetHeight;
function windowwidth () {
var de = Document.documentelement;
return self.innerwidth| | (de && de.offsetwidth) | | Document.body.offsetWidth;
JavaScript Common functions