Event.observe(window,'load',initLinkObserver);

function initLinkObserver () {
	$$('.press_pagination_link').each(function (link) {
		Event.observe(link,'click',function (e) {
			new Ajax.Request(link.href, {
				method: 'post',
				evalScripts: true,
				onSuccess: function (response) {
					eval(response.responseText)
					initLinkObserver();
				}
			});
			e.stop();
		});
	});
}


function controlloJS (id, tipo, velocita, orientamento) {
	if (tipo == 'elenco') {
		// elenco
	} else if (tipo == 'marquee') {
		// marquee
		var options = { speed : (velocita ? velocita/1000 : 2) };
		if (orientamento == 0) {
			new verticalMarquee('presses_'+id,options);
		} else {
			new horizontalMarquee('presses_'+id,options);
		} 	
	} else if (tipo == 'random') {
		// random
		var classe = '.press_type_'+id;
		var list = $$(classe);
		list.each(function (press) {
			press.setStyle({'display':'none'});
		});
		var n = Math.floor(Math.random()*list.size());
		list[n].setStyle({'display':'block'});
		
		if (velocita) slideshow(classe, velocita);		
	}
}

function slideshow (classe, velocita) {
	//alert('slideshow')	
}


function maxFieldSize (field, size) {
	if (size > 0 && field.value.length > size) {
		field.value = field.value.substring(0, size);
		alert('Il limite per questo campo è di '+size+' caratteri.');		
	}
}

