$(document).ready(function()
{
    var browserWidth = getBrowserWidth();

    if ( browserWidth < 1024 )
    {
        $('.centerMain').css({
            'left': '20px',
            'margin-left': '0'
        });
    }
    
    if (browserWidth > 960){
    	$('html').css('overflow-x', 'hidden');
    }

	$('#listAllSol').css('display', 'none');
	$('#listSoftweb').css('display', 'none');
	$('#boxMenuSolucoes').css('display', 'none');
	var sliderStatus = false;

	$("#menuSolucoes .menuAction").mouseenter(function() {
		$("#boxMenuSolucoes").stop(true, true).slideDown();
	});
	
	$("#menuSolucoes").mouseleave(function() {
		$("#boxMenuSolucoes").stop(true, true).slideUp();
	});
	


	//Faq Solução
	$(".descSolucao dt").click(function(event) {
		$(event.target).next('dd').slideToggle();
	});
	

	//Form fale com o consultor
	$("#faleConsultor").click(function() {
		$("#formConsultor").slideToggle();
		return false;
	});
    
    
	$('.topoMenuButton li.show').mouseover(function(){  
		$('#listAllSol').css('display', 'block');
	});
	
	$('.topoMenuButton li.show').mouseout(function(){   
		$('#listAllSol').css('display', 'none');
	});

	$('#menuSoftweb').mouseover(function(){  
		$('#listSoftweb').css('display', 'block');
	});
	
	$('#menuSoftweb').mouseout(function(){   
		$('#listSoftweb').css('display', 'none');
	});
	
	$('#menuSoftWeb li.show').mouseover(function(){  
		$('#soft-menu-beneficios').css('display', 'block');
	});
	
	$('#menuSoftWeb li.show').mouseout(function(){   
		$('#soft-menu-beneficios').css('display', 'none');
	});
	
	$('.showMore').click(function(){
		var display = $(this).attr('display');
		$('#'+display).slideToggle();
	});

	//Tips
	$("*[boxtip]").hover(function(){
		
		var tid = $(this).attr('id');
		var box = $(this).attr('boxtip');
		var offset = $(this).position();
        
		$("#" + box)
		.css("position", "absolute")
		.css("top", (offset.top - 35 - $("#" + box).height()) + "px")
		.css("left", (offset.left) + "px")
		.css("display", "block")
		.fadeIn("fast");
		
	}, function(){
		var tid = $(this).attr('id');
		var box = $(this).attr('boxtip');
		$("#" + box).css("display","none");
	});
	
	//Tips com click
	$("*[boxtip-click]").click(function(){
		
		var box = $(this).attr('boxtip-click');
		var offset = $(this).position();
		var boxsel = $("#" + box);
		
		if ($(boxsel).data('show') == 1)
		{
			$(boxsel).css("display","none");
			$(boxsel).data('show',0);
		} else {
			$(boxsel)
                .css("position", "absolute")
                //.css("top", (offset.top - 35 - $("#" + box).height()) + "px")
                .css("left", (offset.left) + "px")						
                .css("display", "block")
                .fadeIn("fast")
                .data('show', 1);
		}
	});
	
	//$('a.lightbox').lightBox();
	
	$(".table-zebra tr:nth-child(odd)").addClass("zebra-odd");
	
	$('#menuAcesso .dcmenu').hover(function(){  
		$(this).find('.menu').toggle();
	});
	
	$('.menu').mouseleave(function(){ 
		//$(this).css('display', 'none');
	});
	
    
    // campo dúvida //
    var duvida = $('#duvida');
    if ( duvida.val() == '' ) duvida.val(duvida.attr('frasePadrao'));
    duvida.focus(function()
    {
        if ( $(this).val() == $(this).attr('frasePadrao') )
            $(this).val('');
    });
    duvida.blur(function()
    {
        if ( $(this).val().replace(/^\s+|\s+$/, '') == '' )
            $(this).val($(this).attr('frasePadrao'));
    });
    
    $('input[type=image].botao').click(function()
    {
        var duvida = $('#duvida');
        var duvidaValue = duvida.val().replace(/^\s+|\s+$/, '').replace(/\s{2,}/, ' ');
        if ( (duvidaValue == duvida.attr('frasePadrao')) || (duvidaValue == '') )
        {
            alert(' O campo "'+duvida.attr('frasePadrao')+'" deve ser preenchido!');
            duvida.focus();
            return false;
        }
    });
    
});


/**
 * Tamanho da janela
 * @return {Integer}
 */
function getBrowserWidth()
{
    if ( window.innerWidth ) {
        return window.innerWidth;
    } else if ( document.documentElement && document.documentElement.clientWidth != 0 ) {
        return document.documentElement.clientWidth;
    } else if ( document.body ) {
        return document.body.clientWidth;
    }
    return 0;
}


var IE6UPDATE_OPTIONS = {
	icons_path : "../js/ie6update/images/",
	message : "O Internet Explorer necessita de updates para visualizar esta página corretamente. Clique aqui para atualizar... ",
	url : "http://www.microsoft.com/brasil/windows/internet-explorer/worldwide-sites.aspx"
};

/**
 * Abre um popup
 * @param {String} url
 * @param {Integer} w
 * @param {Integer} h
 */
function popup(url, w, h)
{
	var screenW = screen.width;
	var screenH = screen.height;
	var left = (screenW - w) / 2;
	var top = (screenH - h) / 2;
	window.open(url,'popup', 'width='+w+', height='+h+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

