$(document).ready(function(){
	$('h2[class=realTitle]').flash(
		{
			src: './swf/jfr.swf',
			flashvars: {
				css: [
					'* { color: #596671; letter-spacing: -2px; }',
					'a { color: #000000; text-decoration: none; }',
					'a:hover { text-decoration: underline; }'
				].join(' '),
			wmode: 'transparent'
			}
		},
		{ version: 7 },
		function(htmlOptions) {
			htmlOptions.flashvars.txt = this.innerHTML;
			this.innerHTML = '<div>'+this.innerHTML+'</div>';
			var $alt = $(this.firstChild);
			htmlOptions.height = $alt.height();
			htmlOptions.width = $alt.width();
			$alt.addClass('alt');
			$(this)
				.addClass('flash-replaced')
				.prepend($.fn.flash.transform(htmlOptions));
		}
	);


	$('h3[class=subTitle]').flash(
		{
			src: './swf/jfr.swf',
			flashvars: {
				css: [
					'* { color: #596671; letter-spacing: -1px; }',
					'a { color: #000000; text-decoration: none; }',
					'a:hover { text-decoration: underline; }'
				].join(' '),
			wmode: 'transparent'
			}
		},
		{ version: 7 },
		function(htmlOptions) {
			htmlOptions.flashvars.txt = this.innerHTML;
			this.innerHTML = '<div>'+this.innerHTML+'</div>';
			var $alt = $(this.firstChild);
			htmlOptions.height = $alt.height();
			htmlOptions.width = $alt.width();
			$alt.addClass('alt');
			$(this)
				.addClass('flash-replaced')
				.prepend($.fn.flash.transform(htmlOptions));
		}
	);


	var nav = $('#navegacaoInterna');
	if( nav ) {
		$('#navegacaoInterna a').flash(
			{
				src: './swf/jfr.swf',
				flashvars: {
					css: [
						'* { color: #596671; letter-spacing: -1px;  }',
						'a { color: #596671; text-decoration: none; font-size: 20px; }',
					].join(' '),
				wmode: 'transparent'
				}
			},
			{ version: 7 },
			function(htmlOptions) {
				htmlOptions.flashvars.txt = '<a href="'+ this.href +'">'+ this.innerHTML +'</a>';
				this.innerHTML = '<span>'+this.innerHTML+'</span>';
				var $alt = $(this.firstChild);
				htmlOptions.height = $alt.height();
				htmlOptions.width = $alt.width()+5;
				$alt.addClass('alt');
				$(this)
					.addClass('flash-replaced')
					.prepend($.fn.flash.transform(htmlOptions));
			}
		);
	}


	if( document.body.id == 'bodyHome' ) {
		$('#movie').flash(
		{
			src: './swf/banner.swf',
			width: 710,
			height: 360,
			wmode: 'transparent'
			}
		);
	}


	parseFormNoLabels( 'ProdutoBuscarForm' );
	parseFormNoLabels( 'CadastroCadastrarForm' );
	$( '#AcessoRapido' ).addClass('parsed');

	$("#AcessoRapido_secoes").change(function(){
		location = this.value;
	});


	var target = $('.picturesToEnlarge a');
	if( target && target.lightBox ) target.lightBox();

	var target = $('a.picturesToEnlarge');
	if( target && target.lightBox ) target.lightBox();


});



var parseFormNoLabels = function( $tgt )
{
	$( '#' + $tgt ).addClass('parsed');
	jQuery.each( $( '#' + $tgt + ' label' ), function()
	{
		$d = this.innerHTML.replace(/:?(<([^>]+)>)/ig,"");
		var $inputTgt = $( '#'+ this.attributes['for'].value );

		$inputTgt[0].originalValue = $d;
		if( $inputTgt[0].value=='' ) $inputTgt[0].value = $d;

		$inputTgt.bind("focus", function(e){ if(this.value==this.originalValue) this.value=''; });
		$inputTgt.bind("blur", function(e){ if(this.value=='') this.value=this.originalValue; });

		this.style.display = 'none';
	});

}
