var eqCounter = 0;

function EqualColumns()
{
	this.eqa = 0;
	this.eqth = 0;
	this.eqtw = 0;

	var c, e, el;
    if (document.getElementById)
    {
        this.blocks = new Array();
        for (i = 0; i < arguments.length; i += 2)
        {
            el = null;
            c = document.getElementById(arguments[i]);
            if (c)
            {
                e = c.getElementsByTagName(arguments[i+1]);
                if (e)
                {
                    el = e[e.length-1];
                    if (!el.id)
                    {
                        el.id = "myeq" + (eqCounter++);
                    }
                }
            }
            if (c && el)
            {
                this.blocks.push(c);
                this.blocks.push(el);
            }
        }
        //setInterval("P7_eqT2()",10);
		this.startCalculate();
    }
}

EqualColumns.prototype.startCalculate = function() {
    if (this.eqth != document.body.offsetHeight || this.eqtw != document.body.offsetWidth)
    {
        this._startCalculate();
    }
}

EqualColumns.prototype._startCalculate = function() {
    var i, oh, h = 0, tg, el, np, dA = this.blocks, an = this.eqa;
    if (dA && dA.length)
    {
        for (i = 0; i < dA.length; i += 2)
        {
            dA[i+1].style.paddingBottom = '';
        }
        for (i = 0; i < dA.length; i += 2)
        {
            //oh = dA[i].clientHeight;        
            oh = dA[i].offsetHeight;
            oh = dA[i].offsetHeight;
//alert("begin=" + oh)
            h = (oh > h) ? oh : h;
        }
//alert("max=" + h)
        for (i = 0; i < dA.length; i += 2)
        {
            //oh = dA[i].clientHeight;        
            oh = dA[i].offsetHeight;
            oh = dA[i].offsetHeight;
//alert("end=" + oh)
//alert("need=" + (oh < h))
            if (oh < h)
            {
                np = h - oh;
//alert("raz=" + np)
		dA[i+1].style.paddingBottom = np + "px";
            }
        }
        this.eqa = 1;
        this.eqth = document.body.offsetHeight;
        this.eqtw = document.body.offsetWidth;
    }
}

var eqCounterBtoomLn = 0;
function EqualColumnsBottomLine()
{
	this.eqa = 0;
	this.eqth = 0;
	this.eqtw = 0;

	var c, e, el;
    if (document.getElementById)
    {
        this.blocks = new Array();
        for (i = 0; i < arguments.length; i += 2)
        {
            el = null;
            c = document.getElementById(arguments[i]);
            if (c)
            {
                e = c.getElementsByTagName(arguments[i+1]);
                if (e)
                {
                    el = e[e.length-1];
                    if (!el.id)
                    {
                        el.id = "myeqbt" + (eqCounterBtoomLn++);
                    }
                }
            }
            if (c && el)
            {
                this.blocks.push(c);
                this.blocks.push(el);
            }
        }
        //setInterval("P7_eqT2()",10);
		this.startCalculate();
    }
}

EqualColumnsBottomLine.prototype.startCalculate = function() {
    if (this.eqth != document.body.offsetHeight || this.eqtw != document.body.offsetWidth)
    {
        this._startCalculate();
    }
}

EqualColumnsBottomLine.prototype._startCalculate = function() {
    var i, oh, h = 0, tg, el, np, dA = this.blocks, an = this.eqa;
    if (dA && dA.length)
    {
        for (i = 0; i < dA.length; i += 2)
        {
            dA[i+1].style.paddingBottom = '';
        }
        for (i = 0; i < dA.length; i += 2)
        {
            var posTop = getElementPosition(dA[i]);
            var mrBottom = parseInt(dA[i].style.marginBottom);
            if (isNaN(mrBottom)) mrBottom = 0;
            oh = posTop.top + dA[i].clientHeight - mrBottom;
            h = (oh > h) ? oh : h;
        }
        
        for (i = 0; i < dA.length; i += 2)
        {
            var posTop = getElementPosition(dA[i]);
            var mrBottom = parseInt(dA[i].style.marginBottom);
            if (isNaN(mrBottom)) mrBottom = 0;                        
            oh = posTop.top + dA[i].clientHeight - mrBottom;            
            if (oh < h)
            {
                np = h - oh;
                
		dA[i+1].style.paddingBottom = np + "px";
            }
           
        }
        this.eqa = 1;
        this.eqth = document.body.offsetHeight;
        this.eqtw = document.body.offsetWidth;
    }
}






function getElementPosition(obj)
{
var elem = obj;

if (elem != 'null')	{
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem.offsetParent)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
} else { return {"left":0, "top":0, "width": 0, "height":0};  }
}
function getPosition(obj){ 
var left=0,top=0;
while(obj) { 
  left+=obj.offsetLeft-obj.scrollLeft;
  top+=obj.offsetTop-obj.scrollTop;  
  if(obj.style.borderTopWidth!='') top+=parseInt(obj.style.borderTopWidth);
  if(obj.style.borderLeftWidth!='')left+=parseInt(obj.style.borderLeftWidth);  
  obj=obj.offsetParent; 
}
return {left:left,top:top};
}

function setObjHeight(objone, objtwo, objthree){
	var objoneHeight = 0;	
	var objtwoHeight = 0;
	var objthreeHeight = 0;
	if(objone != 'null'){
		objoneHeight = objone.clientHeight;	
	}
	if(objtwo != 'null'){
		objtwoHeight = objtwo.clientHeight;
	}
	if(objthree != 'null'){
		objthreeHeight = objthree.clientHeight;
	}
	
	if (parseInt(objoneHeight) > parseInt(objtwoHeight) && parseInt(objoneHeight) > parseInt(objthreeHeight)) {
		if(objtwo != 'null'){
		objtwo.style.height = String(objoneHeight) + "px";
		}
		if(objthree != 'null'){
		objthree.style.height = String(objoneHeight) + "px";
		}
		if(objone != 'null'){
		objone.style.height = String(objoneHeight) + "px";
		}
	} else if (parseInt(objtwoHeight) > parseInt(objthreeHeight)) {
		if(objone != 'null'){
		objone.style.height = String(objtwoHeight) + "px";
		}
		if(objthree != 'null'){
		objthree.style.height = String(objtwoHeight) + "px";
		}
		if(objtwo != 'null'){
		objtwo.style.height = String(objtwoHeight) + "px";
		}
	} else {
		if(objone != 'null'){
		objone.style.height = String(objthreeHeight) + "px";
		}
		if(objtwo != 'null'){
		objtwo.style.height = String(objthreeHeight) + "px";
		}
		if(objthree != 'null'){
		objthree.style.height = String(objthreeHeight) + "px";
		}
	}
}

window.onload = function() {
	setObjHeight(document.getElementById("i-video-cont-1"),document.getElementById("i-video-cont-2"),document.getElementById("i-video-cont-3"));

	//new EqualColumns('dhtml-page1', 'div', 'dhtml-page2', 'div', 'dhtml-page3', 'div');
	document.getElementById("dhtml-page1").style.display = "none";
	document.getElementById("dhtml-page2").style.display = "none";
	document.getElementById("dhtml-page3").style.display = "none";

	document.getElementById("dhtml-hidden-id").style.visibility = "visible";
	document.getElementById("dhtml-hidden-id").style.height = "auto";
	document.getElementById("dhtml-hidden-id").style.width = "auto";

	document.getElementById("dhtml-message-id").style.display = "none";
	document.getElementById("dhtml-page" + activePage).style.display = "block";
	document.getElementById("dhtml-scroll-id").style.backgroundPosition = -14*(3 - activePage) + "px 0px";

}
