var estados = null;
$(document).ready(function() {   		
    
    if(estados == null){
        estados = $("#campoEstado").html();
    }
    
    $("a[rel=gallery_group]").fancybox({
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'titlePosition' 	: 'over'
    }); 
	
	
    $('ul.thumb-images li a').live('click', function() {
        selector = "#image-" + $(this).attr('id');       
        $('ul.main-images li').removeClass('active');
        $(selector).addClass('active');
        return false;
    })   
	
    $('a.panel').live('click', function() {
        $(this).hide();
        $('#box-login').show();
        return false;
    })  
	
    $('a.close-box').live('click', function() {
        $('#box-login').hide();
        $('a.panel').show();
        return false;
    })
    
    $("#bt-login").click(function(){
        $('#loginError').hide();
        jQuery.post(LINK_BASE+"index/login", {
            login: $('#code').val(),
            senha: $('#password').val()
        }, function(data) {
            if(data == 'OK'){
                window.location.href = LINK_BASE;
            }else{
                $('#loginError').show();
            }
        });        
    });
    
    $("#esqueci-senha").click(function(){
        $("#login").hide();
        $("#esqueci").show();
        return false;
    });
    
    $("#bt-solicitar").click(function(){
        if($('#code2').val() != ''){
            $('#esqueciSucesso').hide();
            $('#esqueciError').hide();
            jQuery.post(LINK_BASE+"index/esqueci", {
                login: $('#code2').val()
            }, function(data) {
                if(data == 'OK'){
                    $('#esqueciSucesso').show();
                    $('#code2').val('');
                }else{
                    $('#esqueciError').show();
                }
            });   
        }
        return false;
    });
    $("#esqueci-cancelar").click(function(){
        $("#login").show();
        $("#esqueci").hide();
        return false;
    });    
    
    $("#pais").change(function(){
        if($(this).val() != 'Brasil'){
            $("#campoEstado").html('<input type="text" id="estado" name="estado" maxlenght="4" class="campotxt"/>');
        }else{
            $("#campoEstado").html(estados);
        }
    });
}); 

function formatText(index, panel) {
    return index + "";
}
//    
//$(function () {
//    $('#slider').anythingSlider({ 
//        easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
//        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
//        delay: 7000,                    // How long between slide transitions in AutoPlay mode
//        startStopped: false,            // If autoPlay is on, this can force it to start stopped
//        animationTime: 600,             // How long the slide transition takes
//        hashTags: false,                // Should links change the hashtag in the URL?
//        buildNavigation: true,       	// If true, builds and list of anchor links to link to each slide
//        pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
//        startText: "",             		// Start text    
//        stopText: "",               	// Stop text
//        navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
//    });
//});
