/* --- js/generic.js -- start -------------------------------------- *
 * 
 * $Id: generic.js 562 2011-09-26 23:16:02Z vugluskr $
 *
 * Require:
 */

// Взято с javascript.ru

// Создает "цепочку" наследования между "объектами".
function extend(Child, Parent) {
    var F = function() { };
    F.prototype = Parent.prototype;
    Child.prototype = new F();
    Child.prototype.constructor = Child;
    Child.superclass = Parent.prototype;
}

// копирует все свойства из src в dst,
// включая те, что в цепочке прототипов src до Object
function mixin(dst, src){
    // tobj - вспомогательный объект для фильтрации свойств,
    // которые есть у объекта Object и его прототипа
    var tobj = {}
    for(var x in src){
        // копируем в dst свойства src, кроме тех, которые унаследованы от Object
        if((typeof tobj[x] == "undefined") || (tobj[x] != src[x])){
            dst[x] = src[x];
        }
    }
    // В IE пользовательский метод toString отсутствует в for..in
    if(document.all && !document.isOpera){
        var p = src.toString;
        if(typeof p == "function" && p != dst.toString && p != tobj.toString &&
         p != "\nfunction toString() {\n    [native code]\n}\n"){
            dst.toString = src.toString;
        }
    }
}

// Переводит секунды в массив hour,min,sec
function sec_to_hms(sec) {
    var t = new Array();

    t.unshift(sec % 60);
    sec -= t[0];
    t.unshift(sec % 3600);
    sec -= t[0];
    t[0] /= 60;
    t.unshift(sec / 3600);

    return t;
}
function sec_to_hmsstr(sec) {
    var t = sec_to_hms(sec);
    for (var idx = 0; idx < t.length; idx++)
	if (t[idx] < 10)
	    t[idx] = '0' + t[idx];
    return t;
}
if ($.blockUI != undefined) {
    var e = document.createElement('span');
    e.appendChild(document.createTextNode('Загрузка... '));
    e.appendChild(document.createElement('img'));
    e = e.lastChild;
    e.setAttribute('src', '/res/wait.gif');
    e.setAttribute('alt', 'ожидание');
    e = e.parentNode;
    var msg_ajax_wait = e;

    $.blockUI.defaults['message'] = e;
}
/* --- js/generic.js -- start -------------------------------------- */

