/* jQuery function to create smallcaps on any element */
(function($) {
    $.fn.extend({
        smallCaps: function(options) {
            var defaults = {multiplier: 1.2}
            var options =  $.extend(defaults, options);
            return this.each(function() {
                var obj = $(this);
                $(obj).html($(obj).html().replace(/\b([A-Z])/g,'<span style="font-size:'+ parseInt(parseInt($(obj).css('font-size')) * options.multiplier) + 'px !important;">$1</span>'));
            });
        }
    });
})(jQuery);

function switch_lang() {
    var saved_path = '';
    var paths = window.location.pathname.split('/');
    var new_lang_code = $('select[name="language"] option:selected').val();
    var len = paths.length;
    
    if( len > 1 )
        for( i=2; i<len; i++ )
            saved_path += '/' + paths[i];
    
    var new_url = window.location.protocol.replace(/\:/g, '') + '://' + window.location.host + '/' + new_lang_code + saved_path;    
    window.location = new_url;
}

$(function() {
    $('#_language').msDropDown();

    $('#footer_nav h3, .nivo-caption h1').smallCaps({multiplier:1.38});
    $('.top-menu h3, .nivo-caption h2').smallCaps({multiplier:1.2});
    //Cufon.replace('h1, h2, h3, h4, h5, h6', { hover:true });

    /*
        $('.nivo-caption H1').smallCaps({multiplier:1.88});
        $('.nivo-caption H2').smallCaps({multiplier:1.2});
        Cufon.replace('.nivo-caption H1, .nivo-caption H2');
        Cufon.replace('.nivo-caption p');
    */
    
	//Remove outline from links
	$('a').click(function() {
		$(this).blur();
	});
	    
    $('#topnav_1').hover(
        function() {
            $('#dropdown_1').show();
        },
        function() {
            $('#dropdown_1').hide();
        }
    );

	if( $('#slider').length > 0 ) {
        $('#slider').nivoSlider({
            effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
            slices:15, // For slice animations
            animSpeed:750, // Slide transition speed
            pauseTime:6000, // How long each slide will show
            startSlide:0, // Set starting Slide (0 index)
            directionNav:true, // Next & Prev navigation
            directionNavHide:true, // Only show on hover
            controlNav:true, // 1,2,3... navigation
            controlNavThumbs:false, // Use thumbnails for Control Nav
            controlNavThumbsFromRel:false, // Use image rel for thumbs
            controlNavThumbsSearch: '.jpg', // Replace this with...
            controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
            keyboardNav:false, // Use left & right arrows
            pauseOnHover:true, // Stop animation while hovering
            manualAdvance:true, // Force manual transitions
            captionOpacity:0.8, // Universal caption opacity
            prevText: 'Prev', // Prev directionNav text
            nextText: 'Next', // Next directionNav text
            customChange: function() {
                Cufon.replace('.nivo-caption p', {fontFamily: 'Aller'});
                Cufon.replace('.nivo-caption h1, .nivo-caption h2', {fontFamily: 'Aller Bold'});
            }
        });

        /*
        $('#partners').carousel('#previous', '#next');
        
        //The auto-scrolling function
        function slide(){
          $('#next').click();
        }
        
        //Launch the scroll every 3.5 seconds
        var intervalId = window.setInterval(slide, 3500);
    
        //On user click deactivate auto-scrolling
        $('#previous, #next').click(
            function(event) {
              if(event.originalEvent) {
                  window.clearInterval(intervalId);
              }
            }
        );
        */

        /*
        $('div.slideme').click(function() {
            $('.core_open').hide();
            $('.slideme').addClass('core_inactive');
            $('.slideme').removeClass('core_active');
            $(this).addClass('core_active');
            $(this).removeClass('core_inactive');
            $('#core_open_' + this.id).show();
        });
        */
    }
    
    /*
    $('#___plusone_0 iframe').ready(function() {
        setTimeout("$('#___plusone_0').addClass('grid_2'); $('#___plusone_0').css('width', '');", 850);        
    });
    */
});

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20990403-1']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
