﻿
var j$ = jQuery.noConflict();

//Dialog
//var attribute;
function DialogBegin() {
    //attribute = this.id;
    j$("#dialog").html("<div style=\" text-align:center;  padding-top:30px; \"><img alt=\"\" title=\"\" src=\"http://club.finamauto.ru/Content/ajax.gif\" /></div>");
}

function DialogSuccess(t, w, h) {
    j$("#dialog").dialog({
        height: h,
        width:w,
        draggable: false,
        closeOnEscape: true,
        resizable: false,
        title: t,
        autoOpen: true,
        modal: true
    });

}

function DialogBegin2(trg) {
    //attribute = this.id;
    j$(trg).html("<div style=\" text-align:center;  padding-top:30px; \"><img alt=\"\" title=\"\" src=\"http://club.finamauto.ru/Content/ajax.gif\" /></div>");
}

function DialogSuccess2(t, trg, w, h) {
    j$(trg).dialog({
        height: h,
        width: w,
        draggable: false,
        closeOnEscape: true,
        resizable: false,
        title: t,
        autoOpen: true,
        modal: true
    });

}


function DialogSimpleSuccess(t,autoclose) {
    
    j$("#dialog").dialog({
        draggable: false,
        closeOnEscape: true,
        resizable: false,
        title: t,
        autoOpen: true,
        modal: true

    });
    if(autoclose==true)
    {
        DialogFadePause(3000);
    }
}

function DialogClose(text) {
    j$("#dialog").html("<div style=\"text-align:center; color: red; padding-top: 15px; font-weight: bold;\">" + text + "</div>");
    DialogFade();
}

function DialogFadePause(delay) {
    j$("#dialog").fadeIn("normal", function() {
        j$.timer(delay, function(timer) {
            j$("#dialog").fadeOut("normal");
            timer.stop();
            setTimeout(DialogHide, 400);
        });
    });
}

function DialogFade() {
    j$("#dialog").fadeIn("normal", function() {
        j$.timer(1000, function(timer) {
            j$("#dialog").fadeOut("normal");
            timer.stop();
            setTimeout(DialogHide, 400);
        });
    });
}

function DialogHide() {
    j$("#dialog").dialog("destroy");
}

function DialogRefresh(array, boolFade, text) {
    if (array != null) {
        var list = array.split(",");
        for (var i = 0; i < list.length; i = i + 1) {
            j$("#" + list[i]).click();
        }
    }
    if (boolFade != null) {
        if (boolFade == true) {
            if (text == null) text = 'Data processing completed!';
            DialogClose(text);
        }
    }
}
//Subrun
function SubrunBegin() {
    j$("#subrun").html("<div style=\"padding: 20px 20px 20px 20px;\"><img alt=\"\" title=\"\" src=\"http://club.finamauto.ru/Files/Images/ajax-loader-big.gif\" /> Loading...</div>");
}

function SubrunSuccess(t, w, h) {
    j$("#subrun").dialog({
        draggable: true,
        closeOnEscape: false,
        resizable: true,
        title: t,
        autoOpen: true,
        width: w,
        height: h,
        modal: true,
        buttons: {
            "Close window": function() {
                SubrunFade();
            }
        }
    });
}

function SubrunClose(text) {
    j$("#subrun").html("<div style=\"text-align:center; color: red; padding-top: 15px; font-weight: bold;\">" + text + "</div>");
    SubrunFade();
}

function SubrunFade() {
    j$("#subrun").fadeIn("normal", function() {
        j$.timer(1000, function(timer) {
            j$("#subrun").fadeOut("normal");
            timer.stop();
            setTimeout(SubrunHide, 400);
        });
    });
}

function SubrunHide() {
    j$("#subrun").dialog("destroy");
}

function SubrunRefresh(array, boolFade, text) {
    if (array != null) {
        var list = array.split(",");
        for (var i = 0; i < list.length; i = i + 1) {
            j$("#" + list[i]).click();
        }
    }
    if (boolFade != null) {
        if (boolFade == true) {
            if (text == null) text = 'Data processing completed!';
            SubrunClose(text);
        }
    }
}
