// JavaScript Document
$(document).ready( function(){
	
	// Tamanho da barra lateral
	if ( $("#rightColumn").height() > $("#leftColumn").height() )
		$("#leftColumn").height( $("#rightColumn").height() );
		
	$("#supportSolucao li:even").css('background-color','#E7E7E7');
	$("#support li:even").css('background-color','#E7E7E7');
	$("#leftColumn *").css({position:'relative'});
	$("#loginInterno").css('position','relative');
	$(".contentSolucaoDes").css('position','relative');
	
	
	//Limpa os inputs no OnFocus e volta com o valor no OnBlur
	var value;
	$(".inputText").focus( function(){
		if ( $(this).val() == $(this).attr('title') )
			$(this).val('');
	});
	$(".inputText").blur( function(){
		( $(this).val() == '' ) ? $(this).val( $(this).attr('title') ) : null;
	});
	
	// Muda os boxes de GAM
	var divWanted = location.href.split('#');
	var textClass;
	var imgSrc;
	if ( divWanted.length > 1 ){
		$("#steps li a[class*=selected]").removeClass('selected');
		$("#steps li a[href=#"+divWanted[1]+"]").addClass('selected');
		changeBox( $("#steps li a[class*=selected]").attr('href') );
	}
	
	if( $("#steps li a").hasClass('selected') ){
		textClass = $('#steps li a[class*=selected]').attr('class');
		imgSrc = $('#steps li a[class*=selected]').children().attr('src');
		$('#steps li a[class*=selected]').removeClass(textClass).addClass('arialGray14 selected');
		$('#steps li a[class*=selected]').children().attr('src','img/bullet_gray.jpg');
		pointerMove( $('#steps li a[class*=selected]').attr('rel') )
	}
	
	$("#steps li a").click( function(){
	if ( $(this).attr('href') == 'solicite-demonstracao.php' ){
		return true;
	} else {
		stepClick( $(this) );
		return false;
	}
	});
	
	function stepClick( object ){
		$("#steps li a[class*=arialGray14]").removeClass('arialGray14').addClass(textClass).children().attr('src',imgSrc);
		textClass = $(object).attr('class');
		imgSrc = $(object).children().attr('src');
		$(object).removeClass(textClass).addClass('arialGray14');
		$(object).children().attr('src','img/bullet_gray.jpg');
		pointerMove( $(object).attr('rel') );
		changeBox( $(object).attr('href') );
		
	}
	
	function pointerMove( pos ){
		$("img#pointer").animate( { left: pos+'px'} , 'fast' );
	}
	
	function changeBox( div ){
		$("#stepBox div:visible").css('display','none');
		$("#stepBox "+div).fadeIn('slow');
		$("#stepBox div *").css('display','');
	//	$("#stepBox div span").css('display','none');
	}
	
	// Tamanho do box dos posts
	if ( $("#postFooterContentLeft").height() > $("#postFooterContentRight").height() )
		$("#postFooterContentRight").height( $("#postFooterContentLeft").height() );
	else 
		$("#postFooterContentLeft").height( $("#postFooterContentRight").height() );
		
	// Tamanho do box de contato em Fça uma visita
	if ( $("#visitForm").height() > $("#visitRight").height() )
		$("#visitRight").height( $("#visitForm").height() );
	else 
		$("#visitRight").height( $("#visitForm").height() );
		
	/************************/
	/* BLOG BUG FIX
	/*************************/
	$("#sideBar").css({position:'relative'});
	
});
function openAdress(){
	$(".adressForm").fadeIn('slow');
	$("#locop").val('t');
}
function closeAdress(){
	$(".adressForm").fadeOut('slow');
	$("#de").val('');
	$('#locop').val('l');
}
function enviarPost( id , url , div ){
	$('#'+div).html('Enviando...');
	var form = $('#'+id).serialize();
	$.post( url , form, function (data){
		$('#'+div).html(data);						  
	});
}
function carregarUrl(url,target){
	$("#"+target+"").load(url);
}

function openFaq(span){
	if($("#"+span+"").hasClass('open')){
		$("#"+span+"").slideUp('fast');
		$("#"+span+"").removeClass('open');
	}else{
		$("#"+span+"").slideDown('fast');
		$("#"+span+"").addClass('open');
	}
}
