
returnFunctions = new Array();
addReturn = function(fn)
{
	returnFunctions.push(fn);
}


makeRequest = function(args)
{
	var action = {
		action		:	'processRequestAsync.php',
		parameters	:	{
							'args'	:	args
						},
		onComplete	:	function(response)
						{
							$('corpo').addClass('div_loading2');
							$('corpo').setHTML(response);
						
							transformAnchors();
						
							responseLoaded = function()
							{
								while(fn = returnFunctions.pop())
								{
									fn();
								}
							}
						
							if (!$('corpo').hasClass('div_loading'))
							{
								h = corpo.clientHeight;
								
								corpo.style.height = '0';
								corpo.style.opacity = .0;
								
								corpo_fx.start({
									'height'	: h,
									'opacity'	: 1
								}).chain(function()
								{
									corpo.style.height = 'auto';
									corpo.className = '';
									responseLoaded();
								});
							} else
							{
								responseLoaded();
							}
						}
	}
	
	if (args != '')
	{
		new Feature(action);
	}
};

transformAnchors = function()
{
	var anchors = document.getElementsByTagName('a');
	for (i = 0; i < anchors.length; i++)
	{
		var anchor = anchors[i];
		var transform = anchor.attributes.getNamedItem('transform');
		if (transform)
		{
			switch (transform.value)
			{
				case 'ajax':
					anchor.href = '#' + anchor.attributes.getNamedItem('args').value;
					anchor.attributes.removeNamedItem('args');
					break;
			}
			anchor.attributes.removeNamedItem('transform');
		}
	}
};

/**
*
*	executa 'fn' quando o menu estiver carregado
*
*/
var menuFunctions = new Array();
var menuInt = 0;
onMenuLoad = function(fn)
{
	// adiciona a função à fila
	menuFunctions.push(fn);
	// cancela a execução do Interval
	clearInterval(menuInt);
	// cria um novo Interval
	menuInt = setInterval(function()
	{
		if (typeof(menuLoaded) != 'undefined'
		&& menuLoaded == true)
		{
			clearInterval(menuInt);
			while (func = menuFunctions.shift())
			{
				func();
			}
		}
	}, 50);
}

/**
*
*	executa 'fn' quando o corpo estiver carregado
*
*/
var corpoFunctions = new Array();
var corpoInt = 0;
onCorpoLoad = function(fn)
{
	// adiciona a função à fila
	corpoFunctions.push(fn);
	// cancela a execução do Interval
	clearInterval(corpoInt);
	// cria um novo Interval
	corpoInt = setInterval(function()
	{
		if (typeof(corpoLoaded) != 'undefined'
		&& corpoLoaded == true)
		{
			clearInterval(corpoInt);
			while (func = corpoFunctions.pop())
			{
				func();
			}
		}
	}, 50);
}

function showHide(obj, force)
{
	if (typeof(obj) != 'object')
	{
		obj = $(obj);
	}
	if (typeof(force) == 'string')
	{
		obj.style.display = force;
	} else
	{
		if (obj.style.display == '')
		{
			obj.style.display = 'none';
		} else if (obj.style.display == 'none')
		{
			obj.style.display = '';
		}
	}
}

function select_innerHTML(objeto, innerHTML)
{
	if (navigator.appName == "Microsoft Internet Explorer")
	{ 
		objeto.innerHTML = '';
		var temp = objeto.outerHTML.replace('></', '>' + innerHTML + '</');
		objeto.outerHTML = temp;
	} else
	{
		objeto.setHTML(innerHTML);
	}
}

textoAntes = '';

function checkData(e) {
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	var n = document.getElementById('senhaStd');
	var text = n.value;
	if (code != 8 && code != 46 && textoAntes != text && text.length < 10) {
		if ((code < 48 || code > 57) && (code < 96 || code > 105)) {
			if (code == 191) {
				var t1 = text.substring(0,2);
				if (t1.match("/") != null) {
					text = "0" + text.substring(0,text.length);
				}
				t1 = text.substring(3,5);
				if (t1.match("/") != null) {
					text = text.substring(0,3) + "0" + text.substring(3,text.length);
				}
			} else {
				text = text.substring(0,text.length-1);
			}
		} else {
			if (text.substring(1,2) == "/") {
				text = "0" + text;
			} else if (text.substring(1,2) != "" && text.substring(2,3) != "/") {
				text = text.substring(0,2) + "/" + text.substring(2,10);
			}
			if (text.substring(4,6) == "/") {
				text = text.substring(0,3) + "0" + text.substring(3,4) + "/" + text.substring(5,10);
			} else if (text.substring(4,6) != "" && text.substring(5,6) != "/") {
				text = text.substring(0,5) + "/" + text.substring(5,10);
			}
			if (text.length > 7 && text.substring(6,8) != "19" && text.substring(6,8) != "20" ) {
				text = text.substring(0,6) + "19" + text.substring(6,text.length);
			}
			if (text.length > 9) {
				text = text.substring(0,10);
			}
		}
		n.value = text;
	}
} 

