//global variables that can be used by ALL the function son this page.
var cdoInputs;


function selectAllGlobal(value) {

	selectAllAttivita(value);
	selectAllDisponibili(value);
	selectAllCodicimerceologici(value);
	selectAllZone(value);
	selectAllDimensioneAzienda(value);
	deleteSearchText();
}

function selectAllDimensioneAzienda(value)
{
	//get all the input fields on the page
	var inputSelects = document.getElementsByTagName('SELECT');

	//cycle trough the input fields
	for(var i=0; i < inputSelects.length; i++) {

		nome = inputSelects[i].name;
		if ((nome == 'mainForm:selectAziendaNumeroDipendenti')
			||
			(nome == 'mainForm:selectAziendaFatturato2007')
			||
			(nome == 'mainForm:selectAziendaPercExport'))
		{
			inputSelects[i].selectedIndex = 0;
		}
	}

}


function selectAllAttivita(value) {

	//cycle trough the input fields
	for(var i=0; i < cdoInputs.length; i++) {
		//check if the input is a checkbox
		if(cdoInputs[i].getAttribute('type') == 'checkbox') {
			var myCheckbox = cdoInputs[i];
			
			nome = myCheckbox.getAttribute('name');
			
			//alert(nome);
			
			if ((nome == 'mainForm:attivitaProduzione')
				||
				(nome == 'mainForm:attivitaCommer')
				||
				(nome == 'mainForm:attivitaServizi')
				||
				(nome == 'mainForm:attivitaVenditaDettaglio')
				||
				(nome == 'mainForm:attivitaPrestazione'))
			{
				if (myCheckbox.checked == !value)
					checkChangeSingle(i);
			}
		
		}
	}
	
}


function selectAllDisponibili(value) {

	//cycle trough the input fields
	for(var i=0; i < cdoInputs.length; i++) {
		//check if the input is a checkbox
		if(cdoInputs[i].getAttribute('type') == 'checkbox') {
			var myCheckbox = cdoInputs[i];
			
			nome = myCheckbox.id;
			
			//alert(nome);
			
			if ((nome == 'mainForm:dispPartnershipComm')
				||
				(nome == 'mainForm:dispPartnershipProd')
				||
				(nome == 'mainForm:dispSviluppoRete')
				||
				(nome == 'mainForm:dispContratto')
				||
				(nome == 'mainForm:dispFornituraBeni')
				||
				(nome == 'mainForm:dispFornituraServ'))
			{
				if (myCheckbox.checked == !value)
					checkChangeSingle(i);
			}
		
		}
	}
}


function selectAllCodicimerceologici(value) {

	//cycle trough the input fields
	for(var i=0; i < cdoInputs.length; i++) {
		//check if the input is a checkbox
		if(cdoInputs[i].getAttribute('type') == 'checkbox') {
			var myCheckbox = cdoInputs[i];
			
			title = myCheckbox.title;
			title = title.substring(0,5);
			str = "ateco";
			
			//alert(title);
			
			if (str == title)
			{
				if (myCheckbox.checked == !value)
					checkChangeSingle(i);
			}
			
		}
	}
}


function selectAllZone(value) {

	//cycle trough the input fields
	for(var i=0; i < cdoInputs.length; i++) {
		//check if the input is a checkbox
		if(cdoInputs[i].getAttribute('type') == 'checkbox') {
			var myCheckbox = cdoInputs[i];
			
			nome = myCheckbox.id;

			if ((nome == 'mainForm:zonaNordestaltoadige') ||
				(nome == 'mainForm:zonaNordestfriuliveneziagiulia') ||
				(nome == 'mainForm:zonaNordesttrentino') ||
				(nome == 'mainForm:zonaNordestveneto') ||
				(nome == 'mainForm:zonaCentroemiliaromagna') ||
				(nome == 'mainForm:zonaNordovestliguria') ||
				(nome == 'mainForm:zonaNordovestlombardia') ||
				(nome == 'mainForm:zonaNordovestpiemonte') ||
				(nome == 'mainForm:zonaNordovestvalledaosta') ||
				(nome == 'mainForm:zonaCentrolazio') ||
				(nome == 'mainForm:zonaCentromarche') ||
				(nome == 'mainForm:zonaCentrotoscana') ||
				(nome == 'mainForm:zonaCentroumbria') ||
				(nome == 'mainForm:zonaCentroabruzzo') ||
				(nome == 'mainForm:zonaSudbasilicata') ||
				(nome == 'mainForm:zonaSudcalabria') ||
				(nome == 'mainForm:zonaSudcampania') ||
				(nome == 'mainForm:zonaSudmolise') ||
				(nome == 'mainForm:zonaSudpuglia') ||
				(nome == 'mainForm:zonaIsolesardegna') ||
				(nome == 'mainForm:zonaIsolesicilia') ||
				(nome == 'mainForm:zonaUe') ||
				(nome == 'mainForm:zonaExtraUe') ||
				(nome == 'mainForm:zonaAfrica') ||
				(nome == 'mainForm:zonaAsia') ||
				(nome == 'mainForm:zonaMedioriente') ||
				(nome == 'mainForm:zonaNordamerica') ||
				(nome == 'mainForm:zonaSudamerica') ||
				(nome == 'mainForm:zonaOceania'))
			{
				if (myCheckbox.checked == !value)
					checkChangeSingle(i);
			}
		
		}
	}
}

function deleteSearchText() {

	//get all the input fields on the page
	inputQuerySpalla = document.getElementById('spallaForm:searchQuerySpalla');
	inputQueryIt = document.getElementById('mainForm:searchQueryIt');
	inputQueryEn = document.getElementById('mainForm:searchQueryEn');
	if (inputQuerySpalla != null) inputQuerySpalla.value = '';
	if (inputQueryIt != null) inputQueryIt.value = '';
	if (inputQueryEn != null) inputQueryEn.value = '';

}

function selectAllSezioniVetrina(value) {

	//cycle trough the input fields
	for(var i=0; i < cdoInputs.length; i++) {
		//check if the input is a checkbox
		if(cdoInputs[i].getAttribute('type') == 'checkbox') {
			var myCheckbox = cdoInputs[i];
			
			title = myCheckbox.title;
			title = title.substring(0,7);
			str = "sezione";
			
			if (str == title)
			{
				if (myCheckbox.checked == !value)
					checkChangeSingle(i);
			}
			
		}
	}
}

function selectAllTipiAzienda(value) {

	//cycle trough the input fields
	for(var i=0; i < cdoInputs.length; i++) {
		//check if the input is a checkbox
		if(cdoInputs[i].getAttribute('type') == 'checkbox') {
			var myCheckbox = cdoInputs[i];
			
			title = myCheckbox.title;
			title = title.substring(0,11);
			str = "tipiAzienda";
			
			if (str == title)
			{
				if (myCheckbox.checked == !value)
					checkChangeSingle(i);
			}
			
		}
	}
}

function checkAllCodicimerceologici() 
{

	//cycle trough the input fields
	for(var i=0; i < cdoInputs.length; i++) {
		//check if the input is a checkbox
		if(cdoInputs[i].getAttribute('type') == 'checkbox') {
			var myCheckbox = cdoInputs[i];
			
			title = myCheckbox.title;
			title = title.substring(0,5);
			str = "ateco";
			
			//alert(title);
			
			if (str == title)
			{
				if (myCheckbox.checked == true)
					return true;	
			}
			
		}
	}
	alert("Per generare il PDF e' necessario selezionare un'area merceologica.");
	return false;
}
