/*
 * jQuery PlaceHolder 1.0.2
 * http://www.kegles.com.br/placeholder/
 *
 * Copyright 2011, Nataniel Kegles
 * Free to use and abuse under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Octuber 2011
 *
 * ****************
 * ** HOW TO USE **
 * ****************
 * - Add holder="text" to inputs
 * - Use input.holder CSS class to style holdered fields
 *
 * ****************
 * ** CHANGELOG! **
 * ****************
 * Version: 1.0.2 - Date: 2011-10-31
 * - Improved search for holding fields with "holder!=''"
 * - Solved compatibility issues with jQuery.meiomask
 * - Added password fields compatibility
 *
 */

//search by holder fields
$(document).ready(function() {
    $("input[type=text,type=password][holder!='']").each(function(){
            var field = $(this);
            var ffield = $(field).attr("id")+"__jquery_placeholder_passwordFakeField";
            //replace password fields with a fake field
            if ($(field).attr("type") == "password") {
                var newfield  = $("<input type='text' class='"+$(field).attr("class")+"' id='"+ffield+"' tabindex='"+$(field).attr("tabindex")+"' holder='"+$(field).attr("holder")+"' />").focus(function() {
                                    $(this).hide();
                                    $(field).show();
                                    $(field).focus();
                                }).keypress(function(event) {
                                    event.preventDefault();
                                });
                $(newfield).insertBefore(field);
                $(field).hide();
            }
            //bind focus event
            $(field).bind("focus",function() {
                if ($(field).hasClass("holder")) {
                    $(field).val("");
                    $(field).removeClass("holder");
                }
            });
            //bind blur event, if is a password field and value='' show the fakefield
            $(field).bind("blur",function() {
                if ($(field).val() == "") {
                    if ($(field).attr("type") == "password") {
                        $(field).hide();
                        $("#"+ffield).show();
                    }
                    else {
                        $(field).val($(field).attr("holder"));
                        $(field).addClass("holder");
                    }
                }
            });
    });
    setTimeout("__jquery_placeholder_goTitling()",100);
});

//change the holding values
function __jquery_placeholder_goTitling() {
    $("input[type=text][holder!=''][value='']").each(function(){
        $(this).val($(this).attr("holder"));
        $(this).addClass("holder");
    });
}

//search by holder fields
$(document).ready(function() {
    
     $(".header a").tooltip({

       // tweak the position
       offset: [10, 2],

       // use the "slide" effect
       effect: 'slide'

    // add dynamic plugin with optional configuration for bottom edge
    }).dynamic({ bottom: { direction: 'down', bounce: true } });
    
    $(".footer a").tooltip({

       // tweak the position
       offset: [10, 2],

       // use the "slide" effect
       effect: 'slide'

    // add dynamic plugin with optional configuration for bottom edge
    }).dynamic({ top: { direction: 'up', bounce: true } });

    
    $(".aboutArticle img").tooltip({

       // tweak the position
       offset: [10, 2],

       // use the "slide" effect
       effect: 'slide'

    // add dynamic plugin with optional configuration for bottom edge
    }).dynamic({ top: { direction: 'up', bounce: true } });
    
  
});


//scrolling
$(document).ready(function() {
   $(".upperMenu").localScroll();
});

$(document).ready(function() {

    var url = window.location.toString();
    var anchor = url.split('#');
    
    if($("ul.tabs li:first").hasClass("active")){
    //When page loads...
    
    $(".tab_content div.newsContainers").hide(); //Hide all content
        
    if(anchor.length > 1 && anchor[1] != 'home'){
        $("ul.tabs li").removeClass("active").show();
        $("ul.tabs li a."+anchor[1]).parent().addClass("active").show(); //Activate first tab
        $('.'+anchor[1]).fadeIn();
        $.scrollTo('a[name=content]', 0 );
    }
    else{
        //$("ul.tabs li:first").addClass("active").show(); //Activate first tab  
        $(".tab_content div.newsContainers:first").fadeIn(); //Hide all content
    }
    
                   
    
    
    //On Click Event
    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content div.newsContainers").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        var activeTab = activeTab.split('#');
        $('.'+activeTab[1]).fadeIn(); //Fade in the active ID content
        $.scrollTo('a[name=content]', 1500 );
        return false;
    });
        
    }

});


$(document).ready(function() {

    /* This is basic - uses default settings */
    
    $(".galery a").fancybox();
    
    /* Using custom settings */

    /* Apply fancybox to multiple items */
    
    $(".galery a.group").fancybox({
        'transitionIn'    :    'elastic',
        'transitionOut'    :    'elastic',
        'speedIn'        :    600, 
        'speedOut'        :    200, 
        'overlayShow'    :    false
    });
    
});
