var alignment_bug = function() {
	var obj = $t('html')[0];
	if (( document.body.clientWidth + parseInt( getStyle( $t('html')[0], 'margin-left' ) ) ) % 2 == 1) obj.style.marginLeft = '-1px';
	else obj.style.marginLeft = 0;
};

var arrumaMovie = function() {
	$('movie').style.width = ( parseInt ( ( (document.body.clientWidth - 900)/2 ) + ( 900 - parseInt( $('movie').getStyle('margin-left') ) ) ) ) +'px';
}

window.onresize= alignment_bug;


bodyLoad.add( function() {
	arrumaMovie();
	p = window.onresize;
	window.onresize = function() {
		p();
		arrumaMovie();
	}
	alignment_bug();

}, true );


// video
bodyLoad.add(
	function() {

		if(document.body.id!='bodyCapa') {
			loadSwf( $('movie'), 'swf/internas.swf', 780, 230, true );
		} else {
			loadSwf( $('movie'), 'swf/topo.swf', 980, 380, true );
		}


		var quemUsa = $('quemUsa');
		if( quemUsa )
		{
			//new lightBox( quemUsa, 'fotos/peq_', 'fotos/' );
			quemUsa.$t('li').forEach(
				function( el ){
					var img = $t('img', el)[0].getAttribute('src');
					//var acao = $t('a', el)[0].onclick;
					var destino = $t('a', el)[0].href;
					loadSwf(el,'./swf/fotos.swf',186,180,true, {foto: img} );

					var div = DOM.create( 'div' );
					div.style.height = '180px';
					div.style.width = '186px';
					div.style.position = 'absolute';
					div.style.cursor = 'pointer';
					if( isMSIE ) {
						div.style.filter = 'alpha(opacity = 0)';
						div.style.background = 'blue';
					}


					//Evt.add( el, 'click', acao );
					Evt.add( el, 'click', function(){ location = destino; } );
					DOM.before( div, $t( 'object', el)[0] );

				}
			);
		}




		var video = $('video');
		if( !video ) return;

		var el = video.$t('a')[0];

		var hRef = el.getAttribute( 'href' );

		Evt.add( el , 'click',
			function( evt ){
				Evt.cancel( evt );
				var videoUrl = hRef.substring( hRef.indexOf( 'v=' )+2 );

				var posEComercial = videoUrl.indexOf( '&' );
				if( posEComercial!=-1 ) videoUrl = videoUrl.substring( 0 , posEComercial );

				var video = new lightBox();
				//video.createArea( '<div style="width:425px;height:344px;"><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/'+ videoUrl +'&hl=pt-br&color1=0x7E9DB1&color2=0x113855"></param><embed src="http://www.youtube.com/v/'+ videoUrl +'&hl=pt-br&color1=0x7E9DB1&color2=0x113855" type="application/x-shockwave-flash" width="425" height="344"></embed></object></div>', $('conteudo') );
				var str = generateSwfCode('swf/video/mediaplayer.swf',405,344,0,{ width:405, height:344, file:'video.flv', autostart:true});
				video.createArea( '<div style="width:405px;height:344px;">' + str + '</div>', $('conteudo') );
			}
		);

	}

)
