﻿function findPosX(obj)
{   
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function getW()
{
    var w;
    if (document.innerWidth)
    { 
        w=document.innerWidth;
    } 
    else if (document.documentElement.clientWidth)
    { 
        w=document.documentElement.clientWidth;
    } 
    else if (document.body)
    { 
        w=document.body.clientWidth; 
    }
    
    return w;
}

function getH()
{
    var h;
    if (document.innerHeight)
    { 
        h=document.innerHeight;
    } 
    else if (document.documentElement.clientHeight)
    { 
        h=document.documentElement.clientHeight;
    } 
    else if (document.body)
    { 
        h=document.body.clientHeight; 
    }
    
    return h;
}

function centeredObject(objC)
{
    var _cc = document.getElementById(objC);
    
    if (_cc)
    {
        _cc.style.left = (getW() - _cc.offsetWidth)/2 + (document.all==null ? "px":"");
        _cc.style.top  = (getH() - _cc.offsetHeight) / 3 + (document.all==null ? "px":"");
    }
}

function alignmentIFrame(parentContainer, myIFrame)
{
    var _i = document.getElementById(myIFrame);
    
    if (_i)
    {
        var _p = document.getElementById(parentContainer);
        _i.height = _p.offsetHeight;
    }
}