/*
    Document   : main
    Created on : 20/10/2010, 09:31:00
    Author     : CarlosGarcia
    Description:
    Purpose of the javascript follows.
*/
var isLoadedGalery = false;
var isLoadedContact = false;
var isLoadedSeriesIImagine = false;
var isLoadedSeriesISee = false;
var isLoadedAbout = false;
var isAnimating = false;
var windowW = $(window).width();
var windowH = $(window).height();


$(document).ready(function() {
    getDimensions();
    $('#pan_about').hide();
    $('#pan_series_i_see').hide();
    $('#pan_series_i_imagine').hide();
    $('#pan_contact').hide();
    $('#pan_gallery').hide();
    $('#pan_projects').hide();
    if (currentContent != '#pan_home')
    	$('#pan_home').hide();
    
    
    $(window).bind("resize", getDimensions);
    
    $('.container_header_menu :button').click(function(e) {

        swapContent(this.id);

    });

    $('#bt_twitter').click(function(e) {

        url = "http://twitter.com/@herworlds";
        window.open( url, "Member Listing", "menubar=0,location=center,height=500,width=700" );

    });

    $('#bt_facebook').click(function(e) {

        url = "http://www.facebook.com/pages/Juliana-Manara-Photography/118541241524663";
        window.open( url, "Member Listing", "menubar=0,location=center,height=500,width=700" );

    });

     $('#bt_printsale').click(function(e) {

        window.open("http://www.theworldiimagine.com","_blank");

    });

    $('#last_gallery').css("display", "none");

    $('.preloader').hide();

});//Close Document Ready

function getDimensions() {
    windowH = $(window).height();
    windowW = $(window).width();
}

function setBgColor (color){
    $('html').css('background-color', color);
    
}

function swapContent(n_id){

    switch(n_id){

        case "bt_email":
                                   
                setBgColor('#f2f1ec');

                if (isLoadedContact == false){
                    url = "index.php?r=site/contato";
                    $('#pan_contact').load(url);
                    isLoadedContact = true;
                }
                $('#pan_projects').fadeOut('slow');
                $(currentContent).fadeOut('slow');
                $('#pan_contact').fadeIn('slow');
                
                currentContent = "#pan_contact";

                break;
            
        case "bt_profile":

                setBgColor('#f2f1ec');
                $('#pan_projects').fadeOut('slow');
                if (isLoadedAbout == false){

                    url = "index.php?r=site/perfil";
                    $('#pan_about').load(url);
                     
                    isLoadedAbout = true;
                }

                $(currentContent).fadeOut('slow');
                $('#pan_about').fadeIn('slow');

               

                currentContent = "#pan_about";
                
                break;

        case "bt_series_i_see":

                window.location.hash = '/site/series/i_see';
                $('#pan_projects').fadeOut('slow');
                $(currentContent).fadeOut('slow');
                
                if(isLoadedSeriesISee == true){
                   
                    $('#pan_series_i_see').fadeIn('slow');

                    setBgColor('#777777');
                }

                if (isLoadedSeriesISee == false){

                    $('.preloader').show("slow");
                    
                    url  = "index.php?r=site/series&type=i_see";

                    $('#pan_series_i_see').load(url, function(){

                        $('.preloader').hide();
                        
                        $('#pan_series_i_see').fadeIn('slow');

                        setBgColor('#929292');
                    });

                    isLoadedSeriesISee = true;
                }

                currentContent = "#pan_series_i_see";

                changeTextColor();
                break;

         case "bt_series_i_imagine":
        	 $('#pan_projects').fadeOut('slow');
                setBgColor('#F2F1EC');

                window.location.hash = '/site/series/i_imagine';
                
                $(currentContent).fadeOut('slow');

                if(isLoadedSeriesIImagine == true){
                    $('#pan_series_i_imagine').fadeIn('slow');
                }

                if (isLoadedSeriesIImagine == false){

                    $('.preloader').show("slow");
                    
                    url  = "index.php?r=site/series&type=i_imagine";
                    
                    $('#pan_series_i_imagine').load(url, function(){
                        
                        $('.preloader').hide();
                        
                        $('#pan_series_i_imagine').fadeIn('slow');
                        
                        
                    });

                    isLoadedSeriesIImagine = true;
                    
                }
                
                currentContent = "#pan_series_i_imagine";

                changeTextColor();
                break;

         case "bt_home":
        	 $('#pan_projects').fadeOut('slow');
                setBgColor('#f2f1ec');
                $(currentContent).fadeOut('slow');
                $('#pan_home').fadeIn('slow',function(){
                     $('.world_i_see').hide();
                     $('.world_i_imagine').hide();
                });
                    
                currentContent = "#pan_home";
                break;

           case "bt_gallery":
        	   $('#pan_projects').fadeOut('slow');
                $(currentContent).fadeOut('slow');
                $('#pan_gallery').fadeIn('slow');               
                
                currentContent = "#pan_gallery";
                break;

           case "bt_back_home":
        	   $('#pan_projects').fadeOut('slow');
                $(currentContent).fadeOut('slow');
                $('#pan_home').fadeIn('slow');
               
                currentContent = "#pan_home";
                break;

    }    

    //$("#trace").text(currentContent + " - " + n_id);
    
}

function showGallery(urlGallery, galleryTitle){

    setBgColor('#f2f1ec');
        
    $('.preloader').show("slow");

    $('.menu').css("display", "none");

    $('.container_menu_gallery').hide();
    
    $('#pan_gallery').load(urlGallery, function(){
        
        $('#gallery_container').show("fast");
        
    });

    if (currentContent != "#pan_gallery") {
        $(currentContent).fadeOut('slow');
        $('#pan_gallery').fadeIn('slow');
    }

    $('#pan_series_i_imagine').fadeOut('slow');

    $('#last_gallery').css("display", "block");

    $('#title_helper').val(galleryTitle);

    window.location.hash = urlGallery;

    currentContent = "#pan_gallery";
    
}

function changeTextColor(){

    if(currentContent == "#pan_series_i_see" ){
        $('.title_gallery').css("color", "#FFFFFF");
        $('.title_gallery_p').css("color", "#FFFFFF");
     
    }else{
        $('.title_gallery').css("color", "#606060");
        $('.title_gallery_p').css("color", "#606060");
    }

}



function escondeTudo(projeto, botao) {
	var currentProject='';
	if (vetorProjetos.length > 0) {
		for (var i=0; i<vetorProjetos.length; i++) {
			$(vetorProjetos[i]).hide();
		}
	}
	$('#pan_home').hide();
	//$('.preloader').show("slow");
	changeTextColor();
	$(currentContent).hide();
	currentContent = '#pan_projects';
	$(currentProject).fadeOut('slow');
	$(currentContent).fadeIn('slow');
	$(projeto).fadeIn('slow');
	currentProject = projeto;
	setBgColor('#f2f1ec');
	$('.title_gallery').css("color", "#606060");
    $('.title_gallery_p').css("color", "#606060");
    $('.preloader').hide();
    mudaEstiloBotao(botao);
}

function limpaLinks() {
	$('.no-default').css(
    		{
    			'color': '#606060',
    			'font-weight': 'normal'
    		});
}
function mudaEstiloBotao(botao) {
	$(botao).css(
    		{
    			'color': '#a4c9aa',
    			'font-weight': 'bold'
    		});
}

function exibeCarrossel(carrossel) {
	$(carrossel).slideToggle();
}

function fechaCarrossel(carrossel) {
	$(carrossel).slideUp();
}
