/**
 * @author Erivaldo Alves de Oliveira Junior
 * @version 1.0.0
 * @mail junemil@gmail.com / esc326@msn.com
 *
 *
 * $Date: 2009-10-10 01:13:55 -0500 (sábado, 10 Outubro 2009) $
 * $Rev:  0001 - 2009-10-27 21:07:00 -0000 (terça, 29 Outubro 2009) $
**/

$( function(){
	/*
	$( '#txtBusca' ).val( $( '#txtBusca' ).attr( 'alt' ) ).bind( 'focus', function(){
		if( $( this ).val() == $( this ).attr( 'alt' ) ){
			$( this ).val( '' );
		}
	}).bind( 'keyup', function(){
		if( $( this ).val() == '' ){
			$( this ).val( $( this ).attr( 'alt' ) );
		}
	}).bind( 'blur', function(){
		if( $( this ).val() == '' ){
			$( this ).val( $( this ).attr( 'alt' ) );
		}
	});*/
	
	$( '.trans' ).each( function(){
		$( this ).attr( "height", parseInt( $( this ).height() ) + "px");
	});
	
	$( '.showHide' ).each( function(){
		$( this ).attr( 'height', $( this ).height() );
	});
	
	$( '.btShowHide' ).bind( 'click', function(){
		$ref	= $(this).parent().parent().parent().parent();
		if ( $( '.showHide', $ref ).attr( 'nextStatus' ) == 'show' ){
			var height 		= parseInt( $('.showHide', $ref).attr( 'height' ) );
			$( '.showHide', $ref ).attr( 'nextStatus', 'hide' ).animate({ height: height + 'px' }, 1000);
			$( '.trans', $ref ).animate({height: (height + 10) + 'px'}, 1000);
		}else{
			$( '.showHide', $ref ).attr( 'nextStatus', 'show' ).animate({height: '0px'}, 1000);
			$( '.trans', $ref ).animate({height: '17px'}, 1000);
		}
	});
	
	$( '.btClose' ).bind( 'click', function(){
		$(this).parent().parent().parent().hide();
	});
	
	$( '.move' ).draggable();
	mainmenu();
	
	scrollPannels();
	posicionar();
	
	$( window ).bind( 'resize', function(){
		posicionar();
	});
	
});

function posicionar(){
	var $left;
	$left	= ( parseInt( $( window ).width() ) - 1040 ) / 2 ;
	$top	= ( parseInt( $( window ).height() - 550 ) ) / 2;
	
	if ($left > 0){
		$( '#contentALL' ).css({ left : $left + 'px' });
	}else{
		$( '#contentALL' ).css({ left : '0px' });
	}
	
	if ($top > 0){
		$( '#contentALL' ).css({ top : $top + 'px' });
	}else{
		$( '#contentALL' ).css({ top : '0px' });
	}
}

function mainmenu(){
	$( "#nav ul li ul" ).css({ display: "none" });
	$( "#nav li" ).hover( function(){
		$( this ).find( 'ul:first' ).css({ visibility: "visible", display: "none" }).show( 300 );
	},function(){
		$( this ).find( 'ul:first' ).css({ visibility: "hidden" });
	} );
}