/*********************************************************************************/
/**										**/
/**		Montagem:	Hudson Marinho (http://www.hudsonmarinho.co.cc/)	**/
/**		Contato: 	fale@hudsonmarinho.co.cc			**/
/**		Ano:		Março/2011				**/
/**										**/
/*********************************************************************************/

function empty(v){
	if(v==null || v==0 || v=='' || v=="")
	{
		return true;
	}
	else
	{
		return false;
	}
}




$(function(){
	
	//substitui o target="_blank"
	$('a[rel="blank"]').click(function(){
		window.open(this.href);
		return false;
	});
	
	
	// menu
	$('ul#menu > li ul li a').hover(function(){
		$(this).animate({
			'opacity'			: '1.0',
			'-moz-opacity'		: '1.0',
			'filter'			: 'alpha(opacity=100)'
		}, 'fast');
	},function(){
		$(this).animate({
			'opacity'			: '0.6',
			'-moz-opacity'		: '0.6',
			'filter'			: 'alpha(opacity=60)'
		}, 'fast');
	});
	
	
	// menu accordeon
	$("ul#menu li ul.subMenu").hide();
	
	$("ul#menu li a").click(function(){
		$(this).parent().parent().find("ul.subMenu:visible").animate({'height' : 'hide'});
		$(this).parent().find("ul.subMenu:hidden").animate({'height' : 'show'});
	});
	
	
	//align bg ao centro e redimenciona
	$.fn.supersized.options = {  
		startwidth:			1440,
		startheight:		764,
		minsize:			.50,
		vertical_center:	1,
		slideshow:			0,
		navigation:			1,
		transition:			1,
		pause_hover:		0,
		slide_counter:		1,
		slide_captions:		1,
		slide_interval:		7000
	};
	
	$('#bodyImage').supersized();
	
	
	//ajaxSite
	function pageload(hash)
	{
		$('form#formSearch').hide();
		
		if(hash)
		{
			$.browser.msie ? hash = encodeURIComponent(hash) : "";
			
			if(hash == 'blog')
			{
				$('#load').load("blog/", function(){
					$('form#formSearch').show();
				});
			}
			else
			{
				//alert("pages/" + hash + ".php");
				$('#load').load("pages/" + hash + ".php");
				
				if(hash == 'empreendimentos' || hash == 'empreendimentos-realizadas' || hash == 'empreendimentos-em-andamento' || hash == 'empreendimentos-lancamentos')
				{
					$("ul#menu li ul.subMenu").show();	
				}
			}
		}
		else
		{
			$("#load").empty();
			window.location = '#home';
		}
	}
	
	if(!window.location.hash)
	{
		$("#load").empty();
		window.location = '#home';
	}
	
	//alert(pageload())
	
	//$("#load").load("pages/home.php");
	
	$.historyInit(pageload, "pages/home.php");
	
	$("a[rel='history']").click(function(){
		var hash = this.href;
		
		hash = hash.replace(/^.*#/, '');
		$.historyLoad(hash);
		
		return false;
	});
	
	
	// blog
	/*$('.blogSupport').cycle({
		fx:     'scrollLeft',
		speed:  'slow',
		timeout: 12000,
		next:   'li.blogPaginationRight a',
		prev:   'li.blogPaginationLeft a'
	});*/
	
	
	//fale conosco
	$('#pageContato > input, #pageContato > textarea').focus(function(){
		var id = $(this).attr('id');
		
		if(id == 'nome')
		{
			$(this).css({'background-position' : '-420px 0px'});
		}
		if( id == 'email')
		{
			$(this).css({'background-position' : '-420px -40px'});
		}
		if( id == 'telefone')
		{
			$(this).css({'background-position' : '-420px -80px'});
		}
		if( id == 'mensagem')
		{
			$(this).css({'background-position' : '-420px -120px'});
		}
	}).blur(function(){
		var id = $(this).attr('id');
		
		if(id == 'nome')
		{
			$(this).css({'background-position' : '0 0px'});
		}
		if( id == 'email')
		{
			$(this).css({'background-position' : '0 -40px'});
		}
		if( id == 'telefone')
		{
			$(this).css({'background-position' : '0 -80px'});
		}
		if( id == 'mensagem')
		{
			$(this).css({'background-position' : '0 -120px'});
		}
	});
	
	
	
	$('input[title!=""]').hint();
});
