<!-- alterValue(this, 'nome'); -->



function removeSelected(){

	parentN = $('menu_footer');
//	alert(parentN.childNodes.length);
	for (var ix=0; ix < parentN.childNodes.length; ix++) {
		if (parentN.childNodes[ix].className == 'selected') parentN.childNodes[ix].className = '';
	}
}

function updateSelected(item){

	parentN = item.parentNode;
	for (var ix=0; ix < parentN.childNodes.length; ix++) {
		if (parentN.childNodes[ix].className == 'selected') parentN.childNodes[ix].className = '';
	}
	item.className = 'selected';
}

function errorMessage(){
	new Effect.Pulsate("error");
}

function isIE(){
	//alert(Browser.is_ie);
	return Browser.is_ie;
}

function ajaxSubmit(form, div) {
	var params = Form.serialize(form);
	new Ajax.Updater(div,
					form.action, {
					method:'post',
					postBody:params,
					evalScripts: true,
					encoding: 'ISO-8859-1', //UTF-8
					onComplete: function(transport) {
					// Executa depois de todo o load
						//setTimeout('adjustPage()', 120);
						setTimeout('scrollMenu()', 100);
					}
    });
    setTimeout('errorMessage()', 120);
	//errorMessage();
}

function updatePage(url, content) {
	if (!content){
	 	if ($('cms_content')) content = 'cms_content';
	 	//if ($('loader')) content = 'loader';
	 }
	UnTip()
    var pars = '';
	menudomeio();
    $(content).innerHTML= '<img src="/media/images/ajax-loader.gif"/>';
    if ($('bkgs')){
    	$('bkgs').innerHTML= '';
    }
	$(content).style.textAlign = "center";
	if(Browser.is_ie){
		if($('menu_left')){$('menu_left').style.display = "none";}
	} else {
		if($('menu_left')){
			$('menu_left').style.visibility = "hidden";
			$('menu_left').style.width = "0px";
			$('menu_left').style.height = "0px";
			//('menu_left').style.position = "static";
		}
	}
	if($('push')) $('push').style.display = "none";
    var myAjax = new Ajax.Updater(content,
                                  url,
                                  {
                                      method: 'get',
                                      parameters: pars,
                                      evalScripts: true,
									  onSuccess: function(transport) {
										// Executa incio
                                      },
									  onComplete: function(response) {
									  //alert(response.getHeader('Content-Type'));
									  	//eval(response.responseText);
                                      	$(content).style.textAlign = "";
                                      	pageTracker._trackPageview(url); 
									  	setTimeout('addReflections()', 400);
                                      	/*
                                      	var testexxx = $(content).offsetHeight;
                                      	var windowHeight = getWindowHeight();
                                      	var footerHeight = $('footer').offsetHeight;

                                      	alert(windowHeight + ' altura da janela');
                                      	alert(testexxx + ' altura do content');
                                      	alert(footerHeight + ' altura do footer');







				if (windowHeight > 0) {
				//alert('alturada janela é > que 0')
					var contentHeight = $(content).offsetHeight;
					var footerElement = $('footer');
					var footerHeight  = footerElement.offsetHeight;

					alert(windowHeight - (contentHeight + footerHeight));
					if (windowHeight - (contentHeight + footerHeight) >= 0) {
						footerElement.style.position = 'absolute';
						footerElement.style.top = (windowHeight - footerHeight) + 150 +'px';
					}
					else {
					alert('stat');
						footerElement.style.position = 'static';
					}
				}













                                      	//alert(testexxx);
                                      	//alert(windowHeight);



                                      	//$('footer').style.display = 'none';
               */
										//setTimeout('adjustPage()', 300);
										//$('footer').style.display = '';
				    				 }
                                  }
                                  );

	//wait(1000,function(){alert('hello');});
}

function emptyFunc(){}

function alterValue(component, val) {
    if (component.value == '') {
        component.value = val;
    } else if (component.value == val) {
        component.value = '';
    }
}

function varyReflect() {
	if (cool == 10) {
		cool = 1;
	}
	Reflection.add(document.getElementById('indeed'), { opacity: cool/10 });

	document.getElementById('indeeda').innerHTML = cool*10;
	cool++;
}

/**
 * Preenche uma combo box a partir de um array
*/
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
    var i, j;
    var prompt;

    if ((itemArray == '0') || (itemArray == -1) || (itemArray == null)) {
        selectCtrl.disabled = true;
    } else {
        selectCtrl.disabled = false;
    }

    // empty existing items
    for (i = selectCtrl.options.length; i >= 0; i--) {
        selectCtrl.options[i] = null;
    }
    prompt = (itemArray != null) ? goodPrompt : badPrompt;
    if (prompt == null) {
        j = 0;
    } else {
        selectCtrl.options[0] = new Option(prompt);
        j = 1;
    }
    if (itemArray != null) {
        // add new items
        for (i = 0; i < itemArray.length; i++) {
            selectCtrl.options[j] = new Option(itemArray[i][0]);
            if (itemArray[i][1] != null) {
                selectCtrl.options[j].value = itemArray[i][1];
            }
            j++;
        }
        // select first item (prompt) for sub list
        selectCtrl.options[0].selected = true;
    }
}


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

