function confirm_action() {
	if (confirm('Are you sure?')) { return true; }
	else { return false; }
}


function confirm_submit() {
	if (confirm('Please check all form fields very carefully.' )) { return true; }
	else { return false; }
}


function adduploader(container_id, form_name, max){
	var thisid=0;
	var uploaders_container=document.getElementById(container_id);

	if(uploaders_container.hasChildNodes()){
		thisid+=uploaders_container.childNodes.length
	}
	
	thisid++;

	if(thisid <= max){
		var uploaderhtml='' + thisid + ': <input type="file" name="' + form_name + '[' + thisid + ']">';
		var dNew=document.createElement('div');
		dNew.id='uploader'+thisid;
		dNew.innerHTML=uploaderhtml;
		uploaders_container.appendChild(dNew)
	} else {
		alert('Maximum uploaders: ' + max );
	}

}



function tree_expand(id, name){

	var expander = document.getElementById(name + "_li_expander_" + id);
	var container = document.getElementById(name + "_ul_" + id);
	
	if(container){
		if(container.style.display != 'none') {
			container.style.display = 'none';
			expander.className = "exp_expander_plus";
		} else {
			container.style.display = 'block';
			expander.className = "exp_expander_minus";
		}
	}

	return false;

}	


function tree_select(id, name){

	var container = document.getElementById(name + "_id");

	var new_element = document.getElementById(name + "_li_element_" + id);
	var old_element = document.getElementById(name + "_li_element_" + container.value);

	if(old_element){
		old_element.className = "exp_normal";
	}

	container.value = id;
	new_element.className = "exp_selected";

	return false;

}



function dropdown_options(el_name, zIndex){

	var el_options = document.getElementById(el_name + "_options");

	if(el_options.style.display=="none"){
		el_options.style.display="block";
		
		if(zIndex>0){
			el_options.style.zIndex = zIndex;
		}

	} else {
		el_options.style.display="none";
	}

}

function dropdown_select(el_name, type, name){
		
	var el_options = document.getElementById(el_name + "_options");
	var el_display = document.getElementById(el_name + "_display");
	var el_result = document.getElementById(el_name + "_result");

	if(type || name){
		el_display.innerHTML = name;
		el_result.value = type;
	}

	el_options.style.display="none";

	return false;
			
}



function lengthcounter(field_id, counter_id, max) {

	var field=document.getElementById(field_id);
	var counter=document.getElementById(counter_id);

	if(field.value.length > max) {
		field.value = field.value.substring(0, max);
		counter.innerHTML = "0";
	} else  {
		counter.innerHTML = max - field.value.length;
	}

 }

