
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].offsetHeight;        
            oh = dA[i].offsetHeight;
            h = (oh > h) ? oh : h;
        }
        for (i = 0; i < dA.length; i += 2)
        {
            oh = dA[i].offsetHeight;        
            oh = dA[i].offsetHeight;
            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;
    }
}
window.onload = function (){

	var ptvBlockOne = document.getElementById("NPpoliceTV1");
	var ptvBlockTwo = document.getElementById("NPpoliceTV2");
	var ptvLoadMsg = document.getElementById("loading-message-ptv");
	var ptvOuterBlock = document.getElementById("NPpoliceTV");

	var btBlockOne = document.getElementById("NPblutube1");
	var btBlockTwo = document.getElementById("NPblutube2");
	var btLoadMsg = document.getElementById("loading-message-bt");
	var btOuterBlock = document.getElementById("NPblutube");
	
	//show blocks before equal
	if ( ptvBlockOne != null ) ptvBlockOne.style.display = "block" ; 
	if ( ptvBlockTwo != null ) ptvBlockTwo.style.display = "block" ; 
	if ( btBlockOne != null ) btBlockOne.style.display = "block" ; 
	if ( btBlockTwo != null ) btBlockTwo.style.display = "block" ; 
	new EqualColumns('NPpoliceTV1', 'div', 'NPpoliceTV2', 'div' );
	new EqualColumns('NPblutube1', 'div', 'NPblutube2', 'div' );

	if ( ptvBlockOne != null ) ptvBlockOne.style.display = "block" ; 
	if ( ptvBlockTwo != null ) ptvBlockTwo.style.display = "none" ; 
	if ( btBlockOne != null ) btBlockOne.style.display = "block" ; 
	if ( btBlockTwo != null ) btBlockTwo.style.display = "none" ; 

	ptvLoadMsg.style.display = "none";
	btLoadMsg.style.display = "none";
	ptvOuterBlock.style.height = "auto"	;
	ptvOuterBlock.style.visibility = "visible";
	btOuterBlock.style.height = "auto"	;
	btOuterBlock.style.visibility = "visible";
	
}

selCounterPTV = 1;
selCounterBT = 1;
/*
function changeCounterPTV(block, cnt) {
	var counter = 0;
	var blockToShow = "";
	var blockCounter = "";
	counter =  (block == "PTV" ? selCounterPTV : selCounterBT ); 
	blockToShow = ( block == "PTV" ? "NPpoliceTV" : "NPblutube" ) ; 
	blockCounter = ( block == "PTV" ? "NPCounterPTV" : "NPCounterBT" ) ; 
  
	document.getElementById(blockToShow + counter ).style.display = "none";
	counter += cnt 
	if (counter <= 0) {
		counter = 2; 
	}
	if ( counter >= 3 ) {
		counter = 1;
	}
	document.getElementById(blockToShow + counter).style.display = "block";
	pos = 0;
	if (counter == 2) { pos = -6;}
	
	document.getElementById(blockCounter).style.backgroundPosition = "0px " + pos + "px";
	if ( block == "PTV" ) {
		selCounterPTV = counter;
	} else {
		selCounterBT = counter;

	}
	return;
}
*/

selCounterNP = 1;
function changeCounterPTV(cnt) {
	document.getElementById("NPpoliceTV" + selCounterNP).style.display = "none";
	document.getElementById("PTVSelPage" + selCounterNP).style.display = "block";
	selCounterNP += cnt 
	if (selCounterNP <= 0) {
		selCounterNP = 2; 
	} 
	if (selCounterNP >= 3) {
		selCounterNP = 1; 
	} 
	document.getElementById("NPpoliceTV" + selCounterNP).style.display = "block";
	document.getElementById("PTVSelPage" + selCounterNP).style.display = "none";
	pos = 0;
	if (selCounterNP == 2) { pos = -6;}
	
	document.getElementById("NPCounterPTV").style.backgroundPosition = "0px " + pos + "px";
	return;
}

selCounterNB = 1;
function changeCounterBT(cnt) {
	document.getElementById("NPblutube" + selCounterNB).style.display = "none";
	document.getElementById("BTSelPage" + selCounterNB).style.display = "block";
	selCounterNB += cnt 
	if (selCounterNB <= 0) {
		selCounterNB = 2; 
	} 
	if (selCounterNB >= 3) {
		selCounterNB = 1; 
	} 
	document.getElementById("NPblutube" + selCounterNB).style.display = "block";
	document.getElementById("BTSelPage" + selCounterNB).style.display = "none";
	pos = 0;
	if (selCounterNB == 2) { pos = -6;}
	
	document.getElementById("NPCounterBT").style.backgroundPosition = "0px " + pos + "px";
	return;
}

