var eqCounter = 0;

var loadingPage = false;
var whatsHotUrl = '';
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;
    }
}

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 checkSignUpForm(fObj) {
	if (!checkEmail(fObj.email.value)) { alert("Please enter your valid email address.");  fObj.email.focus();   return false; }
	return true;
}



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 _httpRequest(url,par)
{
 var httpR = false;
 if(window.XMLHttpRequest && !(window.ActiveXObject)) 
 {
  try { httpR = new XMLHttpRequest(); } catch(e) { httpR = false; }
 } else if(window.ActiveXObject) 
 {
  try { httpR = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { 
   try { httpR = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { httpR = false; }
  }
 }
 if (httpR) {
  httpR.open("POST", String(url), false);
  httpR.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  httpR.send(par);
  return String(httpR.responseText);
 } else { return; }
}


function addLoadEvent(func) {
        var oldonload = window.onload;
        if (typeof window.onload != 'function') {
                window.onload = func;
        }
        else {
                window.onload = function() {
                        oldonload();
                        func();
                }
        }
}

function doLoadBanner(idName) {
  var id = document.getElementById(String(idName));  
  if (id != null) {
    var innerContent = String(id.innerHTML).toLowerCase().replace(/<!--\/\/begin\/\//gi,"").replace(/\/\/end\/\/-->/gi,"");
    document.getElementById(String(idName)).innerHTML = innerContent;   
  }
}


	window.onload = function() {

	try {	
	 new EqualColumns('topfoto1', 'kbd','topfoto2', 'kbd','topfoto3', 'kbd','topfoto4', 'kbd');
	} catch(e){} 
	try {
	 new EqualColumns('topdesc1', 'div','topdesc2', 'div','topdesc3', 'div','topdesc4', 'div');
	} catch(e){}
	
		//document.getElementById("ppdesc1").style.marginBottom = "0px";
	
	  //alert(document.getElementById("tips").style.marginBottom);
	  try {
  		document.getElementById("wrapfoto").style.visibility = "visible";
  		document.getElementById("wrapfoto").style.height = "auto";
  		document.getElementById("wrapfotodesc").style.visibility = "visible";
  		document.getElementById("wrapfotodesc").style.height = "auto";
		} catch(e){}
		try {
  		if (document.getElementById("topfoto2")!= null)  document.getElementById("topfoto2").style.display = "none";
  		if (document.getElementById("topfoto3")!= null)  document.getElementById("topfoto3").style.display = "none";
  		if (document.getElementById("topfoto4")!= null)  document.getElementById("topfoto4").style.display = "none";
		} catch(e){}
		try {
  		if (document.getElementById("topdesc2")!= null)  document.getElementById("topdesc2").style.display = "none";
  		if (document.getElementById("topdesc3")!= null)  document.getElementById("topdesc3").style.display = "none";
  		if (document.getElementById("topdesc4")!= null)  document.getElementById("topdesc4").style.display = "none";
		} catch(e){}
		try {
		  if (document.getElementById("blauer") != null) document.getElementById("blauer").style.position = "relative";
		} catch(e){}
		//document.getElementById("ifoto-ruler").style.bottom = "102px";
		//document.getElementById("ifoto-ruler").style.bottom = "103px";
		
	  try {	 
		  new EqualColumns('resources', 'div', 'columnist', 'div');
		} catch(e){}
		//try {	
		 // new EqualColumns('bptopstories', 'div', 'exclnotes', 'div', 'photoreport', 'div');
		//} catch(e){}
		try {	
		  new EqualColumns('searches', 'div','network', 'div');
		} catch(e){}
		
//		new EqualColumns('featured', 'div', 'blutub', 'div');
    try {
  		new EqualColumns('markDivPZ0', 'div', 'markDivPZ1', 'div','markDivPZ2', 'div','pcmDIVbr','div','p1-sign-up-block-cont','div');
  
  		document.getElementById("markDivPZ1").style.display = "none";
  		document.getElementById("markDivPZ2").style.display = "none";
  
  		document.getElementById("pz-mess").style.display = "none";
  		document.getElementById("hidPZ").style.height = "auto";
  		document.getElementById("hidPZ").style.visibility = "visible";
		} catch(e){}

    try {
  		new EqualColumns('featuredBLUT1', 'div','featuredBLUT2', 'div','featuredBLUT3', 'div','featuredBLUT4', 'div','featuredBLUT5', 'div');
      if (document.getElementById("featuredBLUT2")!= null)  document.getElementById("featuredBLUT2").style.display = "none";
  		if (document.getElementById("featuredBLUT3")!= null)  document.getElementById("featuredBLUT3").style.display = "none";
  		if (document.getElementById("featuredBLUT4")!= null)  document.getElementById("featuredBLUT4").style.display = "none";
  		if (document.getElementById("featuredBLUT5")!= null)  document.getElementById("featuredBLUT5").style.display = "none";
  		document.getElementById("fBLUT-mess").style.display = "none";
  		document.getElementById("featuredBLUT").style.height = "auto";
  		document.getElementById("featuredBLUT").style.visibility = "visible";
		} catch(e){}
		try {
    	new EqualColumns('NPpoliceTV1', 'div','NPpoliceTV2', 'div');
      if (document.getElementById("NPpoliceTV1")!= null)  document.getElementById("NPpoliceTV1").style.display = "block";
  		if (document.getElementById("NPpoliceTV2")!= null)  document.getElementById("NPpoliceTV2").style.display = "none";
  		document.getElementById("fBLUT-mess2").style.display = "none";
  		document.getElementById("NPpoliceTV").style.height = "auto";
  		document.getElementById("NPpoliceTV").style.visibility = "visible";
    } catch(e){}
    try {
		  new EqualColumns('NPpoliceTV','div','featuredBLUT','div');
		} catch(e){}
 
		//changeMarkPZ(Math.floor(Math.random()*3)); 

   	//new EqualColumnsBottomLine('advance-your-career','div','deals','div');
   	try {
		  new EqualColumnsBottomLine('deals','div','advance-your-career','div');
		} catch(e){}
		
		loadingPage = true;

		//changeMarkPZ(Math.floor(Math.random()*3));
		try {
  		changeMarkPZ(0);
  
  		doLoadBanner("banners");
  		doLoadBanner("banners2");
    } catch(e){}
	}
	
	function verticalAlignEC(el1, el2, offs) {
			try {
  			var h = parseInt($(el1).css('padding-bottom'));
  			$(el1).css('padding-bottom', Math.floor(h / 2));
  			$(el2).css('padding-top', h - Math.floor(h / 2) + offs);
      } catch (e) {
        return;
      }
      return;
}

var bnmp_active_tab = 1;
/*var active_tab = 1;*/
var v_active_tab = 1;
/*function bnmp_selectTab(tab) {
  if (bnmp_active_tab != tab) {
    if (tab == 1) {
      document.getElementById("tabs").className = "";
    } else {
      document.getElementById("tabs").className = "secondTabActive";
    }
    document.getElementById("bnmptab" + tab).className = "";
    document.getElementById("BNMPEQ" + tab).style.display = "block";
    document.getElementById("bnmptab" + bnmp_active_tab).className = "no-selected";
    document.getElementById("BNMPEQ" + bnmp_active_tab).style.display = "none";
    bnmp_active_tab = tab;
  }
}*/

function selectTab(tab, obj) {
  if (active_tab != tab) {
    obj.className = "selected";
    document.getElementById("PZEQ" + tab).style.display = "block";
    document.getElementById("pzTab" + active_tab).className = "";
    if (tab == 3) document.getElementById("pzTab3").borderLeft = "none";
    document.getElementById("PZEQ" + active_tab).style.display = "none";
    active_tab = tab;
  }
}
function v_selectTab1(dir) {
  document.getElementById("VEQ" + v_active_tab).style.display = "none";
  document.getElementById("vTab" + v_active_tab).className = "";
  v_active_tab += dir;
  if (v_active_tab == 3) v_active_tab = 1;
  if (v_active_tab == 0) v_active_tab = 2;
  document.getElementById("VEQ" + v_active_tab).style.display = "block";
  document.getElementById("vTab" + v_active_tab).className = "active";
}
function v_selectTab2(tab) {
  if (v_active_tab != tab) {
    document.getElementById("VEQ" + v_active_tab).style.display = "none";
    document.getElementById("vTab" + v_active_tab).className = "";
    document.getElementById("VEQ" + tab).style.display = "block";
    document.getElementById("vTab" + tab).className = "active";
    v_active_tab = tab;
  }
}
function initDHTML1(){
  try {
		try {
    document.getElementById("bnmp-mess").style.margin=0+"px";
    		 // new EqualColumns('BNMPEQ1', 'kbd', 'BNMPEQ2', 'kbd', 'wrapexclnotes', 'div', 'photoreport', 'div');	
		  new EqualColumns('BNMPEQ1', 'kbd', 'wrapexclnotes', 'div', 'photoreport', 'div');
		} catch(e){}



  } catch(e){}
  try {
		document.getElementById("bnmp-mess").style.display = "none";
		document.getElementById("bnmp-hide").style.visibility = "visible";
		document.getElementById("bnmp-hide").style.height = "auto";
  } catch(e){}
  try {
		document.getElementById("BNMPEQ1").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("BNMPEQ2").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("BNMPEQ" + bnmp_active_tab).style.display = "block";
  } catch(e){}
}
function initDHTML2(){
  
  try {
  if (document.getElementById("PZEQ1")==null) {
    new EqualColumns('PZEQ2', 'div', 'PZEQ3', 'div', 'PZEQ4', 'kbd');
  } else {
    new EqualColumns('PZEQ1', 'div', 'PZEQ2', 'div', 'PZEQ3', 'div', 'PZEQ4', 'kbd');
    }
  } catch(e){}

  try {
		document.getElementById("pz-mess").style.display = "none";
		document.getElementById("pz-hide").style.visibility = "visible";
		document.getElementById("pz-hide").style.height = "auto";
  } catch(e){}
  try {
		document.getElementById("PZEQ1").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("PZEQ2").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("PZEQ3").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("PZEQ" + active_tab).style.display = "block";
  } catch(e){}
}
function initDHTML3(){
  try {
    new EqualColumns('VEQ1', 'kbd', 'VEQ2', 'kbd');
  } catch(e){}
  try {
		document.getElementById("v-mess").style.display = "none";
		document.getElementById("v-hide").style.visibility = "visible";
		document.getElementById("v-hide").style.height = "auto";
  } catch(e){}
  try {
		document.getElementById("VEQ1").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("VEQ2").style.display = "none";
  } catch(e){}
  try {
		document.getElementById("VEQ" + v_active_tab).style.display = "block";
  } catch(e){}
}

function VAlign() {
  try {
    verticalAlignEC('#v-hide > div[id*=\'myeq\']', '#v-hide', 5);
    //product zone
    verticalAlignEC('#PZEQ1 > div[id*=\'myeq\']', '#PZEQ1', 5);
    verticalAlignEC('#PZEQ2 > div[id*=\'myeq\']', '#PZEQ2', 5);
    verticalAlignEC('#PZEQ3 > div[id*=\'myeq\']', '#PZEQ3', 5);
    //verticalAlignEC('#myeq4', '#VEQ2', 0);
    //verticalAlignEC('#myeq3', '#VEQ1', 0);
  }
  catch(e) {}
}

function CenterDivTd() {
  try {
    //alert($("#carrers td.right-side").attr(offsetHeight));
  }
  catch(e) {}
}

function initDHTML1111(){
  try {
    new EqualColumns('BNMPEQ1', 'div', 'wrapexclnotes', 'div');
  } catch(e){}
}
 
addLoadEvent(initDHTML1);
addLoadEvent(initDHTML3);
addLoadEvent(initDHTML2);
addLoadEvent(VAlign);


