/* -------------------------------------------------- */
/* SOURCE CODE                                        */
/* -------------------------------------------------- */
/**
*
* @copyright Copyright (c) 2007, NETCRIATIVA
*
*/

function getURL() {
	url = new String(document.URL);

	pos = url.indexOf("//") + 2;
	tam = url.length;
	url = url.slice(pos, tam);

	pos = url.indexOf("/");
	tam = url.length;
	url = url.slice(0, pos);

	url = 'http://www.sbte.org.br/'

	return url;
}

STYLEFILE_IMAGE       = getURL() + "imagens/procurar.gif";
STYLEFILE_IMAGEHEIGHT = 21;
STYLEFILE_IMAGEWIDTH  = 66;
STYLEFILE_WIDTH       = 200;


$(document).ready(function() {
	$('#bannerrotativo').cycle({ fx:'fade', speed:1000, timeout:7000 });


/* -------------------------------------------------- */
/* INICIAL                                            */
/* -------------------------------------------------- */
	if ($("#inicial").length > 0)
	{
/*
		Shadowbox.init({assetURL: getURL(), handleLgImages: 'drag'});
		Shadowbox.open({type: 'img', title: 'Aviso', content: getURL() + 'imagens/avisos/premiacoes_sbte2008.jpg'});
*/
	}
/* -------------------------------------------------- */


/* -------------------------------------------------- */
/* A SOCIEDADE - DIRETORIAS ANTERIORES                */
/* -------------------------------------------------- */
	if ($("#asociedade_diretorias-anteriores").length > 0)
	{
		$("h4 a").click(function() {
			divDisplay = $("#" + $(this).attr("class")).css("display");

			if ((divDisplay == '') || (divDisplay == undefined) || (divDisplay == 'none'))
			{
				$("#" + $(this).attr("class")).css("display","block");
			}
			else
			{
				$("#" + $(this).attr("class")).css("display","none");
			}
		})
	}
/* -------------------------------------------------- */


/* -------------------------------------------------- */
/* A SOCIEDADE - LINHA DO TEMPO                       */
/* -------------------------------------------------- */
	if ($("#asociedade_linha-do-tempo").length > 0)
	{
		var options = {
			assetURL: getURL(),
			width: 480,
			height: 335,
			keysClose: ['f', 27]
		};

		Shadowbox.init(options);
	}
/* -------------------------------------------------- */


/* -------------------------------------------------- */
/* ASSOCIADO                                          */
/* -------------------------------------------------- */
	if ($("#associado").length > 0)
	{
		if ($("#frmPremiacaoVotacao").length > 0)
		{
			$("#frmPremiacaoVotacao button").click(function() {
				var fCandidatoC = $("input[type=radio][name=f_Candidato_C]:checked").val();
				var fCandidatoA = $("input[type=radio][name=f_Candidato_A]:checked").val();

				$.post(getURL() + "_lib/ajax/premiacao-votacao.php", { candidatoC: fCandidatoC, candidatoA: fCandidatoA }, 
					function(data) {
						$("#premiacao").html(data);
					}
				);
			})
		}
	}
/* -------------------------------------------------- */


/* -------------------------------------------------- */
/* CADASTRO                                           */
/* -------------------------------------------------- */
	if ($("#cadastro").length > 0)
	{
		if ($("#frmCadastro").length > 0)
		{
			$("input[type=file]").stylefile({
				image: STYLEFILE_IMAGE,
				imageheight : STYLEFILE_IMAGEHEIGHT,
				imagewidth : STYLEFILE_IMAGEWIDTH,
				width : STYLEFILE_WIDTH
			});


/* -------------------------------------------------- */
/* ATUAÇÃO - OUTROS                                   */
/* -------------------------------------------------- */
			$("input[id='f_Atuacao_Outros']").click(function() {
				if ($('#f_Atuacao_Outros:checked').is(':checked'))
				{
					// Mostra o campo 'outros' para preenchimento
					$("span.span_atuacao_outros").css("display","block");

					// Ativa o campo 'outros' para preenchimento
					$("#f_AtuacaoOutros").removeAttr("disabled");
				}
				else
				{
					// Remove o campo 'outros'
					$("span.span_atuacao_outros").css("display","none");

					// Desativa o campo 'outros'
					$("#f_AtuacaoOutros").attr("disabled", "disabled");
				}
			})
/* -------------------------------------------------- */


			// Validação
			$("#frmCadastro").validate();
		}
	}
/* -------------------------------------------------- */


/* -------------------------------------------------- */
/* O EMBRIÃO                                          */
/* -------------------------------------------------- */
	if ($("#oembriao").length > 0)
	{
		$('#content-right').pager('ul');
	}
/* -------------------------------------------------- */


/* -------------------------------------------------- */
/* RECADASTRO                                         */
/* -------------------------------------------------- */
	if ($("#recadastro").length > 0)
	{
		if ($("#frmRecadastro").length > 0)
		{
			$("input[type=file]").stylefile({
				image: STYLEFILE_IMAGE,
				imageheight : STYLEFILE_IMAGEHEIGHT,
				imagewidth : STYLEFILE_IMAGEWIDTH,
				width : STYLEFILE_WIDTH
			});


/* -------------------------------------------------- */
/* ATUAÇÃO - OUTROS                                   */
/* -------------------------------------------------- */
			$("input[id='f_Atuacao_Outros']").click(function() {
				if ($('#f_Atuacao_Outros:checked').is(':checked'))
				{
					// Mostra o campo 'outros' para preenchimento
					$("span.span_atuacao_outros").css("display","block");

					// Ativa o campo 'outros' para preenchimento
					$("#f_AtuacaoOutros").removeAttr("disabled");
				}
				else
				{
					// Remove o campo 'outros'
					$("span.span_atuacao_outros").css("display","none");

					// Desativa o campo 'outros'
					$("#f_AtuacaoOutros").attr("disabled", "disabled");
				}
			})
/* -------------------------------------------------- */


			// Validação
			$("#frmRecadastro").validate();
		}
	}
/* -------------------------------------------------- */


/* -------------------------------------------------- */
/* SUBMISSÃO                                          */
/* -------------------------------------------------- */
	if ($("#submissao").length > 0)
	{
		if ($("#frmAutor").length > 0)
		{
			// Validação
			$("#frmAutor").validate();
		}

		if ($("#frmResumo").length > 0)
		{
			// Validação
			$("#frmResumo").validate();

			// Editor de texto
			new nicEditor({iconsPath : getURL() + 'imagens/nicEditorIcons.gif', buttonList : ['bold','italic','underline','subscript','superscript']}).panelInstance('f_Texto');
		}
	}
/* -------------------------------------------------- */


/* -------------------------------------------------- */
/* SUBMISSÃO 2ª VIA                                   */
/* -------------------------------------------------- */
	if ($("#submissao-2via").length > 0)
	{
		if ($("#frmAutor").length > 0)
		{
			// Validação
			$("#frmAutor").validate();
		}

		if ($("#frmResumo").length > 0)
		{
			// Validação
			$("#frmResumo").validate();

			// Editor de texto
			new nicEditor({iconsPath : getURL() + 'imagens/nicEditorIcons.gif', buttonList : ['bold','italic','underline','subscript','superscript']}).panelInstance('f_Texto');
		}
	}
/* -------------------------------------------------- */






/* -------------------------------------------------- */
/* RESUMO                                             */
/* -------------------------------------------------- */
	if ($("#resumo").length > 0)
	{
		if ($("#frmAutor").length > 0)
		{
			// Validação
			$("#frmAutor").validate();
		}

		if ($("#frmResumo").length > 0)
		{
			// Validação
			$("#frmResumo").validate();

			// Editor de texto
			new nicEditor({iconsPath : getURL() + 'imagens/nicEditorIcons.gif', buttonList : ['bold','italic','underline','subscript','superscript']}).panelInstance('f_Texto');
		}
	}
/* -------------------------------------------------- */




});