/**
 * Confere se o parametro ? externo do javascript
 * Check is the parameter is alien of the javascript
 *
 *@param  objElement
 *@return bool
 */
function isAlien( objElement )
{
	return isObject( objElement ) && typeof a.constructor != 'function';
}

/**
 * Confere se o parametro enviado ? um array
 * Check if the parameter sended is one array
 *
 @param mixElement
 @return bool
 */
function isArray( objMix )
{
	return isObject( objMix ) && objMix.constructor == Array;
}

/**
 * Confere se o objeto enviado ? um boleano
 * Check if the parameter sended is one bool
 *
 @param mixElement
 @return bool
 */
function isBoolean( objMix )
{
	return typeof objMix == 'boolean';
}

/**
 * Confere se o objeto ou texto enviado e vazio
 * Check if the object or string sended is empty
 *
 * @param mixElement
 * @return bool
 */
function isEmpty( mixElement )
{
	var strProperty, mixValue;
	if( isObject( mixElement ) )
	{
		for( strProperty in mixElement )
		{
			mixValue = o[ strProperty ];
			if( isUndefined( mixValue ) && isFunction( mixValue ) )
			{
				return( false );
			}
		}
	}
	else
	{
		return( ( mixElement == "" ) );
	}
}

/**
 * Confere se o parametro enviado ? uma fun??o
 * Check if the parameter sended is one function
 *
 @param mixElement
 @return bool
 */
function isFunction( mixElement )
{
	return typeof mixElement == 'function';
}


function existFunction( strNameFunction )
{
	if ( window[ strNameFunction ] != undefined )
	{
		return isFunction( window[ strNameFunction ] ); 
	}
	else
	{
		return false;
	}  
}

/**
 * Confere se o parametro enviado ? nulo
 * Check if the parameter sended is null
 *
 @param mixElement
 @return bool
 */
function isNull( mixElement )
{
	return typeof mixElement == 'object' && !mixElement;
}

/**
 * Confere se o parametro enviado ? um n?mero
 * Check if the parameter sended is one number
 *
 @param mixElement
 @return bool
 */
function isNumber( mixElement )
{
	return typeof mixElement == 'number' && isFinite( mixElement );
}

/**
 * Confere se o elemento enviado ? um objeto
 * Check if the element sended is one object
 *
 @param mixElement
 @return bool
 */
function isObject( mixElement )
{
	return ( mixElement && typeof mixElement == 'object' ) || isFunction( mixElement );
}

/**
 * Confere se o elemento enviado ? um texto
 * Check if the element sended is one string
 *
 @param mixElement
 @return bool
 */
function isString( mixElement )
{
	return typeof mixElement == 'string';
}

/**
 * Confere se o elemento enviado ? indefinido
 * Check if the element sended is undefined
 *
 @param mixElement
 @return bool
 */
function isUndefined( mixElement )
{
	return typeof mixElement == 'undefined';
}

/**
 * Confere se o elemento html é um select
 *
 @param _mixElement
 @return bool
 */
function isHtmlSelect( _mixElement )
{
	// Obrigando a parametrizacao de determinadas informacoes
	if( _mixElement == undefined ) return( false );
	
	// Capturando objetos os elementos em questao
	var objElement = ( isObject( _mixElement ) ) ? _mixElement : document.getElementById( _mixElement );
	
	if( document.all )
	{
		var strOuterHtmlElement = objElement.outerHTML;
		var boolReturn = ( strOuterHtmlElement.substring( 0 , 7 ) == "<SELECT" ) ? true : false;
	}
	else
	{
		var boolReturn = ( objElement.constructor == "[HTMLSelectElement]" ) ? true : false;
	}
	
	// Retorno da funcao
	return( boolReturn );
}

/**
 * Retorna um inteiro que identifica a tecla pressionada
 * Return a integer that identify a pressed key
 *
 * @param handler de evento de tecla
 * @return integer
 */
function getIntKeyCode( keyEvent )
{
	var intKeyCode = ( (keyEvent.which) ? keyEvent.which : keyEvent.keyCode );
	if ( keyEvent.shiftKey )
	{
		intKeyCode += 1000;
	}
	return intKeyCode;
}

/**
 * Retorna o "tipo" da tecla pressionada
 * Return the "type" of the pressed key
 *
 * @require getIntKeyCode
 * @param integer
 * @return string
 */
staticIntLastTypeKeyCode 	= "unknown";
staticIntLastKeyCode		= -1;
function getKeyType( intKeyCode )
{
	var strType = "unknown";

	if ( staticIntLastTypeKeyCode == "special" )
	{
		strType = "letter";
	}
 	else if( intKeyCode == 8 )
	{
		strType = "backspace";
	}
	else if( ( intKeyCode == 9 ) || ( intKeyCode == 1009 ) )
	{
		strType = "tab";
	}
 	else if( intKeyCode == 13 )
	{
		strType = "enter";
	}
	else if( intKeyCode == 32 )
	{
		strType = "space";
	}
	else if( ( ( intKeyCode >= 33 ) && ( intKeyCode <= 40 ) )  || ( ( intKeyCode >= 1033 ) && ( intKeyCode <= 1040 ) ) )
	{
		strType = "position";
	}
	else if( intKeyCode == 46 )
	{
		strType = "delete";
	}
	else if( ( ( intKeyCode >= 48 ) && ( intKeyCode <= 57 ) ) || ( ( intKeyCode >= 96 ) && ( intKeyCode <= 105 ) ) )
//	else if( ( intKeyCode >= 48 ) && ( intKeyCode <= 57 ) )
	{
		strType = "number";
	}
	else if( ( ( intKeyCode >= 59 ) && ( intKeyCode <= 90 ) ) || ( ( intKeyCode >= 1059 ) && ( intKeyCode <= 1090 ) ) )
//	else if( ( ( intKeyCode >= 97 ) && ( intKeyCode <= 122 ) ) || ( ( intKeyCode >= 1097 ) && ( intKeyCode <= 1122 ) ) )
	{
		strType = "letter";
	}
	else if( ( intKeyCode >= 112 ) && ( intKeyCode <= 123 ) )
	{
		strType = "Fn";
	}
	else if( ( intKeyCode == 219 ) || ( intKeyCode == 1219 ) || ( intKeyCode == 222 ) || ( intKeyCode == 1222 ) )
	{
		strType = "special";
	}

	staticIntLastKeyCode		= intKeyCode;
	staticIntLastTypeKeyCode	= strType;

	return( strType );
}

/**
 * Remove todos os numeros inteiros de uma string
 * Remove from one string all the not numerical (integer) elements
 *
 * @param string Text
 * @return integer
 * @example alert(forceInt("1a2b3c4"))
 */
function forceInt( Text, leftZeros )
{
    Text += '';
	leftZeros = (leftZeros == undefined) ? false : leftZeros;

	Numbers = "1234567890\n";
	NewText = "";
	for( i = 0 ; i < Text.length ; i++ ){
		if( Numbers.indexOf( Text.charAt(i) ) != -1 ){
			NewText += Text.charAt(i);
		}
	}
	if (NewText == ""){
		return "";
	}

	if(!leftZeros){
		// a base tem de ser forcada para 10
		// porque o default e base 8 caso NewText comece com 0
		NewText = parseInt(NewText,10);
	}

	return( NewText );
}

/**
 * Remove todos os numeros doubles de uma string
 * Remove from one string all the not numirical (double) elements
 *
 * @param string Text
 * @param string Dot
 * @return double
 * @example alert(forceDouble("1a2b3c4.5aX"))
 */
function forceDouble(Text, Dot)
{
	Text = Text.replace( Dot , "." );
	Numbers = "1234567890.\n";
	NewText = "";
	var i = 0;
	for(i=0;i<Text.length;i++)
	{
		if(Numbers.indexOf(Text.charAt(i)) != -1)
		{
			NewText += Text.charAt(i);
		}
	}
	if (NewText == ""){
		return "";
	}
	// a base tem de ser forcada para 10
	// porque o default e base 8 caso NewText comece com 0
	floatNew = parseFloat(NewText,10);
	NewText = floatNew + "";
	Text = Text.replace( ".", Dot );
	return Text;
}

/**
 * Muda alguns caracters para o modo html
 * Change some chars to html mode
 *
 @param string strText
 @return string
 */
function entityify( strText )
{
	if (isUndefined(strText))
	{
		return "undefined";
	}

	strText = strText + "";

	strText = strText
	.replace( /&/g , "&amp;" )
	.replace( /</g , "&lt;" )
	.replace( />/g , "&gt;" );

	strText = strText;
	strText = replaceAll( strText, "\n", "<br/>\n" );
	strText = replaceAll( strText, " ", "&nbsp;" );

	return strText;
};

function quote( strText )
{
	var c, i, l = strText.length, o = '"';
	for (i = 0; i < l; i += 1)
	{
		c = strText.charAt(i);
		if (c >= ' ')
		{
			if (c == '\\' || c == " \"" )
			{
				o += '\\';
			}
		o += c;
		}
		else
		{
			switch (c)
			{
				case '\b':
					o += '\\b';
					break;
				case '\f':
					o += '\\f';
					break;
				case '\n':
					o += '\\n';
					break;
				case '\r':
					o += '\\r';
					break;
				case '\t':
					o += '\\t';
					break;
				default:
					c = c.charCodeAt();
					o += '\\u00' + Math.floor(c / 16).toString(16) +
						(c % 16).toString(16);
			}
		}
	}
	return o + '"';
};

/**
 * Remove os espacos em branco dos extremos de um string
 * Remove the white spaces os the limits of some string
 *
 @param string strText
 @return string
 */
function trim( strText )
{
	if (! strText)
	{
		return "";
	}
	return strText.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};

/**
 * remove as ocorrencias de um texto nos extremos do outro
 *@param string strText
 *@param sttring strPeace
 *@param bool boolLeft
 *@param bool boolRigth
 *@return string
 */
function trimString( strText, strPeace, boolLeft, boolRight )
{
	strText += "";

	if (boolLeft == undefined)
	{
		boolLeft = true;
	}

	if (boolRight == undefined)
	{
		boolRight = false;
	}

	intPos = strText.indexOf( strPeace ) ;

	if ( boolLeft )
	while ( intPos == 0 )
	{
		strText = strText.substring( strPeace.length );
		intPos = strText.indexOf( strPeace ) ;
	}

	if ( boolRight )
	while ( intPos == strText.length - strPeace.length )
	{
		strText = strText.substring( 0 , intPos ) ;
		intPos = strText.indexOf( strPeace ) ;
	}

	return strText;
}

/**
 * adiciona texto ao final do corpo do html
 * add text into end of the body
 *@param string strText
 *@param object Div objDivPlace
 *@return void
 */
function printEnd( strText , objDivPlace)
{
	if (objDivPlace == undefined)
		objDivPlace == document.body;

	objDivPlace.innerHTML += strText;
}


/**
 * substitui todas as ocorrencias de um string por outro
 * replace all the ocurrence of some string to another
 *
 *@param  string strText
 *@param  string strFinder
 *@param  string strReplacer
 *@return bool
 */
function replaceAll (strText , strFinder, strReplacer)
{
	strText += "";
	var strSpecials = /(\.|\*|\^|\?|\&|\$|\+|\-|\#|\!|\(|\)|\[|\]|\{|\}|\|)/gi; // :D
	strFinder = strFinder.replace(strSpecials, "\\$1")

	var objRe = new RegExp(strFinder, "gi");
	return strText.replace(objRe, strReplacer);
}

function strCount( strSearch, strText )
{
	strText += "";
	var intCount = 0;

	var intPos = strText.indexOf( strSearch );

	while ( intPos != -1 )
	{
		intCount++;
		strText	= strText.substr( intPos + 1 );
		intPos = strText.indexOf( strSearch );
	}

	return intCount;
}

/**
 * concatena todos os itens de um array ligando-os por um string
 *
 * join all the array elements concatened with one string
 *@param array
 *@param string $str
 *@return string
 */
function implode( strGlue, arrPieces)
{
	if ( arrPieces == undefined )
		return "undefined";
	var strResult = "";
	for(var i = 0; i < arrPieces.length; ++i)
	{
		if (strResult != "")
		{
			strResult += strGlue;
		}

		strResult += arrPieces[i];
	}
	return strResult;
}

function implode_complex( strGlue, arrPieces , intLineCount )
{
	if ( arrPieces == undefined )
		return "undefined";
	if ( intLineCount == undefined )
	{
		var intLineCount = 0;
	}

	var intLineGlue = strCount( "\n" , strGlue );
	var strResult = "";
	for(var i = 0; i < arrPieces.length; ++i)
	{
		if (strResult != "")
		{
			var strPeace = strGlue;
			strPeace = replaceAll( strPeace , "%line" , intLineCount );
			strPeace = replaceAll( strPeace , "%count" , i );
			strPeace = replaceAll( strPeace , "%row" , str_slice_line( arrPieces[i] ) );
			strResult += strPeace;
		}

		intLineCount += strCount( "\n" , arrPieces[i] );
		intLineCount += intLineGlue;

		strResult += arrPieces[i];
	}
	return strResult;
}

function explode( strSeparator , strText )
{
	strText += "";
	strSeparator += "";
	
	var intCount = 0;
	var intCountMax = ( strText.length );
	
	var arrResult = new Array();
	var intSeparatorPos = strText.indexOf( strSeparator );

	var boolInsert = true;
	while( ( intSeparatorPos != -1 ) && ( intCount < intCountMax ) )
	{
		if( intSeparatorPos == 0 )
		{
			var strBefore 	= strText.substr( 0 , 1 );
			var strAfter 	= strText.substr( 1 );
			boolInsert = false;
		}
		else
		{
			var strBefore 	= strText.substr( 0 , intSeparatorPos );
			var strAfter	= strText.substr( intSeparatorPos + 1 );
		}
		if( ( strBefore != undefined ) && ( strBefore != null ) ) arrResult.push( strBefore );
		strText = strAfter;

		var intSeparatorPos = strText.indexOf( strSeparator );
		
		++intCount;
	}
	
	if( boolInsert ) arrResult.push( strText );	
	
	return arrResult;
}

/**
 * Procura por um elemento no array e returna sua posicao caso seja 
 * encontrado, ou -1 caso nao encontre
 * Serarch for a item in the array and return his position if founded or -1
 * in other case
 *
 *@param mixObject mixElement
 *@param array arrConteiner
 *@param integer intNumElementsArray
 *@return integer
 */
function array_search( mixElement, arrConteiner, intNumElementsArray )
{
	if (!arrConteiner)
		return -1;
		
	for(var i = 0; i < arrConteiner.length; ++i)
	{
		if( intNumElementsArray == undefined )
		{
			if (arrConteiner[i] == mixElement)
				return i;
		}
		// Readequando o terceiro parametro
		else
		{	
			if( ( isArray( mixElement ) ) && ( isArray( arrConteiner[ i ] ) ) )
			{
				intNumElementsArrayParam = intNumElementsArray;
				if( mixElement.length < intNumElementsArray ) intNumElementsArrayParam = mixElement.length;
				if( arrConteiner.length < intNumElementsArray ) intNumElementsArrayParam = arrConteiner[ i ].length;
			}
			var boolEqual = true;
			for( var j = 0 ; j < intNumElementsArrayParam ; ++j )
			{
				if( mixElement[ j ] != arrConteiner[ i ][ j ] )
				{
					boolEqual = false;
					break;
				}
			}
			if( boolEqual )
			{
				return i;
			}
		}
	}
	return -1;
}

/**
 * Insere um valor no array caso nao exista no mesmo
 *
 * @param array
 * @param mix
 * @return array
 */
function insertDistinctValueIntoArray( arrElements , mixValue )
{
	if( ( arrElements == undefined ) || ( mixValue == undefined ) )
	{
		return( false );
	}
	if( array_search( mixValue , arrElements ) != -1 )
	{
		arrElements[ arrElements.length ] = mixValue;
	}
	return( arrElements );
}

/**
 * Retorna o Html da Tag ( incluindo a mesma )
 * Return the outer Html of the Tag
 *
 */
function getHtmlString( objDomHtml )
{
	if (!objDomHtml)
		return "";

	if ( isString(objDomHtml) || isNumber(objDomHtml) )
	{
		return objDomHtml;
	}

	if ( objDomHtml.outerHTML )
	{
		return( objDomHtml.outerHTML );
	}

	var parentDiv = document.createElement("div");
	parentDiv.appendChild( objDomHtml );
	return parentDiv.innerHTML;
}

/**
 * Replace a mask in a strHtml for the element
 *@param string strHTML
 *@param string Key
 *@param mix objReplacer
 *@param string Key
 *@param mix objReplacer
 *@param string Key
 *@param mix objReplacer
 *@param ...
 *@return string
 */
function createHtmlByElements( strHTML )
{
	arrArguments = createHtmlByElements.arguments;
	if (arrArguments.length == 0)
	{
		return strHTML;
	}

	if (arrArguments.length % 2 == 0)
	{
		return strHTML;
	}

	for (var i = 1; i < arrArguments.length; i += 2)
	{
		strSearch = arrArguments[ i ];
		mixReplace = arrArguments[ i + 1 ];
		if ( !isString(mixReplace) && !isNumber(mixReplace) )
		{
			mixReplace = getHtmlString( mixReplace );
		}

		strHTML = replaceAll( strHTML, strSearch, mixReplace );
	}

	return strHTML;
}


var autoId = 0;

/**
 * Set a unique and valid Id for some object
 *@param object objElement
 *@return string strHeader
 */
function setId( objElement, strHeader )
{
	if ( (objElement.id == undefined) || (objElement.id == "") )
	{
		objElement.id = strHeader + autoId++;
	}
	return objElement.id;
}

IE = document.all ? true : false;
var mouseX = 0;
var mouseY = 0;

/**
 * Active the function to get the mouse position
 *@return void
 */
function activeMouseGetPosRemedial()
{
	if (!IE) document.captureEvents(Event.MOUSEMOVE);

	// Set-up to use getMouseXY function onMouseMove
	document.onmousemove = getMouseXYRemedial;

	// Temporary variables to hold mouse x-y pos.s

	// Main function to retrieve mouse x-y pos.s
}

/**
 * Called function when the mouse move
 *@version 1.0
 *@param intX
 *@param intY
 *@return bool
 */
function mouseMoveRemedial( intX , intY)
{
	return true;
}

function getMouseXYRemedial(e)
{
	if (IE)
	{
		mouseX = event.clientX + document.body.scrollLeft;
		mouseY = event.clientY + document.body.scrollTop;
	}
	else
	{
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
	if (mouseX < 0){mouseX = 0}
	if (mouseY < 0){mouseY = 0}

	document.MouseX = new Object();
	document.MouseY = new Object();
	document.MouseX.value = mouseX;
	document.MouseY.value = mouseY;

	return mouseMoveRemedial( mouseX, mouseY);
}

function str_repeat( strText, intRepeat )
{
	strReturn = "";
	for ( var i = 0; i < intRepeat; ++i)
	{
		strReturn += strText;
	}
	return strReturn;
}

function str_slice_line( strText )
{
	var strReturn = strText;
	strReturn = replaceAll( strText, "\"" , "\\\'\\'" );
//	strReturn = replaceAll( strReturn, "\'" , "\\\'" );
//	strReturn = replaceAll( strReturn, "\n" , "\\n " );
	strReturn = replaceAll( strReturn, "\n" , " " );
	return strReturn;
}

function str_slice( strText )
{
	var strReturn = strText;
	strReturn = replaceAll( strText, "\"" , "\\\\\"" );
	strReturn = replaceAll( strReturn, "\'" , "\\\'" );
	return strReturn;
}

function showHide( object )
{
  if (object.style.display == "none")
  {
    object.style.display = "block";
    return true;
  }
  else
  {
    object.style.display = "none";
    return false;
  }
}

function removeChildNodes( object )
{
	if( object )
	{
		while ( object.childNodes.length > 0 )
		{
			object.removeChild( object.childNodes[0] , true );
		}
	}
}

function strToDate( strDate )
{
    var arrDate = explode( "/" , strDate  );
    var objDate = new Date( arrDate[2] , arrDate[1] - 1 , arrDate[0] );
    return objDate;
}

// Funcao que realiza um cast array, ou seja, converte um objeto em array
function parseArray( objElement )
{
    // Criando array
    var arrNew = new Array();
    
    // Caso seja uma colecao
    if( objElement.length )
    {
        for( var i = 0; i < objElement.length; ++i )
        {
            arrNew[ i ] = objElement[ i ];
        }
    }
    // Caso nao seja uma colecao
    else
    {
        for( strAttribute in objElement )
        {
            if( isFunction( objElement[ strAttribute ] ) )
            {
                arrNew[ arrNew.length ] = objElement[ strAttribute ];
            }
        }
    }            
    // Retorno da funcao
    return( arrNew );
}

// Funcao que realiza um cast array, ou seja, converte um objeto em array
function parseArrayRecursive( objElement , intDepthOfRecursive )
{
	// Profundidade da recursividade
	if( intDepthOfRecursive == undefined )
	{
		intDepthOfRecursive = -1;
	}
	if( intDepthOfRecursive > 0)
	{
		--intDepthOfRecursive;
	}
	else 
	{
		if( intDepthOfRecursive == 0 )
		{
			return objElement;
		}
		if( intDepthOfRecursive < 0 )
		{
			return null;
		}
	}

    // Criando array
    var arrNew = new Array();
    
    if( objElement == undefined )
    {
        // elemento vazio
    }
    else if( isString( objElement) || isNumber( objElement ) || isBoolean( objElement ) )
    {
       arrNew[ arrNew.length ] = objElement; 
    }
    // Caso seja uma colecao
    else if( objElement.length )
    {
        for( var i = 0; i < objElement.length; ++i )
        {
            arrNew[ i ] = parseArrayRecursive( objElement[ i ] , intDepthOfRecursive );
        }
    }
    // Caso seja uma colecao
    else if( objElement.innerHTML )
    {
        arrNew = objElement.innerHTML;
    }
    // Caso nao seja uma colecao
    else if( isObject( objElement ) )
    {
        for( strAttribute in objElement )
        {
            if( ! isFunction( objElement[ strAttribute ] ) )
            {
                arrNew[ arrNew.length ] = parseArrayRecursive( objElement[ strAttribute ] , intDepthOfRecursive ) ;
            }
        }
    }
    else
    {
    	arrNew = null;
    }
    // Retorno da funcao
    return( arrNew );
}

/**
 * @param objeto form (delimitador inicial)
 * @param qual tag sera procurada
 * @param qual o atributo sera procurado
 * @param qual o valor do atributo a ser procurado
 **/
function getElementsByAttribute( oElm , mixTagName , strAttributeName , strAttributeValue )
{
	if( typeof( mixTagName ) == "string" )
	{
    	var arrElements = ( mixTagName == "*" && oElm.all )? oElm.all : oElm.getElementsByTagName( mixTagName );
	}
	else if( typeof( mixTagName ) == "object" )
	{
		var arrElements = new Array();
		var arrOneOfElements;
		for( var i = 0 ; i < mixTagName.length; ++i )
		{
			arrOneOfElements = oElm.getElementsByTagName( mixTagName[ i ] );
			arrElements.concat( arrOneOfElements );
		}
	}
	else
	{
		var arrElements = oElm.all;
	}
    var arrReturnElements = new Array();

    var oAttributeValue = ( typeof strAttributeValue != "undefined" )? new RegExp( "(^|\\s)" + strAttributeValue + "(\\s|$)" ) : null;
    var oCurrent;
    var oAttribute;
    for( var i = 0 ; i < arrElements.length ; i++ )
    {
        oCurrent = arrElements[ i ];
        oAttribute = oCurrent.getAttribute && oCurrent.getAttribute( strAttributeName );
        if( typeof oAttribute == "string" && oAttribute.length > 0 )
        {
            if( typeof strAttributeValue == "undefined" || ( oAttributeValue && oAttributeValue.test( oAttribute ) ) )
            {
                arrReturnElements.push( oCurrent );
            }
        }
    }
    return arrReturnElements;
}

function truncate( strText , intChar , strComplement , boolSpace )
{
	var strResult = "";
	var intLastSpace = 0;
	
	if( strText == undefined )			strText = "";
	if( intChar == undefined ) 			intChar = 0;
	if( strComplement == undefined )	strComplement = "";
	if( boolSpace == undefined ) 		boolSpace = true;			

	var arrText = explode( "" , strText );
	for( var i = 0 ; i < arrText.length ; ++i )
    {
    	if( i < intChar )
    	{
    		strResult += arrText[ i ];
    		if( arrText[ i ] == " " )
    		{
    			intLastSpace = i;
    		}
    	}
    	else
    	{
    		break;
    	}
    }

    if( intChar <= strText.length )
    {
	   	if( boolSpace )
	   	{
	   		strResult = strResult.substr( 0 , intLastSpace );
	   	}
    	
    	strResult += strComplement;
    }
    
	return( strResult );
}

/**********************************************************************
 * Retorna o label (quando possuir o atributo for) de um determinado
 * elemento do formulario
 *
 * @param mix
 * @return string
 **********************************************************************/
function getLabelFromElement( mixElement )
{
	if( mixElement == undefined ) return( false );
	if( isObject( mixElement ) )
	{
		var strIdElement = mixElement.getAttribute( "id" );
	}
	else
	{
		var strIdElement = mixElement;
	}
	if( document.all )
	{
		arrLabel = document.getElementsByTagName( "LABEL" );
		arrElements = new Array();
		for( var i = 0 ; i < arrLabel.length ; ++i )
		{
			var objLabel = arrLabel[ i ];
			mixReturnForLabel = getForLabelFromIE( objLabel.outerHTML );
			if( mixReturnForLabel !== false )
			{
				if( mixReturnForLabel == strIdElement )
				{
					arrElements.push( objLabel );	
				}
			}
		}
	}
	else
	{
		arrElements = getElementsByAttribute( document.body , "LABEL" , "for" , strIdElement );	
	}
	if( arrElements.length == 0 )
	{
		return( strIdElement );
	}
	else
	{
		return( replaceAll( replaceAll( arrElements[ 0 ].innerHTML , ":" , "" ) , "*" , "" ) );
	}
}
 
/**********************************************************************
* Retorna o for de um label para cobrir o bug do IE
*
* @param string
* @return mix
**********************************************************************/
function getForLabelFromIE( strLabel )
{
	var mixReturnFor = strLabel.indexOf( "for=" );
	if( mixReturnFor == -1 )
	{
		return( false );
	}
	else
	{
		var strPartAfterFor = strLabel.substring( ( mixReturnFor + 4 ) , strLabel.length );
		var mixReturnMaior = strPartAfterFor.indexOf( ">" );
		if( mixReturnMaior == -1 )
		{
			return( false );
		}
		else
		{
			var strPartAfterMaior = strPartAfterFor.substring( 0 , mixReturnMaior );
			return( strPartAfterMaior );
		}
	}
}

/**********************************************************************
* Imprime determinado texto
*
* @param string strMessage
* @return bool
**********************************************************************/
strGlobalMessage = "";
function printMessage( strMessage )
{
	if( strMessage == undefined ) return( false );
	var strIdIframe = "iframeToPrintMessage";
	
	strGlobalMessage = strMessage;

	var objIframeToPrint = document.getElementById( strIdIframe );
	if( objIframeToPrint == undefined )
	{
		var objIframeToPrint = document.createElement( "IFRAME" );
		objIframeToPrint.setAttribute( "id" , strIdIframe );
		objIframeToPrint.setAttribute( "name" , strIdIframe );
		objIframeToPrint.style.cssText = "width:0px; height:0px; border:0px;";
		document.body.appendChild( objIframeToPrint );
		
		var objIframeToPrint = document.getElementById( strIdIframe );
		setTimeout( 'printMessage( strGlobalMessage );' );
		return( false );
	}
	eval( 'parent.' + strIdIframe + '.document.body.innerHTML = "";' ); 
	
	if( document.all )
	{
		eval( 'parent.' + strIdIframe + '.document.body.innerHTML = strGlobalMessage;' );
		setTimeout("frames['" + strIdIframe + "'].focus(); frames['" + strIdIframe + "'].print();", 500);
	} 
	else 
	{
		eval( 'parent.document.getElementById("' + strIdIframe + '").contentDocument.body.innerHTML = strGlobalMessage;' );		
		setTimeout("frames['" + strIdIframe + "'].print();", 500);
	}
	
	return( true );
}

/**********************************************************************
* Insere uma funcao a um evento aplicado a um determinado
* elemento
*
* @param mix _mixElement
* @param string _strEvent
* @param string _strEventFunction
* @return bool
**********************************************************************/
function insertFunctionIntoEventElement( _mixElement , _strEvent , _strEventFunction )
{							
	// Obrigando a parametrizacao de determinadas informacoes
	if( ( _mixElement == undefined ) || ( _strEvent == undefined ) || ( _strEventFunction == undefined ) ) return( false );
	
	// Capturando objetos os elementos em questao
	var objElement = ( isObject( _mixElement ) ) ? _mixElement : document.getElementById( _mixElement );
	
	// Capturando a funcao atual aplicada ao evento
	var strEventFunction = objElement.getAttribute( _strEvent );
	if( strEventFunction == undefined ) 
	{
		strEventFunction = "";
	}
	else
	{
		if( document.all )
		{
			strEventFunction = replaceAll( strEventFunction , 'function anonymous() {' , '' );
			strEventFunction = strEventFunction.substring( 0 , ( strEventFunction.length - 2 ) );
			strEventFunction = replaceAll( strEventFunction , '\n' , '' );
		}
	}
	strEventFunction = _strEventFunction + strEventFunction;
	
	// Aplicando a funcao no elemento
	if( document.all )
	{	
		eval( 'objElement.' + _strEvent + ' = new Function( "' + strEventFunction + '" );' );
	}
	else
	{
		objElement.setAttribute( _strEvent , strEventFunction );						
	}
							
	// Retorno da funcao
	return( true );
}
