window.addEvent('domready',function(){

	$$( 'a.external' ).each( function( item ) {
		item.setProperty( 'target', '_blank' );
	});

	// mootools lang
	if( document.body.hasClass( 'pt' ) ) Locale.use( 'pt-PT' );
	else if( document.body.hasClass( 'en' ) ) Locale.use( 'en-EN' );

	// newsletter form validate
	if( $$( '#newsletterForm .formSubmit' ).length > 0 ) {
		var formValidation = new Form.Validator.Inline( 'newsletterForm', {
			onElementPass: function( el ) {
				el.getParent( 'p' ).removeClass( 'fieldError' );
			},
			onElementFail: function( el ) {
				el.getParent( 'p' ).addClass( 'fieldError' );
			}
		});
		$$( '#newsletterForm .formSubmit' )[0].addEvent( 'click', function( e ) {
			new Event.stop( e );
			if( formValidation.validate() ) new cpscaptcha( 'newsletterForm', '#newsletterForm' );
		});
	}

	// search form overText
	if( $( 'searchForm' ) ) {
		new OverText( ( 'searchInput' ) );
	}

	// mailTo modal open
	$$( '.mailTo' ).each( function( item ) {
		item.addEvent( 'click',function( e ) {
			Event( e ).stop();
			Shadowbox.open({
				player:  'iframe',
				content: './window/contactar.php?email=' + item.get( 'rel' ),
				height: 600,
				width: 600
			});
		});
	});

});
Shadowbox.init({players: ["html", "iframe", "img"]});

// sIFR
var fluxBold = { src: '/_tools/sifr/atrotis.swf' };
sIFR.activate( fluxBold );
sIFR.replace( fluxBold, {
	selector: 'h3, h5',
	wmode: 'transparent',
	css: [
		'.sIFR-root { color: #186DBA; font-size: 24px; }',
		'h3 { color: #186DBA; font-size: 24px; }',
		'h5 a { color: #186DBA; font-size: 18px; text-decoration: none; }',
		'h5 a:hover { color: #BA965C; }'
	]
});
