
$(document).ready(function(){

    $('#awards_images').cycle();

    $('#partnership img').mouseover(function() {
        var file_name = $(this).attr('src').split('gray_');
        $(this).attr('src', urlBase+'files/medias/images/small/'+ file_name[1]);
    });
    $('#partnership img').mouseout(function() {
        var file_name = $(this).attr('src').split('small/');

        $(this).attr('src', urlBase+'files/medias/images/small/gray_'+ file_name[1]);
    });

    $('a[class!=home]').click(function(){
        $.cookie('amtrans', true);
    })

    function scroll() {
        if($.cookie('amtrans')=='true') {
        $('html, body').scrollTop(340);
        $.cookie('amtrans', null)
        }
    }

    scroll();
    
    $("a[rel^='prettyPhoto']").prettyPhoto();

var open_menu;

    $('#menu li span').click(function() {
        if(open_menu!=$(this).html()) {
        open_menu = $(this).html()
        $('#menu li ul').slideUp('slow');
        }
        $('#menu li span').attr('class', '');
        $('#menu li.selected').attr('class', 'menu');
        $('#menu li span').css('color', 'black');
        $(this).attr('class', 'selected');
        $(this).css('color', 'white');
        $('+ ul', this).slideDown('slow');
    });

    

    $('#about_company').click(function() {
        var dataString = '';
        $.ajax({
            type: "POST",
            url: "index/about",
            data: dataString,
            async: false,
            success: function(serverResponse) {
                $.cookie('amtrans', true);
                $('#main_content').html(serverResponse);
                scroll();
                if($('#awards').html()!=undefined) {
                    if($('#awards').css('display')=='block') {
//                        $('#awards').css('display', 'none');
                    } else {
                        $('#awards').css('display', 'block');
                    }
                }
                
            }
        });
    });
    $('#offer').click(function() {
        var dataString = '';
        $.ajax({
            type: "POST",
            url: "index/offer",
            data: dataString,
            async: false,
            success: function(serverResponse) {
                $.cookie('amtrans', true);
                $('#main_content').html(serverResponse);
                scroll();
                if($('#awards').html()!=undefined) {
                    if($('#awards').css('display')=='block') {
                        $('#awards').css('display', 'none');
                    } else {
                        //$('#awards').css('display', 'block');
                    }
                }
                
            }
        });
    });
    $('#innovation').click(function() {
        var dataString = '';
        $.ajax({
            type: "POST",
            url: "index/innovation",
            data: dataString,
            async: false,
            success: function(serverResponse) {
                $.cookie('amtrans', true);
                $('#main_content').html(serverResponse);
                scroll();
                if($('#awards').html()!=undefined) {
                    if($('#awards').css('display')=='block') {
                        $('#awards').css('display', 'none');
                    } else {
                        //$('#awards').css('display', 'block');
                    }
                }
            }
        });
    });


});
