var interval_ID;
var maxHeight = 0;
var maxHeightMenuTabs = 0;
var invertedDirection = 0;

var interval_IDCategoriesLook;
var maxWidth = 0;
var maxWidthMenuTabs = 0;


$(window).addEvent('domready', function(){
	if( document.getElementById('indexLogin') )
		initFormFields('indexLogin');
	if( document.getElementById('indexNewsContent') )
		initScrollNews()
});

function getHeight(id){
	if($(id+'Table')){ 
		maxHeight = $(id+'Table').offsetHeight;
	}
	if($(id)) { 
		maxHeightMenuTabs = $(id).style.height; 
		maxHeightMenuTabs = parseInt(maxHeightMenuTabs.replace("px", ""));
	}
}

function getWidth(id){
	if($(id+'Table')){ 
		maxWidth = $(id+'Table').offsetWidth;
	}
	if($(id)) { 
		maxWidthMenuTabs = $(id).style.width; 
		maxWidthMenuTabs = parseInt(maxWidthMenuTabs.replace("px", ""));
	}
}
	

function initScrollNews(){
	invertedDirection = 0;
	var divId = "indexNewsContent";
	var step = -1;
	getHeight(divId);
	interval_ID = setInterval('startScrollNews("'+divId+'",'+step+');',100);
	/*clearInterval(interval_ID);
	setTimeout('initScrollNews()', 16);
	startScroll(divId,step)*/
}

function startScrollNews(divID, step){
 	var the_style = getStyleObject(divID);
	if (the_style)
  {
 		if(the_style.top != "")var current_top = parseInt(the_style.top);
		else var current_top = 0;

		if(invertedDirection == 0 && (current_top <= (-maxHeight + (maxHeightMenuTabs))))invertedDirection = 1;
		else if(current_top == 0) invertedDirection = 0;
		
		if(invertedDirection)step = -(step);
		else step = +(step);
		
		var new_top = current_top + step;
		
		if(step > 0 && current_top < 0 ){ 
			if (document.layers) the_style.top = new_top;
			else the_style.top = new_top + "px";
		} 
		if(step < 0 && current_top >= (-maxHeight + (maxHeightMenuTabs))){
			if (document.layers) the_style.top = new_top;
			else the_style.top = new_top + "px";
		}
  }
}
