﻿// Assurland  javascript ressources

// Assurland navigation site mode
var al_siteMode;
// Assurland random number
var al_assurlandRandomNumber;
// A/B Testing variation id
var al_abtv;

//////////////////////////////
// Liwio tracking
/////////////////////////////
var al_liwio = false;
var al_liwioDebug = false;
var al_liwioProduct = null;
function lwCall(f, p1, p2, p3) {
    try {
        if (al_liwio) {
            if (p1 != null) p1 = lwClean(p1);
            if (p2 != null) p2 = lwClean(p2);
            if (p3 != null) p3 = lwClean(p3);
            if (al_liwioDebug)
                alert("Lw." + f + "('" + p1 + "'" + (p2 != null ? ",'" + p2 + "'" : "") + (p3 != null ? ",'" + p3 + "'" : "") + ")");
            if (p3 != null && p2 != null && p1 != null)
                eval("Lw." + f + "('" + p1 + "', '" + p2 + "', '" + p3 + "')");
            else if (p2 != null && p1 != null)
                eval("Lw." + f + "('" + p1 + "', '" + p2 + "')");
            else if (p1 != null)
                eval("Lw." + f + "('" + p1 + "')");
        }
    } catch (ex) {
        if (al_liwioDebug) alert(ex);
    }
}
function lwClean(str) {
    var str2 = '' + str;
    str2 = str2.replace(/[ÀÁÂÃÄÅ]/g, "A");
    str2 = str2.replace(/[àáâãäå]/g, "a");
    str2 = str2.replace(/[ÒÓÔÕÖØ]/g, "O");
    str2 = str2.replace(/[òóôõöø]/g, "o");
    str2 = str2.replace(/[ÈÉÊË]/g, "E");
    str2 = str2.replace(/[èéêë]/g, "e");
    str2 = str2.replace(/[ÌÍÎÏ]/g, "I");
    str2 = str2.replace(/[ìíîï]/g, "i");
    str2 = str2.replace(/[ÙÚÛÜ]/g, "U");
    str2 = str2.replace(/[ùúûü]/g, "u");
    str2 = str2.replace(/[Ÿ]/g, "Y");
    str2 = str2.replace(/[ÿ]/g, "y");
    str2 = str2.replace(/[Ñ]/g, "N");
    str2 = str2.replace(/[ñ]/g, "n");
    str2 = str2.replace(/[Ç]/g, "C");
    str2 = str2.replace(/[ç]/g, "c");
    str2 = str2.replace(new RegExp("\\'", "g"), "\\'");
    str2 = str2.replace(/^\s+/g, '').replace(/\s+$/g, '');
    return str2;
}
function lwEvent(p1, p2, p3) {
    lwCall("event", p1, p2, p3);
}
function lwTrans(p1, p2, p3) {
    lwCall("trans", p1, p2, p3);
}
function lwTpv(p1, p2, p3) {
    lwCall("tpv", p1, p2, p3);
}
function lwTpvUrl(url, p1) {
    try {
        var p = url.substring(url.indexOf("/", 7), url.length);
        if (p1 != null && p1 != "") {
            p += "#" + p1.replace(/^\s+/g, '').replace(/\s+$/g, '').replace(/\s/g, "-");
        }
        lwTpv(p);
    } catch (ex) {
        if (al_liwioDebug) alert(ex);
    }
}
function lwTpvUrlFull(p1) {
    try {
        lwTpvUrl(document.location.href, p1);
    } catch (ex) {
        if (al_liwioDebug) alert(ex);
    }
}
function lwTpvUrlBase(p1) {
    try {
        var url = document.location.href;
        if (url.indexOf("?") > 0) {
            // Url without query string
            url = url.substring(0, url.indexOf("?"));
        }
        if (url.indexOf("#") > 0) {
            // Url without query string
            url = url.substring(0, url.indexOf("#"));
        }
        lwTpvUrl(url, p1);
    } catch (ex) {
        if (al_liwioDebug) alert(ex);
    }
}

/////////////////////////////////////////////////////////////////////
//                         OLD COMMON                             //
////////////////////////////////////////////////////////////////////
var al_debug = false;

function displayAspNetFrameworkError(message, error) {
    if (al_debug)
        alert(message + "\n" +
                "Service Error: " + error.get_message() + "\n" +
                "Status Code: " + error.get_statusCode() + "\n" +
                "Exception Type: " + error.get_exceptionType() + "\n" +
                "Timedout: " + error.get_timedOut() + "\n" +
                "Stack Trace: " + error.get_stackTrace());
    else
        alert(message + "\n" +
        "Service Error: " + error.get_message() + "\n" +
        "Status Code: " + error.get_statusCode() + "\n" +
        "Exception Type: " + error.get_exceptionType() + "\n" +
        "Timedout: " + error.get_timedOut());
}

//////////////////////////////
// Browser detection
/////////////////////////////

// Thanks to http://www.quirksmode.org/js/detect.html
var BrowserDetect = {
    init: function() {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function(data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function(dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};
BrowserDetect.init();

//////////////////////////////
// Basic functions
/////////////////////////////

function trim(str) {
    return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
function trimChar(str, c) {
    return trimCharRight(trimCharLeft(str, c), c);
}
function trimCharLeft(str, c) {
    reg = new RegExp("^(" + c + ")+", "g");
    return str.replace(reg, '');
}
function trimCharRight(str, c) {
    reg = new RegExp("(" + c + ")+$", "g");
    return str.replace(reg, '');
}
function removeAccents(str) {
    var str2 = '' + str;
    str2 = str2.replace(/[ÀÁÂÃÄÅ]/g, "A");
    str2 = str2.replace(/[àáâãäå]/g, "a");
    str2 = str2.replace(/[ÒÓÔÕÖØ]/g, "O");
    str2 = str2.replace(/[òóôõöø]/g, "o");
    str2 = str2.replace(/[ÈÉÊË]/g, "E");
    str2 = str2.replace(/[èéêë]/g, "e");
    str2 = str2.replace(/[ÌÍÎÏ]/g, "I");
    str2 = str2.replace(/[ìíîï]/g, "i");
    str2 = str2.replace(/[ÙÚÛÜ]/g, "U");
    str2 = str2.replace(/[ùúûü]/g, "u");
    str2 = str2.replace(/[Ÿ]/g, "Y");
    str2 = str2.replace(/[ÿ]/g, "y");
    str2 = str2.replace(/[Ñ]/g, "N");
    str2 = str2.replace(/[ñ]/g, "n");
    str2 = str2.replace(/[Ç]/g, "C");
    str2 = str2.replace(/[ç]/g, "c");
    return str2;
}

function strTofixed(str) {
    if (str) {
        return (parseFloat(str.replace(/,/g, '.'))).toFixed(2).replace(/\./g, ',');
    }
    return "";
}

function strReplace(str1, regExpPattern, str3) {
    return str1.replace(new RegExp("" + regExpPattern + "", "g"), str3);
}

function getInt(value) {
    return value * 1;
}
function isInt(value) {
    return !isNaN(getInt(value));
}
function getDouble(value) {
    return value.replace(/\,/g, ".") * 1.0;
}
function isDouble(value) {
    return !isNaN(getDouble(value));
}
function getStr(value) {
    return "" + value;
}

function mouseX(e) {
    if (e.pageX)
        return e.pageX;
    else if (e.clientX)
        return e.clientX + scrollX();
    else return null;
}
function mouseY(e) {
    if (e.pageY) return e.pageY;
    else if (e.clientY)
        return e.clientY + scrollY();
    else return null;
}
function scrollX() {
    var offsetX = 0;
    if (!window.pageXOffset) {
        if (!(document.documentElement.scrollLeft == 0))
            offsetX = document.documentElement.scrollLeft;
        else
            offsetX = document.body.scrollLeft;
    }
    else
        offsetX = window.pageXOffset;
    return offsetX;
}
function scrollY() {
    var offsetY = 0;
    if (!window.pageYOffset) {
        if (!(document.documentElement.scrollTop == 0))
            offsetY = document.documentElement.scrollTop;
        else
            offsetY = document.body.scrollTop;
    }
    else
        offsetY = window.pageYOffset;
    return offsetY;
}

function scrollToTop() {
    //scrollY_Move(0);
    // Delay update seems to be required to move scroll 
    // after updatepanel update
    setTimeout("scrollTo(0,0);", 100);
}

function getElementPositionAttribute(elt) {
    if (elt.currentStyle)
        return elt.currentStyle.position;
    else
        return window.getComputedStyle(elt, null).position;
}

function getFirstAbsoluteOrRelativeParent(elt) {
    if (elt == null || elt == document)
        return null;

    var pos = getElementPositionAttribute(elt);
    if (pos != null && (pos == "relative" || pos == "absolute")) {
        return elt;
    }
    else {
        if (elt.parentNode != null)
            return getFirstAbsoluteOrRelativeParent(elt.parentNode);
        else
            return null;
    }
}
function getRelativeBounds(elt, popup) {
    var relativeParent = getFirstAbsoluteOrRelativeParent(popup.parentNode);
    if (relativeParent != null) {
        var boundsParent = Sys.UI.DomElement.getBounds(relativeParent);
        var boundsElt = Sys.UI.DomElement.getBounds(elt);
        boundsElt.x = boundsElt.x - boundsParent.x;
        boundsElt.y = boundsElt.y - boundsParent.y;
        return boundsElt;
    }
    else {
        return Sys.UI.DomElement.getBounds(elt);
    }
}

function addToArray(array, value) {
    if (array != null)
        array[array.length] = value;
}

// Cross-browser implementation of element.addEventListener()
function addListener(element, type, expression, bubbling) {
    bubbling = bubbling || false;
    if (window.addEventListener) { // Standard
        element.addEventListener(type, expression, bubbling);
        return true;
    } else if (window.attachEvent) { // IE
        element.attachEvent('on' + type, expression);
        return true;
    } else return false;
}
function removeListener(element, type, expression, bubbling) {
    bubbling = bubbling || false;
    if (window.removeEventListener) { // Standard
        element.removeEventListener(type, expression, bubbling);
        return true;
    } else if (window.detachEvent) { // IE
        element.detachEvent('on' + type, expression);
        return true;
    } else return false;
}
function goToURL(url, parent) {
   // alert("goToURL");
    /*window.location.href = url;*/
    /* location.href don't send HTTP_REFERER in request header on IE */
    if (typeof parent == 'undefined')
        parent = false;
    var w = (parent ? window.parent : window);
    if (BrowserDetect.browser == 'Explorer') {
       
        var fakeLink = w.document.createElement("a");
        fakeLink.href = url;
        //alert("fakeLink.click");
        w.document.body.appendChild(fakeLink);
        fakeLink.click();   // click() method defined in IE only
    }
    else {
      //  alert("sends referrer in FF");
        w.location.href = url;  // sends referrer in FF, not in IE 
    }
}
function setVisibility(eltId, visible) {
    (visible ? show(eltId) : hide(eltId));
}
function show(eltId) {
    if ($get(eltId) != null)
        $get(eltId).style.display = 'block';
}
function showInline(eltId) {
    if ($get(eltId) != null)
        $get(eltId).style.display = 'inline';
}
function hide(eltId) {
    if ($get(eltId) != null)
        $get(eltId).style.display = 'none';
}
function showHide(eltId) {
    $get(eltId).style.display = (($get(eltId).style.display == 'none') || ($get(eltId).style.display == '')) ? 'block' : 'none';
}
function showTable(tblId) {
    var elt = $get(tblId);
    if (elt != null) {
        if (typeof window.opera != "undefined")
            elt.style.display = 'table';
        else if (navigator.appName == 'Microsoft Internet Explorer')
            elt.style.display = 'block';
        else
            elt.style.display = 'table';
    }
}
function showRow(rowId) {
    var elt = $get(rowId);
    if (elt != null) {
        if (typeof window.opera != "undefined")
            elt.style.display = 'table-row';
        else if (navigator.appName == 'Microsoft Internet Explorer')
            elt.style.display = 'block';
        else
            elt.style.display = 'table-row';
    }
}
function showCell(cellId) {
    var elt = $get(cellId);
    if (elt != null) {
        if (typeof window.opera != "undefined")
            elt.style.display = 'table-cell';
        else if (navigator.appName == 'Microsoft Internet Explorer')
            elt.style.display = 'block';
        else
            elt.style.display = 'table-cell';
    }
}
function hideTable(tblId) {
    hide(tblId);
}
function hideRow(rowId) {
    hide(rowId);
}
function hideCell(cellId) {
    hide(cellId);
}
function isRowVisible(rowId) {
    if ($get(rowId) != null)
        return $get(rowId).style.display != 'none';
    return false;
}
function showRows(rowIdArray) {
    if (rowIdArray != null)
        for (var i = 0; i < rowIdArray.length; i++)
        showRow(rowIdArray[i]);
}
function hideRows(rowIdArray) {
    if (rowIdArray != null)
        for (var i = 0; i < rowIdArray.length; i++)
        hideRow(rowIdArray[i]);
}
function setRowVisibility(rowId, visible) {
    if (visible == true)
        showRow(rowId);
    else
        hideRow(rowId);
}
function setCellVisibility(rowId, visible) {
    if (visible == true)
        showCell(rowId);
    else
        hideCell(rowId);
}
function hideElementByTypeIn(parentId, eltType) {
    var elt = $get(parentId);
    if (elt != null) {
        var obj = elt.getElementsByTagName(eltType);
        if (obj && obj.length) {
            for (var i = 0; i < obj.length; i++) {
                hide(obj[i].id);
            }
        }
    }
}
function setInnerHtml(eltId, text) {
    var elt = $get(eltId);
    if (elt != null)
        elt.innerHTML = text;
}
/* http://blog.stevenlevithan.com/archives/faster-than-innerhtml */
function replaceHtml(el, html) {
    var oldEl = typeof el === "string" ? document.getElementById(el) : el;
    /*@cc_on // Pure innerHTML is slightly faster in IE
    oldEl.innerHTML = html;
    return oldEl;
    @*/
    var newEl = oldEl.cloneNode(false);
    newEl.innerHTML = html;
    oldEl.parentNode.replaceChild(newEl, oldEl);
    /* Since we just removed the old element from the DOM, return a reference
    to the new element, which can be used to restore variable references. */
    return newEl;
}
function setIFrameHtml(id, str) {
    var iFrame = document.getElementById(id);
    var iFrameBody;
    if (iFrame.contentDocument) { // FF
        iFrameBody = iFrame.contentDocument.getElementsByTagName('body')[0];
    }
    else if (iFrame.contentWindow) { // IE
        iFrameBody = iFrame.contentWindow.document.getElementsByTagName('body')[0];
    }
    iFrameBody.innerHTML = str;
}
function setEltEnabled(eltId, enabled) {
    var elt = $get(eltId);
    if (elt != null)
        elt.disabled = !enabled;
}
function setBtnEnabled(eltId, enabled) {
    setEltEnabled(eltId, enabled);
}
function setDropDownListEnabled(eltId, enabled) {
    setEltEnabled(eltId, enabled);
}
function setTextBoxEnabled(eltId, enabled) {
    var elt = $get(eltId);
    if (elt != null) {
        if (enabled == true) {
            elt.disabled = false;
            elt.style.background = "#FFFFFF";
        }
        else {
            elt.disabled = true;
            elt.style.background = "#CCCCCC";
        }
    }
}
function setRadioButtonListEnabled(groupName, enabled) {
    var radioGroup = document.getElementsByName(groupName);
    for (var i = 0; i < radioGroup.length; i++)
        radioGroup[i].disabled = !enabled;
}
function clearDropDownList(eltId) {
    var elt = $get(eltId);
    if (elt != null) {
        elt.options.length = 0;
    }
}
function clearSelectionDropDownList(eltId) {
    var elt = $get(eltId);
    if (elt != null) {
        if (elt.options.length > 0)
            elt.options[0].selected = true;
    }
}
function selectItemDropDownList(eltId, value) {
    var elt = $get(eltId);
    if (elt != null) {
        for (var j = 0; j < elt.options.length; j++) {
            if (elt.options[j].value == value) {
                elt.options[j].selected = true;
                break;
            }
        }
    }
}
function clearSelectionRadioButtonList(groupName) {
    var radioGroup = document.getElementsByName(groupName);
    for (var i = 0; i < radioGroup.length; i++)
        radioGroup[i].checked = false;
}
function selectItemRadioButtonList(groupName, value) {
    var radioGroup = document.getElementsByName(groupName);
    for (var i = 0; i < radioGroup.length; i++) {
        if (radioGroup[i].value == value) {
            radioGroup[i].checked = true;
            break;
        }
    }
}
function getRadioButtonListSelectedValue(groupName) {
    var radioGroup = document.getElementsByName(groupName);
    for (var i = 0; i < radioGroup.length; i++) {
        if (radioGroup[i].checked == true) {
            return radioGroup[i].value;
        }
    }
    return null;
}
function getRadioButtonItem(groupName, value) {
    var radioGroup = document.getElementsByName(groupName);
    for (var i = 0; i < radioGroup.length; i++) {
        if (radioGroup[i].value == value) {
            return radioGroup[i];
        }
    }
    return null;
}

function addBookmark(phrase, lien) {
    if (document.all) {
        window.external.AddFavorite(lien, phrase);
    }
    else {
        if (window.sidebar) {
            window.sidebar.addPanel(phrase, lien, "");
        }
        else {
            if (navigator.userAgent.indexOf('WebKit/') > -1) {
                alert("Appuyez sur (CTRL + D)! pour ajouter cette page en favoris sur chrome.");
            }
            else {
                alert("Désolé! Votre navigateur ne supporte pas cette fonctionnalité.");
            }
        }
    }
    return true;
}

function disableEnterKey(e) {
    var key;
    if (window.event)
        key = window.event.keyCode;
    else
        key = e.which;
    if (key == 13)
        return false;
    else
        return true;
}

function dropDownList_fill_NoProp(eltId, formDataListTypeId) {
    var dropDownList_fillCallback_NoProp = function(result, eventArgs) {
        dropDownList_bind_NoProp(eltId, formDataListTypeId, result);
    }
    // This is the callback function invoked if the Web service failed.
    var dropDownList_fillFailedCallback_NoProp = function(error) {

        displayAspNetFrameworkError("AssurlandWeb.WebRessourcesAccess.GetFormDataList_NoProp failed", error);
    }
    // Call WS
    AssurlandWeb.WebRessourcesAccess.GetFormDataList(formDataListTypeId, dropDownList_fillCallback_NoProp, dropDownList_fillFailedCallback_NoProp);
}

function dropDownList_bind_NoProp(eltId, formDataListTypeId, result) {
    var dv = "";
    var bFindSelectedValue = false;
    var optionsDefaultValue;

    var elt = $get(eltId);
    if (elt != null) {
        // Clear list
        dropDownList_clear(eltId);

        // Feed new list
        if (result.length > 0) {
            for (var i = 0; i < result.length; i++) {
                var j = i;
                elt.options[j] = new Option(result[i].Text, result[i].Value);
            }
        }
    }
}

function getJsErrorDescription(err) {
    if (typeof (err.description) === "undefined")
        return err.toString();
    else
        return err.description;
}
function alertJsErrorDescription(err) {
    try { alert(getJsErrorDescription(err)) } catch (err2) { alert("Error in error alert ...") };
}

//////////////////////////////
// Rect area
/////////////////////////////

function RectArea() {
    this.x = 0;
    this.y = 0;
    this.width = 0;
    this.height = 0;
}
RectArea.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'x = ' + this.x + '\n';
        str = str + 'y = ' + this.y + '\n';
        str = str + 'width = ' + this.width + '\n';
        str = str + 'height = ' + this.height + '\n';
        return str;
    }
}
RectArea.prototype =
{
    PtIn: function(x, y) {
        if (x >= this.x && x <= (this.x + this.width))
            if (y >= this.y && y <= (this.y + this.height))
            return true
        return false;
    }
}

//////////////////////////////
// Popup 
/////////////////////////////
// import from old open.js

var browser2 = 1;
if (navigator.appName.substring(0, 8) == "Netscape") browser2 = 1;
if (navigator.appName.substring(0, 9) == "Microsoft") browser2 = 0;
var ns4 = (document.layers) ? true : false; //NS 4 
var ie4 = (document.all) ? true : false; //IE 4 
var dom = (document.getElementById) ? true : false; //DOM 

function openWin(url, dimx, dimy, fen) {
    if (browser2 == 0 && navigator.appVersion.indexOf("Win") > 0) dimy = dimy - 19;
    featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrolling=no,scrollbars=no,resizable=no,width=" + dimx + ",height=" + dimy;
    cl = window.open(url, fen, featur);
    if (browser2 == 1) cl.focus(); else cl = window.open(url, fen, featur);
}
function openWinNet(url, dimx, dimy, top, left, fen) {
    if (browser2 == 0 && navigator.appVersion.indexOf("Win") > 0) dimy = dimy - 19;
    featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrolling=yes,scrollbars=yes,resizable=no,top=" + top + ",left=" + left + ",width=" + dimx + ",height=" + dimy;
    cl = window.open(url, fen, featur);
    if (browser2 == 1) cl.focus(); else cl = window.open(url, fen, featur);
}
function openWinScroll(url, dimx, dimy, fen) {
    if (browser2 == 0 && navigator.appVersion.indexOf("Win") > 0)
        dimy = dimy - 19;
    featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrolling=auto,scrollbars=yes,resizable=no,width=" + dimx + ",height=" + dimy;

    if (browser2 == 1) {
        cl = window.open(url, fen, featur);
        cl.focus();
    }
    else {
        window.open(url, fen, featur);

    }
}
function openWinScrollWithMaximise(url, dimx, dimy, fen) {
    if (browser2 == 0 && navigator.appVersion.indexOf("Win") > 0)
        dimy = dimy - 19;
    featur = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrolling=auto,scrollbars=yes,resizable=yes,width=" + dimx + ",height=" + dimy;
    cl = window.open(url, fen, featur);
    if (browser2 == 1)
        cl.focus();
    else cl = window.open(url, fen, featur);
}
var newpageOpenHtmlContentPopup;
function openHtmlContentPopup(dimx, dimy, fen, title, htmlContent) {

    if (newpageOpenHtmlContentPopup) { newpageOpenHtmlContentPopup.close(); }
    newpageOpenHtmlContentPopup = open("", fen, 'width=' + dimx + ',height=' + dimy + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrolling=no,scrollbars=no,resizable=no');
    newpageOpenHtmlContentPopup.document.write("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>");
    newpageOpenHtmlContentPopup.document.write("<html><head><title>" + title + "</title></head>");
    newpageOpenHtmlContentPopup.document.write("<body><div style='font-size:12px;font-family:arial;text-align:justify;'>" + htmlContent + "<br/><br/><a href='#' onclick='window.close();'>Fermer la fenêtre</a></div></body></html>");

}

//////////////////////////////
// Date
/////////////////////////////

function getNowDate() {
    return new Date();
}
function getTodayDate() {
    var d = getNowDate();
    return new Date(d.getFullYear(), d.getMonth(), d.getDate())
}
function getTodayYear() {
    return getNowDate().getFullYear();
}
function getMonthFirstDayDate(d) {
    return new Date(d.getFullYear(), d.getMonth(), 1);
}
function getCurrentMonthFirstDayDate() {
    return getMonthFirstDayDate(getTodayDate());
}
function getMonthLastDayDate(d) {
    return addDays(addMonths(getMonthFirstDayDate(d), 1), -1);
}
function getNextMonthFirstDayDate(d) {
    d = addMonths(d, 1);
    return new Date(d.getFullYear(), d.getMonth(), 1);
}
function addDays(d, n) {
    d.setDate(d.getDate() + n)
    return d;
}
function addMonths(d, n) {
    d.setMonth(d.getMonth() + n);
    return d;
}
function addYears(d, n) {
    d.setYear(d.getFullYear() + n);
    return d;
}
function getDateStringByFormat(d, sFormat) {
    var jour;
    var mois;
    var annee;

    jour = d.getDate();
    if (jour < 10)
        jour = '0' + jour;
    mois = d.getMonth() + 1;
    if (mois < 10)
        mois = '0' + mois;
    annee = d.getFullYear();

    switch (sFormat) {
        case 'dd/MM/yyyy':
            return jour + '/' + mois + '/' + annee;
            break;
        case 'MM/yyyy':
            return mois + '/' + annee;
            break;
    }
    return "";
}
function getDateByFormat(strDate, sFormat) {
    var jour;
    var mois;
    var annee;
    var iTmp1;
    var iTmp2;
    switch (sFormat) {
        case 'dd/MM/yyyy':
            iTmp1 = 0;
            iTmp2 = strDate.indexOf('/');
            jour = strDate.substr(iTmp1, iTmp2 - iTmp1);
            iTmp1 = iTmp2 + 1
            iTmp2 = strDate.indexOf('/', iTmp1);
            mois = strDate.substr(iTmp1, iTmp2 - iTmp1) - 1;
            annee = strDate.substr(iTmp2 + 1);
            break;
        case 'MM/yyyy':
            iTmp1 = 0;
            iTmp2 = strDate.indexOf('/');
            mois = strDate.substr(iTmp1, iTmp2 - iTmp1) - 1;
            annee = strDate.substr(iTmp2 + 1);
            break;
    }
    // TODO : vérifier cohérence date
    return new Date(annee, mois, jour);
}
function isValidDate(d) {
    if (d == "NaN" || d == "Invalid Date" || d == null)
        return false
    return true
}
function isTrueValidDate(day, month, year) {
    var dteDate = new Date(year, month - 1, day);
    return ((day == dteDate.getDate()) && ((month - 1) == dteDate.getMonth()) && (year == dteDate.getFullYear()));
}
function getValidDate(day, month, year) {
    if (isTrueValidDate(day, month, year))
        return new Date(year, month - 1, day);
    return null;
}
function calcul_age(date_birthday) {
    var age;
    var dateNow = new Date();
    age = dateNow.getFullYear() - date_birthday.getFullYear();
    if (dateNow.getMonth() <= date_birthday.getMonth()) {
        age--;
        if (dateNow.getMonth() == date_birthday.getMonth())
            if (dateNow.getDate() >= date_birthday.getDate())
            age++;
    }
    return age;
}
function GetMonthText(iMonth) {
    iMonth = iMonth * 1.0;
    switch (iMonth) {
        case 1:
            return "janvier";
            break;
        case 2:
            return "février";
            break;
        case 3:
            return "mars";
            break;
        case 4:
            return "avril";
            break;
        case 5:
            return "mai";
            break;
        case 6:
            return "juin";
            break;
        case 7:
            return "juillet";
            break;
        case 8:
            return "août";
            break;
        case 9:
            return "septembre";
            break;
        case 10:
            return "octobre";
            break;
        case 11:
            return "novembre";
            break;
        case 12:
            return "décembre";
            break;
    }
}

//////////////////////////////
// Help bubble
/////////////////////////////

function HelpPoup_PopupProperties(popupId, iframeId, htmlTargetElementId) {
    this.popupId = popupId;
    this.iframeId = iframeId;
    this.htmlTargetElementId = htmlTargetElementId;
    this.visible = false;
    this.senderArea = new RectArea();
}
HelpPoup_PopupProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'popupId = ' + this.popupId + '\n';
        str = str + 'iframeId = ' + this.iframeId + '\n';
        str = str + 'htmlTargetElementId = ' + this.htmlTargetElementId + '\n';
        str = str + 'visible = ' + this.visible + '\n';
        str = str + 'senderArea = ' + this.senderArea.toString() + '\n';
        return str;
    }
}

var helppopup_popupPropertiesArray;
function helppopup_init() {
    helppopup_popupPropertiesArray = new Array();
    // Add onmouse event
    // Add and remove depending on number of popup shown
    //addListener(document, 'mousemove', helppopup_updateAllPopupVisibility);
}
function helppopup_addPopup(popupId, iframeId, htmlTargetElementId) {
    var obj = new HelpPoup_PopupProperties(popupId, iframeId, htmlTargetElementId);
    helppopup_popupPropertiesArray[popupId] = obj;
}
function helppopup_show(senderId, popupId, pos, helpType, helpGroupId, helpElementId) {
    // Get popup properties
    var prop = helppopup_popupPropertiesArray[popupId];

    if (prop == null)
        return false;

    // Add click event listener if required
    if (helppopup_getNbVisiblePopup() == 0) {
        addListener(document, 'mousemove', helppopup_updateAllPopupVisibility);
    }

    // Get DOM elements
    var sender = $get(senderId);
    var popup = $get(popupId);
    var iframe = $get(prop.iframeId);
    var htmlTargetElement = $get(prop.htmlTargetElementId);
    var boundSender = Sys.UI.DomElement.getBounds(sender);
    // /!\ Popup can be in a relative or absolute container.
    // Relative position to this container has to be used instead of window position
    var relativeBoundSender = getRelativeBounds(sender, popup); //Sys.UI.DomElement.getBounds(target);
    var boundPopup = Sys.UI.DomElement.getBounds(popup);

    // Hide popup
    //popup.style.display = 'none';

    // Bound failed to get width/height from css attribut ...
    var widthPopup = popup.style.width.replace(/px/g, "");
    var heightPopup = popup.style.height.replace(/px/g, "");
    var widthSender = boundSender.width;
    var heightSender = boundSender.height;
    var margin = 5;
    // Compute new position
    var x = relativeBoundSender.x;
    var y = relativeBoundSender.y;
    switch (pos) {
        case "TopLeft":
            x = x + widthSender - widthPopup;
            y = y - heightPopup - margin;
            break;
        case "TopRight":
            x = x;
            y = y - heightPopup - margin;
            break;
        case "Left":
            x = x - widthPopup - margin;
            y = y;
            break;
        case "Right":
            x = x + widthSender + margin;
            y = y;
            break;
        case "BottomLeft":
            x = x + widthSender - widthPopup;
            y = y + heightSender + margin;
            break;
        case "BottomRight":
            x = x;
            y = y + heightSender + margin;
            break;
    }
    Sys.UI.DomElement.setLocation(popup, x, y);
    htmlTargetElement.scrollTop = 0;
    htmlTargetElement.innerHTML = '<img src="http://content.assurland.com/Images2/loading_help.gif" alt="" />';

    // Show popup
    popup.style.display = 'block';

    // Update iframe heigth
    if (iframe != null) {
        iframe.style.height = htmlTargetElement.offsetHeight + 15;
    }

    // Update popup state
    var areaMargin = 5;
    prop.visible = true;
    prop.senderArea.x = boundSender.x - areaMargin;
    prop.senderArea.y = boundSender.y - areaMargin;
    prop.senderArea.width = boundSender.width + 2 * areaMargin;
    prop.senderArea.height = boundSender.height + 2 * areaMargin;

    // Update content
    var helppopup_succeededCallback = function(result, eventArgs) {
        if (result == null) {
            htmlTargetElement.innerHTML = '<span class="al_helpPopupTextTitle">Help not found</span>';
        }
        else {
            // if (result.Title != "")
            //    htmlTargetElement.innerHTML = '<span class="al_helpPopupTextTitle">' + result.Title + '</span><br/><br/><div class="al_helpPopupTextContent">' + result.Text + '</div>';
            //else
            htmlTargetElement.innerHTML = '<div class="al_helpPopupTextContent">' + result.Text + '</div>';

            // Liwio tracking
            if (helpType == "Form")
                lwEvent(al_liwioProduct, "Aide-F-" + helpElementId + "-" + result.Title);
            else if (helpType == "Restitution")
                lwEvent(al_liwioProduct, "Aide-PB-" + helpGroupId + "-" + helpElementId + "-" + result.Title);
        }
    }
    // This is the callback function invoked if the Web service failed.
    var helppopup_failedCallback = function(error) {
        htmlTargetElement.innerHTML = '<span class="al_helpPopupTextTitle">Error</span>';
        //displayAspNetFrameworkError("AssurlandWeb.WebRessourcesAccess.GetFormHelp failed",error);
    }

    // Call WS
    if (helpType == "Form")
        AssurlandWeb.WebRessourcesAccess.GetFormHelp(helpElementId, helppopup_succeededCallback, helppopup_failedCallback);
    else if (helpType == "Restitution")
        AssurlandWeb.WebRessourcesAccess.GetProductBaseHelp(helpGroupId, helpElementId, helppopup_succeededCallback, helppopup_failedCallback);
    else
        helppopup_succeededCallback(null, null);
}
function helppopup_hide(senderId, popupId) {
    // Hide popup
    hide(popupId);
    var prop = helppopup_popupPropertiesArray[popupId];
    if (prop != null) {
        prop.visible = false;
        // Remove mousemove event listener if required
        if (helppopup_getNbVisiblePopup() == 0) {
            removeListener(document, 'mousemove', helppopup_updateAllPopupVisibility);
        }
    }
}
// Sometimes, popup is not hidden after onmouseover event 
// (depending on sender/link size, mouse speed, ... ?)
// To resolve this unexpected bug, popup are hidden if 
// required (mouse is not the sender area and popup is still visible)
// at each mousemove event (performance leak ?)
function helppopup_updateAllPopupVisibility(e) {
    if (helppopup_popupPropertiesArray != null) {
        var prop;
        var x = mouseX(e);
        var y = mouseY(e);
        for (key in helppopup_popupPropertiesArray) {
            prop = helppopup_popupPropertiesArray[key];
            if (prop.visible == true) {
                if (prop.senderArea.PtIn(x, y) == false) {
                    helppopup_hide(null, prop.popupId);
                }
            }
        }
    }
}
function helppopup_getNbVisiblePopup() {
    var nb = 0;
    for (var i = 0; i < helppopup_popupPropertiesArray.length; i++) {
        if (helppopup_popupPropertiesArray[i].visible == true) {
            nb++;
        }
    }
    return nb;
}

function helpLink_changeHelpElementId(hlId, helpGroupId, helpElementId) {
    var hl = $get(hlId);
    var type = "onmouseover";
    var linkAction = hl.onmouseover;

    if (linkAction == "") {
        type = "onclick";
        linkAction = hl.onclick;
    }
    linkAction = linkAction.toString();
    var newLink = "linkAction =" + linkAction.substring(0, linkAction.substring(0, linkAction.lastIndexOf(",")).lastIndexOf(","));
    newLink += ',"' + helpGroupId + '","' + helpElementId + '");\n};';
    eval(newLink);
    newLink = linkAction;
    if (type == "onmouseover")
        hl.onmouseover = newLink;
    else
        hl.onclick = newLink;
}

///////////////////////////////////////////////////////////////////
//        OLD FORM.js                                            //
///////////////////////////////////////////////////////////////////
// Assurland form client framework

var formId = null;
var formUpdatePanelId = null;
var formBtnValidateId = null;

////////////////////////////////////////
// WebForms
////////////////////////////////////////

var prm;
// Do before asynchrone page post
function beginRequest() {
    $get(formBtnValidateId).disabled = true;
    document.body.style.cursor = "progress";
    prm._scrollPosition = null;
}
// Do after asynchrone page post
function endRequest() {
    $get(formBtnValidateId).disabled = false;
    document.body.style.cursor = "";
    prm._scrollPosition = null;
}
if (typeof (Sys.WebForms) != 'undefined') {
    prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(beginRequest);
    prm.add_endRequest(endRequest);
}

function form_doBeforePost() {
    // NOT REQUIRED ANYMORE (Form background is white on white. Not flicked effect)
    //    if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version < 7)
    //    {
    //        /* 
    //            [IE6] During aschynchrone postback in updatepanel, dropdownlists flash
    //            due to windows Interet Explorer rendering method. 
    //            Page background, and not parent background, is visible. 
    //            To attenuate this bad effect, dropdownlist are hidden before postback
    //            to show parent background instead of page background.
    //        */
    //        var panel = $get(formUpdatePanelId);
    //        if(panel != null)
    //        {
    //            hideElementByTypeIn(formUpdatePanelId, "select");
    //        }
    //    }
}

function form_escapeIFrame() {
    if (top.location != self.document.location) {
        // Post form in a new window
        document.forms[0].target = '_blank';
        // Remove asynchrone trigger on update panel
        if (formUpdatePanelId)
            Sys.WebForms.PageRequestManager.getInstance()._updateControls([formUpdatePanelId], [], [], 180);
    }
}

////////////////////////////////////////
// Dynamic form error message manager
////////////////////////////////////////

var VALID = 0;
var ERROR = 1;
var WARNING = 2;

function ErrMgr_FormEltProperties(eltId, state, msgEltId, group, cssClassError, cssClassWarning) {
    //TODO eltid=> targetId
    // element = label du message id
    this.eltId = eltId;
    this.state = state;
    this.msgEltId = msgEltId;
    this.group = group;
    this.cssClassError = cssClassError;
    this.cssClassWarning = cssClassWarning;
}
ErrMgr_FormEltProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'eltId = ' + this.eltId + '\n';
        str = str + 'state = ' + this.state + '\n';
        str = str + 'msgEltId = ' + this.msgEltId + '\n';
        str = str + 'group = ' + this.group + '\n';
        str = str + 'cssClassError = ' + this.cssClassError + '\n';
        str = str + 'cssClassWarning = ' + this.cssClassWarning + '\n';
        return str;
    }
}
function ErrMgr_GroupProperties(name, rowId, questionRowId, questionCellId, arrowEltId, changeLabelQuestionActivate) {
    this.name = name;
    this.rowId = rowId;
    this.questionRowId = questionRowId;
    this.questionCellId = questionCellId;
    this.arrowEltId = arrowEltId;
    this.changeLabelQuestionActivate = changeLabelQuestionActivate;
    this.formEltPropertiesArray = new Array();
}
ErrMgr_GroupProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'name = ' + this.name + '\n';
        str = str + 'rowId = ' + this.rowId + '\n';
        str = str + 'questionRowId = ' + this.questionRowId + '\n';
        str = str + 'questionCellId = ' + this.questionCellId + '\n';
        str = str + 'arrowEltId = ' + this.arrowEltId + '\n';
        return str;
    }
}
ErrMgr_GroupProperties.prototype =
{
    getState: function() {
        var state = VALID;
        for (i in this.formEltPropertiesArray) {
            if (this.formEltPropertiesArray[i].state == 1)
                return ERROR;
            else
                if (this.formEltPropertiesArray[i].state == 2)
                state = WARNING;
        }
        return state;
    }
}

// Arrays of form control' error properties
var errMgr_formEltPropertiesArray;
// Array of form group' error properties
var errMgr_groupPropertiesArray;
// Global error message ID
var errMgr_globalErrorMessageId = null;
// Error picto tooltip
var errMgt_errorPictoToolTip = "Cette information est incorrecte. Merci de la corriger afin de pouvoir passer à l'étape suivante.";
// Warning picto tooltip
var errMgt_warningPictoToolTip = "Cette information ne semble pas cohérente. Merci de vérifier votre saisie.";
// Error manager basic functions
function errMgr_reset() {
    errMgr_formEltPropertiesArray = new Array();
    errMgr_groupPropertiesArray = new Array();
}
function errMgr_init() {
    errMgr_reset();
}
function errMgr_addFormElt(eltId, state, msgEltId, group, groupRowId, groupQuestionRowId, groupQuestionCellId, arrowEltId, cssClassError, cssClassWarning, changeLabelQuestionActivate) {
    var obj = new ErrMgr_FormEltProperties(eltId, state, msgEltId, group, cssClassError, cssClassWarning);
    //alert(obj.toString());
    errMgr_formEltPropertiesArray[eltId] = obj;
    if (group != null) {
        if (errMgr_groupPropertiesArray[group] == null) {
            errMgr_addGroup(group, groupRowId, groupQuestionRowId, groupQuestionCellId, arrowEltId, changeLabelQuestionActivate);
        }
        var objGroup = errMgr_groupPropertiesArray[group];
        objGroup.formEltPropertiesArray[eltId] = obj;
    }
}
function errMgr_addGroup(name, rowId, questionRowId, questionCellId, arrowEltId, changeLabelQuestionActivate) {
    var obj = new ErrMgr_GroupProperties(name, rowId, questionRowId, questionCellId, arrowEltId, changeLabelQuestionActivate);
    errMgr_groupPropertiesArray[name] = obj;
}
function errMgr_pageHasError() {
    for (key in errMgr_formEltPropertiesArray) {
        if (errMgr_formEltPropertiesArray[key].state == ERROR)
            return true;
    }
    return false;
}
// Error manager function to notify state change
function errMgr_changeState(eltId, state, message) {
    //alert("errMgr_changeState : " + message);
    var eltProp = errMgr_formEltPropertiesArray[eltId];
    if (eltProp != null) {

        // Liwio tracking
        if (state == WARNING) {
            lwEvent(al_liwioProduct, "warning", strReplace(eltId, "ctl00_ContentPlaceHolder1_", ""));
        }

        eltProp.state = state;
        // Hide/Show error message associoted to
        if ($get(eltProp.msgEltId) != null) {
            if (eltProp.state == 0)
                hide(eltProp.msgEltId);
            else {
                var msgEltCtrl = $get(eltProp.msgEltId)
                if (message != "")
                    msgEltCtrl.innerHTML = message;

                if (state == 1)
                    msgEltCtrl.className = eltProp.cssClassError;
                else
                    msgEltCtrl.className = eltProp.cssClassWarning;

                show(eltProp.msgEltId);

                msgEltCtrl = null;
            }
            groupProp = errMgr_groupPropertiesArray[eltProp.group];

            if (groupProp != null) {
                if ($get(groupProp.rowId) != null) {
                    //alert(groupProp.getState());
                    // Check state of all element in group
                    // and hide/show associated row
                    if (groupProp.getState() == VALID) {
                        if (groupProp.changeLabelQuestionActivate && $get(groupProp.questionCellId) != null)
                            $get(groupProp.questionCellId).rowSpan = 1;

                        hideRow(groupProp.rowId);
                        if (groupProp.arrowEltId != null) {
                            ErrorPicto = form_eltPropertiesObjArray[groupProp.arrowEltId];
                            if (ErrorPicto) {
                                $get(ErrorPicto.arrowId).className = ErrorPicto.cssClass;
                                $get(ErrorPicto.pictoId).className = ErrorPicto.cssClass;
                            }
                        }
                    }
                    else {
                        if (groupProp.changeLabelQuestionActivate && $get(groupProp.questionCellId) != null)
                            $get(groupProp.questionCellId).rowSpan = 2;

                        showRow(groupProp.rowId);
                        if (groupProp.getState() == ERROR) {
                            if (groupProp.arrowEltId != null) {
                                ErrorPicto = form_eltPropertiesObjArray[groupProp.arrowEltId];
                                if (ErrorPicto) {
                                    $get(ErrorPicto.arrowId).className = ErrorPicto.cssClassError;
                                    picto = $get(ErrorPicto.pictoId);
                                    picto.className = ErrorPicto.cssClassError;
                                    picto.title = errMgt_errorPictoToolTip;
                                }
                            }
                        }
                        else {
                            if (groupProp.arrowEltId != null) {
                                ErrorPicto = form_eltPropertiesObjArray[groupProp.arrowEltId];
                                if (ErrorPicto) {
                                    $get(ErrorPicto.arrowId).className = ErrorPicto.cssClassWarning;
                                    picto = $get(ErrorPicto.pictoId);
                                    picto.className = ErrorPicto.cssClassWarning;
                                    picto.title = errMgt_warningPictoToolTip;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // Update global error message visibility
    errMgr_updateGlobalErrorMessageVisibility();
}
// Update global error visibility
function errMgr_updateGlobalErrorMessageVisibility() {
    if (errMgr_pageHasError() == true)
        show(errMgr_globalErrorMessageId);
    else
        hide(errMgr_globalErrorMessageId);
}
// Get element state
function errMgr_getState(eltId) {
    var state = VALID;
    eltProp = errMgr_formEltPropertiesArray[eltId];
    if (eltProp != null) {
        state = eltProp.state;
    }
    return state;
}
// Init default error manager
errMgr_init();

////////////////////////////////////////
// Form element additional properties
////////////////////////////////////////

var form_eltPropertiesObjArray = new Array();
function _fp(eltId) { return form_eltPropertiesObjArray[eltId]; }
function form_addEltPropertiesObj(eltId, prop) {
    form_eltPropertiesObjArray[eltId] = prop;
}

function ErrorPictoProperties(ucId, cssClass, cssClassError, cssClassWarning, arrowId, pictoId) {
    this.ucId = ucId;
    this.arrowId = arrowId;
    this.pictoId = pictoId;
    this.cssClass = cssClass;
    this.cssClassError = cssClassError;
    this.cssClassWarning = cssClassWarning;
}

function TextBoxWrapperProperties(ucId, eltId, initialValue, errorMode, defaultText, currentValueIsDefaultText, cssClass, cssClassFocus, cssClassError, cssClassDefaultText, cssClassDefaultTextError, cssClassWarning, messageError, clientFunctionError, clientFunctionWarning, allowDefaultValue, hasMask, mask, inputDirectionMask, clearMaskOnLostFocus, clientFunctionRemoveMask, zipCodeDropDownListDynamicVisibility) {
    this.ucId = ucId;
    this.eltId = eltId;
    this.initialValue = initialValue;
    this.errorMode = errorMode;
    this.defaultText = defaultText;
    this.currentValueIsDefaultText = currentValueIsDefaultText;
    this.cssClass = cssClass;
    this.cssClassFocus = cssClassFocus;
    this.cssClassError = cssClassError;
    this.cssClassDefaultText = cssClassDefaultText;
    this.cssClassDefaultTextError = cssClassDefaultTextError;
    this.cssClassWarning = cssClassWarning;
    this.messageError = messageError;
    this.clientFunctionError = clientFunctionError;
    this.clientFunctionWarning = clientFunctionWarning;
    this.allowDefaultValue = allowDefaultValue;
    this.hasMask = hasMask;
    this.mask = mask;
    this.inputDirectionMask = inputDirectionMask;
    this.clearMaskOnLostFocus = clearMaskOnLostFocus;
    this.clientFunctionRemoveMask = clientFunctionRemoveMask;
    this.zipCodeDropDownListDynamicVisibility = zipCodeDropDownListDynamicVisibility;

}
TextBoxWrapperProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'eltId = ' + this.eltId + '\n';
        str = str + 'initialValue = ' + this.initialValue + '\n';
        str = str + 'errorMode = ' + this.errorMode + '\n';
        str = str + 'defaultText = ' + this.defaultText + '\n';
        str = str + 'currentValueIsDefaultText = ' + this.currentValueIsDefaultText + '\n';
        str = str + 'cssClass = ' + this.cssClass + '\n';
        str = str + 'cssClassFocus = ' + this.cssClassFocus + '\n';
        str = str + 'cssClassError = ' + this.cssClassError + '\n';
        str = str + 'cssClassDefaultText = ' + this.cssClassDefaultText + '\n';
        str = str + 'cssClassDefaultTextError = ' + this.cssClassDefaultTextError + '\n';
        str = str + 'cssClassWarning = ' + this.cssClassWarning + '\n';
        str = str + 'messageError = ' + this.messageError + '\n';
        str = str + 'clientFunctionError = ' + this.clientFunctionError + '\n';
        str = str + 'clientFunctionWarning = ' + this.clientFunctionWarning + '\n';
        str = str + 'allowDefaultValue = ' + this.allowDefaultValue + '\n';
        str = str + 'hasMask = ' + this.hasMask + '\n';
        str = str + 'inputDirectionMask = ' + this.inputDirectionMask + '\n';
        str = str + 'clearMaskOnLostFocus = ' + this.clearMaskOnLostFocus + '\n';
        str = str + 'clientFunctionRemoveMask = ' + this.clientFunctionRemoveMask + '\n';
        str = str + 'zipCodeDropDownListDynamicVisibility = ' + this.zipCodeDropDownListDynamicVisibility + '\n';
        return str;
    }
}
function DropDownListWrapperProperties(ucId, eltId, initialValue, errorMode, cssClass, cssClassFocus, cssClassError, formDataListTypeId, hfIdFormDataListTypeLoadedOnClient, populatedOnClient, defaultValue, currentValueIsDefaultValue, cssClassWarning, messageError, clientFunctionError, clientFunctionWarning) {
    this.ucId = ucId;
    this.eltId = eltId;
    this.initialValue = initialValue;
    this.errorMode = errorMode;
    this.cssClass = cssClass;
    this.cssClassFocus = cssClassFocus;
    this.cssClassError = cssClassError;
    this.formDataListTypeId = formDataListTypeId;
    this.hfIdFormDataListTypeLoadedOnClient = hfIdFormDataListTypeLoadedOnClient;
    this.populatedOnClient = populatedOnClient;
    this.defaultValue = defaultValue;
    this.currentValueIsDefaultValue = currentValueIsDefaultValue;
    this.cssClassWarning = cssClassWarning;
    this.messageError = messageError;
    this.clientFunctionError = clientFunctionError;
    this.clientFunctionWarning = clientFunctionWarning;
}
DropDownListWrapperProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'eltId = ' + this.eltId + '\n';
        str = str + 'initialValue = ' + this.initialValue + '\n';
        str = str + 'errorMode = ' + this.errorMode + '\n';
        str = str + 'cssClass = ' + this.cssClass + '\n';
        str = str + 'cssClassFocus = ' + this.cssClassFocus + '\n';
        str = str + 'cssClassError = ' + this.cssClassError + '\n';
        str = str + 'formDataListTypeId = ' + this.formDataListTypeId + '\n';
        str = str + 'hfIdFormDataListTypeLoadedOnClient = ' + this.hfIdFormDataListTypeLoadedOnClient + '\n';
        str = str + 'populatedOnClient = ' + this.populatedOnClient + '\n';
        str = str + 'defaultValue = ' + this.defaultValue + '\n';
        str = str + 'currentValueIsDefaultValue = ' + this.currentValueIsDefaultValue + '\n';
        str = str + 'cssClassWarning = ' + this.cssClassWarning + '\n';
        str = str + 'messageError = ' + this.messageError + '\n';
        str = str + 'clientFunctionError = ' + this.clientFunctionError + '\n';
        str = str + 'clientFunctionWarning = ' + this.clientFunctionWarning + '\n';
        return str;
    }
}
function DateDropDownListWrapperProperties(ucId, ddlDayId, ddlMonthId, ddlYearId, selectionMode, initialValue, errorMode, cssClass, cssClassFocus, cssClassError, cssClassWarning, messageError, clientFunctionError, clientFunctionWarning) {
    this.ucId = ucId;
    this.ddlDayId = ddlDayId;
    this.ddlMonthId = ddlMonthId;
    this.ddlYearId = ddlYearId;
    this.selectionMode = selectionMode;
    this.initialValue = initialValue;
    this.errorMode = errorMode;
    this.cssClass = cssClass;
    this.cssClassFocus = cssClassFocus;
    this.cssClassError = cssClassError;
    this.cssClassWarning = cssClassWarning;
    this.messageError = messageError;
    this.clientFunctionError = clientFunctionError;
    this.clientFunctionWarning = clientFunctionWarning;
}
DateDropDownListWrapperProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'ddlDayId = ' + this.ddlDayId + '\n';
        str = str + 'ddlMonthId = ' + this.ddlMonthId + '\n';
        str = str + 'ddlYearId = ' + this.ddlYearId + '\n';
        str = str + 'selectionMode = ' + this.selectionMode + '\n';
        str = str + 'initialValue = ' + this.initialValue + '\n';
        str = str + 'errorMode = ' + this.errorMode + '\n';
        str = str + 'cssClass = ' + this.cssClass + '\n';
        str = str + 'cssClassFocus = ' + this.cssClassFocus + '\n';
        str = str + 'cssClassError = ' + this.cssClassError + '\n';
        str = str + 'cssClassWarning = ' + this.cssClassWarning + '\n';
        str = str + 'messageError = ' + this.messageError + '\n';
        str = str + 'clientFunctionError = ' + this.clientFunctionError + '\n';
        str = str + 'clientFunctionWarning = ' + this.clientFunctionWarning + '\n';
        return str;
    }
}
DateDropDownListWrapperProperties.prototype =
{
    getValue: function() {
        var v = '';
        if (this.selectionMode == 1) {
            v = v + $get(this.ddlDayId).value;
            v = v + '/';
        }
        v = v + $get(this.ddlMonthId).value;
        v = v + '/';
        v = v + $get(this.ddlYearId).value;
        return v;
    }
}
function RadioButtonListWrapperProperties(ucId, eltId, initialValue, errorMode, cssClass, cssClassError, groupName, defaultValue, currentValueIsDefaultValue, cssClassWarning, messageError, clientFunctionError, clientFunctionWarning) {
    this.ucId = ucId;
    this.eltId = eltId;
    this.initialValue = initialValue;
    this.errorMode = errorMode;
    this.cssClass = cssClass;
    this.cssClassError = cssClassError;
    this.groupName = groupName;
    this.defaultValue = defaultValue;
    this.currentValueIsDefaultValue = currentValueIsDefaultValue;
    this.cssClassWarning = cssClassWarning;
    this.messageError = messageError;
    this.clientFunctionError = clientFunctionError;
    this.clientFunctionWarning = clientFunctionWarning;
}
RadioButtonListWrapperProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'eltId = ' + this.eltId + '\n';
        str = str + 'initialValue = ' + this.initialValue + '\n';
        str = str + 'errorMode = ' + this.errorMode + '\n';
        str = str + 'cssClass = ' + this.cssClass + '\n';
        str = str + 'cssClassError = ' + this.cssClassError + '\n';
        str = str + 'groupName = ' + this.groupName + '\n';
        str = str + 'defaultValue = ' + this.defaultValue + '\n';
        str = str + 'currentValueIsDefaultValue = ' + this.currentValueIsDefaultValue + '\n';
        str = str + 'cssClassWarning = ' + this.cssClassWarning + '\n';
        str = str + 'messageError = ' + this.messageError + '\n';
        str = str + 'clientFunctionError = ' + this.clientFunctionError + '\n';
        str = str + 'clientFunctionWarning = ' + this.clientFunctionWarning + '\n';
        return str;
    }
}
function CallBackInfoWrapperProperties(ucId, dayId, monthId, hourId, phoneNumberId) {
    this.ucId = ucId;
    this.dayId = dayId;
    this.monthId = monthId;
    this.hourId = hourId;
    this.phoneNumberId = phoneNumberId;
}
CallBackInfoWrapperProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'dayId = ' + this.dayId + '\n';
        str = str + 'monthId = ' + this.monthId + '\n';
        str = str + 'hourId = ' + this.hourId + '\n';
        str = str + 'phoneNumberId = ' + this.phoneNumberId + '\n';
        return str;
    }
}

function ListItem(v, t, i) {
    this.Value = v;
    this.Text = t;
    this.ImageUrl = i;
}
ListItem.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'Value = ' + this.Value + '\n';
        str = str + 'Text = ' + this.Text + '\n';
        str = str + 'ImageUrl  = ' + this.ImageUrl + '\n';
        return str;
    }
}

////////////////////////////////////////
// Form element handler
////////////////////////////////////////

var maskSpace = String.fromCharCode(160);
function RemoveNumericMask(str) {
    var reg;
    // Remove space first
    reg = new RegExp("(" + maskSpace + ")", "g");
    str = str.replace(reg, "");
    // Remove all '_' on left
    str = trimCharLeft(str, " ");
    // Replace all '_' By ''
    str = str.replace(/( )/g, "");
    return str;
}

function RestoreNumericMask(value) {
    //rajout d'un espace tout les 3 caract
    var maskedValue = '';
    value = "" + value;
    for (var i = value.length - 1; i >= 0; i--) {
        maskedValue = value.charAt(i) + maskedValue;
        if (i > 0 && (value.length - i) % 3 == 0) {
            maskedValue = " " + maskedValue;
        }

    }
    return maskedValue;
}

function RemovePhoneNumberMask(str) {
    // Remove space first
    reg = new RegExp("(" + maskSpace + ")", "g");
    str = str.replace(reg, "");
    // Remove all '_'
    reg = new RegExp("(_)", "g");
    str = str.replace(reg, "");
    // Remove all '.'
    reg = new RegExp("(\\.)", "g");
    str = str.replace(reg, "");
    return str;
}

function textBox_findCssClass(eltId) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        var state = errMgr_getState(eltId);
        if (state == WARNING) {
            // Warning
            return prop.cssClassWarning;
        }
        else if (state == ERROR) {
            // Error
            if (prop.currentValueIsDefaultText)
                return prop.cssClassDefaultTextError;
            else
                return prop.cssClassError;
        }
        else {
            // No error, no warning
            if (prop.currentValueIsDefaultText)
                return prop.cssClassDefaultText;
            else
                return prop.cssClass;
            return
        }
    }
    return "";
}

function textBox_clear(eltId) {
    var elt = $get(eltId);
    if (elt != null) {
        elt.value = "";
        var prop = form_eltPropertiesObjArray[elt.id];
        if (prop != null) {
            if (prop.defaultText != null) {
                elt.value = prop.defaultText;
                prop.currentValueIsDefaultText = true;
            }
        }
        textBox_clearError(eltId);
    }
}
function textBox_clearError(eltId) {
    var elt = $get(eltId);
    if (elt != null) {
        var prop = form_eltPropertiesObjArray[eltId];
        if (prop != null) {
            prop.errorMode = false;
            errMgr_changeState(eltId, VALID);
            elt.className = textBox_findCssClass(eltId);
        }
    }
}
function textBox_disable(eltId) {
    textBox_setEnabled(eltId, false);
}
function textBox_enable(eltId) {
    textBox_setEnabled(eltId, true);
}
function textBox_setEnabled(eltId, enabled) {
    setTextBoxEnabled(eltId, enabled);
    if (enabled == false)
        textBox_clearError(eltId);
}
function textBox_reset(eltId) {
    textBox_clear(eltId);
}
function textBox_show(eltId) {
    show(eltId);
}
function textBox_hide(eltId) {
    textBox_clearError(eltId);
    hide(eltId);
}
function textBox_onfocus(sender) {
    var prop = form_eltPropertiesObjArray[sender.id];
    if (prop != null) {
        if (prop.defaultText != null) {
            if (prop.currentValueIsDefaultText && sender.value == prop.defaultText)
                sender.value = '';
        }
        if (prop.cssClassFocus != null) {
            sender.className = prop.cssClassFocus;
        }

        if (prop.hasMask) {
            // Chrome remove cursor in next non accessible events
            // Force move cursor after (n ms)
            if (navigator.userAgent.indexOf('WebKit/') > -1) {
                setTimeout("setSelectionRangeChrome('" + sender.id + "')", 10);
            }
        }
    }
}
function textBox_onblur(sender) {
    var prop = form_eltPropertiesObjArray[sender.id];
    if (prop != null) {
        var value = sender.value;

        // Remove mask if required
        if (prop.hasMask && prop.clearMaskOnLostFocus)
            value = prop.clientFunctionRemoveMask(value);

        // Move to default value ?
        if (prop.defaultText != null
            && (value == '' || (value == prop.defaultText && !prop.allowDefaultValue)
            || value == prop.mask)) {
            prop.currentValueIsDefaultText = true
            sender.value = prop.defaultText;
            value = sender.value;
        }
        else
            prop.currentValueIsDefaultText = false

        // Has warning ?
        var messWarning = "";
        if (prop.clientFunctionWarning != null) {
            messWarning = prop.clientFunctionWarning(sender);
        }

        if (prop.errorMode == false) {
            if (messWarning != "")
                errMgr_changeState(prop.eltId, WARNING, messWarning);
            else
                errMgr_changeState(prop.eltId, VALID);
        }
        else {
            var messError = "";
            if (prop.clientFunctionError == null) {
                if (value == prop.initialValue)
                    messError = prop.messageError;
            }
            else {
                messError = prop.clientFunctionError(sender);
            }
            if (messError != "") {
                errMgr_changeState(prop.eltId, ERROR, messError);
            }
            else {
                if (messWarning != "")
                    errMgr_changeState(prop.eltId, WARNING, messWarning);
                else
                    errMgr_changeState(prop.eltId, VALID);
            }
        }

        // Update CssClass
        sender.className = textBox_findCssClass(prop.eltId);
    }
}
function textBox_onUpdate(sender) {
    //Function call to update error or warning message and css style
    if (sender)
        sender.onblur();
}
/* Cursor to Mask on chrome */
function setSelectionRangeChrome(id) {
    var prop = form_eltPropertiesObjArray[id];
    if (prop != null) {
        var input = $get(prop.eltId);
        if (input.setSelectionRange) {
            if (prop.inputDirectionMask == 0)
                input.setSelectionRange(-1, -1);
            else
                input.setSelectionRange(input.value.length, input.value.length);
        }
        input.focus();
    }
}

function dropDownList_findCssClass(eltId) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        var state = errMgr_getState(eltId);
        if (state == WARNING) {
            // Warning
            return prop.cssClassWarning;
        }
        else if (state == ERROR) {
            return prop.cssClassError;
        }
        else {
            return prop.cssClass;
        }
    }
    return "";
}
function dropDownList_clear(eltId) {
    var elt = $get(eltId);
    if (elt != null) {
        clearDropDownList(eltId);
        var prop = form_eltPropertiesObjArray[eltId];
        if (prop != null) {
            prop.formDataListTypeId = -1;
            if (prop.populatedOnClient == true) {
                var hf = $get(prop.hfIdFormDataListTypeLoadedOnClient);
                if (hf != null)
                    hf.value = "-1";
            }
        }
        dropDownList_clearError(eltId);
    }
}
function dropDownList_clearSelection(eltId) {
    var elt = $get(eltId);
    if (elt != null) {
        clearSelectionDropDownList(eltId);
        var prop = form_eltPropertiesObjArray[eltId];
        if (prop != null) {
            if (prop.defaultValue != null)
                elt.value = prop.defaultValue;
        }
        dropDownList_clearError(eltId);
    }
}
function dropDownList_clearError(eltId) {
    var elt = $get(eltId);
    if (elt != null) {
        var prop = form_eltPropertiesObjArray[eltId];
        if (prop != null) {
            prop.errorMode = false;
            errMgr_changeState(eltId, VALID);
            elt.className = dropDownList_findCssClass(eltId);
        }
    }
}
function dropDownList_disable(eltId) {
    dropDownList_setEnabled(eltId, false);
}
function dropDownList_enable(eltId) {
    dropDownList_setEnabled(eltId, true);
}
function dropDownList_setEnabled(eltId, enabled) {
    setDropDownListEnabled(eltId, enabled);
    if (enabled == false)
        dropDownList_clearError(eltId);
}
function dropDownList_reset(eltId) {
    dropDownList_clearSelection(eltId);
}
function dropDownList_show(eltId) {
    show(eltId);
}
function dropDownList_hide(eltId) {
    dropDownList_clearError(eltId);
    hide(eltId);
}
function dropDownList_onfocusin(sender) {
    var prop = form_eltPropertiesObjArray[sender.id];
    if (prop != null) {
        if (prop.cssClassFocus != null) {
            if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version >= 7)
                sender.className = prop.cssClassFocus;
            else {
                // See dropDownList_onfocus
            }
        }
    }
}
function dropDownList_onfocus(sender) {
    var prop = form_eltPropertiesObjArray[sender.id];
    if (prop != null) {
        if (prop.cssClassFocus != null) {
            if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version >= 7) {
                // See dropDownList_onfocusin ...
            }
            else
                sender.className = prop.cssClassFocus;
        }
    }
}
function dropDownList_onchange(sender) {
    var prop = form_eltPropertiesObjArray[sender.id];
    if (prop != null) {
        var value = sender.value;

        // Default value is allowed.
        // After any change, value is not default value anymore
        prop.currentValueIsDefaultValue = false;

        var messWarning = "";
        if (prop.clientFunctionWarning != null) {
            messWarning = prop.clientFunctionWarning(sender);
        }

        if (prop.errorMode == true) {
            var messError = "";
            if (prop.clientFunctionError == null) {
                if (value == prop.initialValue)
                    messError = prop.messageError;
            }
            else
                messError = prop.clientFunctionError(sender);

            if (messError != "") {
                errMgr_changeState(prop.eltId, ERROR, messError);
            }
            else {
                if (messWarning != "")
                    errMgr_changeState(prop.eltId, WARNING, messWarning);
                else
                    errMgr_changeState(prop.eltId, VALID);
            }
        }
        else
            if (messWarning != "")
            errMgr_changeState(prop.eltId, WARNING, messWarning);
        else
            errMgr_changeState(prop.eltId, VALID);
    }
    // Css class is updated in onblur event
}
function dropDownList_onblur(sender) {
    var prop = form_eltPropertiesObjArray[sender.id];
    if (prop != null) {
        sender.className = dropDownList_findCssClass(prop.eltId);
    }
    // Control state is updated in onchange event
}
function dropDownList_fill(eltId, formDataListTypeId, defaultValue, selectedValue, addFirstItemText, firstItemText, forceDefaultValue) {
    var dropDownList_fillCallback = function(result, eventArgs) {
        dropDownList_bind(eltId, formDataListTypeId, result, defaultValue, selectedValue, addFirstItemText, firstItemText, forceDefaultValue);
    }
    // This is the callback function invoked if the Web service failed.
    var dropDownList_fillFailedCallback = function(error) {
        // Clear list and update formDataListTypeId property 
        // to allow list update on server-side on postback even if request failed ...
        var prop = form_eltPropertiesObjArray[eltId];
        if (prop != null) {
            if (formDataListTypeId == -1 || prop.formDataListTypeId != formDataListTypeId) {
                dropDownList_clear(eltId);
                prop.formDataListTypeId = formDataListTypeId;
                var hf = $get(prop.hfIdFormDataListTypeLoadedOnClient);
                if (hf != null)
                    hf.value = formDataListTypeId;
            }
        }

        displayAspNetFrameworkError("AssurlandWeb.WebRessourcesAccess.GetFormDataList failed", error);
    }
    // Call WS
    AssurlandWeb.WebRessourcesAccess.GetFormDataList(formDataListTypeId, dropDownList_fillCallback, dropDownList_fillFailedCallback);
}
function dropDownList_bind(eltId, formDataListTypeId, result, defaultValue, selectedValue, addFirstItemText, firstItemText, forceDefaultValue) {
    var prop = form_eltPropertiesObjArray[eltId];
    var dv = "";
    var bFindSelectedValue = false;
    var optionsDefaultValue;
    if (addFirstItemText == null)
        addFirstItemText = true;
    if (firstItemText == null || firstItemText == "")
        firstItemText = "-- Sélectionnez --";
    if (forceDefaultValue == null)
        forceDefaultValue = false;
    if (prop != null) {
        if (formDataListTypeId != -1 && prop.formDataListTypeId == formDataListTypeId) {
            if (forceDefaultValue)
                $get(eltId).value = defaultValue;
            return;
        }

        var elt = $get(eltId);
        if (elt != null) {
            // Clear list
            dropDownList_clear(eltId);

            // Update form data list type id
            prop.formDataListTypeId = formDataListTypeId;
            var hf = $get(prop.hfIdFormDataListTypeLoadedOnClient);
            if (hf != null)
                hf.value = formDataListTypeId;

            // Feed new list
            if (result.length > 0) {
                if (addFirstItemText) {
                    elt.options[0] = new Option(firstItemText, "");
                }
                for (var i = 0; i < result.length; i++) {
                    var j = i;
                    if (addFirstItemText) {
                        j = i + 1;
                    }
                    elt.options[j] = new Option(result[i].Text, result[i].Value);
                    if (selectedValue)
                        if (result[i].Value == selectedValue) {
                        elt.options[j].selected = true;
                        bFindSelectedValue = true;
                    }
                    if (defaultValue)
                        if (result[i].Value == defaultValue) {
                        optionsDefaultValue = elt.options[j];
                    }
                }
                if (!bFindSelectedValue || forceDefaultValue)
                    if (optionsDefaultValue)
                    optionsDefaultValue.selected = true;
            }
        }
    }
}
function dropDownList_onUpdate(sender) {
    //Function call to update error or warning message and css style
    if (sender) {
        sender.onchange();
        sender.onblur();
    }
}

function dateDropDownList_clearSelection(eltId) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        clearSelectionDropDownList(prop.ddlDayId);
        clearSelectionDropDownList(prop.ddlMonthId);
        clearSelectionDropDownList(prop.ddlYearId);
    }
    dateDropDownList_clearError(eltId)
}
function dateDropDownList_clearError(eltId) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        prop.errorMode = false;
        errMgr_changeState(eltId, VALID);
    }
}
function dateDropDownList_reset(eltId) {
    dateDropDownList_clearSelection(eltId);
}
function dateDropDownList_show(eltId) {
    alert("Not implemented method (dateDropDownList_show)");
}
function dateDropDownList_hide(eltId) {
    alert("Not implemented method (dateDropDownList_hide)");
}
function dateDropDownList_getDate(eltId) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        if ($get(prop.ddlDayId))
            return new Date($get(prop.ddlYearId).value, $get(prop.ddlMonthId).value - 1, $get(prop.ddlDayId).value);
        else {
            if ($get(prop.ddlYearId).value > 0)
                return new Date($get(prop.ddlYearId).value, $get(prop.ddlMonthId).value - 1, 1);
            else
                return null;
        }
    }
    return null;
}
function dateDropDownList_setDate(eltId, date) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        if ($get(prop.ddlDayId))
            $get(prop.ddlDayId).value = date.getDate();

        $get(prop.ddlMonthId).value = date.getMonth() + 1;
        $get(prop.ddlYearId).value = date.getFullYear();
    }
}
function dateDropDownList_onfocusin(sender, parentId) {
    var prop = form_eltPropertiesObjArray[parentId];
    if (prop != null) {
        if (prop.cssClassFocus != null) {
            if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version >= 7)
                sender.className = prop.cssClassFocus;
            else {
                // See dropDownList_onfocus
            }
        }
    }
}
function dateDropDownList_onfocus(sender, parentId) {
    var prop = form_eltPropertiesObjArray[parentId];
    if (prop != null) {
        if (prop.cssClassFocus != null) {
            if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version >= 7) {
                // See dropDownList_onfocusin ...
            }
            else
                sender.className = prop.cssClassFocus;
        }
    }
}
function dateDropDownList_onblur(sender, parentId) {
    var prop = form_eltPropertiesObjArray[parentId];
    if (prop != null) {
        var ddlDay = $get(prop.ddlDayId);
        var ddlMonth = $get(prop.ddlMonthId);
        var ddlYear = $get(prop.ddlYearId);
        var value = prop.getValue();
        var messWarning = "";
        if (prop.clientFunctionWarning != null) {
            messWarning = prop.clientFunctionWarning(sender);
        }
        if (prop.errorMode == true) {
            var messError = "";
            if (prop.clientFunctionError == null) {
                if (value == prop.initialValue)
                    messError = prop.messageError;
            }
            else
                messError = prop.clientFunctionError(sender);

            if (messError != "") {
                sender.className = prop.cssClassError;
                // Please see onchange event for other dropdownlist css updates
                //errMgr_changeState(prop.ucId, 1);
            }
            else {
                if (messWarning != "")
                    sender.className = prop.cssClassWarning;
                else
                    sender.className = prop.cssClass;
                // Please see onchange event for other dropdownlist css updates
                //errMgr_changeState(prop.ucId, 0);
            }
        }
        else {
            if (messWarning != "")
                sender.className = prop.cssClassWarning;
            else
                sender.className = prop.cssClass;
        }
    }
}
function dateDropDownList_onchange(sender, parentId) {
    var prop = form_eltPropertiesObjArray[parentId];
    if (prop != null) {
        var ddlDay = $get(prop.ddlDayId);
        var ddlMonth = $get(prop.ddlMonthId);
        var ddlYear = $get(prop.ddlYearId);
        var value = prop.getValue();

        var messWarning = "";
        if (prop.clientFunctionWarning != null) {
            messWarning = prop.clientFunctionWarning(sender);
        }
        if (prop.errorMode == true) {
            // Please see onblur event for sender dropdownlist css updates
            var messError = "";
            if (prop.clientFunctionError == null) {
                if (value == prop.initialValue)
                    messError = prop.messageError;
            }
            else
                messError = prop.clientFunctionError(sender);

            if (messError != "") {
                if (prop.selectionMode == 1)
                    if (sender.id != ddlDay.id)
                    ddlDay.className = prop.cssClassError;
                if (sender.id != ddlMonth.id)
                    ddlMonth.className = prop.cssClassError;
                if (sender.id != ddlYear.id)
                    ddlYear.className = prop.cssClassError;
                errMgr_changeState(prop.ucId, ERROR, messError);
            }
            else {
                if (messWarning != "") {
                    if (prop.selectionMode == 1)
                        if (sender.id != ddlDay.id)
                        ddlDay.className = prop.cssClassWarning;
                    if (sender.id != ddlMonth.id)
                        ddlMonth.className = prop.cssClassWarning;
                    if (sender.id != ddlYear.id)
                        ddlYear.className = prop.cssClassWarning;
                    errMgr_changeState(prop.ucId, WARNING, messWarning);
                }
                else {
                    if (prop.selectionMode == 1)
                        if (sender.id != ddlDay.id)
                        ddlDay.className = prop.cssClass;
                    if (sender.id != ddlMonth.id)
                        ddlMonth.className = prop.cssClass;
                    if (sender.id != ddlYear.id)
                        ddlYear.className = prop.cssClass;
                    errMgr_changeState(prop.ucId, VALID);
                }
            }
        }
        else {
            if (messWarning != "") {
                if (prop.selectionMode == 1)
                    if (sender.id != ddlDay.id)
                    ddlDay.className = prop.cssClassWarning;
                if (sender.id != ddlMonth.id)
                    ddlMonth.className = prop.cssClassWarning;
                if (sender.id != ddlYear.id)
                    ddlYear.className = prop.cssClassWarning;
                errMgr_changeState(prop.ucId, WARNING, messWarning);
            }
            else {
                if (prop.selectionMode == 1)
                    if (sender.id != ddlDay.id)
                    ddlDay.className = prop.cssClass;
                if (sender.id != ddlMonth.id)
                    ddlMonth.className = prop.cssClass;
                if (sender.id != ddlYear.id)
                    ddlYear.className = prop.cssClass;
                errMgr_changeState(prop.ucId, VALID);
            }
        }
    }
}
function dateDropDownList_onUpdate(sender) {
    //Function call to update error or warning message and css style
    if (sender) {
        sender.onchange();
        sender.onblur();
    }
}

function radioButtonList_clearSelection(eltId) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        $get(prop.eltId).className = prop.cssClass;
        clearSelectionRadioButtonList(prop.groupName);
        if (prop.defaultValue != null) {
            selectItemRadioButtonList(prop.groupName, prop.defaultValue);
        }
        radioButtonList_clearError(eltId);
    }
}
function radioButtonList_clearError(eltId) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        prop.errorMode = false;
        errMgr_changeState(eltId, VALID);
        $get(prop.eltId).className = prop.cssClass;
    }
}
function radioButtonList_disable(eltId) {
    radioButtonList_setEnabled(eltId, false);
}
function radioButtonList_enable(eltId) {
    radioButtonList_setEnabled(eltId, true);
}
function radioButtonList_setEnabled(eltId, enabled) {
    var prop = form_eltPropertiesObjArray[eltId];
    if (prop != null) {
        setRadioButtonListEnabled(prop.groupName, enabled);
    }
    if (enabled == false)
        radioButtonList_clearError(eltId);
}
function radioButtonList_reset(eltId) {
    radioButtonList_clearSelection(eltId);
}
function radioButtonList_show(eltId) {
    show(eltId);
}
function radioButtonList_hide(eltId) {
    radioButtonList_clearError(eltId);
    hide(eltId);
}
function radioButtonList_click(sender, rblId) {
    var prop = form_eltPropertiesObjArray[rblId];
    if (prop != null) {
        var elt = $get(prop.eltId);
        var value = "";
        if (sender != null)
            value = sender.value;

        // Default value is allowed.
        // After any change, value is not default value anymore
        prop.currentValueIsDefaultValue = false;

        var messWarning = "";
        if (prop.clientFunctionWarning != null) {
            messWarning = prop.clientFunctionWarning(sender);
        }
        if (elt != null) {
            if (prop.errorMode == true) {
                var messError = "";
                if (prop.clientFunctionError == null) {
                    if (value == prop.initialValue)
                        messError = prop.messageError;
                }
                else
                    messError = prop.clientFunctionError(sender);

                if (messError != "") {
                    elt.className = prop.cssClassError;
                    errMgr_changeState(prop.eltId, ERROR, messError);
                }
                else {
                    if (messWarning != "") {
                        elt.className = prop.cssClassWarning;
                        errMgr_changeState(prop.eltId, WARNING, messWarning);
                    }
                    else {
                        elt.className = prop.cssClass;
                        errMgr_changeState(prop.eltId, VALID);
                    }
                }
            }
            else {
                if (messWarning != "") {
                    elt.className = prop.cssClassWarning;
                    errMgr_changeState(prop.eltId, WARNING, messWarning);
                }
                else {
                    elt.className = prop.cssClass;
                    errMgr_changeState(prop.eltId, VALID);
                }
            }
            radioButtonList_setClassSelected(prop.groupName)
        }
    }
}
function radioButtonList_setClassSelected(groupName) {
    var radioGroup = document.getElementsByName(groupName);
    for (var i = 0; i < radioGroup.length; i++) {
        radioGroup[i].parentNode.className = radioGroup[i].parentNode.className.replace(' al_selected', '');
        if (radioGroup[i].checked)
            radioGroup[i].parentNode.className = radioGroup[i].parentNode.className + ' al_selected';
    }
}
function radioButtonList_setSelectedValue(rblId, value) {
    var prop = form_eltPropertiesObjArray[rblId];
    if (prop != null) {
        selectItemRadioButtonList(prop.groupName, value);
    }
    radioButtonList_onUpdateById(rblId);
}
function radioButtonList_getSelectedValue(rblId) {
    var prop = form_eltPropertiesObjArray[rblId];
    if (prop != null) {
        return getRadioButtonListSelectedValue(prop.groupName)
    }
    return null;
}
function radioButtonList_getItemByValue(rblId, value) {
    var prop = form_eltPropertiesObjArray[rblId];
    if (prop != null) {
        return getRadioButtonItem(prop.groupName, value);
    }
    return null;
}
function radioButtonList_getLabelItemByValue(rblId, value) {
    var item = radioButtonList_getItemByValue(rblId, value);
    // Search associated label
    var elt = $get(rblId);
    if (elt != null) {
        var obj = elt.getElementsByTagName("label");
        if (obj && obj.length) {
            for (var i = 0; i < obj.length; i++) {
                if (obj[i].htmlFor == item.id) {
                    return obj[i]
                }
            }
        }
    }
}
function radioButtonList_updateLabelByValue(rblId, value, text) {
    var label = radioButtonList_getLabelItemByValue(rblId, value);
    if (label != null) {
        label.innerHTML = text;
    }
}
function radioButtonList_isCurrentValueIsDefaultValue(rblId) {
    var prop = form_eltPropertiesObjArray[rblId];
    if (prop != null) {
        return prop.currentValueIsDefaultValue
    }
    return false;
}

function radioButtonList_onUpdateById(rblId) {
    //Function call to update error or warning message and css style
    radioButtonList_click(null, rblId);
}
function radioButtonList_onUpdate(sender) {
    //Function call to update error or warning message and css style
    if (sender) {
        sender.onclick();
    }
}

////////////////////////////////////////
// Zip code / Insee code
////////////////////////////////////////

function zipcode_textBox_keyUp(sender, ddlEltId) {
    if (sender.value.length == 5) {
        zipcode_initLocations(sender, sender.value, ddlEltId);
    } else {
        hide(ddlEltId);
    }
}

function zipcode_initLocations(sender, zipCode, ddlEltId, defaultInseeCode) {
    var zipcode_succeededCallback = function(result, eventArgs) {
        // This is the callback function invoked if the Web service succeeded.
        // It accepts the result object as a parameter.
        var ddl = $get(ddlEltId);
        if (ddl) {
            // Reset error
            dropDownList_clearError(ddlEltId);
            //show location dropdownlist
            show(ddlEltId);
            // Reset width
            ddl.style.width = null;
            // Clear first
            ddl.options.length = 0;
            // Init dropdownlist next
            if (result.length == 0) {
                ddl.options[0] = new Option("sans objet", "");
            }
            else if (result.length == 1) {
                ddl.options[0] = new Option(result[0].Location, result[0].InseeCode);
            }
            else {
                ddl.options[0] = new Option("-- Sélectionnez --", "");
                for (var i = 0; i < result.length; i++) {
                    ddl.options[i + 1] = new Option(result[i].Location, result[i].InseeCode);
                }
            }
            if (defaultInseeCode != null) {
                for (var j = 0; j < ddl.options.length; j++) {
                    if (ddl.options[j].value == defaultInseeCode) {
                        ddl.options[j].selected = true;
                        break;
                    }
                }
            }
        }
    }
    if (zipCode) {
        // Call WS
        AssurlandWeb.WebRessourcesAccess.GetLocations(zipCode, zipcode_succeededCallback, zipcode_failedCallback);
    }
    else {
        var ddl = $get(ddlEltId);
        // Clear
        ddl.options.length = 0;
        // Reset error
        dropDownList_clearError(ddlEltId);
        // Hide ?
        var prop = form_eltPropertiesObjArray[sender.id];
        if (prop != null) {
            if (prop.zipCodeDropDownListDynamicVisibility) {
                //hide location dropdownlist
                hide(ddlEltId);
            }
        }
    }
}
// This is the callback function invoked if the Web service failed.
function zipcode_failedCallback(error) {
    displayAspNetFrameworkError("AssurlandWeb.WebRessourcesAccess.GetLocations failed", error);
}

function ZipCode_SearchBoxProperties(popupId, iframeId, tbIdZipCode, lbIdLocation) {
    this.popupId = popupId;
    this.iframeId = iframeId;
    this.tbIdZipCode = tbIdZipCode;
    this.lbIdLocation = lbIdLocation;
    this.tbIdTargetZipCode = null;
    this.ddlIdTargetLocation = null;
    this.visible = false;
}
ZipCode_SearchBoxProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'popupId = ' + this.popupId + '\n';
        str = str + 'iframeId = ' + this.iframeId + '\n';
        str = str + 'tbIdZipCode = ' + this.tbIdZipCode + '\n';
        str = str + 'lbIdLocation = ' + this.lbIdLocation + '\n';
        str = str + 'tbIdTargetZipCode = ' + this.tbIdTargetZipCode + '\n';
        str = str + 'ddlIdTargetLocation = ' + this.ddlIdTargetLocation + '\n';
        str = str + 'visible = ' + this.visible + '\n';
        return str;
    }
}

var zipcode_searchBoxPropertiesArray;
function zipcode_searchBoxInit() {
    zipcode_searchBoxPropertiesArray = new Array();
    // Add and remove depending on number of popup shown
    //addListener(document, 'click', zipcode_updateAllSearchBoxVisibility);   
}
function zipcode_addSearchBox(popupId, iframeId, tbIdZipCode, lbIdLocation) {
    var obj = new ZipCode_SearchBoxProperties(popupId, iframeId, tbIdZipCode, lbIdLocation, null, null);
    zipcode_searchBoxPropertiesArray[popupId] = obj;
}
function zipcode_searchBoxShow(senderId, popupId, tbIdTargetZipCode, ddlIdTargetLocation) {
    var prop = zipcode_searchBoxPropertiesArray[popupId];
    if (prop != null) {
        // Update configuration
        prop.tbIdTargetZipCode = tbIdTargetZipCode;
        prop.ddlIdTargetLocation = ddlIdTargetLocation;
        // Show popup
        var popup = $get(popupId);
        var target = $get(tbIdTargetZipCode);
        if (popup != null && target != null) {
            // Compute new location
            var margin = 5;
            //var boundTarget = Sys.UI.DomElement.getBounds(target);
            // /!\ Popup can be in a relative or absolute container.
            // Relative position to this container has to be used instead of window position
            var boundTarget = getRelativeBounds(target, popup); //Sys.UI.DomElement.getBounds(target);
            var x = boundTarget.x;
            var y = boundTarget.y + boundTarget.height + margin;
            Sys.UI.DomElement.setLocation(popup, x, y);
            // Show popup
            $get(prop.tbIdZipCode).value = '';
            $get(prop.lbIdLocation).options.length = 0;
            show(popupId);
            //prop.visible = true;
            // Delay visible property update to not hide popup in concurrent function 
            // zipcode_updateAllSearchBoxVisibility() called by onclick event
            setTimeout("zipcode_searchBoxSetVisible('" + popupId + "',true);", 50);
            //zipcode_searchBoxSetVisible(popupId, true);
        }
    }
}
function zipcode_searchBoxHide(popupId) {
    zipcode_searchBoxSetVisible(popupId, false);
    hide(popupId);
}
function zipcode_searchBoxSwitchVisibility(senderId, popupId, tbIdTargetZipCode, ddlIdTargetLocation) {
    var prop = zipcode_searchBoxPropertiesArray[popupId];
    if (prop != null) {
        if (prop.visible && prop.tbIdTargetZipCode == tbIdTargetZipCode) {
            // Hide
            zipcode_searchBoxHide(popupId);
        }
        else {
            // Hide & shown in anoter place
            zipcode_searchBoxHide(popupId);
            zipcode_searchBoxShow(senderId, popupId, tbIdTargetZipCode, ddlIdTargetLocation);
        }
    }
}
function zipcode_searchBoxSetVisible(popupId, visible) {
    var prop = zipcode_searchBoxPropertiesArray[popupId];
    if (prop != null) {
        // Add click event listener if required
        if (visible && zipcode_getNbVisibleSearchBox() == 0) {
            addListener(document, 'click', zipcode_updateAllSearchBoxVisibility);
        }

        prop.visible = visible;

        // Remove click event listener if required
        if (!visible && zipcode_getNbVisibleSearchBox() == 0) {
            removeListener(document, 'click', zipcode_updateAllSearchBoxVisibility);
        }
    }
}
function zipcode_searchBox_keyUp(sender, popupId) {
    if (sender.value.length >= 3) {
        var str = sender.value;
        var prop = zipcode_searchBoxPropertiesArray[popupId];
        if (prop != null) {
            var zipcode_searchBoxSucceededCallback = function(result, eventArgs) {
                // This is the callback function invoked if the Web service succeeded.
                // It accepts the result object as a parameter.
                var lb = $get(prop.lbIdLocation);
                if (lb) {
                    // Clear first
                    lb.options.length = 0;
                    // Init listbox next
                    if (result.length == 0) {
                        // Nothing to do ...
                    }
                    else {
                        for (var i = 0; i < result.length; i++) {
                            lb.options[i] = new Option(result[i].Location + " (" + result[i].ZipCode + ")", result[i].InseeCode);
                        }
                    }
                }
            }
            // Call WS
            AssurlandWeb.WebRessourcesAccess.SearchLocations(str, zipcode_searchBoxSucceededCallback, zipcode_searchBoxFailedCallback);
        }
    }
}
function zipcode_searchBoxValidate(popupId) {
    // Init linked form input
    var prop = zipcode_searchBoxPropertiesArray[popupId];
    if (prop != null) {
        var locationLb = $get(prop.lbIdLocation);
        var targetZipCodeTb = $get(prop.tbIdTargetZipCode);
        var targetLocationDdl = $get(prop.ddlIdTargetLocation);
        var inseeCode = locationLb.value;
        var zipCode = '';
        // Get zipcode
        var zipcode_searchBoxValidateSucceededCallback = function(result, eventArgs) {
            if (result != null) {
                zipCode = result.ZipCode;
                // Update form
                targetZipCodeTb.value = zipCode;
                // Reset error
                textBox_clearError(prop.tbIdTargetZipCode);
                // Update location
                zipcode_initLocations(targetZipCodeTb, zipCode, prop.ddlIdTargetLocation, inseeCode);
            }
        }
        // Call WS
        AssurlandWeb.WebRessourcesAccess.GetZipCodeByInseeCode(inseeCode, zipcode_searchBoxValidateSucceededCallback, zipcode_searchBoxFailedCallback);
    }
    // Hide popup
    zipcode_searchBoxHide(popupId);
}
// This is the callback function invoked if the Web service failed.
function zipcode_searchBoxFailedCallback(error) {
    displayAspNetFrameworkError("AssurlandWeb.WebRessourcesAccess.GetZipCodeByInseeCode failed", error);
}
function zipcode_updateAllSearchBoxVisibility(e) {
    if (zipcode_searchBoxPropertiesArray != null) {
        var areaMargin = 2;
        var prop;
        var x = mouseX(e);
        var y = mouseY(e);
        for (key in zipcode_searchBoxPropertiesArray) {
            prop = zipcode_searchBoxPropertiesArray[key];
            if (prop.visible == true) {
                var boundSender = Sys.UI.DomElement.getBounds($get(prop.popupId));
                var area = new RectArea();
                area.x = boundSender.x - areaMargin;
                area.y = boundSender.y - areaMargin;
                area.width = boundSender.width + 2 * areaMargin;
                area.height = boundSender.height + 2 * areaMargin;

                if (area.PtIn(x, y) == false)
                    zipcode_searchBoxHide(prop.popupId);
            }
        }
    }
}
function zipcode_getNbVisibleSearchBox() {
    var nb = 0;
    for (var i = 0; i < zipcode_searchBoxPropertiesArray.length; i++) {
        if (zipcode_searchBoxPropertiesArray[i].visible == true) {
            nb++;
        }
    }
    return nb;
}

////////////////////////////////////////
// Address
////////////////////////////////////////
var address_sex;

function address_warningTitleAndSex(sender) {
    if (sender.value != '') {
        var title = sender.value.substr(0, 2);
        if ((title == "MA" && address_sex != "F") || (address_sex == "F" && title == "MO")) {
            if (address_sex == "F")
                return "Vous avez déclaré auparavant être une femme, êtes vous certain d'avoir sélectionné la bonne civilité ? ";
            else
                return "Vous avez déclaré auparavant être un homme, êtes vous certain d'avoir sélectionné la bonne civilité ? ";
        }
    }
    return "";
}

var address_sex_2;
function address_warningTitleAndSex2(sender) {

    if (sender.value != '') {
        var title = sender.value.substr(0, 2);
        if ((title == "MA" && address_sex_2 != "F") || (address_sex_2 == "F" && title == "MO")) {
            if (address_sex_2 == "F")
                return "Vous avez déclaré que c'était une femme, êtes vous certain d'avoir sélectionné la bonne civilité ? ";
            else
                return "Vous avez déclaré que c'était un homme, êtes vous certain d'avoir sélectionné la bonne civilité ? ";
        }
    }
    return "";
}

////////////////////////////////////////
// Agencies
////////////////////////////////////////

var agency_addressId;
var agency_ddlAgencyId;
var agency_ddlDepartmentId;

// Carrefour Agency
function agency_carrefourUpdateDepartment(dep) {
    // Call
    var agency_carrefourUpdateDepartment_Callback = function(result, eventArgs) {
        //alert(result);
        dropDownList_bind(agency_ddlAgencyId, -1, result, "", "", true, "-- Sélectionnez un magasin --");
        /*if ($get(rblProposalTypeOneButtonId)) {
            var rbl = $get(rblProposalTypeOneButtonId).getElementsByTagName('input');
            for (var x = 0; x < rbl.length; x++) {
                if (rbl[x].checked) {
                    if (rbl[x].value == '3') {
                        $get(agency_ddlAgencyId).options[$get(agency_ddlAgencyId).options.length - 1] = null;
                    }
                }
            }
        } else {
            $get(agency_ddlAgencyId).options[$get(agency_ddlAgencyId).options.length - 1].text = "Etre rappelé(e) par un conseiller";
        }*/
    }
    AssurlandWeb.AgencyAccess.SearchCarrefourAgencies(dep, agency_carrefourUpdateDepartment_Callback, agency_carrefourUpdateDepartment_FailedCallback);
}
function agency_carrefourUpdateDepartment_FailedCallback(error) {
    displayAspNetFrameworkError("AssurlandWeb.AgencyAccess.SearchCarrefourAgencies failed", error);
}

function agency_carrefourChange() {
    if ($get(agency_ddlAgencyId).value == '09940') {
        document.location.href = document.location.href.replace('&type=3', '&type=2');
    }
}

// MMA Agency
var agency_rbAgency1Id;
var agency_rbAgency2Id;
var agency_rbAgency3Id;
var agency_rbAgency4Id;
var agency_rowErrAgencyId;

function agency_mmaUpdateDepartment(dep) {
    // Call
    var agency_mmaUpdateDepartment_Callback = function(result, eventArgs) {
        //alert(result);
        dropDownList_bind(agency_ddlAgencyId, -1, result, "", "", true, "-- Sélectionnez une agence --");
    }
    AssurlandWeb.AgencyAccess.SearchMmaAgencies(dep, agency_mmaUpdateDepartment_Callback, agency_mmaUpdateDepartment_FailedCallback);
}
function agency_mmaUpdateDepartment_FailedCallback(error) {
    displayAspNetFrameworkError("AssurlandWeb.AgencyAccess.SearchMmaAgencies failed", error);
}
function agency_mmaAgencyRadioButtonClick() {
    // Get selected agency index
    var rbChecked = 0;
    if ($get(agency_rbAgency1Id).checked == true)
        rbChecked = 1;
    else if ($get(agency_rbAgency2Id).checked == true)
        rbChecked = 2;
    else if ($get(agency_rbAgency3Id).checked == true)
        rbChecked = 3;
    else if ($get(agency_rbAgency4Id).checked == true)
        rbChecked = 4;

    // Enable/disable department search
    if (rbChecked == 4) {
        dropDownList_enable(agency_ddlDepartmentId)
        dropDownList_enable(agency_ddlAgencyId)
    }
    else {
        dropDownList_disable(agency_ddlDepartmentId)
        dropDownList_disable(agency_ddlAgencyId)
    }
}

////////////////////////////////////////
// Proposal call back
////////////////////////////////////////
var rowCallBackOnlyId;

function CallBackInfo_Calendar() {
    this.dates = new Array();
    this.rangesByDate = new Array();
}
CallBackInfo_Calendar.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'dates = ' + this.dates + '\n';
        return str;
    }
}
CallBackInfo_Calendar.prototype =
{
    getDaysByMonth: function(month) {
        var array = new Array();
        for (var i = 0; i < this.dates.length; i++) {
            if (this.dates[i].getMonth() == (month - 1)) {
                addToArray(array, this.dates[i]);
            }
        }
        return array;
    }
}

var callbackinfo_calendar = new CallBackInfo_Calendar();
function callbackinfo_addDate(d) {
    addToArray(callbackinfo_calendar.dates, d);
}
function callbackinfo_addRange(strDate, range) {
    if (callbackinfo_calendar.rangesByDate[strDate] == null)
        callbackinfo_calendar.rangesByDate[strDate] = new Array();
    addToArray(callbackinfo_calendar.rangesByDate[strDate], range);
}
function callbackinfo_getDateString(d) {
    var str = callbackinfo_getDayString(d) + '/' + callbackinfo_getMonthString(d) + '/' + d.getFullYear();
    return str;
}
function callbackinfo_getDayString(d) {
    var day = d.getDate();
    if (day > 9)
        return day
    else
        return "0" + day
}
function callbackinfo_getMonthString(d) {
    var month = d.getMonth() + 1;
    if (month > 9)
        return month
    else
        return "0" + month
}

function callbackinfo_updateMonth(ucId, month) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update days
        var dates = callbackinfo_calendar.getDaysByMonth(month);
        var elt = $get(prop.dayId);
        dropDownList_clear(prop.dayId);
        if (dates.length > 0) {
            // Update liste
            for (var i = 0; i < dates.length; i++) {
                elt.options[i] = new Option(callbackinfo_getDayString(dates[i]), callbackinfo_getDateString(dates[i]));
            }
            // Update range
            callbackinfo_updateDay(ucId, callbackinfo_getDateString(dates[0]));
        }
        else {
            elt.options[0] = new Option("sans objet", "");
        }
    }
}
function callbackinfo_updateDay(ucId, day) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update open hours
        var elt = $get(prop.hourId);
        dropDownList_clear(prop.hourId);
        if (callbackinfo_calendar.rangesByDate[day] != null) {
            var rangeArray = callbackinfo_calendar.rangesByDate[day];
            // Update liste
            for (var i = 0; i < rangeArray.length; i++) {
                elt.options[i] = new Option(rangeArray[i], rangeArray[i]);
            }
        }
        else {
            elt.options[0] = new Option("sans objet", "");
        }
    }
}
function callbackinfo_setEnabled(ucId, enabled) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        dropDownList_setEnabled(prop.dayId, enabled);
        dropDownList_setEnabled(prop.monthId, enabled);
        dropDownList_setEnabled(prop.hourId, enabled);
        textBox_setEnabled(prop.phoneNumberId, enabled);
    }
}

////////////////////////////////////////
// Misc functions (shared product js)
////////////////////////////////////////

function isValidBonusByDrivLicenceDate(bonus, drivLicenceDate) {
    var years = calcul_age(drivLicenceDate);
    return isValidBonus(bonus, years);
}
function isValidBonus(bonus, years) {
    if ((years < 12 && bonus == 0.5) || (years < 11 && bonus <= 0.51) || (years < 10 && bonus <= 0.54) || (years < 9 && bonus <= 0.57) || (years < 8 && bonus <= 0.6) || (years < 7 && bonus <= 0.64) || (years < 6 && bonus <= 0.68) || (years < 5 && bonus <= 0.72) || (years < 4 && bonus <= 0.76) || (years < 3 && bonus <= 0.8) || (years < 2 && bonus <= 0.85) || (years < 1 && bonus <= 0.9)) {
        return false;
    }
    return true;
}
function getBonusFromForm(bonus) {
    if (bonus >= 10.0) return 0.5;
    return bonus;
}
function getDefaultBonus(years) {
    switch (years) {
        case 0: return 1.0;
        case 1: return 0.95;
        case 2: return 0.9;
        case 3: return 0.85;
        case 4: return 0.8;
        case 5: return 0.76;
        case 6: return 0.72;
        case 7: return 0.68;
        case 8: return 0.64;
        case 9: return 0.6;
        case 10: return 0.57;
        case 11: return 0.54;
        case 12: return 0.51;
        case 13: return 0.5;
        case 14: return 10;
        case 15: return 20;
        case 16: return 30;
        case 17: return 40;
        case 18: return 50;
        default: return 60;
    }
}
function getBonusLabel(bonus) {
    switch (bonus) {
        case 1.0: return "1 soit ni bonus, ni malus";
        case 10: return "0,50 soit 50% de bonus";
        case 20: return "0,50 soit 50% de bonus";
        case 30: return "0,50 soit 50% de bonus";
        case 40: return "0,50 soit 50% de bonus";
        case 50: return "0,50 soit 50% de bonus";
        case 60: return "0,50 soit 50% de bonus";
        default:
            if (bonus > 1.0)
                return strReplace(bonus.toFixed(2), "\\.", ",") + " soit " + (bonus - 1).toFixed(0) + "% de malus";
            else
                return strReplace(bonus.toFixed(2), "\\.", ",") + " soit " + ((1 - bonus) * 100).toFixed(0) + "% de bonus";
    }
}
function getMaturity(month) {
    var maturity;
    var dNow = new Date();
    //year
    if (dNow.getMonth() + 1 == month) {
        dNow.setDate(dNow.getDate() + 1);
        if (dNow.getDate() < 10)
            maturity = "0" + dNow.getDate() + "/";
        else
            maturity = dNow.getDate() + "/";

        if (dNow.getMonth() * 1 + 1 < 10)
            maturity = maturity + "0" + (dNow.getMonth() * 1 + 1) + "/";
        else
            maturity = maturity + (dNow.getMonth() * 1 + 1) + "/";

        maturity = maturity + dNow.getFullYear();
    }
    else {
        if (dNow.getMonth() + 1 < month)
            maturity = "01/" + month + "/" + dNow.getFullYear()
        else
            maturity = "01/" + month + "/" + (dNow.getFullYear() + 1)
    }
    return maturity;
}

/////////////////////////////////////////////////////////////////////////
//          OLD WEBRESSOURCESACCESS.asmx.js                            //
////////////////////////////////////////////////////////////////////////
Type.registerNamespace('AssurlandWeb');
AssurlandWeb.WebRessourcesAccess = function() {
    AssurlandWeb.WebRessourcesAccess.initializeBase(this);
    this._timeout = 0;
    this._userContext = null;
    this._succeeded = null;
    this._failed = null;
}
AssurlandWeb.WebRessourcesAccess.prototype = {
    _get_path: function() {
        var p = this.get_path();
        if (p) return p;
        else return AssurlandWeb.WebRessourcesAccess._staticInstance.get_path();
    },
    GetFormHelp: function(helpId, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'GetFormHelp', false, { helpId: helpId }, succeededCallback, failedCallback, userContext);
    },
    GetProductBaseHelp: function(groupId, eltId, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'GetProductBaseHelp', false, { groupId: groupId, eltId: eltId }, succeededCallback, failedCallback, userContext);
    },
    GetFormDataList: function(listId, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'GetFormDataList', false, { listId: listId }, succeededCallback, failedCallback, userContext);
    },
    GetLocations: function(zipCode, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'GetLocations', false, { zipCode: zipCode }, succeededCallback, failedCallback, userContext);
    },
    GetZipCode: function(zipCode, inseeCode, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'GetZipCode', false, { zipCode: zipCode, inseeCode: inseeCode }, succeededCallback, failedCallback, userContext);
    },
    GetZipCodeByInseeCode: function(inseeCode, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'GetZipCodeByInseeCode', false, { inseeCode: inseeCode }, succeededCallback, failedCallback, userContext);
    },
    SearchLocations: function(start, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'SearchLocations', false, { start: start }, succeededCallback, failedCallback, userContext);
    } 
}
AssurlandWeb.WebRessourcesAccess.registerClass('AssurlandWeb.WebRessourcesAccess', Sys.Net.WebServiceProxy);
AssurlandWeb.WebRessourcesAccess._staticInstance = new AssurlandWeb.WebRessourcesAccess();
AssurlandWeb.WebRessourcesAccess.set_path = function(value) { AssurlandWeb.WebRessourcesAccess._staticInstance.set_path(value); }
AssurlandWeb.WebRessourcesAccess.get_path = function() { return AssurlandWeb.WebRessourcesAccess._staticInstance.get_path(); }
AssurlandWeb.WebRessourcesAccess.set_timeout = function(value) { AssurlandWeb.WebRessourcesAccess._staticInstance.set_timeout(value); }
AssurlandWeb.WebRessourcesAccess.get_timeout = function() { return AssurlandWeb.WebRessourcesAccess._staticInstance.get_timeout(); }
AssurlandWeb.WebRessourcesAccess.set_defaultUserContext = function(value) { AssurlandWeb.WebRessourcesAccess._staticInstance.set_defaultUserContext(value); }
AssurlandWeb.WebRessourcesAccess.get_defaultUserContext = function() { return AssurlandWeb.WebRessourcesAccess._staticInstance.get_defaultUserContext(); }
AssurlandWeb.WebRessourcesAccess.set_defaultSucceededCallback = function(value) { AssurlandWeb.WebRessourcesAccess._staticInstance.set_defaultSucceededCallback(value); }
AssurlandWeb.WebRessourcesAccess.get_defaultSucceededCallback = function() { return AssurlandWeb.WebRessourcesAccess._staticInstance.get_defaultSucceededCallback(); }
AssurlandWeb.WebRessourcesAccess.set_defaultFailedCallback = function(value) { AssurlandWeb.WebRessourcesAccess._staticInstance.set_defaultFailedCallback(value); }
AssurlandWeb.WebRessourcesAccess.get_defaultFailedCallback = function() { return AssurlandWeb.WebRessourcesAccess._staticInstance.get_defaultFailedCallback(); }
AssurlandWeb.WebRessourcesAccess.set_path("/Ws/WebRessourcesAccess.asmx");
AssurlandWeb.WebRessourcesAccess.GetFormHelp = function(helpId, onSuccess, onFailed, userContext) { AssurlandWeb.WebRessourcesAccess._staticInstance.GetFormHelp(helpId, onSuccess, onFailed, userContext); }
AssurlandWeb.WebRessourcesAccess.GetProductBaseHelp = function(groupId, eltId, onSuccess, onFailed, userContext) { AssurlandWeb.WebRessourcesAccess._staticInstance.GetProductBaseHelp(groupId, eltId, onSuccess, onFailed, userContext); }
AssurlandWeb.WebRessourcesAccess.GetFormDataList = function(listId, onSuccess, onFailed, userContext) { AssurlandWeb.WebRessourcesAccess._staticInstance.GetFormDataList(listId, onSuccess, onFailed, userContext); }
AssurlandWeb.WebRessourcesAccess.GetLocations = function(zipCode, onSuccess, onFailed, userContext) { AssurlandWeb.WebRessourcesAccess._staticInstance.GetLocations(zipCode, onSuccess, onFailed, userContext); }
AssurlandWeb.WebRessourcesAccess.GetZipCode = function(zipCode, inseeCode, onSuccess, onFailed, userContext) { AssurlandWeb.WebRessourcesAccess._staticInstance.GetZipCode(zipCode, inseeCode, onSuccess, onFailed, userContext); }
AssurlandWeb.WebRessourcesAccess.GetZipCodeByInseeCode = function(inseeCode, onSuccess, onFailed, userContext) { AssurlandWeb.WebRessourcesAccess._staticInstance.GetZipCodeByInseeCode(inseeCode, onSuccess, onFailed, userContext); }
AssurlandWeb.WebRessourcesAccess.SearchLocations = function(start, onSuccess, onFailed, userContext) { AssurlandWeb.WebRessourcesAccess._staticInstance.SearchLocations(start, onSuccess, onFailed, userContext); }
var gtc = Sys.Net.WebServiceProxy._generateTypedConstructor;
if (typeof (AssurlandWeb.OnlineHelp) === 'undefined') {
    AssurlandWeb.OnlineHelp = gtc("AssurlandWeb.OnlineHelp");
    AssurlandWeb.OnlineHelp.registerClass('AssurlandWeb.OnlineHelp');
}
Type.registerNamespace('common');
if (typeof (common.ZipCode) === 'undefined') {
    common.ZipCode = gtc("common.ZipCode");
    common.ZipCode.registerClass('common.ZipCode');
}

/////////////////////////////////////////////////////
// UserTracking.asmx/js                            //
/////////////////////////////////////////////////////
Type.registerNamespace('AssurlandWeb');
AssurlandWeb.UserTracking = function() {
    AssurlandWeb.UserTracking.initializeBase(this);
    this._timeout = 0;
    this._userContext = null;
    this._succeeded = null;
    this._failed = null;
}
AssurlandWeb.UserTracking.prototype = {
    _get_path: function() {
        var p = this.get_path();
        if (p) return p;
        else return AssurlandWeb.UserTracking._staticInstance.get_path();
    },
    Track: function(funnel, pageType, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'Track', false, { funnel: funnel, pageType: pageType }, succeededCallback, failedCallback, userContext);
    }
}
AssurlandWeb.UserTracking.registerClass('AssurlandWeb.UserTracking', Sys.Net.WebServiceProxy);
AssurlandWeb.UserTracking._staticInstance = new AssurlandWeb.UserTracking();
AssurlandWeb.UserTracking.set_path = function(value) { AssurlandWeb.UserTracking._staticInstance.set_path(value); }
AssurlandWeb.UserTracking.get_path = function() { return AssurlandWeb.UserTracking._staticInstance.get_path(); }
AssurlandWeb.UserTracking.set_timeout = function(value) { AssurlandWeb.UserTracking._staticInstance.set_timeout(value); }
AssurlandWeb.UserTracking.get_timeout = function() { return AssurlandWeb.UserTracking._staticInstance.get_timeout(); }
AssurlandWeb.UserTracking.set_defaultUserContext = function(value) { AssurlandWeb.UserTracking._staticInstance.set_defaultUserContext(value); }
AssurlandWeb.UserTracking.get_defaultUserContext = function() { return AssurlandWeb.UserTracking._staticInstance.get_defaultUserContext(); }
AssurlandWeb.UserTracking.set_defaultSucceededCallback = function(value) { AssurlandWeb.UserTracking._staticInstance.set_defaultSucceededCallback(value); }
AssurlandWeb.UserTracking.get_defaultSucceededCallback = function() { return AssurlandWeb.UserTracking._staticInstance.get_defaultSucceededCallback(); }
AssurlandWeb.UserTracking.set_defaultFailedCallback = function(value) { AssurlandWeb.UserTracking._staticInstance.set_defaultFailedCallback(value); }
AssurlandWeb.UserTracking.get_defaultFailedCallback = function() { return AssurlandWeb.UserTracking._staticInstance.get_defaultFailedCallback(); }
AssurlandWeb.UserTracking.set_path("/Ws/UserTracking.asmx");
AssurlandWeb.UserTracking.Track = function(funnel, pageType, onSuccess, onFailed, userContext) { AssurlandWeb.UserTracking._staticInstance.Track(funnel, pageType, onSuccess, onFailed, userContext); }
if (typeof (AssurlandWeb.UserTrackingFunnel) === 'undefined') {
    AssurlandWeb.UserTrackingFunnel = function() { throw Error.invalidOperation(); }
    AssurlandWeb.UserTrackingFunnel.prototype = { UNKNOWN: 0, FORM_CAR_V1: 1, FORM_HEALTH_V1: 2, FORM_HOME_V1: 3, FORM_MOTO_V1: 4, FORM_LPR_V1: 5, FORM_VIE_V1: 6, FORM_LIFE_V1: 7, FORM_BORROW_V1: 8, FORM_CYCLO_V1: 9 }
    AssurlandWeb.UserTrackingFunnel.registerEnum('AssurlandWeb.UserTrackingFunnel', true);
}
if (typeof (AssurlandWeb.UserTrackingPage) === 'undefined') {
    AssurlandWeb.UserTrackingPage = function() { throw Error.invalidOperation(); }
    AssurlandWeb.UserTrackingPage.prototype = { BA: 1, QUOTATION_WAIT: 2, RESTIT: 3, PROPOSAL_WAIT: 4, THANKS: 5, FORM_CAR_V1_P1: 6, FORM_CAR_V1_P2: 7, FORM_CAR_V1_P3: 8, FORM_CAR_V1_P4: 9, FORM_HEALTH_V1_P1: 10, FORM_HEALTH_V1_P2: 11, FORM_HOME_V1_P1: 12, FORM_HOME_V1_P2: 13, FORM_HOME_V1_P3: 14, FORM_MOTO_V1_P1: 15, FORM_MOTO_V1_P2: 16, FORM_MOTO_V1_P3: 17, FORM_MOTO_V1_P4: 18, FORM_CYCLO_V1_P1: 19, FORM_CYCLO_V1_P2: 20, FORM_CYCLO_V1_P3: 21, FORM_CYCLO_V1_P4: 22, FORM_LPR_V1_P1: 23, FORM_VIE_V1_P1: 24, FORM_VIE_V1_P2: 25, FORM_LIFE_V1_P1: 26, FORM_BORROW_V1_P1: 27, FORM_BORROW_V1_P2: 28, FORM_CAR_V1_PROPOSAL: 29, FORM_HEALTH_V1_PROPOSAL: 30, FORM_HOME_V1_PROPOSAL: 31, FORM_MOTO_V1_PROPOSAL: 32, FORM_CYCLO_V1_PROPOSAL: 33, FORM_LPR_V1_PROPOSAL: 34, FORM_VIE_V1_PROPOSAL: 35, FORM_LIFE_V1_PROPOSAL: 36, FORM_BORROW_V1_PROPOSAL: 37 }
    AssurlandWeb.UserTrackingPage.registerEnum('AssurlandWeb.UserTrackingPage', true);
}

// Track question
function track(funnelId, pageId) {
    AssurlandWeb.UserTracking.Track(funnelId, pageId, null, null);
}

/////////////////////////////////////////////////////
// CaptchaAccess.asmx/js                           //
/////////////////////////////////////////////////////
Type.registerNamespace('AssurlandWeb');
AssurlandWeb.CaptchaService = function() {
    AssurlandWeb.CaptchaService.initializeBase(this);
    this._timeout = 0;
    this._userContext = null;
    this._succeeded = null;
    this._failed = null;
}
AssurlandWeb.CaptchaService.prototype = {
    _get_path: function() {
        var p = this.get_path();
        if (p) return p;
        else return AssurlandWeb.CaptchaService._staticInstance.get_path();
    },
    Checking: function(CaptchaRecorded, CaptchaSessionKey, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'Checking', false, { CaptchaRecorded: CaptchaRecorded, CaptchaSessionKey: CaptchaSessionKey }, succeededCallback, failedCallback, userContext);
    } 
}
AssurlandWeb.CaptchaService.registerClass('AssurlandWeb.CaptchaService', Sys.Net.WebServiceProxy);
AssurlandWeb.CaptchaService._staticInstance = new AssurlandWeb.CaptchaService();
AssurlandWeb.CaptchaService.set_path = function(value) { AssurlandWeb.CaptchaService._staticInstance.set_path(value); }
AssurlandWeb.CaptchaService.get_path = function() { return AssurlandWeb.CaptchaService._staticInstance.get_path(); }
AssurlandWeb.CaptchaService.set_timeout = function(value) { AssurlandWeb.CaptchaService._staticInstance.set_timeout(value); }
AssurlandWeb.CaptchaService.get_timeout = function() { return AssurlandWeb.CaptchaService._staticInstance.get_timeout(); }
AssurlandWeb.CaptchaService.set_defaultUserContext = function(value) { AssurlandWeb.CaptchaService._staticInstance.set_defaultUserContext(value); }
AssurlandWeb.CaptchaService.get_defaultUserContext = function() { return AssurlandWeb.CaptchaService._staticInstance.get_defaultUserContext(); }
AssurlandWeb.CaptchaService.set_defaultSucceededCallback = function(value) { AssurlandWeb.CaptchaService._staticInstance.set_defaultSucceededCallback(value); }
AssurlandWeb.CaptchaService.get_defaultSucceededCallback = function() { return AssurlandWeb.CaptchaService._staticInstance.get_defaultSucceededCallback(); }
AssurlandWeb.CaptchaService.set_defaultFailedCallback = function(value) { AssurlandWeb.CaptchaService._staticInstance.set_defaultFailedCallback(value); }
AssurlandWeb.CaptchaService.get_defaultFailedCallback = function() { return AssurlandWeb.CaptchaService._staticInstance.get_defaultFailedCallback(); }
AssurlandWeb.CaptchaService.set_path("/Ws/CaptchaAccess.asmx");
AssurlandWeb.CaptchaService.Checking = function(CaptchaRecorded, CaptchaSessionKey, onSuccess, onFailed, userContext) { AssurlandWeb.CaptchaService._staticInstance.Checking(CaptchaRecorded, CaptchaSessionKey, onSuccess, onFailed, userContext); }

////////////////////////////////////////
// Form 2 
////////////////////////////////////////
// One question per page
// && select answer by one click

var FORM2_STEP_1 = 1;
var FORM2_STEP_2 = 2;
var FORM2_STEP_3 = 3;
var FORM2_STEP_4 = 4;

// List collection
var form2_list;
// Funnel ID
var form2_funnelId;
// Shadow submit button
var form2_validateBtnId;
// Progress bar ID
var form2_progressBarPanelId;
// Back hyperlink ID
var form2_backBtnId;
// Next hyperlink ID
var form2_nextBtnId;
// Question label ID
var form2_questionLabelId;
// Sub Question Label Id
var form2_subQuestionLabelId
// Help cell ID
var form2_helpCellId;
// Help link ID
var form2_helpHlId;
// Header table ID
var form2_headerId;
// Header label ID
var form2_headerLabelId;
// Back loading functions stack
var form2_backLoadFctStack
// Back URL
var form2_backUrl;
// Current question group panel ID
var form2_panelId;
// Current question group loading function
var form2_loadFct;
// Current question group validation function
var form2_validateFct;
// Directory which contains progress bar images
var form2_progressBarImage;
// Step number
var form2_stepNumber;
// Current step
var form2_currentStep = 1;
// Question number by step
var form2_questionNumberByStep;
// Percent progress bar main parent row
var form2_progressBarPercentParentRowId;
// Percent middle progress bar
var form2_progressBarPercentTblId;
// Current progress bar question number
var form2_progressBarPercentValidedQuestionNumber = 0;
// Current progress bar percent
var form2_progressBarPercentValue = 0.0;
// Wait animation between question
var form2_addWaitAnimation = false;
var form2_inProgressAnimationDuration = 250;
var form2_inProgressAnimationPanelId;
var form2_inProgressThread = new Array();
// Captcha
var form2_hasCaptcha = false;
// Header cell ID
var form2_headerCellId;
// Progressbar main table ID
var form2_progressBarTblId;
// Div Business Data
var form2_businessDataId;
// Pattern Hidden Field ID
var form2_patternHiddenField = "ctl00_ContentPlaceHolder1_hf";
// Quotation Criteria ID
var form2_quotationId;
// Product Type
var form2_productType;
// Partner Link ID
var form2_partnerLinkId;
// Cota Saver ID
var form2_cotaSaverId;
// Find last question to be loaded
var form2_findLastQuestion = (document.location.href.indexOf('&qid=&') > 0);
// Last date of quotation
var form2_lastQuotationDate = "";

// Manage question number
function form2_getQuestionNumberBeforeStep(step) {
    var nb = 0;
    for (var i = 1; i < step; i++) {
        nb += form2_questionNumberByStep[i];
    }
    return nb;
}
function form2_getPreviousQuestionNumber() {
    return form2_backLoadFctStack.length;
}
function form2_updateQuestionNumberByStep() {
    alert("method not implemented");
}
// Manage list
function form2_addList(listId, list) {
    if (form2_list == null)
        form2_list = new Array();
    form2_list['L' + listId] = list; // Force associative array
}
function form2_getList(listId) {
    return form2_list['L' + listId];
}
function form2_initDefaultList() {
    // Boolean
    form2_addList(LBT_LIST_BOOLEAN, [new ListItem(1, "Oui"), new ListItem(0, "Non")]);
    // Day
    var list = new Array();
    for (var i = 1; i <= 31; i++) {
        addToArray(list, new ListItem(i, i));
    }
    form2_addList(CT_LIST_DAY, list);
    // Month
    form2_addList(CT_LIST_MONTH, [new ListItem(1, "Janvier"), new ListItem(2, "Février"), new ListItem(3, "Mars"), new ListItem(4, "Avril"), new ListItem(5, "Mai"), new ListItem(6, "Juin"), new ListItem(7, "Juillet"), new ListItem(8, "Août"), new ListItem(9, "Septembre"), new ListItem(10, "Octobre"), new ListItem(11, "Novembre"), new ListItem(12, "Décembre")]);
}
// Track question
function form2_track(pageId) {
    track(form2_funnelId, pageId);
}
// Alert if b is true and return !b
function form2_alert(b, msg, trackingCode) {
    if (b) {
        if (!form2_findLastQuestion) {
            // Liwio tracking
            lwEvent(al_liwioProduct, 'error', (trackingCode != null ? strReplace(trackingCode, "ctl00_ContentPlaceHolder1_", "") : "Unkown field"));
            // Error message
            alert(msg);
        } else {
            form2_findLastQuestion = false;
        }
    }
    return !b;
}
// Alert if b is true and return !b
function form2_warning(b, msg, trackingCode) {
    if (b) {
        if (!form2_findLastQuestion) {
            // Liwio tracking
            lwEvent(al_liwioProduct, 'warning', (trackingCode != null ? strReplace(trackingCode, "ctl00_ContentPlaceHolder1_", "") : "Unkown field"));
            // Warning message    
            return confirm(msg);
        } else {
            form2_findLastQuestion = false;
        }        
    }
    return true;
}
// Submit form and send data so server
function form2_submit() {
    $get(form2_validateBtnId).click();
}
// Validate current question group
function form2_validate() {
    form2_validateFct();

    // Add if used in onclick event
    return false;
}
// Update progress bar
function form2_updateProgressBar(step) {
    var n = "al_progressBar";
    if (step > 1)
        n = "al_progressBar_" + step;
    if ($get(form2_progressBarPanelId).className != n)
        $get(form2_progressBarPanelId).className = n;
}
function form2_updateProgressBarPercent() {
    // Calculate progress
    var q = form2_getPreviousQuestionNumber() - form2_getQuestionNumberBeforeStep(form2_currentStep);
    var q2 = form2_progressBarPercentValidedQuestionNumber - form2_getQuestionNumberBeforeStep(form2_currentStep);
    var p = q / form2_questionNumberByStep[form2_currentStep];

    var percentByStep = Math.floor(100 / form2_stepNumber);
    var offset = (form2_currentStep - 1) * percentByStep;
    p = Math.ceil(offset + p * percentByStep);
    if (q2 < q) {//ascending
        if (p > form2_progressBarPercentValue)
            form2_progressBarPercentValue = p;
    }
    else {//decreasing
        form2_progressBarPercentValue = p;
    }
    // Update progress bar style
    if (form2_progressBarPercentValue == 0)
        $get(form2_progressBarPercentParentRowId).className = "al_start";
    else if (form2_progressBarPercentValue >= 100.0) {
        $get(form2_progressBarPercentParentRowId).className = "al_end";
        $get(form2_progressBarPercentTblId).style.width = "100%";
    }
    else {
        $get(form2_progressBarPercentParentRowId).className = "al_inprogress";
        $get(form2_progressBarPercentTblId).style.width = form2_progressBarPercentValue + "%"
    }

    // Update
    form2_progressBarPercentValidedQuestionNumber = form2_getPreviousQuestionNumber();
}
function form2_showProgressBar() {
    show(form2_progressBarPanelId);
    showTable(form2_progressBarTblId);
    $get(form2_headerCellId).className = 'al_headerText';
}
function form2_hideProgressBar() {
    hide(form2_progressBarPanelId);
    hideTable(form2_progressBarTblId);
    $get(form2_headerCellId).className = 'al_headerTextNoProgressBar';
}
// Set question label
function form2_setQuestionText(str, lblId) {
    if (lblId == null)
        lblId = form2_questionLabelId;
    str = str.replace(" ?", "&nbsp;?");
    str = str.replace(" :", "&nbsp;:");
    str = trim(str);
    setInnerHtml(lblId, str);
}
// Set question label
function form2_setSubQuestionText(str, lblId) {
    if (lblId == null)
        lblId = form2_subQuestionLabelId;
    if (str != null && str != "")
        str = "<br />" + str;
    else
        str = "";
    str = str.replace(" ?", "&nbsp;?");
    str = str.replace(" :", "&nbsp;:");
    str = trim(str);
    setInnerHtml(lblId, str);
}
// Get question label
function form2_getQuestionText() {
    return trim($get(form2_questionLabelId).innerHTML.replace("&nbsp;", " "));
}
// Show current question group panel ID
function form2_showQuestion(panelId) {
    if (form2_panelId != panelId) {
        hide(form2_panelId);
        form2_panelId = panelId;
        show(form2_panelId);
    } else if ($get(form2_panelId).style.display == "none") {
        show(form2_panelId);
    }
}
// Hide and disable help
function form2_disableHelp(helpCellId) {
    if (helpCellId == null)
        helpCellId = form2_helpCellId;
    hideCell(helpCellId);
}
// Show and configure help
function form2_enableHelp(helpElementId, helpHlId, helpCellId) {
    if (helpHlId == null)
        helpHlId = form2_helpHlId;
    helpLink_changeHelpElementId(helpHlId, "", helpElementId);
    if (helpCellId == null)
        helpCellId = form2_helpCellId;
    showCell(helpCellId);
}
// Enable/Disable back button
function form2_disableBack() {
    $get(form2_backBtnId).className = "al_disabled"
}
function form2_disableBackClick() {
    form2_disableBack();
    $get(form2_backBtnId).onclick = null;
}
function form2_enableBack() {
    $get(form2_backBtnId).className = "al_enabled"
}
function form2_enableBackClick() {
    form2_enableBack();
    $get(form2_backBtnId).onclick = form2_goBack;
}
// Enable/Disable next button
function form2_disableNext() {
    $get(form2_nextBtnId).className = "al_disabled"
}
function form2_disableNextClick() {
    form2_disableNext();
    $get(form2_nextBtnId).onclick = null;
}
// Show and configure back button
function form2_enableNext() {
    $get(form2_nextBtnId).className = "al_enabled"
}
function form2_enableNextClick() {
    form2_enableNext();
    $get(form2_nextBtnId).onclick = form2_validate;
}
// Show back/next button
function form2_enableNavigation() {
    form2_enableBackClick();
    form2_enableNextClick();
}
// Hhide navigation
function form2_disableNavigation() {
    form2_disableBackClick();
    form2_disableNextClick();
}
// Update back
function form2_updateBack() {
    if (form2_backLoadFctStack.length == 0 && form2_backUrl == "")
        form2_disableBack();
    else
        form2_enableBack();
}
// Go back
function form2_goBack() {
    // Get back function from stack and go back
    if (form2_backLoadFctStack.length > 0) {
        // Liwio tracking
        lwEvent(al_liwioProduct, form2_getQuestionText(), 'clic.retour');

        // Hide current question panel
        hide(form2_panelId);

        // Unload controls, if required, will be done in next loading function
        // Load back
        form2_loadFct = form2_backLoadFctStack.pop();
        form2_loadFct();
    }
    else {
        if (form2_backUrl != "")
            goToURL(form2_backUrl + "?b=1")
    }
    // Update back button state
    form2_updateBack();

    // Add if used in onclick event
    return false;
}
// Go next question group
function form2_goNext(nextLoadFct, enableBackLoadFct) {
    if (typeof enableBackLoadFct == "undefined")
        enableBackLoadFct = true;
    if(enableBackLoadFct){
        // Update back load function stack
        form2_backLoadFctStack.push(form2_loadFct);
    }
    
    // Unload controls, if required, will be done in next loading function
    // Load next
    form2_loadFct = nextLoadFct;
    
    // Reset all loading's threads
    form2_inProgressThread = new Array();
    if (form2_idPeriodicalExecuter) {
        clearTimeout(form2_idPeriodicalExecuter);
    }
    
    if (form2_addWaitAnimation) {
        form2_waitAndLoad(enableBackLoadFct);
    } else {
        form2_loadFct();
        // Update back button state
        form2_updateBack();
    }
}
// form2_goNext
function form2_waitAndLoad(enableBackLoadFct) {
    // Hide current question panel
    hide(form2_panelId);
    // Disable navigation
    form2_disableNavigation();
    // Start loading
    if (enableBackLoadFct)
        form2_startInProgressWait('form2_waitAndLoad');
    // Load next function
    form2_loadFct();
    // Stop loading after N ms
    if(enableBackLoadFct)
        setTimeout("form2_stopInProgressWait('form2_waitAndLoad');", form2_inProgressAnimationDuration);
}
// Update form
var form2_idPeriodicalExecuter = null;
function form2_update(qPanelId, validateFct, qLabel, helpElementId, step, trackPageId, qSubLabel, onCompletedFct) {
    var form2_fct = function() {
        if (form2_idPeriodicalExecuter)
            clearTimeout(form2_idPeriodicalExecuter);
        if (form2_inProgressThread.length == 0) {
            form2_updateComplete(qPanelId, validateFct, qLabel, helpElementId, step, trackPageId, qSubLabel, onCompletedFct);
        } else {
            form2_idPeriodicalExecuter = setTimeout(form2_fct, 100);
        }
    }
    form2_fct();
}
// Update form when all is completed or loaded
function form2_updateComplete(qPanelId, validateFct, qLabel, helpElementId, step, trackPageId, qSubLabel, onCompletedFct) {
    if (form2_findLastQuestion) {
        // Update question label
        form2_setQuestionText('Chargement en cours...');
        form2_setSubQuestionText('');
        form2_disableHelp();
        // Track page
        if (trackPageId != null)
            form2_track(trackPageId);
        // Liwio tracking
        if (form2_backLoadFctStack.length > 0)
            lwTpvUrl(form2_getQuestionText());
        // Auto validate
        validateFct();
        // Stop loading if last question has been found
        if (form2_findLastQuestion) {
            return;
        } else if (form2_backLoadFctStack.length > 0) {
            // Hide header
            hide(form2_headerDivId);
            // Hide footer
            hide(form2_footerTableId);
            // Show cota saver
            show(form2_cotaSaverId);
            // Hide template links and content
            if (typeof assurland_setActiveLink == 'function')
                assurland_setActiveLink(false);
        }
    }
    // Update question label
    form2_setQuestionText(qLabel);
    form2_setSubQuestionText(qSubLabel);
    // Update help
    if (helpElementId != null)
        form2_enableHelp(helpElementId);
    else
        form2_disableHelp();

    // Manage progress bar
    form2_updateQuestionNumberByStep();
    if (step != null && step != form2_currentStep) {
        // Autosave if step has increased (Cota Saver)
        if (step > form2_currentStep)
            form2_updateQuotation();
        form2_currentStep = step;
        form2_updateProgressBar(step);
    } else if ((form2_backLoadFctStack.length > 0 ) && (form2_backLoadFctStack.length % 10) == 0) {
        // Autosave all 10 questions (Cota Saver)
        form2_updateQuotation();
    }
    form2_updateProgressBarPercent();

    // Hide loading
    hide(form2_inProgressAnimationPanelId);

    // Show question panel
    form2_validateFct = validateFct;
    form2_showQuestion(qPanelId);
    
    // Enable navigation
    form2_enableNavigation();
    form2_updateBack();

    // Track page
    if (trackPageId != null)
        form2_track(trackPageId);

    // Liwio tracking
    if (form2_backLoadFctStack.length > 0)
        lwTpvUrlBase(form2_getQuestionText());

    // Callback function after loading
    if (typeof onCompletedFct == 'function') {
        onCompletedFct();
    }
}
// Add wait progress thread animation
function form2_startInProgressWait(idThread) {
    // Add current running thread
    for (var i = 0; i < form2_inProgressThread.length; i++) {
        if (form2_inProgressThread[i] == idThread) {
            return;
        }
    }
    form2_inProgressThread.push(idThread);
    
    // Show loading
    if (form2_inProgressThread.length == 1) {
        show(form2_inProgressAnimationPanelId);
    }
}
// Remove wait progress thread animation
function form2_stopInProgressWait(idThread) {
    // Set new current running threads
    var currentThread = new Array();
    for (var i = 0; i < form2_inProgressThread.length; i++) {
        if (form2_inProgressThread[i] != idThread) {
            currentThread.push(form2_inProgressThread[i]);
        }
    }
    form2_inProgressThread = currentThread;
}
// Init first load
function form2_init(loadFct, stackLoadFct) {
    // Init table with question number by step
    form2_questionNumberByStep = new Array();
    // Build default list
    form2_initDefaultList();
    // Update stack
    if (stackLoadFct != null)
        form2_backLoadFctStack = stackLoadFct;
    else
        form2_backLoadFctStack = new Array();
    // Update back button state
    form2_updateBack();
    // Load current
    form2_loadFct = loadFct;
    form2_loadFct();
}

////////////////////////////////////////
// Form element additional properties
////////////////////////////////////////

// Default list
var LBT_LIST_BOOLEAN = 0;
// Repeat direction
var LBT_RD_H = 0;
var LBT_RD_V = 1;
// Text align
var LBT_TA_C = 0;
var LBT_TA_L = 1;
var LBT_TA_R = 2;
// Design
var LBT_DESIGN_1 = 1; // Simple texte
var LBT_DESIGN_2 = 2; // 2 columns with background and rollover
var LBT_DESIGN_3 = 3; // Calendar
var LBT_DESIGN_4 = 4; // 3 columns with background and rollover
var LBT_DESIGN_5 = 5; // 2 larges columns with background and rollover
var LBT_DESIGN_6 = 6; // 2 high columns with background and rollover
var LBT_DESIGN_7 = 7; // 4 very high columns with background and rollover (vie only ?)
var LBT_DESIGN_8 = 8; // 4 high columns with background and rollover

function ListBoxTableProperties(ucId, parentUcId, pnlId, tblId, hfId, repeatColumn, repeatDirection, textAlign, fctClick) {
    this.ucId = ucId;
    this.parentUcId = parentUcId;
    this.pnlId = pnlId;
    this.tblId = tblId;
    this.hfId = hfId;
    this.repeatColumn = repeatColumn;
    this.repeatDirection = repeatDirection;
    this.textAlign = textAlign;
    this.fctClick = fctClick;

    // Client-side member
    // Please move to server-side if required
    this.itemDirection = LBT_RD_V;
    this.textOnly = true;
    this.className = "al_listBoxTable1";
    this.itemClassName = null;
    this.itemImageVisible = true;
    this.unit = null;
    this.trackingCode = null;
    this.mainLoad = true;
}
ListBoxTableProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'parentUcId = ' + this.parentUcId + '\n';
        str = str + 'pnlId = ' + this.pnlId + '\n';
        str = str + 'tblId = ' + this.tblId + '\n';
        str = str + 'hfId = ' + this.hfId + '\n';
        str = str + 'repeatColumn = ' + this.repeatColumn + '\n';
        str = str + 'repeatDirection = ' + this.repeatDirection + '\n';
        str = str + 'textAlign = ' + this.textAlign + '\n';
        str = str + 'itemDirection = ' + this.itemDirection + '\n';
        str = str + 'textOnly = ' + this.textOnly + '\n';
        str = str + 'className = ' + this.className + '\n';
        str = str + 'itemClassName = ' + this.itemClassName + '\n';
        str = str + 'unit = ' + this.unit + '\n';
        str = str + 'trackingCode = ' + this.trackingCode + '\n';
        return str;
    }
}

// Selection mode
var CT_MODE_MY = 0;
var CT_MODE_DMY = 1;

// Default list ID
var CT_LIST_DAY = 1;
var CT_LIST_MONTH = 2;

function CalendarTableProperties(ucId, mode, tblId, dayUcId, monthUcId, yearUcId, fctClick) {
    this.ucId = ucId;
    this.mode = mode;
    this.tblId = tblId;
    this.dayUcId = dayUcId;
    this.monthUcId = monthUcId;
    this.yearUcId = yearUcId;
    this.fctClick = fctClick;

    // Client-side member
    // Please move to server-side if required
    this.yearTensInBold = false;
    this.trackingCode = null;
}
CalendarTableProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'mode = ' + this.mode + '\n';
        str = str + 'tblId = ' + this.tblId + '\n';
        str = str + 'dayUcId = ' + this.dayUcId + '\n';
        str = str + 'monthUcId = ' + this.monthUcId + '\n';
        str = str + 'yearUcId = ' + this.yearUcId + '\n';
        str = str + 'yearTensInBold = ' + this.yearTensInBold + '\n';
        str = str + 'trackingCode = ' + this.trackingCode + '\n';
        return str;
    }
}

function Form2_ZipCodeTextBoxProperties(ucId, tbId, ddlId, btnId, lblId, fctClick) {
    this.ucId = ucId;
    this.tbId = tbId;
    this.ddlId = ddlId;
    this.btnId = btnId;
    this.lblId = lblId;
    this.fctClick = fctClick;

    // Client-side member
    // Please move to server-side if required
    this.trackingCode = null;
}
Form2_ZipCodeTextBoxProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'tbId = ' + this.tbId + '\n';
        str = str + 'ddlId = ' + this.ddlId + '\n';
        str = str + 'btnId = ' + this.btnId + '\n';
        str = str + 'lblId = ' + this.lblId + '\n';
        str = str + 'trackingCode = ' + this.trackingCode + '\n';
        return str;
    }
}

function Form2_TextBoxWrapperProperties(ucId, tbId, btnId, lblId, lblUnitId, contentType, fctClick) {
    this.ucId = ucId;
    this.tbId = tbId;
    this.btnId = btnId;
    this.lblId = lblId;
    this.lblUnitId = lblUnitId;
    this.contentType = contentType;
    this.fctClick = fctClick;

    // Client-side member
    // Please move to server-side if required
    this.defaultText = null;
    this.currentValueIsDefaultText = false;
    this.trackingCode = null;
}
Form2_TextBoxWrapperProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'tbId = ' + this.tbId + '\n';
        str = str + 'btnId = ' + this.btnId + '\n';
        str = str + 'lblId = ' + this.lblId + '\n';
        str = str + 'lblUnitId = ' + this.lblUnitId + '\n';
        str = str + 'contentType = ' + this.contentType + '\n';
        str = str + 'defaultText = ' + this.defaultText + '\n';
        str = str + 'currentValueIsDefaultText = ' + this.currentValueIsDefaultText + '\n';
        str = str + 'trackingCode = ' + this.trackingCode + '\n';
        return str;
    }
}

function Form2_DropDownListWrapperProperties(ucId, ddlId, btnId, lblId, lblUnitId, fctClick) {
    this.ucId = ucId;
    this.ddlId = ddlId;
    this.btnId = btnId;
    this.lblId = lblId;
    this.lblUnitId = lblUnitId;
    this.fctClick = fctClick;

    // Client-side member
    // Please move to server-side if required
    this.autoValidation = true;
    this.trackingCode = null;
}
Form2_DropDownListWrapperProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'ddlId = ' + this.ddlId + '\n';
        str = str + 'btnId = ' + this.btnId + '\n';
        str = str + 'lblId = ' + this.lblId + '\n';
        str = str + 'lblUnitId = ' + this.lblUnitId + '\n';
        str = str + 'trackingCode = ' + this.trackingCode + '\n';
        return str;
    }
}

function Form2_DateDropDownListProperties(ucId, mode, ddlDayId, ddlMonthId, ddlYearId, btnId, lblId, fctClick) {
    this.ucId = ucId;
    this.mode = mode;
    this.ddlDayId = ddlDayId;
    this.ddlMonthId = ddlMonthId;
    this.ddlYearId = ddlYearId;
    this.btnId = btnId;
    this.lblId = lblId;
    this.fctClick = fctClick;

    // Client-side member
    // Please move to server-side if required
    this.trackingCode = null;
}
Form2_DateDropDownListProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'ddlDayId = ' + this.ddlDayId + '\n';
        str = str + 'ddlMonthId = ' + this.ddlMonthId + '\n';
        str = str + 'ddlYearId = ' + this.ddlYearId + '\n';
        str = str + 'btnId = ' + this.btnId + '\n';
        str = str + 'lblId = ' + this.lblId + '\n';
        str = str + 'trackingCode = ' + this.trackingCode + '\n';
        return str;
    }
}

function YearMonthDurationTableProperties(ucId, tblId, monthUcId, yearUcId, fctClick) {
    this.ucId = ucId;
    this.tblId = tblId;
    this.monthUcId = monthUcId;
    this.yearUcId = yearUcId;
    this.fctClick = fctClick;

    // Client-side member
    // Please move to server-side if required
    this.trackingCode = null;
}
YearMonthDurationTableProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'tblId = ' + this.tblId + '\n';
        str = str + 'monthUcId = ' + this.monthUcId + '\n';
        str = str + 'yearUcId = ' + this.yearUcId + '\n';
        str = str + 'trackingCode = ' + this.trackingCode + '\n';
        return str;
    }
}

// Design
var FORM2_CONTAINER_DESIGN_0 = 0; // No cells
var FORM2_CONTAINER_DESIGN_1 = 1; // All cells
var FORM2_CONTAINER_DESIGN_2 = 2; // Top
var FORM2_CONTAINER_DESIGN_3 = 3; // Bottom
var FORM2_CONTAINER_DESIGN_4 = 4; // Right
var FORM2_CONTAINER_DESIGN_5 = 5; // Bottom + Right
var FORM2_CONTAINER_DESIGN_6 = 6; // Left
var FORM2_CONTAINER_DESIGN_7 = 7; // Top Bottom

function Form2_FormControlContainerProperties(ucId, pnlId, tblId, lblTopId, lblBottomId, lblLeftId, tblQuestionBarId, lblQuestionBarId, hlQuestionBarHelpId, cellQuestionBarHelpId, childUcId) {
    this.ucId = ucId;
    this.pnlId = pnlId;
    this.tblId = tblId;
    this.lblTopId = lblTopId;
    this.lblBottomId = lblBottomId;
    this.lblLeftId = lblLeftId;
    this.tblQuestionBarId = tblQuestionBarId;
    this.lblQuestionBarId = lblQuestionBarId;
    this.hlQuestionBarHelpId = hlQuestionBarHelpId;
    this.cellQuestionBarHelpId = cellQuestionBarHelpId;
    this.childUcId = childUcId;
}
Form2_FormControlContainerProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'pnlId = ' + this.pnlId + '\n';
        str = str + 'tblId = ' + this.tblId + '\n';
        str = str + 'lblTopId = ' + this.lblTopId + '\n';
        str = str + 'lblBottomId = ' + this.lblBottomId + '\n';
        str = str + 'tblQuestionBarId = ' + this.tblQuestionBarId + '\n';
        str = str + 'lblQuestionBarId = ' + this.lblQuestionBarId + '\n';
        str = str + 'hlQuestionBarHelpId = ' + this.hlQuestionBarHelpId + '\n';
        str = str + 'cellQuestionBarHelpId = ' + this.cellQuestionBarHelpId + '\n';
        str = str + 'childUcId = ' + this.childUcId + '\n';
        return str;
    }
}

function Form2_FormControlCollectionContainerProperties(ucId, pnlId, childUcIds) {
    this.ucId = ucId;
    this.pnlId = pnlId;
    this.childUcIds = childUcIds;
    if (this.childUcIds == null)
        this.childUcIds = new Array();

    // Client-side member
    // Please move to server-side if required
    this.itemNumber = this.childUcIds.length;
}
Form2_FormControlCollectionContainerProperties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'pnlId = ' + this.pnlId + '\n';
        return str;
    }
}

function CalendarTable2Properties(ucId, dayUcId, monthHfId, yearDdlId, labelMonthTbcId, fctClick) {
    this.ucId = ucId;
    this.dayUcId = dayUcId;
    this.monthHfId = monthHfId;
    this.yearDdlId = yearDdlId;
    this.labelMonthTbcId = labelMonthTbcId;
    this.fctClick = fctClick;

    // Client-side member
    // Please move to server-side if required
    this.yearTensInBold = false;
    this.trackingCode = null;
}
CalendarTable2Properties.prototype =
{
    toString: function() {
        var str = "";
        str = str + 'ucId = ' + this.ucId + '\n';
        str = str + 'dayUcId = ' + this.dayUcId + '\n';
        str = str + 'monthHfId = ' + this.monthHfId + '\n';
        str = str + 'yearDdlId = ' + this.yearDdlId + '\n';
        str = str + 'yearTensInBold = ' + this.yearTensInBold + '\n';
        str = str + 'trackingCode = ' + this.trackingCode + '\n';
        return str;
    }
}


////////////////////////////////////////
// Form element handler
////////////////////////////////////////

var listBoxTable_ajaxInProgress = false;
var listBoxTable_ajaxInProgressVisible = false;
var listBoxTable_cells;

function listBoxTable_cellsMgrAdd(id, ucId, value) {
    if (listBoxTable_cells == null)
        listBoxTable_cells = new Array();
    listBoxTable_cells[id] = ({ "ucId": ucId, "v": value });
}
function listBoxTable_cellsMgrGetProperties(id) {
    return listBoxTable_cells[id];
}
function listBoxTable_getInt(ucId) {
    return getInt(listBoxTable_getValue(ucId));
}
function listBoxTable_getValue(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        return $get(prop.hfId).value;
    }
}
function listBoxTable_setValue(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Clear selection
        listBoxTable_clearSelection(ucId);
        // TODO : check if value exist ? 
        // Temporary implemented in render method
        // Update value
        if (value != null)
            $get(prop.hfId).value = value;
        else
            $get(prop.hfId).value = "";
    }
}
function listBoxTable_saveValue(ucId, hfId) {
    $get(hfId).value = listBoxTable_getValue(ucId);
}
function listBoxTable_clearSelection(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update other cell style
        if ($get(prop.tblId) != null) {
            /*var cells = $get(prop.tblId).getElementsByTagName("td");
            for (var i = 0; i < cells.length; i++) {
            cells[i].className = "";
            }*/
            if ($get(prop.tblId).hasChildNodes()) {
                var rows = null;
                var cells = null;
                // tbody
                if ($get(prop.tblId).firstChild.hasChildNodes()) {
                    // tr
                    rows = $get(prop.tblId).firstChild.childNodes
                    for (var i = 0; i < rows.length; i++) {
                        if (rows[i].hasChildNodes()) {
                            // td
                            cells = rows[i].childNodes;
                            for (var j = 0; j < cells.length; j++) {
                                cells[j].className = "";
                            }
                        }
                    }
                }
            }
        }
    }
}
function listBoxTable_setTopClassName(ucId, className) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        $get(prop.pnlId).className = className;
    }
}
function listBoxTable_setRepeatColumn(ucId, repeatColumn) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        prop.repeatColumn = repeatColumn;
    }
}
function listBoxTable_onClick(cell) {
    // Get properties from cell
    var cp = listBoxTable_cellsMgrGetProperties(cell.id);
    if (cp != null) {
        var ucId = cp.ucId;
        var value = cp.v;
        var prop = form_eltPropertiesObjArray[ucId];
        if (prop != null) {
            // Clear selection
            listBoxTable_clearSelection(ucId);
            // Update value
            $get(prop.hfId).value = value;
            cell.className = "al_selected";
            // Do action if required
            if (prop.fctClick != null)
                if (prop.parentUcId != null)
                prop.fctClick(prop.parentUcId, ucId);
            else
                prop.fctClick(ucId);
        }
    }
}
function listBoxTable_onMouseOver(cell) {
    // Get properties from cell
    var cp = listBoxTable_cellsMgrGetProperties(cell.id);
    if (cp != null) {
        var ucId = cp.ucId;
        var value = cp.v;
        var prop = form_eltPropertiesObjArray[ucId];
        if (prop != null) {
            if (value == listBoxTable_getValue(ucId)) {
                cell.className = "al_selectedOver";
            }
            else {
                cell.className = "al_over";
            }
        }
    }
}
function listBoxTable_onMouseOut(cell) {
    // Get properties from cell
    var cp = listBoxTable_cellsMgrGetProperties(cell.id);
    if (cp != null) {
        var ucId = cp.ucId;
        var value = cp.v;
        var prop = form_eltPropertiesObjArray[ucId];
        if (prop != null) {
            if (value == listBoxTable_getValue(ucId)) {
                cell.className = "al_selected";
            }
            else {
                cell.className = "";
            }
        }
    }
}
function listBoxTable_validate(ucId, msg) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (listBoxTable_getValue(ucId) == "") {
            if (msg != null) form2_alert(true, msg, (prop.trackingCode != null ? prop.trackingCode : prop.hfId)); //alert(msg);
            return false;
        }
    }
    return true;
}
function listBoxTable_updateDesign(ucId, designId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (designId == LBT_DESIGN_1) {
            prop.repeatColumn = 0;
            prop.textAlign = LBT_TA_L;
            prop.textOnly = true;
            prop.className = "al_listBoxTable1";
            prop.itemDirection = LBT_RD_V;
        }
        else if (designId == LBT_DESIGN_2) {
            prop.repeatColumn = 2;
            prop.textAlign = LBT_TA_C;
            prop.textOnly = false;
            prop.className = "al_listBoxTable2";
            prop.itemDirection = LBT_RD_V;
        }
        else if (designId == LBT_DESIGN_3) {
            prop.repeatColumn = 6;
            prop.textAlign = LBT_TA_C;
            prop.textOnly = false;
            prop.className = "al_listBoxTable3";
            prop.itemDirection = LBT_RD_V;
        }
        else if (designId == LBT_DESIGN_4) {
            prop.repeatColumn = 3;
            prop.textAlign = LBT_TA_C;
            prop.textOnly = false;
            prop.className = "al_listBoxTable4";
            prop.itemDirection = LBT_RD_V;
        }
        else if (designId == LBT_DESIGN_5) {
            prop.repeatColumn = 2;
            prop.textAlign = LBT_TA_C;
            prop.textOnly = false;
            prop.className = "al_listBoxTable5";
            prop.itemDirection = LBT_RD_H;
        }
        else if (designId == LBT_DESIGN_6) {
            prop.repeatColumn = 2;
            prop.textAlign = LBT_TA_C;
            prop.textOnly = false;
            prop.className = "al_listBoxTable6";
            prop.itemDirection = LBT_RD_V;
        }
        else if (designId == LBT_DESIGN_7) {
            prop.repeatColumn = 4;
            prop.textAlign = LBT_TA_L;
            prop.textOnly = false;
            prop.className = "al_listBoxTable7";
            prop.itemDirection = LBT_RD_V;
        }
        else if (designId == LBT_DESIGN_8) {
            prop.repeatColumn = 4;
            prop.textAlign = LBT_TA_C;
            prop.textOnly = false;
            prop.className = "al_listBoxTable8";
            prop.itemDirection = LBT_RD_V;
        }
    }
}
function listBoxTable_update(ucId, currentValue, fctClick, list, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update properties
        if ($get(currentValue) != null) {
            listBoxTable_setValue(ucId, $get(currentValue).value);
            prop.trackingCode = currentValue;
        }
        else {
            listBoxTable_setValue(ucId, currentValue);
            prop.trackingCode = null;
        }
        //if (fctClick != null)
        prop.fctClick = fctClick;

        var listSave = false;
        if (options != null) {
            if (typeof options.design != "undefined")
                listBoxTable_updateDesign(ucId, options.design);
            if (typeof options.repeatDirection != "undefined")
                prop.repeatDirection = options.repeatDirection;
            if (typeof options.repeatColumn != "undefined")
                prop.repeatColumn = options.repeatColumn;
            if (typeof options.textAlign != "undefined")
                prop.textAlign = options.textAlign;
            if (typeof options.textOnly != "undefined")
                prop.textOnly = options.textOnly;
            if (typeof options.unit != "undefined")
                prop.unit = options.unit;
            if (typeof options.className != "undefined")
                prop.className = options.className;
            if (typeof options.itemClassName != "undefined")
                prop.itemClassName = options.itemClassName;
            if (typeof options.itemImageVisible != "undefined")
                prop.itemImageVisible = options.itemImageVisible;
            if (typeof options.itemDirection != "undefined")
                prop.itemDirection = options.itemDirection;
            if (typeof options.topClassName != "undefined")
                listBoxTable_setTopClassName(ucId, options.topClassName);
            if (typeof options.mainLoad != "undefined")
                prop.mainLoad = options.mainLoad;
        }
        // Get list if required
        if (typeof list == 'number' || typeof list == 'function') {
            var ajax = false;
            var ajaxFct = null;
            if (typeof list == 'number') {
                // This is an ID
                prop.className += " al_listBoxTable_" + list;
                if (prop.itemClassName == null)
                    prop.itemClassName = "al_listItem_" + list;
                // Get list    
                var list2 = form2_getList(list);
                if (list2) {
                    // Fetch list on client
                    listBoxTable_render(ucId, list2);
                } else {
                    // Fetch list on server
                    //alert("ajax:" + list);
                    ajax = true;
                    listSave = true;
                    ajaxFct = function(successCallback, failedCallback) {
                        AssurlandWeb.WebRessourcesAccess.GetFormDataList(list, successCallback, failedCallback);
                    }
                }
            } else if (typeof list == 'function') {
                ajax = true;
                ajaxFct = list; // /!\ list function must have next signature : function(successCallback, failedCallback)
            }

            if (ajax) {
                if (prop.mainLoad) {
                    // Start loading
                    form2_startInProgressWait('listBoxTable_update');
                } else {
                    listBoxTable_ajaxInProgress = true;
                    // Add loading animation
                    setTimeout("if(listBoxTable_ajaxInProgress) {listBoxTable_ajaxInProgressVisible = true;replaceHtml('" + prop.pnlId + "', \"<div class=\'al_loading\'></div>\")};", 100);
                }
                // Fetch list on server
                var listBoxTable_fillCallback = function(result, eventArgs) {
                    if (typeof list == 'number' && listSave)
                        form2_addList(list, result);
                    listBoxTable_render(ucId, result);
                    if (prop.mainLoad) {
                        form2_stopInProgressWait('listBoxTable_update');
                    } else {
                        listBoxTable_ajaxInProgress = false;
                        listBoxTable_ajaxInProgressVisible = false;
                    }
                }
                // This is the callback function invoked if the Web service failed.
                var listBoxTable_fillFailedCallback = function(error) {
                    if (prop.mainLoad) {
                        form2_stopInProgressWait('listBoxTable_update');
                    } else {
                        listBoxTable_ajaxInProgress = false;
                        listBoxTable_ajaxInProgressVisible = false;
                    }
                    displayAspNetFrameworkError("AssurlandWeb.WebRessourcesAccess.GetFormDataList failed", error);
                    // TODO : redirection page d'erreur ?
                }
                // Call function
                ajaxFct(listBoxTable_fillCallback, listBoxTable_fillFailedCallback);
            }
        } else {
            // This a list
            // Render control
            listBoxTable_render(ucId, list);
        }
    }
}
function listBoxTable_reset(ucId, currentValue, fctClick, list, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.design == "undefined")
        options.design = LBT_DESIGN_1;
    if (typeof options.itemClassName == "undefined")
        options.itemClassName = null;
    if (typeof options.itemImageVisible == "undefined")
        options.itemImageVisible = true;
    if (typeof options.repeatDirection == "undefined")
        options.repeatDirection = LBT_RD_V;
    if (typeof options.unit == "undefined")
        options.unit = null;
    if (typeof options.topClassName == "undefined")
        options.topClassName = null;
    // Other options are included in design default value update function

    // Update control
    listBoxTable_update(ucId, currentValue, fctClick, list, options);
}
function listBoxTable_render(ucId, list) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {

        if (typeof list == "number") {
            // Get list from list collection
            list = form2_getList(list);
        }

        var currentValue = listBoxTable_getValue(ucId);
        var currentValueFound = false;

        // Build table
        var id;
        var nbCellsByRow = Math.min((prop.repeatColumn <= 0 ? 1 : prop.repeatColumn), list.length);
        var nbRowsByTable = Math.ceil(list.length / nbCellsByRow);
        var cellSizePercent = 100 / nbCellsByRow + '%';
        var nbCellsInCurrentRow = 0;
        var nbRowsInCurrentTable = 0;
        var nbCellsInCurrentTable = 0;

        var txtAlign = ""
        switch (prop.textAlign) {
            case LBT_TA_L: txtAlign = "left"; break;
            case LBT_TA_R: txtAlign = "right"; break;
            default: txtAlign = "center"; break;
        }
        var className = "al_listBoxTable";
        if (prop.className != null)
            className += " " + prop.className;

        // Start table
        // /!\ Generate HTML and use innerHTML property has been prefered
        // to DOM object implementation for performance reason (IE ...)
        var strBuilder = new Sys.StringBuilder("<table id=\"" + prop.tblId + "\" style=\"text-align:" + txtAlign + "\" class=\"" + className + "\">");

        // Build table content
        var i = 0;
        while (i < list.length && nbCellsInCurrentTable < list.length) {

            if (getStr(list[i].Value) == currentValue) {
                currentValueFound = true;
            }

            if (nbRowsInCurrentTable == 0 || nbCellsInCurrentRow == nbCellsByRow) {
                // Add row
                if (nbRowsInCurrentTable > 0)
                    strBuilder.append("</tr>");
                strBuilder.append("<tr>");
                nbCellsInCurrentRow = 0;
                nbRowsInCurrentTable += 1;
            }

            // Add cell
            nbCellsInCurrentTable++;
            nbCellsInCurrentRow++;

            id = prop.tblId + "_ct" + i;
            strBuilder.append("<td id=\"" + id + "\" style=\"width:" + cellSizePercent + "\" class=\"" + (getStr(list[i].Value) == currentValue ? "al_selected" : "") + "\" onclick=\"listBoxTable_onClick(this);\" onmouseover=\"listBoxTable_onMouseOver(this);\" onmouseout=\"listBoxTable_onMouseOut(this);\">");

            if (prop.textOnly) {
                strBuilder.append("<span class=\"" + (prop.itemClassName != null ? prop.itemClassName + "_" + list[i].Value : "") + "\">" + list[i].Text + (prop.unit != null ? " " + prop.unit : "") + "</span>");
            }
            else {
                strBuilder.append("<div class=\"al_listItem" + (prop.itemClassName != null ? " " + prop.itemClassName + " " + prop.itemClassName + "_" + list[i].Value : "") + "\">");
                strBuilder.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"al_text\">" + list[i].Text + (prop.unit != null ? " " + prop.unit : "") + "</td>");
                if (prop.itemImageVisible) {
                    if (prop.itemDirection == LBT_RD_V)
                        strBuilder.append("</tr><tr>");
                    strBuilder.append("<td class=\"al_img\">");
                    if (typeof list[i].ImageUrl != "undefined" && list[i].ImageUrl != null)
                        strBuilder.append("<img src=\"" + list[i].ImageUrl + "\" />");
                    else
                        strBuilder.append("<img src=\"/Images2/px.gif\" />");
                    strBuilder.append("</td>");
                }
                strBuilder.append("</tr></table></div>");
            }
            strBuilder.append("</td>");

            listBoxTable_cellsMgrAdd(id, ucId, getStr(list[i].Value));

            // Next item index
            if (prop.repeatDirection == 1) {
                // Vertical
                if (nbCellsInCurrentRow == nbCellsByRow && nbRowsInCurrentTable < nbRowsByTable)
                    i = nbRowsInCurrentTable;
                else
                    if (((nbRowsByTable - 1) * nbCellsByRow + nbCellsInCurrentRow) <= list.length)
                    i += nbRowsByTable;
                else
                    i += (nbRowsByTable - 1);
            } else {
                // Horizontal
                i += 1;
            }
        }
        // Complete table
        for (i = nbCellsInCurrentRow; i < nbCellsByRow; i++) {
            strBuilder.append("<td style=\"width:" + cellSizePercent + "\"></td>");
        }
        // Close table
        if (nbRowsInCurrentTable > 0)
            strBuilder.append("</tr>");
        strBuilder.append("</table>");

        // Replace table in document
        // replaceHtml() has been prefered to innerHtml for performance reason
        replaceHtml(prop.pnlId, strBuilder.toString());

        // Current value not found ?
        if (!currentValueFound) {
            listBoxTable_setValue(ucId, "");
        }
    }
}

function calendarTable_getDate(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.mode == 0)
            return getValidDate(1, listBoxTable_getValue(prop.monthUcId), listBoxTable_getValue(prop.yearUcId))
        else
            return getValidDate(listBoxTable_getValue(prop.dayUcId), listBoxTable_getValue(prop.monthUcId), listBoxTable_getValue(prop.yearUcId))
    }
}
function calendarTable_getValue(ucId) {
    return getDateStringByFormat(calendarTable_getDate(ucId), "dd/MM/yyyy");
}
function calendarTable_setValue(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (value != null && value != "") {
            var d = getDateByFormat(value, "dd/MM/yyyy");
            if (prop.mode == 0)
                listBoxTable_setValue(prop.dayUcId, 1);
            else
                listBoxTable_setValue(prop.dayUcId, d.getDate());
            listBoxTable_setValue(prop.monthUcId, d.getMonth() + 1);
            listBoxTable_setValue(prop.yearUcId, d.getFullYear());
        } else {
            listBoxTable_setValue(prop.dayUcId, null);
            listBoxTable_setValue(prop.monthUcId, null);
            listBoxTable_setValue(prop.yearUcId, null);
        }
    }
}
function calendarTable_saveValue(ucId, hfId) {
    $get(hfId).value = calendarTable_getValue(ucId);
}
function calendarTable_onClick(ucId, ucId2) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        var bFull = false;

        if (prop.mode == 0)
            bFull = (listBoxTable_getValue(prop.monthUcId) != "" && listBoxTable_getValue(prop.yearUcId) != "");
        else
            bFull = (listBoxTable_getValue(prop.dayUcId) != "" && listBoxTable_getValue(prop.monthUcId) != "" && listBoxTable_getValue(prop.yearUcId) != "");

        // Do action if required
        if (bFull && ucId2 == prop.yearUcId && prop.fctClick != null)
            prop.fctClick(ucId);
    }
}
function calendarTable_validate(ucId, msg, msg2) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if ((prop.mode == 1 && !listBoxTable_validate(prop.dayUcId))
            || !listBoxTable_validate(prop.monthUcId)
            || !listBoxTable_validate(prop.yearUcId)) {
            if (msg != null) form2_alert(true, msg, prop.trackingCode); //alert(msg);
            return false;
        }
        if (msg2 == null) msg2 = "La date n'est pas valide."
        return calendarTable_validateDate(ucId, msg2);
    }
    return true;
}
function calendarTable_validateDate(ucId, msg) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (calendarTable_getDate(ucId) == null) {
            if (msg != null) form2_alert(true, msg, prop.trackingCode); //alert(msg);
            return false;
        }
    }
    return true;
}
function calendarTable_update(ucId, currentValue, fctClick, minYear, maxYear, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update properties
        if (fctClick != null)
            prop.fctClick = fctClick;

        var order = 1;
        if (options) {
            if (typeof options.mode != "undefined")
                prop.mode = options.mode;
            if (typeof options.yearTensInBold != "undefined")
                prop.yearTensInBold = options.yearTensInBold;
            if (typeof options.yearOrder != "undefined")
                order = options.yearOrder;
        }

        // Update value
        if ($get(currentValue) != null) {
            calendarTable_setValue(ucId, $get(currentValue).value);
            prop.trackingCode = currentValue;
        } else {
            calendarTable_setValue(ucId, currentValue);
            prop.trackingCode = null;
        }

        // Render control
        calendarTable_render(ucId, minYear, maxYear, order);
    }
}
function calendarTable_reset(ucId, currentValue, fctClick, minYear, maxYear, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.mode == "undefined")
        options.mode = CT_MODE_DMY;
    if (typeof options.yearTensInBold == "undefined")
        options.yearTensInBold = false;
    if (typeof options.yearOrder == "undefined")
        options.yearOrder = 1;

    // Update control
    calendarTable_update(ucId, currentValue, fctClick, minYear, maxYear, options);
}
function calendarTable_render(ucId, minYear, maxYear, order) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Re-render day and month is required to select current value
        // Day
        if (prop.mode == CT_MODE_MY) {
            hideCell($get(prop.tblId).rows[0].cells[1].id);
            hideCell($get(prop.tblId).rows[1].cells[1].id);
        }
        else {
            showCell($get(prop.tblId).rows[0].cells[1].id);
            showCell($get(prop.tblId).rows[1].cells[1].id);
            listBoxTable_render(prop.dayUcId, form2_getList(CT_LIST_DAY));
        }
        // Month
        listBoxTable_render(prop.monthUcId, form2_getList(CT_LIST_MONTH));
        // Year
        var list = new Array();
        if (order == 2) {
            for (var i = maxYear; i >= minYear; i--) {
                addToArray(list, new ListItem(i, (i % 10 == 0 && prop.yearTensInBold ? "<b>" + i + "</b>" : i)));
            }
        }
        else {
            for (var i = minYear; i <= maxYear; i++) {
                addToArray(list, new ListItem(i, (i % 10 == 0 && prop.yearTensInBold ? "<b>" + i + "</b>" : i)));
            }
        }
        listBoxTable_render(prop.yearUcId, list);
    }
}

function yearMonthDurationTable_getMonths(ucId) {
    return getInt(yearMonthDurationTable_getValue(ucId));
}
function yearMonthDurationTable_getValue(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        return listBoxTable_getInt(prop.monthUcId) + listBoxTable_getInt(prop.yearUcId) * 12;
    }
}
function yearMonthDurationTable_setValue(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (value != null && value != "") {
            listBoxTable_setValue(prop.monthUcId, value - Math.floor(value / 12) * 12);
            listBoxTable_setValue(prop.yearUcId, Math.floor(value / 12));
        }
        else {
            listBoxTable_setValue(prop.monthUcId, null);
            listBoxTable_setValue(prop.yearUcId, null);
        }
    }
}
function yearMonthDurationTable_saveValue(ucId, hfId) {
    $get(hfId).value = yearMonthDurationTable_getValue(ucId);
}
function yearMonthDurationTable_onClick(ucId, ucId2) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        var bFull = (listBoxTable_getValue(prop.monthUcId) != "" && listBoxTable_getValue(prop.yearUcId) != "");
        // Do action if required
        if (bFull && ucId2 == prop.monthUcId && prop.fctClick != null)
            prop.fctClick(ucId);
    }
}
function yearMonthDurationTable_validate(ucId, msg) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (!listBoxTable_validate(prop.monthUcId) || !listBoxTable_validate(prop.yearUcId)) {
            if (msg != null) form2_alert(true, msg, prop.trackingCode); //alert(msg);
            return false;
        }
    }
    return true;
}
function yearMonthDurationTable_update(ucId, currentValue, fctClick, minYear, maxYear, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update properties
        if ($get(currentValue) != null) {
            yearMonthDurationTable_setValue(ucId, $get(currentValue).value);
            prop.trackingCode = currentValue;
        } else {
            yearMonthDurationTable_setValue(ucId, currentValue);
            prop.trackingCode = null;
        }
        if (fctClick != null)
            prop.fctClick = fctClick;
        if (options) {
            // No options
        }
        // Render control
        yearMonthDurationTable_render(ucId, minYear, maxYear);
    }
}
function yearMonthDurationTable_reset(ucId, currentValue, fctClick, minYear, maxYear, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }

    // Update control
    yearMonthDurationTable_update(ucId, currentValue, fctClick, minYear, maxYear, options);
}
function yearMonthDurationTable_render(ucId, minYear, maxYear) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Re-render month is required to select current value
        var list = new Array();
        for (var i = 0; i <= 11; i++) {
            addToArray(list, new ListItem(i, i));
        }
        listBoxTable_render(prop.monthUcId, list);
        // Year
        list = new Array();
        for (var i = minYear; i <= maxYear; i++) {
            addToArray(list, new ListItem(i, i));
        }
        listBoxTable_render(prop.yearUcId, list);
    }
}

function form2_zipCodeTextBox_getZipCode(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        return $get(prop.tbId).value;
    }
}
function form2_zipCodeTextBox_setZipCode(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        $get(prop.tbId).value = value;
    }
}
function form2_zipCodeTextBox_getInseeCode(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        return $get(prop.ddlId).value;
    }
}
function form2_zipCodeTextBox_setInseeCode(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        $get(prop.ddlId).value = value;
    }
}
function form2_zipCodeTextBox_saveValue(ucId, hfIdZipCode, hfIdInseeCode) {
    $get(hfIdZipCode).value = form2_zipCodeTextBox_getZipCode(ucId);
    $get(hfIdInseeCode).value = form2_zipCodeTextBox_getInseeCode(ucId);
}
function form2_zipCodeTextBox_validate(ucId, msg1, msg2, msg3) {
    if (msg1 == null)
        msg1 = "Veuillez préciser le code postal."
    if (msg2 == null)
        msg2 = "Le code postal n'est pas valide."
    if (msg3 == null)
        msg3 = "Veuillez préciser votre ville."

    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (form2_zipCodeTextBox_getZipCode(ucId) == "") {
            if (msg1 != null) form2_alert(true, msg1, (prop.trackingCode != null ? prop.trackingCode : prop.tbId)); //alert(msg1);
            $get(prop.tbId).focus();
            return false;
        }
        if (form2_zipCodeTextBox_getZipCode(ucId).length < 5) {
            if (msg2 != null) form2_alert(true, msg2, (prop.trackingCode != null ? prop.trackingCode : prop.tbId)); //alert(msg2);
            $get(prop.tbId).focus();
            return false;
        }
        if (form2_zipCodeTextBox_getInseeCode(ucId) == "") {
            if ($get(prop.ddlId).length == 0 || ($get(prop.ddlId).length == 1 && $get(prop.ddlId).options[0].value == "")) {
                if (msg2 != null) form2_alert(true, msg2, prop.trackingCode); //alert(msg2);
                $get(prop.tbId).focus();
                return false;
            }
            if (msg3 != null) form2_alert(true, msg3, prop.trackingCode); //alert(msg3);
            $get(prop.ddlId).focus();
            return false;
        }
    }
    return true;
}
function form2_zipCodeTextBox_updateLocation(ucId, defaultInseeCode) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if ($get(prop.tbId).value.length == 5) {
            zipcode_initLocations(prop.tbId, $get(prop.tbId).value, prop.ddlId, defaultInseeCode);
        }
        else {
            hide(prop.ddlId);
        }
    }
}
function form2_zipCodeTextBox_btnClick(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.fctClick != null)
            prop.fctClick(ucId);
    }
}
function form2_zipCodeTextBox_tryBtnClick(ucId) {
    try { form2_zipCodeTextBox_btnClick(ucId); } catch (err) { alertJsErrorDescription(err); }
}
function form2_zipCodeTextBox_focus(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        $get(prop.tbId).focus();
    }
}
function form2_zipCodeTextBox_update(ucId, currentValueZipCode, currentValueInseeCode, fctClick, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update properties
        if (fctClick != null)
            prop.fctClick = fctClick;

        if (options) {
            if (typeof options.label != "undefined")
                setInnerHtml(prop.lblId, options.label);
            if (typeof options.showButton != "undefined")
                setVisibility(prop.btnId, options.showButton);
        }

        var zipcode;
        var inseeCode;
        if ($get(currentValueZipCode) != null) {
            zipcode = $get(currentValueZipCode).value;
            prop.trackingCode = currentValueZipCode;
        } else {
            zipcode = currentValueZipCode;
            prop.trackingCode = null;
        }
        if ($get(currentValueInseeCode) != null)
            inseeCode = $get(currentValueInseeCode).value;
        else
            inseeCode = currentValueInseeCode;

        if ($get(prop.tbId).value != zipcode) {
            form2_zipCodeTextBox_setZipCode(ucId, zipcode);
            form2_zipCodeTextBox_updateLocation(ucId, inseeCode);
        } else if ($get(prop.ddlId).options.length == 0) {
            form2_zipCodeTextBox_updateLocation(ucId, inseeCode);
        }
        else if ($get(prop.ddlId).value != inseeCode) {
            form2_zipCodeTextBox_setInseeCode(ucId, inseeCode);
        }
    }
}
function form2_zipCodeTextBox_reset(ucId, currentValueZipCode, currentValueInseeCode, fctClick, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.label == "undefined")
        options.label = "Votre code postal";
    if (typeof options.showButton == "undefined")
        options.showButton = true;

    // Update control
    form2_zipCodeTextBox_update(ucId, currentValueZipCode, currentValueInseeCode, fctClick, options);
}
function form2_zipCodeTextBox_render(ucId, inseeCode, label) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        form2_zipCodeTextBox_updateLocation(ucId, inseeCode);
        if (label != null)
            setInnerHtml(prop.lblId, label);
    }
}

function form2_textBox_getInt(ucId) {
    return getInt(RemoveNumericMask(form2_textBox_getValue(ucId)));
}
function form2_textBox_getDouble(ucId) {
    return getDouble(form2_textBox_getValue(ucId));
}
function form2_textBox_getValue(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        return trim($get(prop.tbId).value);
    }
}
function form2_textBox_setValue(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        $get(prop.tbId).value = value;
    }
}
function form2_textBox_saveInt(ucId, hfId) {
    $get(hfId).value = form2_textBox_getInt(ucId);
}
function form2_textBox_saveValue(ucId, hfId) {
    $get(hfId).value = form2_textBox_getValue(ucId);
}
function form2_textBox_validate(ucId, msg, msg2) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        var v = form2_textBox_getValue(ucId);
        if (v == "") {
            if (msg != null) form2_alert(true, msg, (prop.trackingCode != null ? prop.trackingCode : tb.hfId)); //alert(msg);
            return false;
        }
        // Check format
        var valid = true;
        switch (prop.contentType) {
            //case 1: valid = isInt(v); break; 
            case 2: valid = isDouble(v); break;
            //case 6: valid = isInt(RemoveNumericMask(v)); break; 
        }
        if (!valid) {
            if (msg2 == null) msg2 = "Format invalide";
            form2_alert(true, msg2, (prop.trackingCode != null ? prop.trackingCode : prop.tbId)); //alert(msg2);
            return false;
        }
    }
    return true;
}
function form2_textBox_btnClick(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.fctClick != null)
            prop.fctClick(ucId);
    }
}
function form2_textBox_tryBtnClick(ucId) {
    try { form2_textBox_btnClick(ucId); } catch (err) { alertJsErrorDescription(err); }
}
function form2_textBox_onBlur(sender, ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.defaultText != null && form2_textBox_getValue(ucId) == "") {
            form2_textBox_setValue(ucId, prop.defaultText);
            prop.currentValueIsDefaultText = true;
            $get(prop.tbId).className = "al_default";
        } else {
            prop.currentValueIsDefaultText = false;
            $get(prop.tbId).className = "";
        }
    }
}
function form2_textBox_onFocus(sender, ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.defaultText != null && prop.defaultText == sender.value && prop.currentValueIsDefaultText) {
            form2_textBox_setValue(ucId, "");
            $get(prop.tbId).className = "";
        }
    }
}
function form2_textBox_focus(ucId, focusIfEmpty) {
    if (focusIfEmpty == null) focusIfEmpty = true;
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (!focusIfEmpty || $get(prop.tbId).value == "")
            $get(prop.tbId).focus();
    }
}
function form2_textBox_update(ucId, currentValue, fctClick, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update properties
        if ($get(currentValue) != null) {
            form2_textBox_setValue(ucId, $get(currentValue).value);
            prop.trackingCode = currentValue;
        } else {
            form2_textBox_setValue(ucId, currentValue);
            prop.trackingCode = null;
        }
        if (fctClick != null)
            prop.fctClick = fctClick;
        if (options) {
            if (typeof options.label != "undefined")
                setInnerHtml(prop.lblId, options.label);
            if (typeof options.labelUnit != "undefined")
                setInnerHtml(prop.lblUnitId, options.labelUnit);
            if (typeof options.maxLength != "undefined") {
                if (options.maxLength > 0)
                    $get(prop.tbId).maxLength = options.maxLength;
                else
                    $get(prop.tbId).removeAttribute("maxLength");
            }
            if (typeof options.width != "undefined")
                $get(prop.tbId).style.width = options.width;
            if (typeof options.defaultText != "undefined") {
                prop.defaultText = options.defaultText;
                prop.currentValueIsDefaultText = false;
            }
            if (typeof options.showButton != "undefined")
                setVisibility(prop.btnId, options.showButton);
        }
        // Update default value
        form2_textBox_onBlur($get(prop.tbId), ucId);
        // Focus ?
        // Not managed here because textbox might be hidden (IE error ...)
    }
}
function form2_textBox_reset(ucId, currentValue, fctClick, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.label == "undefined")
        options.label = "";
    if (typeof options.labelUnit == "undefined")
        options.labelUnit = "";
    if (typeof options.maxLength == "undefined")
        options.maxLength = "0";
    if (typeof options.width == "undefined")
        options.width = "auto";
    if (typeof options.defaultText == "undefined")
        options.defaultText = null;
    if (typeof options.showButton == "undefined")
        options.showButton = true;

    // Update control
    form2_textBox_update(ucId, currentValue, fctClick, options);
}

function form2_dropDownList_getInt(ucId) {
    return getInt(form2_dropDownList_getValue(ucId));
}
function form2_dropDownList_getDouble(ucId) {
    return getDouble(form2_dropDownList_getValue(ucId));
}
function form2_dropDownList_getValue(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        return $get(prop.ddlId).value;
    }
}
function form2_dropDownList_setValue(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        $get(prop.ddlId).value = value;
    }
}
function form2_dropDownList_saveInt(ucId, hfId) {
    $get(hfId).value = form2_dropDownList_getInt(ucId);
}
function form2_dropDownList_saveValue(ucId, hfId) {
    $get(hfId).value = form2_dropDownList_getValue(ucId);
}
function form2_dropDownList_validate(ucId, msg, msg2) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        var v = form2_dropDownList_getValue(ucId);
        if (v == "") {
            if (msg != null) form2_alert(true, msg, (prop.trackingCode != null ? prop.trackingCode : prop.ddlId)); //alert(msg);
            return false;
        }
    }
    return true;
}
function form2_dropDownList_btnClick(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.fctClick != null)
            prop.fctClick(ucId);
    }
}
function form2_dropDownList_tryBtnClick(ucId) {
    try { form2_dropDownList_btnClick(ucId); } catch (err) { alertJsErrorDescription(err); }
}
function form2_dropDownList_focus(ucId, focusIfEmpty) {
    if (focusIfEmpty == null) focusIfEmpty = true;
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (!focusIfEmpty || $get(prop.ddlId).value == "")
            $get(prop.ddlId).focus();
    }
}
function form2_dropDownList_onChange(sender, ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.autoValidation)
            form2_dropDownList_btnClick(ucId);
    }
}
function form2_dropDownList_update(ucId, currentValue, fctClick, list, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {

        // Update list
        if (typeof list == "number") {
            // Get list from list collection
            list = form2_getList(list);
        }
        dropDownList_bind_NoProp(prop.ddlId, null, list);

        // Update properties
        if ($get(currentValue) != null) {
            form2_dropDownList_setValue(ucId, $get(currentValue).value);
            prop.trackingCode = currentValue;
        } else {
            form2_dropDownList_setValue(ucId, currentValue);
            prop.trackingCode = null;
        }
        prop.fctClick = fctClick;
        if (options) {
            if (typeof options.label != "undefined")
                setInnerHtml(prop.lblId, options.label);
            if (typeof options.labelUnit != "undefined")
                setInnerHtml(prop.lblUnitId, options.labelUnit);
            if (typeof options.width != "undefined")
                $get(prop.ddlId).style.width = options.width;
            if (typeof options.showButton != "undefined")
                setVisibility(prop.btnId, options.showButton);
            if (typeof options.autoValidation != "undefined")
                prop.autoValidation = options.autoValidation;
        }
        // Focus ?
        // Not managed here because dropdownlist might be hidden (IE error ...)
    }
}
function form2_dropDownList_reset(ucId, currentValue, fctClick, list, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.label == "undefined")
        options.label = "";
    if (typeof options.labelUnit == "undefined")
        options.labelUnit = "";
    if (typeof options.width == "undefined")
        options.width = "auto";
    if (typeof options.autoValidation == "undefined")
        options.autoValidation = true;
    if (typeof options.showButton == "undefined")
        options.showButton = true;

    // Update control
    form2_dropDownList_update(ucId, currentValue, fctClick, list, options);
}

function form2_dateDropDownList_getDate(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.mode == 0)
            return getValidDate(1, $get(prop.ddlMonthId).value, $get(prop.ddlYearId).value);
        else
            return getValidDate($get(prop.ddlDayId).value, $get(prop.ddlMonthId).value, $get(prop.ddlYearId).value);
    }
}
function form2_dateDropDownList_getValue(ucId) {
    return getDateStringByFormat(form2_dateDropDownList_getDate(ucId), "dd/MM/yyyy");
}
function form2_dateDropDownList_setValue(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (value != null && value != "") {
            var d = getDateByFormat(value, "dd/MM/yyyy");
            if (prop.mode == 0)
                $get(prop.ddlDayId).value = 1;
            else
                $get(prop.ddlDayId).value = d.getDate();
            $get(prop.ddlMonthId).value = d.getMonth() + 1;
            $get(prop.ddlYearId).value = d.getFullYear();
        }
        else {
            $get(prop.ddlDayId).value = "";
            $get(prop.ddlMonthId).value = "";
            $get(prop.ddlYearId).value = "";
        }
    }
}
function form2_dateDropDownList_saveValue(ucId, hfId) {
    $get(hfId).value = form2_dateDropDownList_getValue(ucId);
}
function form2_dateDropDownList_validate(ucId, msg, msg2) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if ((prop.mode == 1 && $get(prop.ddlDayId).value == "")
            || $get(prop.ddlMonthId).value == ""
            || $get(prop.ddlYearId).value == "") {
            if (msg != null) form2_alert(true, msg, prop.trackingCode); //alert(msg);
            return false;
        }
        if (msg2 == null) msg2 = "La date n'est pas valide."
        return form2_dateDropDownList_validateDate(ucId, msg2);
    }
    return true;
}
function form2_dateDropDownList_validateDate(ucId, msg) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (form2_dateDropDownList_getDate(ucId) == null) {
            if (msg != null) form2_alert(true, msg, prop.trackingCode); //alert(msg);
            return false;
        }
    }
    return true;
}
function form2_dateDropDownList_setVisibilityButton(ucId, visibility) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        setVisibility(prop.btnId, visibility);
    }
}
function form2_dateDropDownList_btnClick(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (prop.fctClick != null)
            prop.fctClick(ucId);
    }
}
function form2_dateDropDownList_tryBtnClick(ucId) {
    try { form2_dateDropDownList_btnClick(ucId); } catch (err) { alertJsErrorDescription(err); }
}
function form2_dateDropDownList_onChange(sender, ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        form2_dateDropDownList_btnClick(ucId);
    }
}
function form2_dateDropDownList_update(ucId, currentValue, fctClick, minYear, maxYear, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update list
        var list = new Array();
        addToArray(list, new ListItem("", "Année"));
        for (var i = maxYear; i >= minYear; i--) {
            addToArray(list, new ListItem(i, i));
        }
        dropDownList_bind_NoProp(prop.ddlYearId, null, list);

        // Update properties
        prop.fctClick = fctClick;
        if (options) {
            if (typeof options.mode != "undefined") {
                prop.mode = options.mode;
                if (prop.mode == CT_MODE_MY)
                    hide(prop.ddlDayId);
                else
                    showInline(prop.ddlDayId);
            }
            if (typeof options.label != "undefined")
                if (options.label != null && options.label != "")
                setInnerHtml(prop.lblId, options.label + "&nbsp;:");
            else
                setInnerHtml(prop.lblId, null);
            if (typeof options.showButton != "undefined")
                form2_dateDropDownList_setVisibilityButton(ucId, options.showButton);
        }

        // Update value
        if ($get(currentValue) != null) {
            form2_dateDropDownList_setValue(ucId, $get(currentValue).value);
            prop.trackingCode = currentValue;
        } else {
            form2_dateDropDownList_setValue(ucId, currentValue);
            prop.trackingCode = null;
        }

        // Focus ?
        // Not managed here because dropdownlist might be hidden (IE error ...)
    }
}
function form2_dateDropDownList_reset(ucId, currentValue, fctClick, minYear, maxYear, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.mode == "undefined")
        options.mode = CT_MODE_DMY;
    if (typeof options.label == "undefined")
        options.label = "";
    if (typeof options.showButton == "undefined")
        options.showButton = true;

    // Update control
    form2_dateDropDownList_update(ucId, currentValue, fctClick, minYear, maxYear, options);
}

function form2_formControlContainer_setVisibility(ucId, visible) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        setVisibility(prop.pnlId, visible);
    }
}
function form2_formControlContainer_show(ucId) {
    form2_formControlContainer_setVisibility(ucId, true);
}
function form2_formControlContainer_hide(ucId) {
    form2_formControlContainer_hide(ucId, false);
}
function form2_formControlContainer_updateDesign(ucId, designId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {

        // TODO : defined mask to manage cell visibility and colspan

        // Hide/Show all cells by default ?
        var visibility = (designId == FORM2_CONTAINER_DESIGN_1 ? true : false);
        for (var i = 0; i < 3; i++) {
            for (var j = 0; j < 3; j++) {
                if (!(i == 1 && j == 1))
                    setCellVisibility($get(prop.tblId).rows[i].cells[j].id, visibility);
            }
        }
        // Update CSS class
        $get(prop.tblId).className = "al_form2_controlContainer al_form2_controlContainer" + designId;
        if (designId == FORM2_CONTAINER_DESIGN_2) {
            // Top text only
            showCell($get(prop.tblId).rows[0].cells[1].id);
        }
        else if (designId == FORM2_CONTAINER_DESIGN_3) {
            // Bottom text only
            showCell($get(prop.tblId).rows[2].cells[1].id);
        }
        else if (designId == FORM2_CONTAINER_DESIGN_4) {
            // Right column only
            showCell($get(prop.tblId).rows[1].cells[2].id);
        }
        else if (designId == FORM2_CONTAINER_DESIGN_5) {
            // Bottom text and right column
            showCell($get(prop.tblId).rows[2].cells[1].id);
            showCell($get(prop.tblId).rows[1].cells[2].id);
        }
        else if (designId == FORM2_CONTAINER_DESIGN_6) {
            // Right column only
            showCell($get(prop.tblId).rows[1].cells[0].id);
        }
        else if (designId == FORM2_CONTAINER_DESIGN_7) {
            // Top & bottom
            showCell($get(prop.tblId).rows[0].cells[1].id);
            showCell($get(prop.tblId).rows[2].cells[1].id);
        }
    }
}
function form2_formControlContainer_update(ucId, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (typeof options.design != "undefined") {
            form2_formControlContainer_updateDesign(ucId, options.design);
            // Custom class is valid only if design specified (class rewrite in update method)
            // To use className without design, please refactor control to manage css class
            if (typeof options.className != "undefined")
                $get(prop.tblId).className = $get(prop.tblId).className + " " + options.className;
        }
        if (typeof options.labelTop != "undefined")
            setInnerHtml(prop.lblTopId, options.labelTop);
        if (typeof options.labelBottom != "undefined")
            setInnerHtml(prop.lblBottomId, options.labelBottom);
        if (typeof options.labelLeft != "undefined")
            setInnerHtml(prop.lblLeftId, options.labelLeft);
        if (typeof options.questionLabel != "undefined" && options.questionLabel != null && options.questionLabel != "") {
            showTable(prop.tblQuestionBarId);
            form2_setQuestionText(options.questionLabel, prop.lblQuestionBarId);
            if (typeof options.helpId != "undefined" && options.helpId != null && options.helpId != "") {
                form2_enableHelp(options.helpId, prop.hlQuestionBarHelpId, prop.cellQuestionBarHelpId);
            } else {
                form2_disableHelp(prop.cellQuestionBarHelpId);
            }
        } else {
            hideTable(prop.tblQuestionBarId);
        }
        if (typeof options.labelHeader != "undefined" && options.labelHeader != null && options.labelHeader != "") {
            showTable(form2_headerId);
            $get(form2_headerLabelId).innerHTML = options.labelHeader;
        } else {
            hideTable(form2_headerId);
            $get(form2_headerLabelId).innerHTML = "";
        }
        if (typeof options.visible != "undefined")
            form2_formControlContainer_setVisibility(ucId, options.visible);
    }
}
function form2_formControlContainer_reset(ucId, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.design == "undefined")
        options.design = FORM2_CONTAINER_DESIGN_0;

    if (typeof options.labelTop == "undefined")
        options.labelTop = "";
    if (typeof options.labelBottom == "undefined")
        options.labelBottom = "";
    if (typeof options.labelLeft == "undefined")
        options.labelLeft = "";
    if (typeof options.className == "undefined")
        options.className = "";
    if (typeof options.questionLabel == "undefined")
        options.questionLabel = "";
    if (typeof options.helpId == "undefined")
        options.helpId = "";
    if (typeof options.visible == "undefined")
        options.visible = true;
    if (typeof options.labelHeader == "undefined")
        options.labelHeader = "";

    // Update control
    form2_formControlContainer_update(ucId, options);
}
function form2_formControlContainer_resetLbt(ucId, options, childUcCurrentValue, childUcFctClick, childUcList, childUcOptions) {
    form2_formControlContainer_reset(ucId, options);
    listBoxTable_reset(_fp(ucId).childUcId, childUcCurrentValue, childUcFctClick, childUcList, childUcOptions);
}


function form2_formControlCollectionContainer_update(ucId, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (typeof options.itemNumber != "undefined") {
            var visible = false;
            for (var i = 0; i < prop.childUcIds.length; i++) {
                // TODO : if not formControlContainer ?
                visible = (i < options.itemNumber ? true : false);
                if (visible && typeof options.itemDisplayMask != "undefined")
                    visible = (Math.pow(2, i) & options.itemDisplayMask ? true : false);
                form2_formControlContainer_setVisibility(prop.childUcIds[i], visible);
            }
        }
    }
}
function form2_formControlCollectionContainer_reset(ucId, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.itemNumber == "undefined")
        options.itemNumber = 1;
    if (typeof options.itemDisplayMask == "undefined")
        options.itemDisplayMask = Math.pow(2, options.itemNumber) - 1;

    // Update control
    form2_formControlCollectionContainer_update(ucId, options);
}

/* HELP LINK GENERATOR */
function addHelpLink(link, helpId, position) {
    link.className = link.className + " al_helpLink";
    addListener(link, 'mouseover', function() { helppopup_show(link.id, 'ctl00_ContentPlaceHolder1_helpPopup_popup', position, 'Form', '', helpId); });
    var newImg = document.createElement('img');
    newImg.className = "al_helpLinkSizer";
    newImg.src = "/Images2/px.gif";
    link.appendChild(newImg);
}

function calendarTable2_getDate(ucId) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        return getValidDate(listBoxTable_getValue(prop.dayUcId), $get(prop.monthHfId).value, $get(prop.yearDdlId).value)
    }
}
function calendarTable2_getValue(ucId) {
    return getDateStringByFormat(calendarTable2_getDate(ucId), "dd/MM/yyyy");
}
function calendarTable2_setValue(ucId, value) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (value != null && value != "") {
            var d = getDateByFormat(value, "dd/MM/yyyy");
            listBoxTable_setValue(prop.dayUcId, d.getDate());
            $get(prop.monthHfId).value = d.getMonth() + 1;
            calendarTable2_updateLabelMonth(ucId, prop.monthHfId);
            $get(prop.yearDdlId).value = d.getFullYear();
        } else {
            listBoxTable_setValue(prop.dayUcId, null);
            $get(prop.monthHfId).value = "1";
            calendarTable2_updateLabelMonth(ucId, null);
            $get(prop.yearDdlId).value = "";
        }
    }
}
function calendarTable2_saveValue(ucId, hfId) {
    $get(hfId).value = calendarTable2_getValue(ucId);
}
function calendarTable2_onClick(ucId, ucId2) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        var bFull = (listBoxTable_getValue(prop.dayUcId) != "" && $get(prop.monthHfId).value != "" && $get(prop.yearDdlId).value != "");
        // Do action if required
        if (bFull && ucId2 == prop.dayUcId && prop.fctClick != null)
            prop.fctClick(ucId);
    }
}
function calendarTable2_validate(ucId, msg, msg2) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (!listBoxTable_validate(prop.dayUcId)
            || ($get(prop.monthHfId).value == "")
            || ($get(prop.yearDdlId).value == "")) {
            if (msg != null) form2_alert(true, msg, prop.trackingCode); //alert(msg);
            return false;
        }
        if (msg2 == null) msg2 = "La date n'est pas valide."
        return calendarTable2_validateDate(ucId, msg2);
    }
    return true;
}
function calendarTable2_validateDate(ucId, msg) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (calendarTable2_getDate(ucId) == null) {
            if (msg != null) form2_alert(true, msg, prop.trackingCode); //alert(msg);
            return false;
        }
    }
    return true;
}
function calendarTable2_update(ucId, currentValue, fctClick, minYear, maxYear, options) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Update properties
        if (fctClick != null)
            prop.fctClick = fctClick;

        var order = 1;
        if (options) {
            if (typeof options.yearTensInBold != "undefined")
                prop.yearTensInBold = options.yearTensInBold;
            if (typeof options.yearOrder != "undefined")
                order = options.yearOrder;
        }

        // Update value
        if ($get(currentValue) != null) {
            calendarTable2_setValue(ucId, $get(currentValue).value);
            prop.trackingCode = currentValue;
        } else {
            calendarTable2_setValue(ucId, currentValue);
            prop.trackingCode = null;
        }

        // Render control
        calendarTable2_render(ucId, currentValue, minYear, maxYear, order);
    }
}
function calendarTable2_reset(ucId, currentValue, fctClick, minYear, maxYear, options) {
    // Set default properties if required
    if (options == null) {
        options = new Object();
    }
    if (typeof options.yearTensInBold == "undefined")
        options.yearTensInBold = false;
    if (typeof options.yearOrder == "undefined")
        options.yearOrder = 1;

    // Update control
    calendarTable2_update(ucId, currentValue, fctClick, minYear, maxYear, options);
}
function calendarTable2_render(ucId, currentValue, minYear, maxYear, order) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        // Day
        listBoxTable_render(prop.dayUcId, form2_getList(CT_LIST_DAY));
        // Month      
        
        // Year
        var list = new Array();
        addToArray(list, new ListItem('', 'Année'));
        if (order == 2) {
            for (var i = maxYear; i >= minYear; i--) {
                addToArray(list, new ListItem(i, i));
            }
        } else {
            for (var i = minYear; i <= maxYear; i++) {
                addToArray(list, new ListItem(i, i));
            }
        }
        dropDownList_bind_NoProp(prop.yearDdlId, null, list);
        if(prop.yearTensInBold){
            for (var i = 1; i < list.length - 1; i++) {
                if ((parseInt($get(prop.yearDdlId).options[i].value) % 10) == 0) {
                    $get(prop.yearDdlId).options[i].className = "al_yearTens";
                }
            }
        }
        // Re-init selected value of dropdownlist
        if ($get(currentValue) != null) {
            if ($get(currentValue).value != null && $get(currentValue).value != "") {
                var d = getDateByFormat($get(currentValue).value, "dd/MM/yyyy");
                $get(prop.yearDdlId).value = d.getFullYear();
            } else {
                $get(prop.yearDdlId).value = "";
            }
        } else {
            if (currentValue != null && currentValue != "") {
                var d = getDateByFormat(currentValue, "dd/MM/yyyy");
                $get(prop.yearDdlId).value = d.getFullYear();
            } else {
                $get(prop.yearDdlId).value = "";
            }
        }
    }
}
function calendarTable2_updateLabelMonth(ucId, currentValue) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        if (currentValue == null) {
            $get(prop.labelMonthTbcId).innerHTML = form2_getList(CT_LIST_MONTH)[0].Text;
        } else if ($get(currentValue) != null) {
            $get(prop.labelMonthTbcId).innerHTML = form2_getList(CT_LIST_MONTH)[parseInt($get(currentValue).value)-1].Text;
        } else {
            $get(prop.labelMonthTbcId).innerHTML = form2_getList(CT_LIST_MONTH)[parseInt(currentValue)-1].Text;
        }
    }
}
function calendarTable2_changeLabelMonth(ucId, stepValue) {
    var prop = form_eltPropertiesObjArray[ucId];
    if (prop != null) {
        var monthHf = $get(prop.monthHfId);
        // Reset value if empty or not between 1 and 12
        if (monthHf.value == null) {
            monthHf.value = 1;
        }
        if (monthHf.value == '') {
            monthHf.value = 1;
        }
        if (monthHf.value <= 0) {
            monthHf.value = 1;
        }
        if (monthHf.value > 12) {
            monthHf.value = 12;
        }
        // Update hidden field
        if ((parseInt(monthHf.value) + stepValue) < 1 ) {
            monthHf.value = 12;
        } else if ((parseInt(monthHf.value) + stepValue) > 12) {
            monthHf.value = 1;
        } else {
            monthHf.value = parseInt(monthHf.value) + stepValue;
        }
        calendarTable2_updateLabelMonth(ucId, prop.monthHfId);
    }
}

/////////////////////////////////////////////////////
// Cota Saver
/////////////////////////////////////////////////////
function form2_updateQuotation(callbackOnSuccess) {
    if (typeof (callbackOnSuccess) == 'undefined') {
        callbackOnSuccess = null;
    }
    if (form2_productType == null || form2_productType == '')
        return;
    if (form2_businessDataId == null || form2_businessDataId == '')
        return;
    if ($get(form2_businessDataId) == null)
        return;
    if ($get(form2_lbtOptinPanelId)== null)
        return;
    var dataJSON = new Array();
    // Business Data
    var listHf = $get(form2_businessDataId).getElementsByTagName('input');
    if (listHf.length > 0) {
        for (var i = 0; i < listHf.length; i++) {
            if (listHf[i].value != null && listHf[i].value != '' && listHf[i].value != '__/__/____' && listHf[i].value != 'sans objet' && listHf[i].value != '__.__.__.__.__') {
                dataJSON.push(form2_keyJSON(listHf[i].id.replace(form2_patternHiddenField, '')) + ':"' + listHf[i].value.replace("'", "\'") + '"');
            }
        }
        // Optin
        listHf = $get(form2_lbtOptinPanelId).getElementsByTagName('input');
        if (listHf.length == 1) {
            if (listHf[0].value != '')
                dataJSON.push('optin:"' + listHf[0].value + '"');
        }
        if (dataJSON.length > 0) {
            //alert('{' + dataJSON.join(',') + '}');
            AssurlandWeb.SessionData.UpdateQuotation(form2_quotationId, form2_productType, '{' + dataJSON.join(',') + '}', form2_partnerLinkId, callbackOnSuccess, function(r) { displayAspNetFrameworkError('AssurlandWeb.SessionData.UpdateQuotation failed', r); });
        }
    }
}
function form2_keyJSON(k) {
    return k.charAt(0).toLowerCase() + k.substring(1);
}

/////////////////////////////////////////////////////
// SessionData.asmx/js                             //
/////////////////////////////////////////////////////
Type.registerNamespace('AssurlandWeb');
AssurlandWeb.SessionData = function() {
    AssurlandWeb.SessionData.initializeBase(this);
    this._timeout = 0;
    this._userContext = null;
    this._succeeded = null;
    this._failed = null;
}
AssurlandWeb.SessionData.prototype = {
    _get_path: function() {
        var p = this.get_path();
        if (p) return p;
        else return AssurlandWeb.SessionData._staticInstance.get_path();
    },
    UpdateQuotation: function(quotationID, productType, dataJSON, partnerLinkId, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'UpdateQuotation', false, { quotationID: quotationID, productType: productType, dataJSON: dataJSON, partnerLinkId: partnerLinkId }, succeededCallback, failedCallback, userContext);
    } 
}
AssurlandWeb.SessionData.registerClass('AssurlandWeb.SessionData', Sys.Net.WebServiceProxy);
AssurlandWeb.SessionData._staticInstance = new AssurlandWeb.SessionData();
AssurlandWeb.SessionData.set_path = function(value) { AssurlandWeb.SessionData._staticInstance.set_path(value); }
AssurlandWeb.SessionData.get_path = function() { return AssurlandWeb.SessionData._staticInstance.get_path(); }
AssurlandWeb.SessionData.set_timeout = function(value) { AssurlandWeb.SessionData._staticInstance.set_timeout(value); }
AssurlandWeb.SessionData.get_timeout = function() { return AssurlandWeb.SessionData._staticInstance.get_timeout(); }
AssurlandWeb.SessionData.set_defaultUserContext = function(value) { AssurlandWeb.SessionData._staticInstance.set_defaultUserContext(value); }
AssurlandWeb.SessionData.get_defaultUserContext = function() { return AssurlandWeb.SessionData._staticInstance.get_defaultUserContext(); }
AssurlandWeb.SessionData.set_defaultSucceededCallback = function(value) { AssurlandWeb.SessionData._staticInstance.set_defaultSucceededCallback(value); }
AssurlandWeb.SessionData.get_defaultSucceededCallback = function() { return AssurlandWeb.SessionData._staticInstance.get_defaultSucceededCallback(); }
AssurlandWeb.SessionData.set_defaultFailedCallback = function(value) { AssurlandWeb.SessionData._staticInstance.set_defaultFailedCallback(value); }
AssurlandWeb.SessionData.get_defaultFailedCallback = function() { return AssurlandWeb.SessionData._staticInstance.get_defaultFailedCallback(); }
AssurlandWeb.SessionData.set_path("/ws/SessionData.asmx");
AssurlandWeb.SessionData.UpdateQuotation = function(quotationID, productType, dataJSON, partnerLinkId, onSuccess, onFailed, userContext) { AssurlandWeb.SessionData._staticInstance.UpdateQuotation(quotationID, productType, dataJSON, partnerLinkId, onSuccess, onFailed, userContext); }

/////////////////////////////////////////////////////
// AccountAccess.asmx/js                           //
/////////////////////////////////////////////////////
Type.registerNamespace('AssurlandWeb');
AssurlandWeb.AccountAccess = function() {
    AssurlandWeb.AccountAccess.initializeBase(this);
    this._timeout = 0;
    this._userContext = null;
    this._succeeded = null;
    this._failed = null;
}
AssurlandWeb.AccountAccess.prototype = {
    _get_path: function() {
        var p = this.get_path();
        if (p) return p;
        else return AssurlandWeb.AccountAccess._staticInstance.get_path();
    },
    UpdateUserProfile: function(Login, ProductType, CaptchaRecorded, CaptchaSessionKey, succeededCallback, failedCallback, userContext) {
        return this._invoke(this._get_path(), 'UpdateUserProfile', false, { Login: Login, ProductType: ProductType, CaptchaRecorded: CaptchaRecorded, CaptchaSessionKey: CaptchaSessionKey }, succeededCallback, failedCallback, userContext);
    } 
}
AssurlandWeb.AccountAccess.registerClass('AssurlandWeb.AccountAccess', Sys.Net.WebServiceProxy);
AssurlandWeb.AccountAccess._staticInstance = new AssurlandWeb.AccountAccess();
AssurlandWeb.AccountAccess.set_path = function(value) { AssurlandWeb.AccountAccess._staticInstance.set_path(value); }
AssurlandWeb.AccountAccess.get_path = function() { return AssurlandWeb.AccountAccess._staticInstance.get_path(); }
AssurlandWeb.AccountAccess.set_timeout = function(value) { AssurlandWeb.AccountAccess._staticInstance.set_timeout(value); }
AssurlandWeb.AccountAccess.get_timeout = function() { return AssurlandWeb.AccountAccess._staticInstance.get_timeout(); }
AssurlandWeb.AccountAccess.set_defaultUserContext = function(value) { AssurlandWeb.AccountAccess._staticInstance.set_defaultUserContext(value); }
AssurlandWeb.AccountAccess.get_defaultUserContext = function() { return AssurlandWeb.AccountAccess._staticInstance.get_defaultUserContext(); }
AssurlandWeb.AccountAccess.set_defaultSucceededCallback = function(value) { AssurlandWeb.AccountAccess._staticInstance.set_defaultSucceededCallback(value); }
AssurlandWeb.AccountAccess.get_defaultSucceededCallback = function() { return AssurlandWeb.AccountAccess._staticInstance.get_defaultSucceededCallback(); }
AssurlandWeb.AccountAccess.set_defaultFailedCallback = function(value) { AssurlandWeb.AccountAccess._staticInstance.set_defaultFailedCallback(value); }
AssurlandWeb.AccountAccess.get_defaultFailedCallback = function() { return AssurlandWeb.AccountAccess._staticInstance.get_defaultFailedCallback(); }
AssurlandWeb.AccountAccess.set_path("/Ws/AccountAccess.asmx");
AssurlandWeb.AccountAccess.UpdateUserProfile = function(Login, ProductType, CaptchaRecorded, CaptchaSessionKey, onSuccess, onFailed, userContext) { AssurlandWeb.AccountAccess._staticInstance.UpdateUserProfile(Login, ProductType, CaptchaRecorded, CaptchaSessionKey, onSuccess, onFailed, userContext); }
var gtc = Sys.Net.WebServiceProxy._generateTypedConstructor;
if (typeof (AssurlandWeb.AccountAccessResponse) === 'undefined') {
    AssurlandWeb.AccountAccessResponse = gtc("AssurlandWeb.AccountAccessResponse");
    AssurlandWeb.AccountAccessResponse.registerClass('AssurlandWeb.AccountAccessResponse');
}

