// JavaScript Document

function updateComponent(item_to_update,url){
		 var myAjax = new Ajax.Updater(
		   item_to_update,
		   url,
		   {
		   method: 'post'
		});
	}

//Updates a component
function updateComponentSource(item_to_update,url,source){
		//var dropdownIndex = document.getElementById('colorsselect').selectedIndex;
		//var dropdownValue = document.getElementById('colorsselect')[dropdownIndex].value;
		//document.write(dropdownValue);
		var dropdownIndex = source.selectedIndex;
		var dropdownValue = source[dropdownIndex].value;
		var final_url = url+'/'+dropdownValue;
		
		 var myAjax = new Ajax.Updater(
		   item_to_update,
		   final_url,
		   {
		   method: 'post'
		});
	}
 
//this function clones the content of a filed in a second field
function cloneFromList(frm)
{	
	var s1 = frm.elements['id_menu_item']; 
	var s2 = frm.elements['name'];  
 	
	b = false; 
	
	s1Index = s1.selectedIndex; 
	val = s1.options[s1Index].text; // current value of s1 
	
	s2.value = val;
	
}

//this function open a pop up used for help
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=350,left = 430,top = 305',title='teste');");
}

//This function retrieves true post the data for boxes
function boxPostUpdate(div_to_update,url_to_get){
		 var myAjax = new Ajax.Updater(
		   div_to_update,
		   url_to_get,
		   {
		   method: 'get'
		});
	}


