function toggleCity(cityId) {
	list = 'list' + cityId;
	city = 'city_' + cityId;
	
	if ($(list).visible()) {
		$(city).addClassName('closed');
	} else {
		$(city).removeClassName('closed');
	}
	
	Effect.toggle(list, 'slide');
	
	return false;
}

function toggleMarket(body) {
	
	Effect.toggle($(body).select('.market-body')[0], 'blind');
	
	if ($(body).select('.market-body')[0].visible()) {
		$(body).removeClassName('open');
	} else {
		$(body).addClassName('open');
	}
	return false;
}

function internToggleMarket(marketId) {
	list = 'marketlist_' + marketId;
	market = 'market_' + marketId;
	
	
	if ($(list).visible()) {
		$(market).removeClassName('open');
		$(market).addClassName('closed');
	} else {
		$(market).addClassName('open');
		$(market).removeClassName('closed');
	}
	
	Effect.toggle(list, 'slide');

	return false;
}

function popupPrint( url )
{
	print = open( url, "printwindow", "width=680, height=500, left=80, top=80, scrollbars=yes, resizable=yes, dependent=yes");
	print.focus();
}

function fillFields() {
	var form = $('new_participation')
	var inputs = form.getInputs('text')
	inputs.each(function(i) {
	  if (i.value == '' && i.alt != '') {
			i.value = i.alt;
		}
	});
}

function clearFields() {
	var form = $('new_participation')
	var inputs = form.getInputs('text')
	inputs.each(function(i) {
	  if (i.value == i.alt) {
			i.value = '';
		}
	});
}

function clearField(field, text) {
	if (field.value == text) {
		field.value = '';
	}
}

function fillField(field, text) {
	if (field.value == '') {
		field.value = text;
	}
}


function switchAlternative(value) {
	if (value != '') {
		$('participation_market_attributes_name').disable();
		$('participation_market_attributes_street').disable();
	} else {
		$('participation_market_attributes_name').enable();
		$('participation_market_attributes_street').enable();
	}
}
