jQuery(function () {
    jQuery('input[type=radio],input[type=checkbox]').css('border', 'none');
});

function getmypays() {
    jQuery('div.getmypays').css('left', (jQuery('img#moneyicon').position().left + 2) + 'px');
    if (jQuery('div.getmypays').css('display') == 'none') {
        jQuery('div.getmypays').css('display', 'block');
    } else {
        jQuery('div.getmypays').css('display', 'none');
    }
}

function getObject(id) {
    if (document.getElementById) {
        return document.getElementById(id);
    } else if (document.all) {
        return document.all[id];
    } else if (document.layers) {
        return document.layers[id];
    }
    return null;
}

function checkingCBox(obj, objname) {
    var objs = document.getElementsByName(objname);
    for (var i in objs)
    objs[i].checked = obj.checked;
}

function warning() {
    var el = document.getElementById('warning');
    if (el.style.display != 'none') {
        el.style.display = 'none';
        setCookie("warning", "none", "Sat, 21-Dec-2012 00:00:00 GMT", "/");
    }
}

function add(block, img, span) {
    var block = "block_" + block;
    var img = img + "st";
    var span = span + "st";
    document.getElementById(block).style.display = "block";
    document.getElementById(img).style.display = "none";
    document.getElementById(span).style.display = "none";
}

function del(block, img, span) {
    var block = "block_" + block;
    var img = img + "st";
    var span = span + "st";
    document.getElementById(block).style.display = "none";
    document.getElementById(img).style.display = "inline";
    document.getElementById(span).style.display = "block";
}

function getPopupWindow(title, data, width) {
    if (title != undefined && data != undefined) {
        var content = '';
        content += '<div class="popup-window">';
        content += '<table cellspacing="0" cellpadding="0" border="0">';
        content += '<tbody>';
        content += '<tr>';
        content += '<td class="tl"><img src="/images/transp.gif" alt="" title="" width="39" height="39" /></td>';
        content += '<td class="t"><img src="/images/transp.gif" alt="" title="" width="1" height="39" /></td>';
        content += '<td class="tr"><img src="/images/transp.gif" alt="" title="" width="39" height="39" /></td>';
        content += '</tr>';
        content += '<tr>';
        content += '<td class="l"><img src="/images/transp.gif" alt="" title="" width="39" height="1" /></td>';
        content += '<td class="c" valign="top"><a href="javascript:" onclick="getPopupWindow()"><img src="/images/popup-close.gif" alt="Закрыть" title="Закрыть" class="popup-close" /></a><h1>' + title + '</h1><br /><br /><div style="cursor:default;color:#000">' + data + '</div></td>';
        content += '<td class="r"><img src="/images/transp.gif" alt="" title="" width="39" height="1" /></td>';
        content += '</tr>';
        content += '<tr>';
        content += '<td class="bl"><img src="/images/transp.gif" alt="" title="" width="39" height="39" /></td>';
        content += '<td class="b"><img src="/images/transp.gif" alt="" title="" width="1" height="39" /></td>';
        content += '<td class="br"><img src="/images/transp.gif" alt="" title="" width="39" height="39" /></td>';
        content += '</tr>';
        content += '</tbody>';
        content += '</table>';
        content += '</div>';
        jQuery('body').prepend(content);
        var top = (jQuery('div.popup-window table').height()) / 2;
        var left = (jQuery('div.popup-window table').width()) / 2;
        jQuery('div.popup-window table').attr('style', 'margin-top:-' + top + 'px;margin-left:-' + left + 'px');
        if (width != undefined && width != '0') {
            left = width / 2;
            jQuery('div.popup-window table').attr('style', 'width:' + width + 'px !important;margin-left:-' + left + 'px !important;margin-top:-' + top + 'px !important');
        }
    } else {
        jQuery('div.popup-window').remove();
    }
}
var ArdzoCalendar = {
    LngEn: {
        _LNG_CAL_D1_: 'пн',
        _LNG_CAL_D2_: 'вт',
        _LNG_CAL_D3_: 'ср',
        _LNG_CAL_D4_: 'чт',
        _LNG_CAL_D5_: 'пт',
        _LNG_CAL_D6_: 'сб',
        _LNG_CAL_D7_: 'вс',
        _LNG_CAL_M1_: 'январь',
        _LNG_CAL_M2_: 'февраль',
        _LNG_CAL_M3_: 'март',
        _LNG_CAL_M4_: 'апрель',
        _LNG_CAL_M5_: 'май',
        _LNG_CAL_M6_: 'июнь',
        _LNG_CAL_M7_: 'июль',
        _LNG_CAL_M8_: 'август',
        _LNG_CAL_M9_: 'сентябрь',
        _LNG_CAL_M10_: 'октябрь',
        _LNG_CAL_M11_: 'ноябрь',
        _LNG_CAL_M12_: 'декабрь',
        _LNG_CAL_TODAY_: 'сегодня'
    },
    TargetIDObj: null,
    open: function (TargetID, Lang, dLeft, dTop) {
        if (Lang == 'ru') this.Lng = this.LngRu;
        else this.Lng = this.LngEn;
        if (document.getElementById('ardzo_calendar')) {
            this.close();
        } else {
            TargetIDObj = document.getElementById(TargetID);
            if (!dLeft) var dLeft = 0;
            if (!dTop) var dTop = 0;
            CalendarDiv = document.createElement('DIV');
            CalendarDiv.setAttribute('id', 'ardzo_calendar');
            var Content = '';
            Content = '<table border="0" cellpadding=0 cellspacing=0 width="100%"><tr><td><SELECT ID=month class="selects" onchange="ArdzoCalendar.display(this.selectedIndex, Year.selectedIndex+1900)">';
            Content += '<OPTION>' + this.Lng._LNG_CAL_M1_ + '<OPTION>' + this.Lng._LNG_CAL_M2_ + '<OPTION>' + this.Lng._LNG_CAL_M3_ + '<OPTION>' + this.Lng._LNG_CAL_M4_ + '<OPTION>' + this.Lng._LNG_CAL_M5_ + '<OPTION>' + this.Lng._LNG_CAL_M6_ + '<OPTION>' + this.Lng._LNG_CAL_M7_ + '<OPTION>' + this.Lng._LNG_CAL_M8_ + '<OPTION>' + this.Lng._LNG_CAL_M9_ + '<OPTION>' + this.Lng._LNG_CAL_M10_ + '<OPTION>' + this.Lng._LNG_CAL_M11_ + '<OPTION>' + this.Lng._LNG_CAL_M12_ + '</SELECT></td><td align=right>';
            Content += '<SELECT ID="year" class="selects" onchange="ArdzoCalendar.display(Month.selectedIndex,this.selectedIndex+1900)">';
            for (var i = 1900; i < 2100; i++) Content += "<OPTION>" + i;
            Content += '</SELECT></td></tr></table>';
            Content += '<table id="cal_table"><thead>';
            Content += '<tr>';
            Content += '<th class="header_rest">' + this.Lng._LNG_CAL_D7_ + '</th><th>' + this.Lng._LNG_CAL_D1_ + '</th><th>' + this.Lng._LNG_CAL_D2_ + '</th><th>' + this.Lng._LNG_CAL_D3_ + '</th><th>' + this.Lng._LNG_CAL_D4_ + '</th><th>' + this.Lng._LNG_CAL_D5_ + '</th><th>' + this.Lng._LNG_CAL_D6_ + '</th>';
            Content += '</tr></thead><tbody>';
            for (var i = 0; i < 6; i++) Content += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
            Content += "</tbody></table>";
            CalendarDiv.innerHTML = Content;
            CalendarDiv.style.position = 'absolute';
            CalendarDiv.style.left = this.calcLeft(TargetIDObj) + dLeft + 'px';
            CalendarDiv.style.top = this.calcTop(TargetIDObj) + TargetIDObj.offsetHeight + dTop + 'px';
            document.body.appendChild(CalendarDiv);
            CalTable = document.getElementById('cal_table');
            Month = document.getElementById('month');
            Year = document.getElementById('year');
            if (TargetIDObj) {
                var x_day = parseInt(TargetIDObj.value.substr(8, 2), 10);
                var x_month = parseInt(TargetIDObj.value.substr(5, 2), 10);
                var x_year = parseInt(TargetIDObj.value.substr(0, 4), 10);
                if (x_day > 0 && x_day <= this.getDaysInMonth(x_month, x_year) && x_month > 0 && x_month < 13 && x_year > 1899 && x_year < 2100) {
                    day = x_day;
                    Month.selectedIndex = x_month - 1;
                    Year.selectedIndex = x_year - 1900;
                    this.display(x_month - 1, x_year, x_day);
                } else this.setToday();
            } else this.setToday();
        }
    },
    close: function () {
        document.body.removeChild(CalendarDiv);
    },
    display: function (x_month, x_year, x_day) {
        x_month = parseInt(x_month, 10);
        x_year = parseInt(x_year, 10);
        var days = this.getDaysInMonth(x_month + 1, x_year);
        if (x_month > 1) var days_before = this.getDaysInMonth(x_month, x_year);
        else var days_before = this.getDaysInMonth(12, x_year - 1);
        if (day > days) day = days;
        if (!x_day) x_day = day;
        var curr_day = 0;
        var firstOfMonth = new Date(x_year, x_month, 1);
        var startingPos = firstOfMonth.getDay();
        for (i = 0; i < 42; i++) {
            curr_day = i - startingPos + 1;
            (CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].cellIndex > 0) ? CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].className = "day" : CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].className = "day_rest";
            if (curr_day <= 0) {
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].innerHTML = curr_day + days_before;
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].className = "day_disabled";
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].onmouseover = "";
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].onmouseout = "";
            } else if (curr_day > 0 && curr_day <= days) {
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].innerHTML = curr_day;
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].onmouseover = this.eventHandlerOver;
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].onmouseout = this.eventHandlerOut;
            } else if (curr_day > days) {
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].innerHTML = curr_day - days;
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].className = "day_disabled"
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].onmouseover = "";
                CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].onmouseout = "";
            }
            CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].onclick = this.eventHandlerClick;
            if (curr_day == x_day) CalTable.rows[Math.floor(i / 7) + 1].cells[i % 7].className = "day_selected";
        }
    },
    eventHandlerOver: function (anEvObj) {
        if (this.className != "day_selected") this.className = "day_mouseover";
    },
    eventHandlerOut: function (anEvObj) {
        if (this.className != "day_selected")(this.cellIndex > 0) ? this.className = "day" : this.className = "day_rest";
    },
    eventHandlerClick: function (anEvObj) {
        var str_day = "";
        var str_month = Month.selectedIndex + 1;
        var str_year = Year.selectedIndex + 1900;
        day = this.innerHTML;
        if (this.className == "day_disabled") {
            (parseInt(day, 10) > 20) ? ArdzoCalendar.setMonth(-1) : ArdzoCalendar.setMonth(1);
        } else {
            (day.toString().length == 1) ? str_day = "0" + day : str_day = day;
            if (str_month < 10) str_month = "0" + str_month;
            TargetIDObj.value = (str_day + "." + str_month + "." + str_year);
            ArdzoCalendar.close();
        }
    },
    setYear: function (val) {
        if (!isNaN(val)) {
            x_year = Year.selectedIndex + 1900;
            x_year = Number(x_year) + val;
            if (x_year < 1900) x_year = 1900;
            if (x_year > 2099) x_year = 2099;
            Year.selectedIndex = x_year - 1900;
            this.display(Month.selectedIndex, Year.selectedIndex + 1900);
        }
    },
    setMonth: function (val) {
        if (!isNaN(val)) {
            var i = 0;
            var x_month = Month.selectedIndex;
            i = x_month + val;
            x_month = i % 12;
            if (x_month < 0) x_month = x_month + 12;
            Month.selectedIndex = x_month;
            this.setYear(Math.floor(i / 12));
            this.display(Month.selectedIndex, Year.selectedIndex + 1900);
        }
    },
    setToday: function () {
        var now = new Date();
        var x_day = now.getDate();
        var x_month = now.getMonth();
        var x_year = now.getFullYear();
        day = x_day;
        Month.selectedIndex = x_month;
        Year.selectedIndex = x_year - 1900;
        this.display(Month.selectedIndex, Year.selectedIndex + 1900, x_day);
    },
    getDaysInMonth: function (x_month, x_year) {
        var days = '';
        if (x_month == 1 || x_month == 3 || x_month == 5 || x_month == 7 || x_month == 8 || x_month == 10 || x_month == 12) days = 31;
        else if (x_month == 4 || x_month == 6 || x_month == 9 || x_month == 11) days = 30;
        else if (x_month == 2) {
            if (this.isLeapYear(x_year)) days = 29;
            else days = 28;
        }
        return (days);
    },
    isLeapYear: function (x_year) {
        if (((x_year % 4) == 0) && ((x_year % 100) != 0) || ((x_year % 400) == 0)) {
            return (true);
        } else {
            return (false);
        }
    },
    calcLeft: function (Obj) {
        var x_ret = 0;
        var oParent = Obj.offsetParent;
        if (oParent == null) return 0;
        else x_ret = Obj.offsetLeft + this.calcLeft(oParent);
        return x_ret;
    },
    calcTop: function (Obj) {
        var x_ret = 0;
        var oParent = Obj.offsetParent;
        if (oParent == null) return 0;
        else x_ret = Obj.offsetTop + this.calcTop(oParent);
        return x_ret;
    }
}

function ConfirmAndGo(message, title, url) {
    jConfirm(message, title, function (r) {
        if (r) {
            window.location = url;
        }
    });
}

function ConfirmAndGo_JQ(message, title, url, id) {
    message = upFirst(message);
    title = upFirst(title);
    jConfirm(message, title, function (r) {
        if (r) {
            jQuery.ajax({
                type: "POST",
                url: url,
                data: "id=" + id,
                cache: false,
                dataType: "json",
                success: function (result) {
                    ConfirmAndGoSuccess(result);
                }
            });
        }
    });
}

function upFirst(str) {
    var tmpStr = str.substring(0, 1).toUpperCase() + str.substring(1);
    return tmpStr;
}

function strpos(haystack, needle, offset) {
    var i = (haystack + '').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}
jQuery(document).ready(function () {});

function toggleObject(id) {
    jQuery('div[id!=' + id + '][rel~=popupwindow]').css('display', 'none');
    var myWidth = jQuery('div#' + id).width() / 2;
    var myHeight = jQuery('div#' + id).height() / 2;
    jQuery('div#' + id).css('margin', '-' + myHeight + 'px 0 0 -' + myWidth + 'px');
    if (jQuery('div#' + id).css('display') == 'none') {
        jQuery('div#' + id).css('display', 'block');
        jQuery('div#' + id + ' input[type=text]:first').focus();
        currentPopupWindow = id;
    } else {
        jQuery('div#' + id).css('display', 'none');
        currentPopupWindow = 'none';
    }
}

function trim(string) {
    return string.replace(/(^\s+)|(\s+$)/g, "");
}

function itErrorReport(id, name) {
    jQuery('#toErrorReport').val(id);
    jQuery('#nameErrorReport').html("<b>" + name + "</b>");
}(function (jQuery) {
    jQuery('a[data-reveal-id]').live('click', function (e) {
        e.preventDefault();
        var modalLocation = jQuery(this).attr('data-reveal-id');
        jQuery('#' + modalLocation).reveal(jQuery(this).data());
    });
    jQuery.fn.reveal = function (options) {
        var defaults = {
            animation: 'fadeAndPop',
            animationspeed: 300,
            closeonbackgroundclick: true,
            dismissmodalclass: 'close-reveal-modal'
        };
        var options = jQuery.extend({}, defaults, options);
        return this.each(function () {
            var modal = jQuery(this),
                topMeasure = parseInt(modal.css('top')),
                topOffset = modal.height() + topMeasure,
                locked = false,
                modalBG = jQuery('.reveal-modal-bg');
            if (modalBG.length == 0) {
                modalBG = jQuery('<div class="reveal-modal-bg" />').insertAfter(modal);
            }
            modal.bind('reveal:open', function () {
                modalBG.unbind('click.modalEvent');
                jQuery('.' + options.dismissmodalclass).unbind('click.modalEvent');
                if (!locked) {
                    lockModal();
                    if (options.animation == "fadeAndPop") {
                        modal.css({
                            'top': jQuery(document).scrollTop() - topOffset,
                            'opacity': 0,
                            'visibility': 'visible'
                        });
                        modalBG.fadeIn(options.animationspeed / 2);
                        modal.delay(options.animationspeed / 2).animate({
                            "top": jQuery(document).scrollTop() + topMeasure + 'px',
                            "opacity": 1
                        }, options.animationspeed, unlockModal());
                    }
                    if (options.animation == "fade") {
                        modal.css({
                            'opacity': 0,
                            'visibility': 'visible',
                            'top': jQuery(document).scrollTop() + topMeasure
                        });
                        modalBG.fadeIn(options.animationspeed / 2);
                        modal.delay(options.animationspeed / 2).animate({
                            "opacity": 1
                        }, options.animationspeed, unlockModal());
                    }
                    if (options.animation == "none") {
                        modal.css({
                            'visibility': 'visible',
                            'top': jQuery(document).scrollTop() + topMeasure
                        });
                        modalBG.css({
                            "display": "block"
                        });
                        unlockModal()
                    }
                }
                modal.unbind('reveal:open');
            });
            modal.bind('reveal:close', function () {
                if (!locked) {
                    lockModal();
                    if (options.animation == "fadeAndPop") {
                        modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
                        modal.animate({
                            "top": jQuery(document).scrollTop() - topOffset + 'px',
                            "opacity": 0
                        }, options.animationspeed / 2, function () {
                            modal.css({
                                'top': topMeasure,
                                'opacity': 1,
                                'visibility': 'hidden'
                            });
                            unlockModal();
                        });
                    }
                    if (options.animation == "fade") {
                        modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
                        modal.animate({
                            "opacity": 0
                        }, options.animationspeed, function () {
                            modal.css({
                                'opacity': 1,
                                'visibility': 'hidden',
                                'top': topMeasure
                            });
                            unlockModal();
                        });
                    }
                    if (options.animation == "none") {
                        modal.css({
                            'visibility': 'hidden',
                            'top': topMeasure
                        });
                        modalBG.css({
                            'display': 'none'
                        });
                    }
                }
                modal.unbind('reveal:close');
            });
            modal.trigger('reveal:open')
            var closeButton = jQuery('.' + options.dismissmodalclass).bind('click.modalEvent', function () {
                modal.trigger('reveal:close')
            });
            if (options.closeonbackgroundclick) {
                modalBG.css({
                    "cursor": "pointer"
                })
                modalBG.bind('click.modalEvent', function () {
                    modal.trigger('reveal:close')
                });
            }
            jQuery('body').keyup(function (e) {
                if (e.which === 27) {
                    modal.trigger('reveal:close');
                }
            });

            function unlockModal() {
                locked = false;
            }

            function lockModal() {
                locked = true;
            }
        });
    }
})(jQuery);

jQuery("#daleebut").live('click',function () { 

    jQuery("#dalee").fadeIn(500);
    jQuery("#daleebut").hide(); 
    }
);

jQuery(".more").live('click',function () {  
    jQuery("#moredlya").fadeIn(500);
    jQuery(".more").hide(); 
    return false;
    
    }
); 
