function ajaxRequest(url, params, complete_method) {
	new Ajax.Request( url, { method: 'get', parameters:params, onSuccess: complete_method });	
}

function inArray(needle, haystack, strict) { 
	for (var i = 0; i < haystack.length; i++) {
		if (strict && (needle == haystack[i]) || !strict && (needle == haystack[i])) 
		{ return true; }
	} return false; 
} 		

function swapVisibility(_id) {
	var el = $(_id);
	if (el)
	{
		if (el.style.display == 'none') setVisible(el);
		else setInvisible(el);
	}
}

function setVisible(el) {
	if (typeof el == "object") el.style.display = '';
	else if ($(el)) $(el).style.display = '';
}

function setInvisible(el) {
	if (typeof el == "object") el.style.display = 'none';
	else if ($(el)) $(el).style.display = 'none';
}

function clean(el) {
	if (typeof el == "object") el.innerHTML = '';
}

function redirect(url) {
	document.location.href = url;
}

function createChildElement(root_element, number, id, content) {
	cell = root_element.insertCell(number);
	cell.id = id 
	cell.innerHTML = content;			
}

function createInputElement(type, root_element, id) {
	var elem = document.createElement("input"); 
	elem.type = type;
	elem.id = id;
	root_element.appendChild(elem);
}

function removeElement(array, removing_element) {
	var temp_array = [];			
	for (i=0; i<array.length; i++) {
		var count = 0;        		        						
  		if(array[i] != removing_element) {
   			temp_array[count] = array[i];
			count++;
   		} 	        		
	}	
	return array = temp_array;
}

function selectInnerHTML(objeto, innerHTML) {
/******
* select_innerHTML - innerHTML to add option(s) to select(s)
* Problem: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Parametros:
* objeto(tipo object): the select
* innerHTML(tipo string): the new innerHTML
*******/
    objeto.innerHTML = ""
    //creating phantom element to receive temp innerHTML
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//if not option, convert do option
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
    //transfering childs of phantom element to options
    for(var i=0;i<selTemp.childNodes.length;i++){
        if(selTemp.childNodes[i].tagName){
            opt = document.createElement("OPTION")
            for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){				
                opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
            }
            opt.value = selTemp.childNodes[i].getAttribute("value")
            opt.text = selTemp.childNodes[i].innerHTML
            if(document.all){ //IEca
                objeto.add(opt)
            }else{
                objeto.appendChild(opt)
            }                    
        }    
    }
    //clear phantom
    document.body.removeChild(selTemp)
    selTemp = null
}