function verifyTextSearch( objElement, strReplace )
{
	if( objElement.value == "" )
	{
		objElement.value = strReplace;
	}
	else if( objElement.value == strReplace )
	{
		objElement.value = "";
	}
}

function changeGoverno( objGoverno )
{
	if( objGoverno.value != "DestaquesDoGoverno" )
	{
		window.open( objGoverno.value );
	}
}

function carouselVisibleIn(carousel, item, i, state, evt)
{
    var idx = carousel.index( i, carouselItemList.length );
    carousel.add( i, carouselGetItemHTML(carouselItemList[ idx - 1 ] ) );
}

function carouselVisibleOut(carousel, item, i, state, evt)
{
    carousel.remove( i );
}

function carouselGetItemHTML( item )
{
    return "<a href=\"" + item.url + "\" target=\"_blank\"><img src=\"" + item.image + "\" width=\"110\" height=\"105\" alt=\"" + item.title + "\" /></a>";
}

function sendEmail( objForm )
{
	$( "#sucesso" ).css( "display", "none" );
	$( "#erro" ).css( "display", "none" );
	var strError = "";
	if( objForm.nome.value == "" )
	{
		strError += "Informe o seu nome.\n";
	}
	if( objForm.email.value == "" )
	{
		strError += "Informe o e-mail de destinatário.\n";
	}
	if( strError != "" )
	{
		$( "#erro-texto" ).empty();
		$( "#erro-texto" ).append( strError );
		$( "#erro" ).fadeIn();
	}
	else
	{
		var strParameters = "name=" + objForm.nome.value;
		strParameters += "&email=" + objForm.email.value;
		strParameters += "&texto=" + objForm.texto.value;
		strParameters += "&codinterno=" + objForm.intcodinterno.value;
		var strUrl = objForm.action;

 		$( "#loading" )
		.ajaxStart
		(
			function()
			{
				$( this ).fadeIn();
				$( "#sendemailform" ).fadeOut();
			}
		)
		.ajaxStop
		(
			function()
			{
				$( this ).fadeOut();
			}
		);

		var strResult;
		$.ajax({ type: "POST", async: false, dataType: "json", url: strUrl, data: strParameters, success: function( data ){ strResult = data; } });
		setData( strResult );
	}
}

function setData( objResult )
{
	if( objResult != undefined )
	{
		if( objResult.error )
		{
			$( "#erro-texto" ).empty();
			$( "#erro-texto" ).append( objResult.error );
			$( "#sendemailform" ).fadeIn();
			$( "#erro" ).fadeIn();
		}
		if( objResult.success )
		{
			$( "#sucesso" ).css( "display", "block" );
			$( "#sucesso-texto" ).empty();
			$( "#sucesso-texto" ).append( objResult.success );
		}
	}
}

function openUrl( strUrl )
{
	window.open( strUrl, "janela", "width=550, height=500, resizable=no, scrollbars=yes, location=no, toolbar=no" );
}