﻿$(document).ready(function () {
    Cufon.replace('.mainMenu > li > a', { fontFamily: "helvetica", hover: true });
    //Cufon.replace('.tres-grand-texte', { fontFamily: "eras", hover: true, textShadow: '#fff 1px 1px' });
    $('a.fancybox').fancybox();
    //$('ol.photos').innerfade({ speed: 'slow', timeout: 4000, type: 'sequence', containerheight: '169px', runningclass: 'photos-slide' });
    $.getScript(document.skinPath + 'js/login.js');
    /* $("#slider").simplyScroll({
    autoMode: 'loop',
    pauseOnHover: false,
    frameRate: 23,
    speed: 2
    });*/
    $('div.rangementFiche table.detail td img').hover(function () {
        $('div.rangementFiche table.detail th img').hide();
        $('div.rangementFiche table.detail th img.' + $(this).attr('class')).show();
    });
    $('#slider').css({ 'position': 'absolute' }).parent().css({ 'overflow': 'hidden', 'position': 'relative' });
    function preUl() {
        var ulWidth = 0;
        $.each($('#slider > li'), function () {
            ulWidth += $(this).outerWidth(true);
            $(this).clone().appendTo('#slider');
        });
        //$('#slider').css({ 'width': ulWidth * 2 });
        $('#slider').css({ 'width': '1972px' });
        sl(ulWidth);
    }
    function sl(ulWidth) {
        $('#slider').animate({ 'marginLeft': '-936px' }, 30000, 'linear', function () {
            $(this).css({ 'marginLeft': '0' });
            sl(ulWidth);
        });
    }
    preUl();

    $('.optaEcomECCreate table.optaForm').eq(2).find('input').eq(3).addClass('obligatoire').after('<span style="color:red;" id="obligeOptavis">obligatoire</span>');
    $('#obligeOptavis').hide();

    var countClic = 0;
    var countOblige = 0;
    var telOk = false;
    $('.optaEcomECCreate a.optaEcomBtn').click(function () {
        countOblige = 0;
        if ($('.optaEcomECCreate table.optaForm').eq(2).find('input').eq(3).val().length == 0) {
            $('#obligeOptavis').show();
            $.each($('.optaEcomECCreate table.optaForm').eq(2).find('input.obligatoire,select.obligatoire'), function (key, val) {
                if ($(val).val().length == 0) {
                    $(val).next().show();
                    countOblige++;
                }
            });
        } else {
            telOk = true;
            $.each($('.optaEcomECCreate table.optaForm').eq(2).find('input.obligatoire,select.obligatoire'), function (key, val) {
                if ($(val).val().length == 0) {
                    $(val).next().show();
                    countOblige++;
                }
            });
        }
        if ((telOk == true) && (countOblige == 0)) {
            countClic = 0;
        }
        if ((telOk == true) && (countClic == 0) && (countOblige == 0)) {
            $(this).click();
        }
        countClic++;
        return false;
    });
    $('.optaEcomECCreate table.optaForm').eq(2).find('input').eq(3).focusout(function () {
        if ($(this).val().length != 0) {
            $(this).next().hide();
        }
    });
    /* modification de la hauteur des divs en gestion du compte */

    /* calcul de la hauteur : */
    var hauteurAdresse = $('.ecFull .ecContent.ecCoord .header .maFiche').height() + $('.ecFull .ecContent.ecCoord .oeEcCoord-Fiche').height();
    $('.ecFull .ecContent.ecCoord .header .mesAdresses').css({'top':hauteurAdresse+'px'});
});
