﻿/// <reference path="JQuery/jquery-1.3.1.js" />
// Global variables
var _timerProDropdown;
var timeout;

//Render the content part (between the first and last <!--Content--> comment)of a page into a div 
function renderPageIntoContainerCallback(response,a,b, options) {
    var responseText = response;
    var cleanedResponseText = responseText.substring(responseText.indexOf('<!--Content-->'), responseText.lastIndexOf('<!--Content-->'));

    if (options.indicator) options.indicator.hide();
    options.targetContainer.innerHTML = cleanedResponseText;

    if (options.callAfterSuccess)
        options.callAfterSuccess();
}

function renderPageIntoContainer(pageUrl, container, callback, delay, indicatorElement) {
    //Ext.Ajax.on("abort", renderPageFailure, null, { indicator: indicatorElement });
    if (delay) {
        window.clearTimeout(timeout);
        timeout = window.setTimeout(function() {
         $(container).load(pageUrl +"#content", null, callback);
        }, delay);
    } else {
        $(container).load(pageUrl + "#content", null, callback);
    }
}

function renderControl(control, container, parameters, callback, delay, indicator) {
   if (indicator) indicator.show();

   renderPageIntoContainer(baseUrl + "AJAX/RenderControl?control=" + control + "&" + parameters + "&originator=" + document.location, container, callback, delay, indicator);

}
$(document).ready(function () {
    
    // Dropdown menu for Pro pages
    $('.dd-menu').bind('mouseleave', function () {
        _timerProDropdown = setTimeout(function () { $('.dd-menu ul').slideUp('fast'); }, 1500);
    });
    $('.dd-menu ul').bind('mouseenter', function () {
        if (_timerLanguage != null) {
            clearTimeout(_timerProDropdown);
        }
    });
    $(document).bind('click', function (ev) {
        if ($(ev.target).parents('.dd-menu').length == 0) {
            $('.dd-menu ul').slideUp('fast');
        }
        else {
            $('.dd-menu ul').slideToggle('fast');
        }
        clearTimeout(_timerProDropdown);
    });

});
//End of file...
