// esempio d'uso: preload('prima.gif', 'seconda.gif', 'terza.gif');

function preload() {
	if (!document.images) return;
	var wl = new Array();
	var arguments = preload.arguments;
	for (var i = 0; i < arguments.length; i++) {
		wl[i] = new Image();
		wl[i].src = arguments[i];
	}
}

function changeImage(id, src) {
	image = document.getElementById(id);
	image.src = src;
}

// TAB BOX ...

function changeTab(tabId) {
	for (i = 1; i <= 4; i++) {
		tabButton = document.getElementById('tbt_' + i);
		tabContent = document.getElementById('tbc_' + i);
		if (tabButton && tabContent) {
			if (i == tabId) {
				tabButton.style.background = 'url(images/box_2_tab_1.jpg) top left no-repeat';
				tabContent.style.display = 'block';
			} else {
				tabButton.style.background = 'url(images/box_2_tab_2.jpg) top left no-repeat';
				tabContent.style.display = 'none';
			}
		}
	}
}

// FORM ...

function inputFocus(inputId) {
	input = document.getElementById(inputId + "_container");
	input.style.backgroundPosition = "-10px -100px";
}

function inputBlur(inputId) {
	input = document.getElementById(inputId + "_container");
	input.style.backgroundPosition = "-10px -10px";
}

function selectFocus(selectId) {
	select = document.getElementById(selectId + "_container");
	select.style.backgroundPosition = "-10px -234px";
	options = document.getElementById(selectId + "_options");
	options.style.display = "block";
}

function selectBlur(selectId) {
	select = document.getElementById(selectId + "_container");
	select.style.backgroundPosition = "-10px -145px";
	options = document.getElementById(selectId + "_options");
	options.style.display = "none";
}

function selectOptionClick(selectId, text, value) {
	selectText = document.getElementById(selectId + "_text");
	selectValue = document.getElementById(selectId);
	options = document.getElementById(selectId + "_options");
	options.style.display = "none";
	selectText.value = text;
	selectValue.value = value;
}

// scroll lista checkbox
function toggleCheckboxList(listId) {
	$('#' + listId).animate({
		height: 'toggle'
	}, 2000);
}


// carosello

var carouselPosition = 0;
var carouselSpeed = 60;
var carouselScroll = true;
var carouselStep = -1;

function initCarousel() {
	setInterval('scrollCarousel()', carouselSpeed);
	contained = document.getElementById('carousel_contained');	
	contained.style.left = carouselPosition + 'px';
}

function scrollCarousel() {
	if (carouselScroll) {
		contained = document.getElementById('carousel_contained');
		if (contained != null) {
			carouselPosition = carouselPosition + carouselStep;
			contained.style.left = carouselPosition + 'px';
		}
		if (carouselPosition < -625) {
			carouselStep = +1;
		}

		if (carouselPosition > 0) {
			carouselStep = -1;
		}
	}
}

function setCarouselStep(step) {
	carouselStep = step;
}

function incCarouselStep() {
	carouselStep-=1;
}

function decCarouselStep() {
	carouselStep+=1;
}




function initPage() {
	//initCarousel();
}

preload('images/chi_siamo_2.jpg', 'images/consumer_magazine_2.jpg', 'images/private_label_2.jpg', 'images/rete_nazionale_2.jpg', 'images/servizi_2.jpg', 'images/bigbutt_1_2.jpg', 'images/bigbutt_2_2.jpg', 'images/bigbutt_3_2.jpg');
