jQuery(document).ready(function($)
{   
    $('#frontpage_image_rotate').innerfade(
    {
        speed: 'slow',
        timeout: 5000,
        type: 'sequence'
    });
    
    $('.button').each(function()
    {
        $(this).after(unescape('%3Cspan class="button"%3Eaa%3C/span%3E'));
        $(this).hide();
        $(this).next('span.button').text($(this).val()).click(function()
        {
            $(this).prev('input.button').click();
        });
    });

    /*$(".increaseFont").click(function()
    {
        var currentFontSize = $('html').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum*1.2;
        $('html').css('font-size', newFontSize);
        return false;
    });*/

    $('#slides_tours').cycle(
    {
        fx:     'fade',
        next:   'a#rArrow_tours',
    	prev:   'a#lArrow_tours' ,
        timeout:   7500
    });

    $('#slides_events').cycle(
    {
        fx:     'none',
        next:   'a#rArrow_events',
    	prev:   'a#lArrow_events' ,
        timeout:   7500
    });

    $('#slides_testimonials').cycle(
    {
        fx:     'none',
        next:   'a#rArrow_testimonials',
    	prev:   'a#lArrow_testimonials' ,
        timeout:   7500
    });

    $('#slide_what_pics').cycle(
    {
        fx:     'none',
        next:   'div#what-product-nav-button-right',
    	prev:   'div#what-product-nav-button-left' ,
        timeout:   7500
    });

    $('a#font-increase').click(function()
    {
        var newsize = 0;
        if ($(this).hasClass("fontsize0"))
        {
            $(this).removeClass("fontsize0");
            $(this).addClass("fontsize1");
            newsize = 1;
            $('.fontsize0').each(function()
            {
                $(this).removeClass("fontsize0");
                $(this).addClass("fontsize1");
            });
        }
        else if ($(this).hasClass("fontsize1"))
        {
            $(this).removeClass("fontsize1");
            $(this).addClass("fontsize2");
            newsize = 2;
            $('.fontsize1').each(function()
            {
                $(this).removeClass("fontsize1");
                $(this).addClass("fontsize2");
            });
        }
        else if ($(this).hasClass("fontsize2"))
        {
            $(this).removeClass("fontsize2");
            $(this).addClass("fontsize3");
            newsize = 0;
            $('.fontsize2').each(function()
            {
                $(this).removeClass("fontsize2");
                $(this).addClass("fontsize3");
            });
        }
        else if ($(this).hasClass("fontsize3"))
        {
            $(this).removeClass("fontsize3");
            $(this).addClass("fontsize0");
            newsize = 0;
            $('.fontsize3').each(function()
            {
                $(this).removeClass("fontsize3");
                $(this).addClass("fontsize0");
            });
        }

        $.post(templateDir + '/AJAX.php?Action=SetFontSize&FontSize=' + newsize,
            function(data){ }
        );
        return false;
    });

    $.post(templateDir + '/AJAX.php?Action=GetFontSize', function(data)
    {
        $('a#font-increase').addClass("fontsize" + data);

        $('p').each(function()
        {
            if (!$(this).parent().parent().parent().hasClass('picBoxDiv'))
            {
                $(this).addClass("fontsize" + data);
            }
        });

        $('div#what-item-bodytext, div#threeColumn-middle-col').contents().each(function()
        {
            $(this).addClass("fontsize" + data);
        })
    });

    $('div[id=events-text]').css('background-color', 'transparent');
    
});

