var arrayOfResult = new Array();
var listCurrent = new Array();
var selectedCampsiteBySearchForm = 0;
var currentPage = 1;

var arrayOfResult = new Array();
var listCurrent = new Array();
var selectedCampsiteBySearchForm = 0;
var currentPage = 1;




/*Formulaire de recherche*/

//initialisation formulaire de recherche//
function initSearchForm() {

    searchForm = new SearchForm(url_result);
    searchForm.SetPopup(false);
    selectSejour = new SelectSejour('', 'arrivalDate', 'departureDate');
    searchForm.SetMode1('territories', 'tb_territories', 'tb_lat', 'tb_lon', 'VarRetour', 'div_detail_all', 'details_ufi.aspx');
    searchForm.SetSuperOS('idos');

    //Services
    addPanelCheckBox('cbService', 'h_categories', false, false, ' service');
}

var template_detail_all = '<div class="preciserLieu"><div class="closePreciserLieuX"><a href="javascript:cachePlace();">X</a></div>{foreach d in data}{if d.admin_code == ""}<a href="javascript:cachePlace();setLatLonTB(${d.gps_latitude},${d.gps_longitude})">${d.name}{else}<a href="javascript:cachePlace();setAdminCode({admin_code:\'${d.admin_code}\'})">${d.name}{/if}{if d.pays != ""}- ${d.pays}{/if}{if d.region != ""}- ${d.region}{/if}{if d.departement != ""}- ${d.departement}{/if}</a><br/>{/foreach}</div>';

//pas d'envoi du form quand l'utilisateur presse ENTER

function stopEvent(event) {
    // Compatibilité IE / Firefox
    if (!event && window.event) {
        event = window.event;
    }
    // IE
    if (event.keyCode == 13) {
        event.returnValue = false;
        event.cancelBubble = true;
    }
    // DOM
    if (event.which == 13) {
        event.preventDefault();
        event.stopPropagation();
    }
}

/*Resultats recherche*/

//Pagination - affichage de la page
function displayPage(pageValue) {
    var pageValueInt = parseFloat(pageValue);
    currentPage = pageValueInt;
    //Affichage de la page
    var content = eval("resultsPage_" + pageValue);

    if (!content) {
        if (nbCamp != 0) { $('ajax-results-loading').show(); }
        PageMethods.GetResponsePage(
				keyResult,
				(pageValueInt - 1) * 10,
				pageValueInt * 10,
				function (result) {
				    eval("resultsPage_" + pageValue + " = " + result + ";");
				    $('ajax-results-loading').hide();
				    $('search-results-pages').innerHTML = eval("resultsPage_" + pageValue);

				}
				);
    }
    else {
        $('search-results-pages').innerHTML = content;
    }

    //class btn
    $$('ul.pagination li.numbers ul li a').each(function (elmLiLink) {
        if (elmLiLink.up('li').className == 'page_' + pageValue) {
            elmLiLink.className = 'active';
        }
        else {
            elmLiLink.className = 'link';
        }
    });

    //prev & next
    if (pageValue == '1') {
        $$('ul.pagination li.prev').each(function (elmPrev) {
            elmPrev.down('a').className = 'active';
            elmPrev.className = 'prev page_1';
        });
    }
    else {
        $$('ul.pagination li.prev').each(function (elmPrev) {
            elmPrev.down('a').className = 'link';
            elmPrev.className = 'prev page_' + (pageValueInt - 1);
        });
    }
    if (pageValue == lastPage) {
        $$('ul.pagination li.next').each(function (elmNext) {
            elmNext.down('a').className = 'active';
            elmNext.className = 'next page_' + pageValue;
        });
    }
    else {
        $$('ul.pagination li.next').each(function (elmNext) {
            elmNext.down('a').className = 'link';
            elmNext.className = 'next page_' + (pageValueInt + 1);
        });
    }
}


//Pagination
function formatNumeration(callPage) {
    currentPage = callPage;
    var indice = 0;
    var futur_inner = '';
    if (currentPage > 3) {
        futur_inner += '<li class="page_1"><a href="#results" class="link" onclick="formatNumeration(1);">1</a></li>';
        futur_inner += '<li>...</li>';
    }
    for (indice = 1; indice <= lastPage; indice++) {
        if ((currentPage - 2) <= indice && indice <= (currentPage + 2)) {
            if (currentPage == indice) {
                futur_inner += "<li class=\"page_" + indice + "\"><a href=\"\#results\" class=\"active\" onclick=\"formatNumeration(" + indice + ");\">" + currentPage + "</a></li>";
            }
            else {
                futur_inner += "<li class=\"page_" + indice + "\"><a href=\"\#results\" class='link' onclick='formatNumeration(" + indice + ");'>" + indice + "</a></li>";
            }
        }
    }
    if ((lastPage - currentPage) > 2) {
        futur_inner += "<li>...</li>";
        futur_inner += "<li class=\"page_" + lastPage + "><a href='#results' class='link' onclick='formatNumeration(" + lastPage + ");'>" + lastPage + "</a></li>";
    }
    $$('ul.numbers-list').each(function (elmul) {
        elmul.innerHTML = futur_inner;
    });


    if (currentPage == '1') {
        $$('ul.pagination li.prev').each(function (elmPrev) {
            elmPrev.down('a').className = 'active';
        });
    }
    else {
        $$('ul.pagination li.prev').each(function (elmPrev) {
            elmPrev.down('a').className = 'link';

        });
    }
    if (currentPage == lastPage) {
        $$('ul.pagination li.next').each(function (elmNext) {
            elmNext.down('a').className = 'active';
        });
    }
    else {
        $$('ul.pagination li.next').each(function (elmNext) {
            elmNext.down('a').className = 'link';
        });
    }
    displayPage(currentPage);
}

function checkForm(oForm) {
    if ($('tb_territories').value != "") {
        sendRequest(oForm);
    }
}

//Pagination des avis consommateurs
//Reviews
function initializeEstablishmentReviews() {
    hideLoading();

    Event.observe('stay-types-select', 'change', function (event) {
        stayTypeToDisplay = this.value;
        callReviews(idE, stayTypeToDisplay, 1)
    });

    //Pagination des resultats - nombres
    $$('ul.reviews-pagination li.numbers ul li a').each(function (elmLiClicked) {
        Event.observe(elmLiClicked, 'click', function (event) {
            pageToDisplay = elmLiClicked.className.substring(5, 7);
            idsToDisplay = $('idStayType').value;
            callReviews(idE, idsToDisplay, pageToDisplay)
        }
        )
    });

    //Pagination des resultats - prev next
    $$('ul.reviews-pagination li.next a').each(function (elmLiNext) {
        Event.observe(elmLiNext, 'click', function (event) {
            pageToDisplay = elmLiNext.className.substring(5, 7);
            idsToDisplay = $('idStayType').value;
            callReviews(idE, idsToDisplay, pageToDisplay)
        });
    });

    //Pagination des resultats - prev next
    $$('ul.reviews-pagination li.prev a').each(function (elmLiPrev) {
        Event.observe(elmLiPrev, 'click', function (event) {
            pageToDisplay = elmLiPrev.className.substring(5, 7);
            idsToDisplay = $('idStayType').value;
            callReviews(idE, idsToDisplay, pageToDisplay)
        });

    });

}

// Avis consommateurs
function callReviews(idEstab, idStayType, numPage) {
    Element.show('ajax-results-loading');
    new Ajax.Updater('reviews', 'http://miniserv/skin3/consorzio/establishment-stay-reviews.aspx',
        { method: 'get', parameters: { idE: idEstab, idS: idStayType, numP: numPage }, onComplete: initializeEstablishmentReviews });
}


//Résultats de recherche
function initializeSearchResults() {
    // setSearchCookie();
    //Pagination des resultats - nombres
    $$('div.results ul.tabs li a').each(function (elm) {
        Event.observe(elm, 'click', function () {
            $$('div.results div.tabs-panel').each(function (tab) {
                tab.hide();
            });
            $$('div.results ul.tabs li').each(function (tabLi) {
                tabLi.className = '';
            });
            elm.up().addClassName('active');
            var tabToDisplay = this.href.split('#');
            $(tabToDisplay[1].sub('#', '')).show();
            if (tabToDisplay[1] == "results-map")
                initMyGmap();
        });
    });



    //Pagination des resultats - nombres
    $$('ul.pagination li.numbers ul li').each(function (elmLiClicked) {
        Event.observe(elmLiClicked, 'click', function (event) {
            currentPage = elmLiClicked.className.substring(5, 7);
            displayPage(elmLiClicked.className.substring(5, 7));
        }
        )
    });

    //Pagination des resultats - prev next
    $$('ul.pagination li.next').each(function (elmLiNext) {
        Event.observe(elmLiNext, 'click', function (event) {
            formatNumeration(currentPage + 1);
        });
    });

    //Pagination des resultats - prev next
    $$('ul.pagination li.prev').each(function (elmLiPrev) {
        Event.observe(elmLiPrev, 'click', function (event) {
            formatNumeration(currentPage - 1);
        });

    });


    $$('div#results-map ul.pagination li').each(function (elm) {
        Event.observe(elm, 'click', function (e) {
            initMyGmap();
        });
    });

    //initialisation de la pagination
    formatNumeration(1);

    //if (argumentForKml != null) initMyGmap();
}

//GGmap
function initializeGoogleMap() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("establishment-map"), { size:
      new GSize(468, 300)
        });

        var icon = new GIcon();
        icon.image = "style/images/marker.png";
        icon.iconSize = new GSize(27, 40);
        icon.iconAnchor = new GPoint(6, 20);
        icon.infoWindowAnchor = new GPoint(5, 1);

        map.setCenter(new GLatLng(latitude, longitude), 12);
        var mapControl = new GMapTypeControl();
        map.addControl(mapControl);
        map.addControl(new GLargeMapControl());

        var etablissement = new GLatLng(latitude, longitude);
        var marker = new GMarker(etablissement, icon);
        map.addOverlay(marker);

    }
}


function initializeProductSearchForm() {
    searchForm = new SearchForm(url_result);
    selectSejour = new SelectSejour('', 'arrivalDate', 'departureDate');
    searchForm.SetPopup(false);
    //initSearchCookie()
    initProductSearchCookie();
    $$('input.dates').each(function (elm) {
        Event.observe(elm, 'focus', function (e) {
            elm.className = 'dates active';
        });
    });
}


function unCheckCb(idCb) {
    if ($(idCb).checked) { $(idCb).checked = false; }
}


function hideLoading() {
    $('ajax-results-loading').hide();
}

//Centrer un élément
Position.center = function (element) {
    var options = Object.extend({
        zIndex: 999,
        update: false
    }, arguments[1] || {});
    element = $(element)
    if (!element._centered) {
        Element.setStyle(element, { position: 'absolute', zIndex:
options.zIndex
        });
        element._centered = true;
    }
    var dims = Element.getDimensions(element);
    Position.prepare();
    var winWidth = self.innerWidth ||
document.documentElement.clientWidth || document.body.clientWidth || 0;
    var winHeight = self.innerHeight ||
document.documentElement.clientHeight || document.body.clientHeight || 0;
    var offLeft = (Position.deltaX + Math.floor((winWidth - dims.width
) / 2));
    var offTop = (Position.deltaY + Math.floor((winHeight - dims.height
) / 2));
    element.style.top = ((offTop != null && offTop > 0) ? offTop : '0')
+ 'px';
    element.style.left = ((offLeft != null && offLeft > 0) ? offLeft :
'0') + 'px';
    if (options.update) {
        Event.observe(window, 'resize', function (evt) {
            Position.center(element);
        }, false);
        Event.observe(window, 'scroll', function (evt) {
            Position.center(element);
        }, false);
    }
}


//Tooltips
var tooltip = function () {
    var id = 'tooltip';
    var top = 3;
    var left = 3;
    var maxw = 180;
    var speed = 10;
    var timer = 20;
    var endalpha = 95;
    var alpha = 0;
    var tt, h;
    var ie = document.all ? true : false;
    return {
        show: function (v, w) {
            if (tt == null) {
                tt = document.createElement('div');
                tt.setAttribute('id', id);
                document.body.appendChild(tt);
                tt.style.opacity = 0;
                tt.style.filter = 'alpha(opacity=0)';
                document.onmousemove = this.pos;
            }
            tt.style.display = 'block';
            tt.innerHTML = v;
            tt.style.width = w ? w + 'px' : 'auto';
            if (!w && ie) {
                tt.style.width = tt.offsetWidth;
            }
            if (tt.offsetWidth > maxw) { tt.style.width = maxw + 'px' }
            h = parseInt(tt.offsetHeight) + top;
            clearInterval(tt.timer);
            tt.timer = setInterval(function () { tooltip.fade(1) }, timer);
        },
        pos: function (e) {
            var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
            var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
            tt.style.top = (u - h) + 'px';
            //tt.style.left = (l + left) + 'px';
            tt.style.left = '155px';
        },
        fade: function (d) {
            var a = alpha;
            if ((a != endalpha && d == 1) || (a != 0 && d == -1)) {
                var i = speed;
                if (endalpha - a < speed && d == 1) {
                    i = endalpha - a;
                } else if (alpha < speed && d == -1) {
                    i = a;
                }
                alpha = a + (i * d);
                tt.style.opacity = alpha * .01;
                tt.style.filter = 'alpha(opacity=' + alpha + ')';
            } else {
                clearInterval(tt.timer);
                if (d == -1) { tt.style.display = 'none' }
            }
        },
        hide: function () {
            clearInterval(tt.timer);
            tt.timer = setInterval(function () { tooltip.fade(-1) }, timer);
        }
    };
} ();




//Search form
function changeRegion(codePays) {
    var tab_listeRegions = getElementsByClassName('listeRegions');
    if (codePays != "") {
        for (i = 0; i < tab_listeRegions.length; i++) {
            tab_listeRegions[i].style.display = 'none'
        }
        $('listeRegions' + codePays).show();
        $('h_territoire').value = codePays;
    }
    if (codePays == "") {
        for (i = 0; i < tab_listeRegions.length; i++) {
            tab_listeRegions[i].style.display = 'none'
        }
    }
}

function selItemListBox(ListBox, itemValue) {
    if (ListBox) {
        var nbOptions = ListBox.options.length;
        for (i = 0; i <= nbOptions; i++) {
            if (ListBox[i].value == itemValue) {
                ListBox[i].selected = "selected";
                $('h_territoire').value = ListBox[i].value;
            }
        }
    }
}

function attribDestination(codeDestination) {
    $('h_territoire').value = codeDestination;
}


function closeopen() {
    if (window.opener && !window.opener.closed) { window.close(); }
}


function selItemListBox(ListBox, itemValue) {
    if (ListBox) {
        var nbOptions = ListBox.options.length;

        for (i = 0; i < nbOptions; i++) {
            if (ListBox[i].value == itemValue) {
                ListBox[i].selected = "selected";
            }
        }
    }
}


//Ouverture PopUp
function openPopUp(productId, divName, divTitle) {
    var popUpContent = $(divName + productId).innerHTML;
    var popUpWin = window.open("", "popUpWin", "location=no,scrollbars,left=30px,top=40px,height=400px,width=600px");
    popUpWin.document.write('<html>' +
        '<head>' +
        '<title>' + divTitle + '</title>' +
        '<style>body{font-size:12px;font-family:verdana;color:#000;line-height:20px}ul{padding-left:20px}.thumbs{text-align:center}.thumbs img{margin:5px;cursor:pointer}.main-picture-block{text-align:center}</style>' +
        '</head>' +
        '<body>' +
        '<div id="popUpContent">' +
        '</div>' +
        '</body>' +
      '</html>');
    popUpWin.document.close();
    popUpWin.document.getElementById("popUpContent").innerHTML += popUpContent;
}





//Affichage image
function displayPicture(idDiv, urlPicture) {
    $(idDiv).src = urlPicture;
}









//ajoute les dates de départ et d'arrivée en inpute hidden en haut de la page et les modifie en fonction des dates choisies par l'utilisateur
function modifHidden(mesDates) {
    if ($("datesejour") != null) {
        var mesDates = $("datesejour").value;
        var concatDates = String(mesDates);
        var arrivalDate = concatDates.substr(0, 10);
        var departureDate = concatDates.substr(11, 10);

        var divReception = $('hiddenzone');


        if ($("arrivalDate") && $("departureDate")) {

            divReception.removeChild($("arrivalDate"));
            divReception.removeChild($("departureDate"));
        }

        var monInput = document.createElement('input');
        monInput.type = "hidden";
        monInput.value = arrivalDate;
        monInput.name = "arrivalDate";
        monInput.id = "arrivalDate";

        var monInput2 = document.createElement('input');
        monInput2.type = "hidden";
        monInput2.value = departureDate;
        monInput2.name = "departureDate";
        monInput2.id = "departureDate";

        divReception.appendChild(monInput);
        divReception.appendChild(monInput2);
    }

}





//Trucs compliqués

Type.registerNamespace('Sys.Net');

Sys.Net.XMLHttpSyncExecutor = function () {
    if (arguments.length !== 0) throw Error.parameterCount();
    Sys.Net.XMLHttpSyncExecutor.initializeBase(this);

    var _this = this;
    this._xmlHttpRequest = null;
    this._webRequest = null;
    this._responseAvailable = false;
    this._timedOut = false;
    this._timer = null;
    this._aborted = false;
    this._started = false;

    this._responseData = null;
    this._statusCode = null;
    this._statusText = null;
    this._headers = null;

    this._onReadyStateChange = function () {
        if (_this._xmlHttpRequest.readyState === 4) {
            _this._clearTimer();
            _this._responseAvailable = true;

            _this._responseData = _this._xmlHttpRequest.responseText;
            _this._statusCode = _this._xmlHttpRequest.status;
            _this._statusText = _this._xmlHttpRequest.statusText;
            _this._headers = _this._xmlHttpRequest.getAllResponseHeaders();

            _this._webRequest.completed(Sys.EventArgs.Empty);
            if (_this._xmlHttpRequest != null) {
                _this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
                _this._xmlHttpRequest = null;
            }
        }
    }

    this._clearTimer = function this$_clearTimer() {
        if (_this._timer != null) {
            window.clearTimeout(_this._timer);
            _this._timer = null;
        }
    }

    this._onTimeout = function this$_onTimeout() {
        if (!_this._responseAvailable) {
            _this._clearTimer();
            _this._timedOut = true;
            _this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
            _this._xmlHttpRequest.abort();
            _this._webRequest.completed(Sys.EventArgs.Empty);
            _this._xmlHttpRequest = null;
        }
    }
}
function Sys$Net$XMLHttpSyncExecutor$get_timedOut() {
    /// <value type="Boolean"></value>
    if (arguments.length !== 0) throw Error.parameterCount();
    return this._timedOut;
}

function Sys$Net$XMLHttpSyncExecutor$get_started() {
    /// <value type="Boolean"></value>
    if (arguments.length !== 0) throw Error.parameterCount();
    return this._started;
}

function Sys$Net$XMLHttpSyncExecutor$get_responseAvailable() {
    /// <value type="Boolean"></value>
    if (arguments.length !== 0) throw Error.parameterCount();
    return this._responseAvailable;
}

function Sys$Net$XMLHttpSyncExecutor$get_aborted() {
    /// <value type="Boolean"></value>
    if (arguments.length !== 0) throw Error.parameterCount();
    return this._aborted;
}

function Sys$Net$XMLHttpSyncExecutor$executeRequest() {
    if (arguments.length !== 0) throw Error.parameterCount();
    this._webRequest = this.get_webRequest();

    if (this._started) {
        throw Error.invalidOperation(String.format(Sys.Res.cannotCallOnceStarted, 'executeRequest'));
    }
    if (this._webRequest === null) {
        throw Error.invalidOperation(Sys.Res.nullWebRequest);
    }

    var body = this._webRequest.get_body();
    var headers = this._webRequest.get_headers();
    this._xmlHttpRequest = new XMLHttpRequest();
    this._xmlHttpRequest.onreadystatechange = this._onReadyStateChange;
    var verb = this._webRequest.get_httpVerb();
    this._xmlHttpRequest.open(verb, this._webRequest.getResolvedUrl(), false); // False to call Synchronously
    if (headers) {
        for (var header in headers) {
            var val = headers[header];
            if (typeof (val) !== "function")
                this._xmlHttpRequest.setRequestHeader(header, val);
        }
    }

    if (verb.toLowerCase() === "post") {
        if ((headers === null) || !headers['Content-Type']) {
            this._xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        }

        if (!body) {
            body = "";
        }
    }

    var timeout = this._webRequest.get_timeout();
    if (timeout > 0) {
        this._timer = window.setTimeout(Function.createDelegate(this, this._onTimeout), timeout);
    }
    this._xmlHttpRequest.send(body);
    var isGecko = (document.addEventListener) ? true : false;
    try {
        if (isGecko) {

            ExecuteCallBackSJAX(Sys.Serialization.JavaScriptSerializer.deserialize(this._xmlHttpRequest.responseText));
            return true;
        }
    }
    catch (e) { return false; }
    this._started = true;
}

function Sys$Net$XMLHttpSyncExecutor$getAllResponseHeaders() {
    /// <returns type="String"></returns>
    if (arguments.length !== 0) throw Error.parameterCount();
    if (!this._responseAvailable) {
        throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'getAllResponseHeaders'));
    }

    return this._headers;
}

function Sys$Net$XMLHttpSyncExecutor$get_responseData() {
    /// <value type="String"></value>
    if (arguments.length !== 0) throw Error.parameterCount();
    if (!this._responseAvailable) {
        throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_responseData'));
    }

    return this._responseData;
}

function Sys$Net$XMLHttpSyncExecutor$get_statusCode() {
    /// <value type="Number"></value>
    if (arguments.length !== 0) throw Error.parameterCount();
    if (!this._responseAvailable) {
        throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_statusCode'));
    }

    return this._statusCode;
}

function Sys$Net$XMLHttpSyncExecutor$get_statusText() {
    /// <value type="String"></value>
    if (arguments.length !== 0) throw Error.parameterCount();
    if (!this._responseAvailable) {
        throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_statusText'));
    }

    return this._statusText;
}

function Sys$Net$XMLHttpSyncExecutor$get_xml() {
    /// <value></value>
    if (arguments.length !== 0) throw Error.parameterCount();
    if (!this._responseAvailable) {
        throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, 'get_xml'));
    }

    var xml = this._responseData;
    if ((!xml) || (!xml.documentElement)) {
        xml = new XMLDOM(this._responseData);
        if ((!xml) || (!xml.documentElement)) {
            return null;
        }
    }
    else if (navigator.userAgent.indexOf('MSIE') !== -1) {
        xml.setProperty('SelectionLanguage', 'XPath');
    }

    if ((xml.documentElement.namespaceURI === "http://www.mozilla.org/newlayout/xml/parsererror.xml") &&
        (xml.documentElement.tagName === "parsererror")) {
        return null;
    }

    if (xml.documentElement.firstChild && xml.documentElement.firstChild.tagName === "parsererror") {
        return null;
    }

    return xml;
}

function Sys$Net$XMLHttpSyncExecutor$abort() {
    if (arguments.length !== 0) throw Error.parameterCount();
    if (!this._started) {
        throw Error.invalidOperation(Sys.Res.cannotAbortBeforeStart);
    }

    if (this._aborted || this._responseAvailable || this._timedOut)
        return;

    this._aborted = true;

    this._clearTimer();

    if (this._xmlHttpRequest && !this._responseAvailable) {
        this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
        this._xmlHttpRequest.abort();

        this._xmlHttpRequest = null;
        var handler = this._webRequest._get_eventHandlerList().getHandler("completed");
        if (handler) {
            handler(this, Sys.EventArgs.Empty);
        }
    }
}

Sys.Net.XMLHttpSyncExecutor.prototype = {
    get_timedOut: Sys$Net$XMLHttpSyncExecutor$get_timedOut,
    get_started: Sys$Net$XMLHttpSyncExecutor$get_started,
    get_responseAvailable: Sys$Net$XMLHttpSyncExecutor$get_responseAvailable,
    get_aborted: Sys$Net$XMLHttpSyncExecutor$get_aborted,
    executeRequest: Sys$Net$XMLHttpSyncExecutor$executeRequest,
    getAllResponseHeaders: Sys$Net$XMLHttpSyncExecutor$getAllResponseHeaders,
    get_responseData: Sys$Net$XMLHttpSyncExecutor$get_responseData,
    get_statusCode: Sys$Net$XMLHttpSyncExecutor$get_statusCode,
    get_statusText: Sys$Net$XMLHttpSyncExecutor$get_statusText,
    get_xml: Sys$Net$XMLHttpSyncExecutor$get_xml,
    abort: Sys$Net$XMLHttpSyncExecutor$abort
}
Sys.Net.XMLHttpSyncExecutor.registerClass('Sys.Net.XMLHttpSyncExecutor', Sys.Net.WebRequestExecutor);
if (typeof (Sys) != 'undefined') {
    Sys.Application.notifyScriptLoaded();
}
var callBackSJAX;
function SetCallBackSJAX(callBack) {
    callBackSJAX = callBack;
}
function ExecuteCallBackSJAX(args) {
    if (callBackSJAX) {
        callBackSJAX(args);
        SetCallBackSJAX(null);
    }
}

function SJAX(methodName, argument, callBack) {
    SetCallBackSJAX(callBack);
    // Instantiate a WebRequest.
    var wRequest = new Sys.Net.WebRequest();
    // Set the request URL.
    wRequest.set_url(PageMethods.get_path() + "/" + methodName);
    // Set the request verb.
    wRequest.set_httpVerb('POST');
    var body = Sys.Serialization.JavaScriptSerializer.serialize(argument);
    wRequest.set_body(body);
    wRequest.get_headers()['Content-Type'] = 'application/json; charset=utf-8';

    var executor = new Sys.Net.XMLHttpSyncExecutor();
    wRequest.set_executor(executor);
    // Execute the request.
    wRequest.invoke();

    if (executor.get_responseAvailable()) {
        return executor.get_object();
    }
    return false;
}
// BetterInnerHTML v1.2, (C) OptimalWorks.net


