// GLOBALS
var AppConfig = {
    sid : $.cookie('PHPSESSID'),
    username : $.cookie('username')
}
var nl = "\n";
var userOnline = false;
function toggleOnlineView(o) {
    var classToShow= o?'.logged_in':'.visitor';
    var classToHide=!o?'.logged_in':'.visitor';

    if (o) userOnline = true;
    $(classToShow).show();
    $(classToHide).hide();
}

function doAction(formID, id, action) {
    act_string = new String(action);
    myRE = new RegExp("delete", "i");
    if (act_string.match(myRE)) {
        if (!window.confirm(window.localemsg['are_you_sure'])) return false;
    }
    $("#"+formID + " input[name=id]").val(id);
    if ($("#"+formID + " input[name=action]").length != 0) {
        $("#"+formID + " input[name=action]").remove();
    }
    $("#"+formID).attr("action", action);
    $("#"+formID).submit();
    return true;
}

$(document).ready(function() {
    $.ajaxSetup({
        cache: false
    }) // IE getJson fucking bugfix
    //    Check if user is online
    var d=new Date();
    var epoch=(d.getTime()-d.getMilliseconds())/1000;
    var ttl=180*60;
    var online=false;
    if ($.cookie('justlogged')&&(1==$.cookie('justlogged'))&&$.cookie('username')&&$.cookie('PHPSESSID')) {
        $.cookie('lastupdate', epoch, {
            path:'/'
        })
        $.cookie('justlogged', '', {
            expires:-1,
            path:'/'
        })
        online=true;
    } else if ($.cookie('lastupdate')&&((epoch-$.cookie('lastupdate'))<ttl)&&$.cookie('username')&&$.cookie('PHPSESSID')) {
        online=true;
    }
    if (online) {
        var timer=setInterval("keepAlive("+ttl+")", ttl/6*1000);
    }
    //    Show datas for logged in/logged out users

    toggleOnlineView(online);
    if (online) {
        if ('STANDART' !== $.cookie('PACKAGE') && $('body.ifgold').length != 0) {
            $('body').addClass('gold-user');
            $('body').addClass($.cookie('PACKAGE').toLowerCase()+'-user');
        }
        if ($('a.myusername').length != 0) {
            $('a.myusername').text($.cookie('username'));
        }
    }

    if (!online) {
        $('.content_back.searchResults .pager a').each(function(i, elem) {
            elem.href='/visitor/join1/';
        })
    }

    //    Loading APE
    if (AppConfig.username && 0 < AppConfig.username.length) {
        var host = document.location.host;
        if (host.indexOf('www.') === 0 || host.indexOf('wws.') === 0 || host.indexOf('wwn.') === 0) {
            host = host.substr(4);
        }
        var realplexor = new Dklab_Realplexor(
            "http://ape."+host+"/",  // Realplexor's engine URL
            "dating" // namespace (optional) *was sites_yehju*
            )

        //        realplexor.subscribe(AppConfig.sid, function() {})
        realplexor.subscribe('id_'+AppConfig.sid, function() {})
        realplexor.subscribe("mailnotif", function(data) {
            openMessagePopupDiv(data);
        })
        realplexor.execute();
    }

    //    Setting thumbs
    if ($('strong.showThumb').length!=0 && typeof $('strong.showThumb').imgPreview=='function') {
        $('strong.showThumb').imgPreview({
            srcAttr:'rel'
        })
    }
    if ($('.profile_photo_link').length!=0 && typeof $('.profile_photo_link').lightBox=='function') {
        if ($.cookie('username')) {
            if (typeof checkPersonalPhoto == "function") {
                if (checkPersonalPhoto()) {
                    $('.profile_photo_link').lightBox();
                } else {
                    $('.profile_photo_link').each(function(i, el) {
                        $(el).unbind();
                        $(el).attr("href", "#");
                        $(el).bind("click", __uploadPhotoAlert);
                    });
                }
            } else {
                $('.profile_photo_link').lightBox();
            }
        } else {
            $('.profile_photo_link').each(function(i, elem) {
                elem.onclick=function() {
                    alert(langLoginForLargePhotos);
                    return false;
                }
                elem.href='/visitor/loginpage/';
            })
        }
    }

    //    AJAX bulk checking online status of users on the page
    var id;
    var ids=[];

    $('em.man').add('em.woman').add('a.man').add('a.woman').add('div.man').add('div.woman').each(function(i, elem) {
        if (elem.id&&!$(elem).hasClass('online')&&''!=(id=elem.id.replace('user', '').replace(/_/g, '')))ids.push(id);
    })

    ids=jQuery.unique(ids);
    if (0!=ids.length) {
        var joinedids=ids.join(',');
        
        $.post("/users/checkOnlineStatus/", {
            ids: joinedids
        }, function(data) {
            if ('false'!=data) {
                userids=eval(data)
                $(userids).each(function(i, elem) {
                    $('.user_'+elem).addClass('online');
                })
            }
        })
    }

    //    Validate forms with 'validate' class
    if ($('form.validate').length!=0) {
        $('form.validate').validate();
    }

    // Submit forms by ENTER key <IE fix>
    if ($.browser.msie) {
        $(function() {
            $('input, select').keydown(function(e) {
                if (e.keyCode == 13) {
                    $(this).parents('form').submit();
                    return false;
                }
                return true;
            })
        })
    }

    //    Platinum bulk form
    if ($('#platinBulkForm').length!=0) {
        $("#useBulks").click(function () {
            $('#bulkForm').slideDown();
        })
        onCountryChange('#country', '#city');
        $(function(){
            $('#msg').keyup(function() {
                limitChars('msg', 500, 'charlimitinfo');
            })
        })
        var bForm = new bulkForm('platinBulkForm');
    }

    //    Login fields mask
    if ($('#loginLogin').length!=0) {
        masker('#loginLogin',langLogin);
        masker('#loginPassword', '****');
    }

    //    Login fields mask
    if ($('#loginLoginErkek').length!=0) {
        masker('#loginLoginErkek',langLogin);
        masker('#loginPasswordErkek', '****');
    }

    //    Login fields mask
    if ($('#loginLoginBayan').length!=0) {
        masker('#loginLoginBayan',langLogin);
        masker('#loginPasswordBayan', '****');
    }

    //    Write message form
    if ($('#writeMessageForm').length!=0 && $('#message_text').length!=0) {
        $("#writeMessageForm").submit(function () {
            if ($("#message_text").val().length<1) {
                alert(langMessageEmpty);
                return false;
            }
            return true;
        })
    }

    //    Login fields mask
    if ($('.kullanici').length!=0) {
        masker('.kullanici',langFillUsername);
    }

    $(function() {
        if ($(".datepicker").length!=0) {
            $(".datepicker").datepicker($.datepicker.regional['tr']);
            $( ".datepicker" ).datepicker( "option", "altField", '#datepickerfield' );
        }
    })

    if(userOnline && location.pathname.match(/^.*visitor\/home.*$/)) {
        $.getJSON('/visitor/inboxCount/', function(total) {
            if (false !== total) {
                $.cookie('msgTotal', total, {
                    path:'/'
                })
                mpStatusTextUpdate(total);
                if ($('#newMsgCounter').length!=0) {
                    if (total>0) {
                        $('#newMsgCounter').text(total);
                    } else {
                        $('#newMsgCounter').replaceWith('<small>'+langNoNewMsgs+'</small>');
                        $('#newMsgCounterTitle').text('');
                        $('#newMsgCounterFooter').text('');
                    }

                }
            }
        })
    }
    if(userOnline && !location.pathname.match(/^.*messages\/inbox.*$/)) {
        var total = $.cookie('msgTotal');
        mpStatusTextUpdate(total);
    }
    recheckOnline();
    if ($('#poetryAddForm').length!=0) {
        $('#poetryAddForm').submit(function () {
            if ($("#poetryAddForm input[name=title]").val().length <3 || $("#poetryAddForm textarea[name=text]").val().length <3) {
                alert (langPoertryEmptyFields);
                return false;
            }
            return true;
        })
    }
    if (userOnline && $(".new-year_pay").length!=0) {
        if ('STANDART' == $.cookie('PACKAGE')) {
            showPromoBanner();
        }
        $(".new-year_pay .close").click(function(){
            closePromoBanner();
            return false;
        })
        if(location.pathname.match(/^.*visitor\/buyMembership.*$/)
            || location.pathname.match(/^.*static\/bankdetails.*$/)) {
            $(".new-year_pay").attr("href","#subPromoBanner");
        }
    }
})

function showPromoBanner() {
    if(!$.cookie("hidePromoBanner")) {
        $(".new-year_pay").css('display','block');
    }
}

function closePromoBanner() {
    $(".new-year_pay").hide();
    createPromoCookie();

}

function createPromoCookie() {
    var now = new Date();
    var date = new Date(now.getFullYear(), now.getMonth(), now.getDate()+1);
    var expires = "; expires="+date.toGMTString();
    document.cookie = "hidePromoBanner=1"+expires+"; path=/";
}

function mpStatusTextUpdate(msgs) {
    if (1 > msgs) {
        $('#mpStatusBar').slideUp();
    } else {
        $('#mpStatusBar').slideUp('slow', function(){
            $('#mpStatusText').html(langNewMsgsAlertPre + msgs + langNewMsgsAlertPost);
            $('#mpTotal').html(msgs);
        })
        $('#mpStatusBar').slideDown();

        if ($('.fbNewMsgCount').length!=0) {
            if (msgs>0) {
                $('.fbNewMsgCount').text(msgs);
                $('.fbNewMsgCount').show();
            } else {
                $('.fbNewMsgCount').hide();
            }
        }
    }
}

function upcheck() {
    var ok = true;
    if (''==$("#loginLogin").val() || ''==$("#loginPassword").val()) {
        ok = false;
    }
    if (ok && (langLogin==$("#loginLogin").val() || '****'==$("#loginPassword").val())) {
        ok = false;
    }
    if (ok) {
        return true;
    }
    alert(langLoginPassCheck);
    return false;
}

function upcheckErkek() {
    var ok = true;
    if (''==$("#loginLoginErkek").val() || ''==$("#loginPasswordErkek").val()) {
        ok = false;
    }
    if (ok && (langLogin==$("#loginLoginErkek").val() || '****'==$("#loginPasswordErkek").val())) {
        ok = false;
    }
    if (ok) {
        return true;
    }
    alert(langLoginPassCheck);
    return false;
}

function upcheckBayan() {
    var ok = true;
    if (''==$("#loginLoginBayan").val() || ''==$("#loginPasswordBayan").val()) {
        ok = false;
    }
    if (ok && (langLogin==$("#loginLoginBayan").val() || '****'==$("#loginPasswordBayan").val())) {
        ok = false;
    }
    if (ok) {
        return true;
    }
    alert(langLoginPassCheck);
    return false;
}

var alertjoin=function() {
    alert(langAlertJoin);
    return false;
}

function openMessagePopupDiv(data) {
    //    Inspired by LightBox
    if ('message' == data.type) {
        mpStatusTextUpdate(data.total);
        $.cookie('msgTotal', data.total, {
            path:'/'
        });
    }
    var overlayBgColor='#000';
    var overlayOpacity=0.8;
    $('body').append('<div id="jquery-overlay"></div>');
    var arrPageSizes=getPageSize();
    var arrPageScroll=getPageScroll();
    $('#jquery-overlay').css({
        backgroundColor:overlayBgColor,
        opacity:overlayOpacity,
        width:arrPageSizes[0],
        height:arrPageSizes[1]
    }).fadeIn();
    $("#MessagePopup").show();
    $('#jquery-overlay').css({
        width:arrPageSizes[0],
        height:arrPageSizes[1]
    });
    $('#mpNick').html(data.from);
    $('#mpAge').html(data.senderAge);
    $('#mpCity').html(data.senderCity);
    $('#mpThumb').attr('src', data.thumb);
    $('#mpText').html(data.text);
    $('#MessagePopup').addClass(data.type);
    $('#MessagePopup').attr('type',data.type);
    $('#MessagePopup .inner .button-box').attr('oldtext', $('#MessagePopup .inner .button-box').text());
    $('#MessagePopup .inner .button-box').text(data.buttonText);
    $('#MessagePopup .inner .button-box').attr('href',data.linkUrl);
    $('#mpText').attr('href',data.linkUrl);
}

function closeMessagePopupDiv() {
    $('#jquery-overlay').remove();
    if ($('#MessagePopup').attr('type').length && '' != $('#MessagePopup').attr('type')) {
        $('#MessagePopup').removeClass($('#MessagePopup').attr('type'));
        $('#MessagePopup').attr('type','');
        $('#MessagePopup .inner .button-box').text($('#MessagePopup .inner .button-box').attr('oldtext'));
    }
    $('#MessagePopup').hide();
}

function openLoginDiv() {
    //    Inspired by LightBox
    var overlayBgColor='#000';
    var overlayOpacity=0.8;
    $('body').append('<div id="jquery-overlay"></div>');
    var arrPageSizes=getPageSize();
    var arrPageScroll=getPageScroll();
    $('#jquery-overlay').css({
        backgroundColor:overlayBgColor,
        opacity:overlayOpacity,
        width:arrPageSizes[0],
        height:arrPageSizes[1]
    }).fadeIn();
    $('#loginDiv').css({
        top:arrPageScroll[1]+(arrPageSizes[3]/10),
        left:arrPageScroll[0]
    }).show();
    $("#loginDiv").show();
    $('#jquery-overlay').css({
        width:arrPageSizes[0],
        height:arrPageSizes[1]
    });
    arrPageScroll=getPageScroll();
    $('#loginDiv').css({
        top:arrPageScroll[1]+(arrPageSizes[3]/10),
        left:arrPageScroll[0]
    });
}

function closeLoginDiv() {
    $('#jquery-overlay').remove();
    $('#loginDiv').hide();
}

function getPageSize() {
    var xScroll, yScroll;

    if (window.innerHeight&&window.scrollMaxY) {
        xScroll=window.innerWidth+window.scrollMaxX;
        yScroll=window.innerHeight+window.scrollMaxY;
    } else if (document.body.scrollHeight>document.body.offsetHeight) {
        xScroll=document.body.scrollWidth;
        yScroll=document.body.scrollHeight;
    } else {
        xScroll=document.body.offsetWidth;
        yScroll=document.body.offsetHeight;
    }

    var windowWidth, windowHeight;

    if (self.innerHeight) {
        if (document.documentElement.clientWidth) {
            windowWidth=document.documentElement.clientWidth;
        } else {
            windowWidth=self.innerWidth;
        }
        windowHeight=self.innerHeight;
    } else if (document.documentElement&&document.documentElement.clientHeight) {
        windowWidth=document.documentElement.clientWidth;
        windowHeight=document.documentElement.clientHeight;
    } else if (document.body) {
        windowWidth=document.body.clientWidth;
        windowHeight=document.body.clientHeight;
    }

    if (yScroll<windowHeight) {
        pageHeight=windowHeight;
    } else {
        pageHeight=yScroll;
    }

    if (xScroll<windowWidth) {
        pageWidth=xScroll;
    } else {
        pageWidth=windowWidth;
    }

    arrayPageSize=new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    return arrayPageSize;
}

function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
        yScroll=self.pageYOffset;
        xScroll=self.pageXOffset;
    } else if (document.documentElement&&document.documentElement.scrollTop) {
        yScroll=document.documentElement.scrollTop;
        xScroll=document.documentElement.scrollLeft;
    } else if (document.body) {
        yScroll=document.body.scrollTop;
        xScroll=document.body.scrollLeft;
    }
    arrayPageScroll=new Array(xScroll, yScroll);
    return arrayPageScroll;
}

function popitup(url) {
    newwindow=window.open(url, 'name', 'height=200, width=300');
    if (window.focus) {
        newwindow.focus();
    }
    return false
}

function popitupbig(url) {
    newwindow=window.open(url, 'name', 'height=600, width=750, scrollbars=1');
    if (window.focus) {
        newwindow.focus();
    }
    return false;
}

function pleaseregister() {
    alert('Siteyi kullanmaya devam etmek için lütfen kay\u0131t olun')
    document.location='/visitor/join1/';
}

function onBirthDateChange() {
    $('#birthday_selected').val('')
    if ('' != $('#reg_birthdateYear').val() &&
        '' != $('#reg_birthdateMonth').val() &&
        '' != $('#reg_birthdateDay').val() )
        {
        $('#birthday_selected').val('1');
    }
    $('#birthday_selected').valid();
}

function onEmailChange() {
    if (('' != $("#emailnameinput").val()) && ('' != $("#emailserverinput").val())) {
        $('#reg_email').val($('#emailnameinput').val()+'@'+$('#emailserverinput').val());
        $('#reg_email').valid();
    }
}

function onCountryChange(countryId, cityId) {
    if (typeof countryId=='undefined')countryId="#country"
    if (typeof cityId=='undefined')cityId="#city"
    $(countryId).val()!=1?$(cityId).attr('disabled', 'disabled'):$(cityId).attr('disabled', '')
}

var registration = {
    _form : null,
    _homepage : false,
    _disabled : false,

    checkLoginExistence : function(login, elementId) {
        $.get("/users/checkLoginExistence/?login="+login,
            function(data) {
                $("#"+elementId).html(eval(data) ? "Yes" : "No");
            })
    },

    submit : function() {
        this._form.submit();
    },

    onCountryChange : function () {

        ($('#reg_country').val() != 1)
        ? $('#reg_city').attr('disabled', 'disabled')
        : $('#reg_city').attr('disabled', '');
    },

    onBirthDateChange : function () {
        $('#birthday_selected').val('');

        if ('' != $('#reg_birthdateYear').val()
            && '' != $('#reg_birthdateMonth').val()
            && '' != $('#reg_birthdateDay').val()) {
            $('#birthday_selected').val('1');
        }

        $('#birthday_selected').valid();
    },

    onEmailChange : function () {
        if (('' != $("#emailnameinput").val()) && ('' != $("#emailserverinput").val())) {
            $('#reg_email').val($('#emailnameinput').val()+'@'+$('#emailserverinput').val());
            $('#reg_email').valid();
        }
    },

    hpShowErrorsHandler : function (errorMap, errorList) {
    /** dont show errors near fields on homepage **/
    },

    hpInvalidHandler : function (form, validator) {
        /** display errors only on submit **/
        var msg = "";
        for (i in validator.errorList) {
            msg += validator.errorList[i].message+"\n";
        }

        setTimeout(function () {
            alert(msg);
        }, 10);
    },

    init : function(form, homepage, disabled, resetBirthDate) {
        var ths = this

        form = $(form);
        homepage = homepage ? true : false;
        disabled = disabled ? true : false;
        resetBirthDate = resetBirthDate ? true : false;

        this._form = form;
        this._homepage = homepage;
        this._disabled = disabled;

        /** try to remove top login form **/
        try{
            $("#topLoginForm").remove();
        } catch (err) {

        }

        if (disabled) {
            form.find("select, input").attr("disabled", true);
        } else {

            $.extend($.validator.messages, {
                required: langFieldRequired,
                email: langEmailUsed
            })


            $.validator.addMethod("username", function(value, element) {
                return value.match(/^[a-z\_IİÖÜÇĞŞıiöüçğş0-9]{4,32}$/i);
            })

            $.validator.addMethod("password", function(value, element) {
                return value.match(/[a-z\_IİÖÜÇĞŞıiöüçğş]+/i);
            })

            $.validator.addMethod("gender", function(value, element) {
                return value.match(/[FM]/i);
            })

            $.validator.addMethod("datusername", function(value, element) {
                var digits = value.match(/[0-9]/gi);
                return (!digits || digits.length <=4);
            })

            form.validate({

                invalidHandler : function (form, validator) {
                    if (ths._homepage) {
                        ths.hpInvalidHandler(form, validator);
                    }
                },

                showErrors: function(errorMap, errorList) {
                    if (ths._homepage) {
                        ths.hpShowErrorsHandler(errorMap, errorList);
                    } else {
                        this.defaultShowErrors();
                    }
                },
                rules: {
                    reg_username: {
                        required: true,
                        minlength: 4,
                        username: true,
                        datusername: true,
                        remote: "/users/checkRegLoginExistence"
                    },
                    reg_password: {
                        required: true,
                        minlength: 5,
                        maxlength: 20,
                        password: true
                    },
                    reg_gender:  {
                        required: true,
                        gender: true
                    },
                    reg_email: {
                        required: true,
                        email: true,
                        remote: "/users/checkRegEmailExistence"
                    },
                    birthday_selected: {
                        required: true
                    },
                    reg_agree: {
                        required: true
                    }
                },
                messages: {
                    reg_username: {
                        required: langEnterNewUsername,
                        minlength: langNickTooShort,
                        username: langNickInvalidChars,
                        datusername: langNick4digits,
                        remote: jQuery.validator.format(langUsernameExists)
                    },
                    reg_password: {
                        required: langEnterPassword,
                        minlength: langPasswordMinlength,
                        maxlength: langPasswordMaxlength,
                        password: langPasswordRegEx
                    },
                    reg_gender: {
                        required: langGenderRequired,
                        gender: langGenderRequired
                    },
                    reg_email: {
                        required: langEnterValidEmail,
                        remote: jQuery.validator.format(langEmailUsed)
                    },
                    reg_country: {
                        required: langCountryRequired
                    },
                    reg_city: {
                        required: langCityRequired
                    },
                    reg_birthdateYear: {
                        required: langBirthYearRequired
                    },
                    reg_birthdateMonth: {
                        required: langBirthMonthRequired
                    },
                    reg_birthdateDay: {
                        required: langBirthDayRequired
                    },
                    birthday_selected: {
                        required: langBirthDateRequired
                    },
                    reg_agree : {
                        required: langAgreeRequired
                    }
                },
                onkeyup : false /*function(element) {
                    if (!this.checkable(element)
                        && (element.name in this.submitted || !this.optional(element)) ) {
                        this.element(element)
                    }
                }*/
            })

            if (resetBirthDate) {
                ths.onBirthDateChange();
            }

            ths.onCountryChange();

            $('#reg_gender').change(function() {
                alert(langGenderCannotBeChanged);
            })

            $("#inputdropdown").click(function () {
                $(".innersambas").toggle();
            })

            $("#emailserverinput").focus(function () {
                $(".innersambas").show();
            })

            $("#emailserverinput").blur(function () {
                setTimeout("$('.innersambas').hide()", 600);
            })

            $(".mailserver").click(function () {
                $("#emailserverinput").val($(this).text());
                $(".innersambas").hide();
                ths.onEmailChange();
            })

            $("#emailnameinput").change(function () {
                ths.onEmailChange();
            })

            $("#emailserverinput").change(function () {
                ths.onEmailChange();
            })

            $('#reg_birthdateYear').change(function() {
                ths.onBirthDateChange();
            })

            $('#reg_birthdateMonth').change(function() {
                ths.onBirthDateChange();
            })

            $('#reg_birthdateDay').change(function() {
                ths.onBirthDateChange();
            })

            $('#reg_country').change(function() {
                ths.onCountryChange();
            })
        }
    }
}

function limitChars(textid, limit, infodiv) {
    var text = $('#'+textid).val();
    var textlength = text.length;
    if (textlength > limit) {
        $('#' + infodiv).html(langMaximumCharsPre + limit + langMaximumCharsPost);
        $('#'+textid).val(text.substr(0,limit));
        return false;
    } else {
        var left = limit - textlength;
        if (left == 0) {
            left='<strong style="color:red">0</strong>'
        }
        $('#' + infodiv).html(langRemainingCharsPre + left + langRemainingCharsPost);
        return true;
    }
}

function masker(el, value) {
    $(el).addClass('maska-zorro');
    $(el).val(value);
    $(el).unbind('focus');
    $(el).unbind('blur');
    $(el).bind('focus',function(){
        if (value == $(this).val()) {
            $(this).removeClass('maska-zorro');
            $(this).val('');
        }
    })
    $(el).bind('blur',function(){
        if ('' == $(this).val()) {
            $(this).addClass('maska-zorro');
            $(this).val(value);
        }
    })
}

function lostPassEmptyCheck() {
    var emailReg = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
    if(!emailReg.test($('#lostPassEmail').val())) {
        alert('Bu e-posta hesab\u0131 ile kay\u0131tl\u0131 kullan\u0131c\u0131 yok');
        return false;
    }
    return true;
}

function clear_div_elements(div) {
    $(div).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    })
}

function cc_disabled() {
    alert('Kredi kart\u0131 ile ödeme \u015fu an aktif değildir. Lütfen havale ile ödeyiniz');
    return false;
}

function recheckOnline() {
    $.get('/visitor/usess/', function(data) {
        toggleOnlineView(parseInt(data));
    });
}
