/*
JAVASCRIPT CRIADO POR JOHN-HENRIQUE
TODOS AS FUN??ES S?O N?O OBSTRUTIVO

*/


/*
	RETRIEVE THE FILENAME OF WORKS
*/
$( document ).ready( function()
{
	
	$( '.busca' ).css( 'text-align', 'left');
	
	
	$( '#form1' ).submit(function()
	{
		
		if( $( '#PaginaNome' ).val() != "" )
		{
			
			if( $( '#PaginaCnpj' ).val() != "" )
			{
				
				if( $( '#PaginaContato' ).val() != "" )	
				{
					
					if( $( '#PaginaFone' ).val() != "" )
					{
						
						if( $( '#PaginaEmail' ).val() != "" )
						{
							
							if( $( '#PaginaOnde' ).val() != "" )
							{
								
								if( ( $( '#PaginaMensagem' ).val() != "" ) || ( $( '#PaginaMensagem' ).val() == "" ) )
								{
									
									return true;
									
								}else{
									
									alert( "Você precisa informar sua mensagem" );
									$( this ).focus();
									return false;
								}
								
							}else{
								
								alert( "Você precisa informar onde nos conheceu" );
								$( this ).focus();
								return false;
							}
							
						}else{
							
							alert( "Você precisa informar o email de contato" );
							$( this ).focus();
							return false;
						}
						
					}else{
						
						alert( "Você prefisa informar o telefone de contato" );
						$( this ).focus();
						return false;
					}
					
				}else{
					
					alert( "Você precisa informar o nome do contato" );
					$( this ).focus();
					return false;
				}
				
			}else{
				alert( "Você precisa informar seu CPF ou o CNPJ da empresa." );
				$( this ).focus();
				return false;
			}
			
		}else{
			
			alert( "Você precisa informar o nome da empresa." );
			$( this ).focus();
			return false;
		}
		
	});
	
	
	var items = '#toolContainer';
	var itemTarget = '.message';
	var itemWidth = 400;
	var itemHeight = 200;
	var windowWidth = 0;
	var windowHeight = 0;
	
	
	$( '.toolss' ).bind( 'mouseover', function(e)
	{
		
		itemContent = $( this ).attr( 'title' );
		
		
		if( itemContent != 'undefined' )
		{
				
				
				var e = e ? e : window.event;
				var positionX = e.pageX? e.pageX: e.clientX + viewport.scrollX;
				var positionY = e.pageY? e.pageY: e.clientY + viewport.scrollY;
				
				
				    if (window.innerWidth) windowWidth = window.innerWidth - 18;
				    else if (document.documentElement && document.documentElement.clientWidth) 
				  		windowWidth = document.documentElement.clientWidth;
				    else if (document.body && document.body.clientWidth) 
				  		windowWidth = document.body.clientWidth;
				  
				    if (window.innerHeight) windowHeight = window.innerHeight - 18;
				  	else if (document.documentElement && document.documentElement.clientHeight) 
				  		windowHeight = document.documentElement.clientHeight;
				  	else if (document.body && document.body.clientHeight) 
				  		windowHeight = document.body.clientHeight;
				  
				  		
				  if( ( positionX + itemWidth ) > windowWidth )
				  {
				  	positionX = positionX - 500;
				  }
				  
				  if( ( positionX - 0 ) < 0 )
				  {
				  	positionX = positionX + 450;
				  }
				  
				  
				  if( ( positionX + itemHeight ) < windowHeight )
				  {
				  	positionY = positionY - 150;
				  }
				  
				  if( ( positionY - itemHeight ) < 0 )
				  {
				  	positionY = positionY + 150;
				  }
				  
				  
				  
				$( items ).css( 'left', ( positionX + 4 ) +'px' )
						.css( 'top', ( positionY + 4 ) +'px' )
						.css( 'position', 'absolute' )
						.css( 'margin', '0' )
						.css( 'padding', '0' );

				$( itemTarget ).html( itemContent );
				
				setTimeout( "$( '"+ items +"').fadeIn();", 3000 );
				stop();
				
				//$( items ).fadeIn(  );
				
				$( this ).bind( 'mouseout', function()
				{
					
					setTimeout( "$( '"+ items +"').fadeOut();", 2000 );
					//$( items ).fadeOut();
				});
				
				
				if(e.preventDefault){
				e.preventDefault();
				}
				return false;
				}
		
	});
	
	
	
});