﻿$(function() {
	// detecta ie6
	if ($.browser.msie && $.browser.version == 6){
		window.location.href('http://www.4vconnect.com/erro.aspx');
	}
    //resolução da tela
    var altura = $(window).height();
    var corpo = $('body').height();
    var largura = $(window).width();

    //menu principal
    if ($('.nav li a').hasClass('ativo')) {
        var topAtivo = $('.nav .ativo').offset().top;
        var leftAtivo = $('.nav .ativo').offset().left;
        var fixLeft = parseInt(leftAtivo - 21);

        $('.ct-sb .nav').prepend('<span class="mn-seta" />');

        $('.mn-seta').css({
            top: topAtivo,
            left: fixLeft
        });

        $('.nav li').hover(function() {
            var topo = $(this).offset().top;
            $('.mn-seta').stop().animate({
                top: topo,
                duration: 'fast'
            });
        }, function() {
            $('.mn-seta').stop().animate({
                top: topAtivo,
                duration: 'fast'
            });
        });
    }
	
	//apaga form buscar
	
	var fValue = $('#s').attr('value');
	$('#s').focus(function(){
		if ($('#s').attr('value') == fValue){
			$('#s').attr('value', ' ');
		}						   
	});
	$('#s').blur(function(){
		if ($('#s').attr('value') == ' '){
			$('#s').attr('value', fValue);
		}						   
	});
	
	//zebra
	$('.ct-qtd-post:odd').css('background', '#fcf3ff');
	
    //slideshow
    $('.ct-slideshow').flash({
        src: 'http://blog.4vconnect.com/wp-content/themes/4vconnect/swf/slideshow.swf',
        width: 739,
        height: 234,
        wmode: 'transparent'
    });

});

//valida form

function validaForm(){
	if ($('#author').val() == "" || $('#author').val() == ""){
		Sexy.error('<h1>erro:</h1><p>digite o nome corretamente</p>');
		return false;
	}
	if ($('#email').val() == "" || $('#email').val().length < 4 || $('#email').val().indexOf("@") < 1 || $('#email').val().indexOf(".") < 7 ){
		Sexy.error('<h1>erro:</h1><p>digite o e-mail corretamente</p>');
		return false;
	}
	if ($('#comment').val() == "" || $('#comment').val().length < 4){
		Sexy.error('<h1>erro:</h1><p>digite uma mensagem</p>');
		return false;
	}

}

// ajusta rodape
$(document).ready(ajustaRodape);
window.setInterval(ajustaRodape, 500);
function ajustaRodape() {
    
    var altura = $(window).height();
    var corpo = $('body').height();
    var fixBottom = parseInt(altura - corpo);

    if (corpo > altura) {

    } else {
        if (altura > 595 && altura > 675) {
            fixBottom = parseInt(fixBottom - 33);
            $('.footer').css('marginTop', fixBottom);
        } else {
            $('.ct').css('paddingBottom', '30');
        }
    }
}