var zen_NewsTypeBoxArr = [];

function zen_NewsAddTypeBox(typeBoxId) {
	zen_NewsTypeBoxArr[zen_NewsTypeBoxArr.length] = typeBoxId;
}

function isTypeSelectionEmpty() {
	if (zen_NewsTypeBoxArr.length == 0)
		return false;
	
	var result = true;
	for(var i=0; i < zen_NewsTypeBoxArr.length; ++i) {
		var element = zen_NewsTypeBoxArr[i]; 
		if (!document.getElementById(element))
			alert('element not found:' + element);
		if (document.getElementById(element).checked)
			result = false;
	}
	return result;
}

var zen_NewsSectionBoxArr = [];

function zen_NewsAddSectionBoxArr(sectionBoxId) {
	zen_NewsSectionBoxArr[zen_NewsSectionBoxArr.length] = sectionBoxId;
}

function isSectionSelectionEmpty() {
	if (zen_NewsSectionBoxArr.length == 0)
		return false;
		
	var result = true;
	for(var i=0; i < zen_NewsSectionBoxArr.length; ++i) {
		var element = zen_NewsSectionBoxArr[i]; 
		if (!document.getElementById(element))
			alert('element not found:' + element);
		if (document.getElementById(element).checked)
			result = false;
	}
	return result;
}

function OnNewsConfigSaveValidate(source, args) {
	if (isTypeSelectionEmpty() || isSectionSelectionEmpty()) {
		if (isLangItalian)
			alert("Errore. E' necessario selezionare almeno un valore per 'sector' e per 'type'");
		else
			alert("Error. You should select at least one sector and type");
			
		return false;
	}
	return true;
}

// -= Scroll =-

if(typeof(Zen)=='undefined')
	var Zen = {};
	
if(typeof(Zen.Components)=='undefined')
	Zen.Components = {};
	
if(typeof(Zen.Components.News)=='undefined')
	Zen.Components.News = {};
	
Zen.Components.News.ScrollList = [];

Zen.Components.News.getScroll = function(id) {
    for(var i = 0; i < Zen.Components.News.ScrollList.length; i++)
        if(Zen.Components.News.ScrollList[i].Id == id)
            return Zen.Components.News.ScrollList[i];
}

Zen.Components.News.Scroll = function (id, height, timeout, step) {
	this.Id = id;
	Zen.Components.News.ScrollList[Zen.Components.News.ScrollList.length] = this;
	this.Height = height;
	this.Timeout = timeout > 0 ? timeout : 100;
	this.Step = step;
	this.Outer = document.getElementById(this.Id + '-outer');
	this.Inner = document.getElementById(this.Id + '-inner');
	//this.Outer.style.height = height + 'px'; - don't working in IE
	this.Outer.style.overflow = 'hidden';
	this.Outer.style.position = 'relative';
	this.Inner.style.position = 'relative';
	this.Position = this.Height;
	this.Outer.onmouseover = new Function("Zen.Components.News.getScroll('" + this.Id + "').Unset()");
	this.Outer.onmouseout = new Function("Zen.Components.News.getScroll('" + this.Id + "').Set()");
	this.Set();
}

Zen.Components.News.Scroll.prototype = {
	Set : function () {
		this.TimerID = setTimeout("Zen.Components.News.getScroll('" + this.Id + "').Tick()", this.Timeout);
	},
	Unset : function () {
		clearTimeout(this.TimerID);
	},
	Tick : function () {
		this.Position = this.Position - this.Step;
		if (this.Position < -this.Inner.offsetHeight)
			this.Position = this.Height;
		this.Inner.style.top = this.Position;
		this.Set();
	}
}
