$(document).ready(function(){

var totalHeight=0;
for(var cnt=0; cnt<$(".news_block").length;cnt++)
{
//totalHeight+=parseInt($(".news_block:eq("+cnt+")").height());
totalHeight+=parseInt($(".news_block:eq("+cnt+")").height());
}
//initResizer();
//alert(totalHeight);
if(parseInt($("#news-ticker-container").height())<totalHeight+150 && $.browser.opera)initNewsTicker();
else if (!$.browser.opera)initNewsTicker();


if ($.browser.msie || $.browser.opera)
	$(".sub-news").addClass("ie-opera-hack");

});

global_z2 = true;
function initNewsTicker(){
	
	$('.news-ticker').each(function(i,o){
			var ef = ((i+1)%2==0)?'swing':'linear';
			ef = 'swing';
			global_z2 = $(o).newsTicker({effect: ef, delay: 500, startTimeout: 1000});
			//.css('color', 'red');
	});
}

function initResizer(){
	setTickersHeight();
	$(window).resize(setTickersHeight);
}


function setTickersHeight(){
	$('.news-ticker').each(function(i,o){
		setTickerHeight(o);
		//alert(i);
	});
}

function setTickerHeight(oDomElem)
{
	if(!oDomElem) return;

	var dim = get_inner_dimensions();  

	var newheight = dim.y - 160;

	if(newheight < 50) newheight = 50;

	newheight = newheight+'px';
	if (oDomElem.style != newheight)
		oDomElem.style.height = newheight;
}

function get_inner_dimensions()
{
  var x,y;
  if (self.innerHeight) // all except Explorer
  {
  	x = self.innerWidth;
  	y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  	// Explorer 6 Strict Mode
  {
  	x = document.documentElement.clientWidth;
  	y = document.documentElement.clientHeight;
  }
  else if (document.body) // other Explorers
  {
  	x = document.body.clientWidth;
  	y = document.body.clientHeight;
  }
  
  return ({ 'x' : x, 'y' : y });
  
}
