var MainMenu1 = function() {
    this.height = 0;
    this.WaitMenuMoveEnd = false;
    this.OneTabOpened = false;
    this.LinearRaiseDiv = function(id, FromHeight, ToHeight, StepHeight, Delay) {
        if (FromHeight == 0) {
            $(id).style.display = 'block';
            $('ngPageOffset').style.display = 'block';
			//$('ngPageOffset').style.marginTop = '10px';
            $('ngPageOffsetAriane').style.display = 'block';
        }
        if (FromHeight >= ToHeight) {
            this.WaitMenuMoveEnd = false;
            return;
        }
        if (FromHeight + StepHeight >= ToHeight) {
            $('ngPageOffset').style.height = ToHeight + 'px';
            $('ngPageOffsetAriane').style.height = ToHeight + 'px';
            $(id).style.height = ToHeight + 'px';
            this.WaitMenuMoveEnd = false;
        } else {
            $('ngPageOffset').style.height = (FromHeight + StepHeight) + 'px';
            $('ngPageOffsetAriane').style.height = (FromHeight + StepHeight) + 'px';
            $(id).style.height = (FromHeight + StepHeight) + 'px';
            window.setTimeout('MainMenu.LinearRaiseDiv(\'' + id + '\',' + (FromHeight + StepHeight) + ','
                + ToHeight + ',' + StepHeight + ',' + Delay + ');', Delay);
        }
    }

    this.LinearReduceDiv = function(id, FromHeight, ToHeight, StepHeight, Delay) {
        if (FromHeight <= ToHeight) {
            if (ToHeight == 0) {
                $(id).style.display = 'none';
                $('ngPageOffset').style.display = 'none';
                $('ngPageOffsetAriane').style.display = 'none';
            }
            this.WaitMenuMoveEnd = false;
            var parentLi = $(this.OneTabOpened).parentNode;
            parentLi.className = '';
            this.OneTabOpened = false;
            return;
        }
        if (FromHeight - StepHeight <= ToHeight) {
            $(id).style.height = ToHeight + 'px';
            $('ngPageOffset').style.height = ToHeight + 'px';
            $('ngPageOffsetAriane').style.height = ToHeight + 'px';
            if (ToHeight == 0) {
                $(id).style.display = 'none';
                $('ngMenuContent').style.display = 'none';
                $('ngPageOffset').style.display = 'none';
                $('ngPageOffsetAriane').style.display = 'none';
                if ($(this.OneTabOpened)) {
                    var parentLi = $(this.OneTabOpened).parentNode;
                    parentLi.className = '';
                }
                this.OneTabOpened = false;
                this.WaitMenuMoveEnd = false;
            }
        } else {
            $('ngPageOffset').style.height = (FromHeight - StepHeight) + 'px';
            $('ngPageOffsetAriane').style.height = (FromHeight - StepHeight) + 'px';
            $(id).style.height = (FromHeight - StepHeight) + 'px';
            window.setTimeout('MainMenu.LinearReduceDiv(\'' + id + '\',' + (FromHeight - StepHeight) + ','
                + ToHeight + ',' + StepHeight + ',' + Delay + ');', Delay);
        }
    }

    this.ClickOnMenuTab = function(tab) {
        if (this.WaitMenuMoveEnd) return;
        if (this.OneTabOpened == tab) {
            this.CloseMenuTab();
        } else {
            var height = 250;
            this.OpenMenuTab(height, null, tab);
        }
    }

    this.OpenMenuTab = function(height, content, tab) {
        $('ngMenuContent').style.display = 'block';
        var id = 'ngMenuContentCenter';
        if (this.WaitMenuMoveEnd) {
            return;
        }
        $('ngFetchTabContent').style.display = 'none';
        $('ngMoreTabContent').style.display = 'none';
        $(tab + 'Content').style.display = 'block';
        if (!this.OneTabOpened) {
            this.WaitMenuMoveEnd = true;
            this.height = height;
            if (BrowserDetect.browser + BrowserDetect.version == "Explorer6") {
                this.LinearRaiseDiv(id, 0, this.height, 30, 0);
            } else {
                this.LinearRaiseDiv(id, 0, this.height, 18, 0);
            }
        } else {
            var parentLi = $(this.OneTabOpened).parentNode;
            parentLi.className = '';
        }
        this.OneTabOpened = tab;
        var parentLi = $(this.OneTabOpened).parentNode;
        parentLi.className = 'ngSelectedMenuLi';
    }

    this.CloseMenuTab = function() {
        var id = 'ngMenuContentCenter';
        if (this.WaitMenuMoveEnd) {
            return;
        }
        this.WaitMenuMoveEnd = true;
        if (BrowserDetect.browser + BrowserDetect.version == "Explorer6") {
            this.LinearReduceDiv(id, this.height, 0, 30, 0);
        } else {
            this.LinearReduceDiv(id, this.height, 0, 18, 0);
        }
        this.height = 0;
    }

    this.CloseWhilePopUpIsOpening = function() {
        if (this.WaitMenuMoveEnd) return false;
        if (this.OneTabOpened) {
            this.CloseMenuTab();
            var parentLi = $(this.OneTabOpened).parentNode;
            parentLi.className = '';
        }
        return true;
    }
}
var MainMenu = new MainMenu1();

var SlideShow1 = function() {
    this.Sense = 0;
    this.__MyMax = 3;

    this.ScrollRight = function(offset) {
        var tmp = 10;
        document.getElementById('ngItemContainer').scrollLeft -= tmp;
        var code = 'Slide.ScrollRight(';
        code += offset - tmp;
        code += ');';
        if (offset - tmp > 0)
            setTimeout(code, 10);
    }

    this.ScrollLeft = function(offset) {
        if (document.getElementById('ngItemContainer').scrollLeft >= (this.__MyMax * 300))
            return;
        var tmp = 10;
        document.getElementById('ngItemContainer').scrollLeft += tmp;
        var code = 'Slide.ScrollLeft(';
        code += offset - tmp
        code += ');';
        if (offset - tmp > 0)
            setTimeout(code, 10);
    }

    this.Job = function() {
        if (document.getElementById('ngItemContainer').scrollLeft >= ((this.__MyMax - 1) * 299)) {
            this.Sense = 1;
        }
        if (Sense = 1 && document.getElementById('ngItemContainer').scrollLeft == 0) {
            this.Sense = 0;
        }
        if(this.Sense == 1){
            window.setTimeout(function() { Slide.ScrollRight(300); Slide.Job(); }, 6000);
        } else {
            window.setTimeout(function() { Slide.ScrollLeft(300); Slide.Job(); }, 6000);
        }
    }

}
window.setTimeout(function() {
    if ($('ngItemContainer') && typeof ($('ngItemContainer')) != "undefined") {
        window.Slide = new SlideShow1();
        window.setTimeout("window.Slide.Job();", 500);
    }
}, 500);
NewsLetterPopUp = function() {
    this.Open = function() {
        MyModalPopup('LOCAL::AjaxPages/NewsLetter/NewsLetterPopUp.htm', NewsLetter.OpenCB);
    }

    this.OpenCB = function(response, params) {
        SuroundWithPopup('ngThisPopup');
        if (__USERINFOS_UserGuid != "" && __USERINFOS_Promo == 1) {
            $('WarningMessage').style.display = 'block';
            $('ngNewsLetterBlk').innerHTML = "&nbsp;";
            $('ngNewsLetterBlk').style.height = '50px';
            window.setTimeout("CloseModalPopup();", 3000);
        }
        else if (__USERINFOS_UserGuid != "") {
            $('ngInputNewsletterTxt').value = __USERINFOS_Email;
        } else {
            InitWaterMark('ngInputNewsletterTxt');
        }
    }


    this.GoNewsletterSignIn = function(Email) {
        //ShowAjaxLoading();
        $('ngNewsLetterSubmit').disabled = true;
        AjaxHttpPost(__URL_POST_RegisterNewsLetter, "Email=" + Email, NewsLetter.GoNewsletterSignInCallBack, null);
    }

    this.GoNewsletterSignInCallBack = function(text, params) {
        //HideAjaxLoading()
        $("WarningMessage").style.display = '';
        if (text == "Invalid") {
            $("WarningMessage").innerHTML = "Email invalide.";
            $('ngNewsLetterSubmit').disabled = false;
        }
        else {
            $("WarningMessage").innerHTML = "Inscription r&eacute;ussie!<br/>Cette fen&ecirc;tre va se fermer dans quelques secondes.";
            window.setTimeout("CloseModalPopup();", 3000);
        }
    }
}

var NewsLetter = new NewsLetterPopUp();