function change_period_date_disabled(model_name){
    disabled = !document.getElementById(model_name + '_establishes_preriod').checked
    for(i = 1;i <= 3;i++){
        start_at_element = document.getElementsByName(model_name + '[start_at(' + String(i) + 'i)]')[0];
        if(start_at_element)
            start_at_element.disabled = disabled;
        end_at_element = document.getElementsByName(model_name + '[end_at(' + String(i) + 'i)]')[0];
        if(end_at_element)
            end_at_element.disabled = disabled;
    }
}

function update_single_value(model_name, attribute_name, action, value){
	document.update_single_value_form.action = action;
	$(model_name + '_' + attribute_name).value = value;
	document.update_single_value_form.submit();
}

function show_tour(url) {
    document.tour.action = (typeof arguments[1] == 'undefined') ? '/tour' : arguments[1]
    document.tour.height.value = (typeof arguments[2] == 'undefined') ? '100%' : arguments[2]
	document.tour.url.value = url;
	document.tour.submit();
}
function show_travel(url) {
	document.travel.url.value = url;
	document.travel.submit();
}

function ajaxAvailable() {
	if (window['ActiveXObject']) {
		try {
			new ActiveXObject('Msxml2.XMLHTTP'); return true;
		} catch (e) {}
		try {
			new ActiveXObject('Microsoft.XMLHTTP'); return true;
		} catch (e) {}
	}
	return window['XMLHttpRequest'] != null;
}

function toggleDisplay(id) {
	if (document.getElementById) {
		var e = document.getElementById(id);
		if (e.style.display != null) {
			if (e.style.display == 'none') {
				e.style.display = '';
			} else {
				e.style.display = 'none';
			}
		}
    }
}
