var aErrorBox = new Array();
var aSucessBox = new Array();

var aLoadingAlign = new Array("left","center","right");

function errorAlert(operation,message){
	div = "<div id=" + operation + " style='display:none;'><img src='/images/boxalert_icon.png' width='85' height='27' /><p><span id='ErrorMessage' class='text_small'>" + message + "</span></p></div>";	
	equal = 0;

	for (var i = 0; i < aErrorBox.length; i++) 
	{
		if(aErrorBox[i] == operation)
			equal = 1;
	}

	if(equal == 0){
		aErrorBox.unshift(operation);
		errLen = aErrorBox.length;
			
		remove = function(){
			var layerRemove = aErrorBox[errLen - 1];

			$(layerRemove).fade({ duration: 0.25, from: 1, to: 0 });

			if($(layerRemove).style.display == 'none')
				$(layerRemove).remove();
			
			aErrorBox.pop();
			errLen = aErrorBox.length;
			
			return true;
		}
		
		$('alertConteiner').insert({ top : div });
		$(operation).appear({ duration: 0.25, from: 0, to: 1 });
		setTimeout("remove();",4000);
	}
}

function successAlert(operation,message){
	div = "<div id=" + operation + "><img src='/images/boxsuccess_icon.png' width='67' height='27' /><p><span id='SuccessMessage' class='text_small'>" + message + "</span></p></div>";	
	equal = 0;

	for (var i = 0; i < aSucessBox.length; i++) 
	{
		if(aSucessBox[i] == operation)
			equal = 1;
	}

	if(equal == 0){
		aSucessBox.unshift(operation);
		sucLen = aSucessBox.length;
			
		remove = function(){
			var layerRemove = aSucessBox[sucLen - 1];

			$(layerRemove).fade({ duration: 0.25, from: 1, to: 0 });

			if($(layerRemove).style.display == 'none')
				$(layerRemove).remove();

			aSucessBox.pop();
			sucLen = aSucessBox.length;
		}
		
		$('alertConteiner').insert({ top : div });
		$(operation).appear({ duration: 0.25, from: 0, to: 1 });
		setTimeout("remove();",4000);
	}
}

function LoadingAnimation(container,link,option,align){
	var animationID = 'saveAnimation' + container;
	var div = "<div id='" + animationID + "'><img src='/images/loader.gif' align='"+ aLoadingAlign[align - 1] +"'></div>";

	if(option == 1){// aparecer animacao
		$(link).style.display = 'none';
		$(container).insert({ 'top' : div });
	}else{// sumir animacao
		$(animationID).remove();
		$(link).style.display = 'block';	
	}
}