$(function () {    $.mouseIsDown = false;   // Tracks status of mouse button    $(document).mousedown(function() {    $.mouseIsDown = true;      // When mouse goes down, set isDown to true    })    .mouseup(function() {    $.mouseIsDown = false;    // When mouse goes up, set isDown to false    });	$("#avtoriz_bg").height($("body").innerHeight());	    $(function(){        $('.themes-box .theme-imgs .one-img').hover(function(){            $('.one-img').removeClass('one-img_active');            $(this).addClass('one-img_active');            $('.theme-titles').html($(this).children('.display_none').html());        }, function(){})    })        $('#finance_dfGweRhd73 a').each(function(index, element){        $(element).attr('href', 'http://click.ubr.ua/goto?from=finance&path=' + $(element).attr('href'));    });        $('#login-show-pass').showPassword('.login-checker', {        text: 'Показать пароль',        className: 'showpass',        name: 'showpass'    });    //ubr tabs    $('.ubr_tabs ul li').click(function(){        if (!$(this).hasClass('disabled')){            $(this).parent('ul').children('li').removeClass('active');            $(this).addClass('active');            $(this).parent('ul').children('li').each(function(index, element){                $('#' + $(element).attr('for:')).hide();            })            $('#' + $(this).attr('for:')).show();            eval($(this).attr('callback:'));        }    });    $('.ubr_tabs ul li.active').click();    $('.col_m .news img, .main .news img').hover(        function(){            switch ($(this).attr('alt'))            {                case 'video':txt = 'Видео-новость';break;                case 'foto':txt = 'Фото-новость';break;                case 'analytics':txt = 'Аналитика';break;                default:txt = '';break;            }            $(this).parent().parent().attr('title', txt);        },        function(){            $(this).parent().parent().attr('title', '');    });        //$('#meta_news_block1641 a').each(function () { $(this).attr('href','http://ubr.ua/goto/?url='+encodeURIComponent($(this).attr('href')))});    //$('#ad_ph_2').each(function () {alert(123)});    $('#reklamaster_informer a').each(function () {$(this).attr('href','http://click.ubr.ua/goto?path=' + encodeURIComponent($(this).attr('href') + '&from=reklamaster_informer'))});	$('.glossary').columnize({width:340});	//var tabContainers = $('div.tabs > div');	//tabContainers.hide().filter(':first').show();        /* scroller */        ubr_scroller_locked = false;        ubr_scroller_scroll = function (direction, who)        {            if (!ubr_scroller_locked) {                ubr_scroller_locked = true;                scrollEasing = 'swing';                scrollFactor = direction == 'left' ? -1 : 1;                ab_parent = $(who).parent('.ubr_scroller');                scroller = $(ab_parent).children('.ubr_scroller_images');                tdPadding = parseInt($(scroller).find('td').css('padding-right').replace("px", ""));                tdWidth = parseInt($(scroller).find('td').css('width').replace("px", ""));                scrollerWidth = $(scroller).width();                currentPosition = $(scroller).scrollLeft();                tableWidth = $(scroller).children('table').width();                tr = $(scroller).find('tr');                pixelsToScroll = scrollerWidth + tdPadding;                // Определяем с какой скоростью прокручивать в зависимости от видимой области                scrollSpeed = pixelsToScroll > 400 ? 1500 : 1000;                numOfElements = parseInt(scrollerWidth / (tdWidth + tdPadding));                newPosition = currentPosition + ( pixelsToScroll * scrollFactor);                if (newPosition < 0)                {                    newPosition = 0;                }                //Проскок вправо                if ((scrollFactor > 0) && (newPosition + tdPadding >= tableWidth)) {                    for (i=0; i<numOfElements; i++)                    {                       $(tr).append('<td class="ubr_scroller_tmp_row">' + $(tr).find('td:eq('+i+')').html() + '</td>');                    }                    $(scroller).animate({scrollLeft: newPosition}, scrollSpeed, scrollEasing, function(){                        $(scroller).scrollLeft(0);                        $('.ubr_scroller_tmp_row').remove();                        ubr_scroller_locked = false;                    });                } else                //Проскок влево                if ((scrollFactor < 0) && (currentPosition == 0)) {                    lastTd = $(tr).find('td:last');                    for (i=numOfElements; i>0; i--)                    {                       $(tr).prepend('<td class="ubr_scroller_tmp_row">' + $(lastTd).html() + '</td>');                       lastTd = $(lastTd).prev();                    }                    currentPosition = scrollerWidth;                    $(scroller).scrollLeft(currentPosition);                    newPosition = currentPosition + ( pixelsToScroll * scrollFactor);                    $(scroller).animate({scrollLeft: newPosition}, scrollSpeed, scrollEasing, function(){                        $('.ubr_scroller_tmp_row').remove();                        $(scroller).scrollLeft(tableWidth - (scrollerWidth + tdPadding));                        ubr_scroller_locked = false;                    });                //Обыкновенный скроллинг                } else {                    //Контроль точности остановки скролинга (актуально для крайних элементов)                    while(newPosition>(tableWidth-pixelsToScroll))                    {                        newPosition = newPosition - (tdPadding/2);                    }                    $(scroller).animate({scrollLeft: newPosition}, scrollSpeed, scrollEasing, function(){                        ubr_scroller_locked = false;                    });                }            }        }        //Включаем кнопки скроллинга влево-вправо        $('.ubr_scroller_left').click(function(){            ubr_scroller_scroll('left', $(this));        });        $('.ubr_scroller_right').click(function(){            ubr_scroller_scroll('right', $(this));        });        //Убираем кнопки скроллинга в случае, если елементов не больше чем может вместиться в область        $('.ubr_scroller').each(function(index, element) {            scrollerElementsCount = $(element).find('.ubr_scroller_images tr td').size();            scroller = $(element).children('.ubr_scroller_images');            tdPadding = parseInt($(scroller).find('td').css('padding-right').replace("px", ""));            tdWidth = parseInt($(scroller).find('td').css('width').replace("px", ""));            scrollerWidth = $(scroller).width();            numOfElements = parseInt(scrollerWidth / (tdWidth + tdPadding));            if (scrollerElementsCount <= numOfElements) {                $(element).children('.ubr_scroller_left').unbind('click').addClass('nocursor').addClass('nobg');                $(element).children('.ubr_scroller_right').unbind('click').addClass('nocursor').addClass('nobg');            }        });        /* /scroller */        /* main indexes */        $('.mainpage_indexes_tab').click(function(){            $('.mainpage_indexes_tab').removeClass('active');            $('.mainpage_indexes').hide();            $('#' + $(this).attr('id') + '_table').show();            $(this).addClass('active');        });        /* /main indexes*/        /* main theme */        $('.main_story_block .frame').hover(function(){            $('.main_story_block .frame').removeClass('active');            $(this).addClass('active');            $('.main_story_block .img_and_descr').html($('#main_theme_' + $(this).text()).html());        }, function(){});        $('.main_story_block .frame').click(function(){            window.location = $('.main_story_block .img_and_descr').find('a').attr('href');        });        /* /main theme */        /* podpiska yandex app */        $('#yandexbtn').click(function(){            if ($('.block_type_6 .popup_yandex').css('display') == 'none') {                $('.block_type_6 .popup_yandex').show(400);            } else {                $('.block_type_6 .popup_yandex').hide(400);            }        });        $('.block_type_6 .popup_yandex').hover(function(){},        function(){            $('.block_type_6 .popup_yandex').hide(400);        });        /* /podpiska yandex app */    $('ul.tabNav li:nth-child(1),ul.tabNav3 li:nth-child(1)').addClass('first');    $('div.tabs table tr').filter(':even').addClass('even');    $('.fourblock div.tabs table tr').filter(':odd').addClass('even');    $('.fourblock div.tabs table tr').filter(':even').removeClass('even');    $('.tabl2 tr').filter(':odd').addClass('even');    $('.petrol tr').filter(':odd').addClass('odd');    var petrolSortImg = $('.petrol img');    petrolSortImg.parent().addClass('sorted');    var sortindex = petrolSortImg.parent().children().index(petrolSortImg);    petrolSortImg.parent().parent().parent().parent().children('.price').html('2');    //$('.petrol td:eq('+sortindex+')').addClass('sorted1');        $('div#comments div.comment').filter(':odd').addClass('odd');        $('div.tabs ul.tabNav a,div.tabs ul.tabNav3 a').click(function () {        tabContainers.hide();        tabContainers.filter(this.hash).show();        $('div.tabs ul.tabNav a,div.tabs ul.tabNav3 a').removeClass('selected');        $(this).addClass('selected');        return false;    }).filter(':first').click();    //$('#menu ul li a').filter(':last').addClass('last');    //$('#level2 li a:first').addClass('first');    $('div#where_see_ubr').hover (function() {        $('#where_see_ubr div').css('display', 'block');    },    function() {        $('#where_see_ubr div').css('display', 'none');    });    $("a.last").hover(function () {    $(this).parents("ul").addClass("hover");    },        function () {		    $(this).parents("ul").removeClass("hover");		}	);    $('#drop2, #dropd2 button').click(function () {        $("#dropd2").toggle();    });    $('#drop').click(function () {        $("#dropd").toggle();    });        $('#enter,.close,#expert_enter').click(function () {        $("#avtoriz,#avtoriz_bg").toggle();        $("#avtoriz").css('top', $(window).scrollTop()+210+'px');    });	    	    $('.add_comment').click(function () {        $(".comment_form").toggle();        if ($(".add_comment").hasClass('rise'))        {            $(".add_comment").removeClass('rise');        }        else        {            $(".add_comment").addClass('rise');        }    });	    $('#sign-up').click(function () {        sign_up_in('up');    });    $('#sign-in').click(function () {        sign_up_in('in');    });			$('#move_to_add_comment').click(function () {		window.location='#comment';		$(".add_comment").addClass('rise');		$(".comment_form").toggle();	});				$('#move_to_all_video').click(function () {		window.location='#allvideo';	});		    $('.view_video').click(function () {        if ($(".view_video").hasClass('rise'))        {            $(".view_video").removeClass('rise');            $("#view_video").show();        }        else        {            $(".view_video").addClass('rise');            $("#view_video").hide();        }    });	$('.more_info, .close2').click(function () {		$("#info").toggle();	});		/**	 * Прокрутка в странице новости блок "новости по теме"	 */	$('.thirdcolumn #scroll_right').click(function() {		beforescroll = $('#theme_scroller').scrollTop();		$('#theme_scroller').scrollTop($('#theme_scroller').scrollTop() + $('#theme_scroller').height());		if (beforescroll == $('#theme_scroller').scrollTop()) {            $('#theme_scroller').scrollTop(0);		}	});	$('.thirdcolumn #scroll_left').click(function() {		beforescroll = $('#theme_scroller').scrollTop();		$('#theme_scroller').scrollTop($('#theme_scroller').scrollTop() - $('#theme_scroller').height());		if (beforescroll == $('#theme_scroller').scrollTop()) {			$('#theme_scroller').scrollTop(9999999);		}	});    $('#analytics_right').click(function() {        beforescroll = $('#analytics_scroll').scrollTop();        $('#analytics_scroll').scrollTop($('#analytics_scroll').scrollTop() + $('#analytics_scroll').height());        if (beforescroll == $('#analytics_scroll').scrollTop()) {            $('#analytics_scroll').scrollTop(0);        }    });    $('#analytics_left').click(function() {        beforescroll = $('#analytics_scroll').scrollTop();        $('#analytics_scroll').scrollTop($('#analytics_scroll').scrollTop() - $('#analytics_scroll').height());        if (beforescroll == $('#analytics_scroll').scrollTop()) {            $('#analytics_scroll').scrollTop(9999999);        }    });		$('a.selAll').click(function() {		$('.deliveryCheckbox').attr('checked', 'checked');	});	$('a.unselAll').click(function() {		$('.deliveryCheckbox').attr('checked', '');	});		/**	 * Информер "Ведущие UBR"	 */		//Вычисляем максимальный ID ведущего новостей	$.maxleaderid 	= ($("#all_leaders > div").length/2)-1;	//Выбираем случайного первого ведущего	$.currentleader = Math.floor(Math.random() * ($.maxleaderid+1) );		//Проставляем лейбл и картинку случайно выбранного ведущего	$('div#li_label').html($('div#leader_label_'+$.currentleader).html());	$('img#li_img').attr('src', $('div#leader_img_'+$.currentleader).html());	$('img#li_img').attr('width', '146');	$('img#li_img').attr('height', '218');		//Действия при клике на кнопку "листать влево"	$('img#leaders_left').click(function(){		if ($.currentleader > 0) {			$.currentleader--;		} else if ($.currentleader < 1) {			$.currentleader = $.maxleaderid;		}		$('div#li_label').html($('div#leader_label_'+$.currentleader).html());		$('img#li_img').attr('src', $('div#leader_img_'+$.currentleader).html());	});		//Действия при клике на кнопку "листать вправо"	$('img#leaders_right').click(function(){		if ($.currentleader < $.maxleaderid) {			$.currentleader++;		} else if ($.currentleader == $.maxleaderid) {			$.currentleader = 0;		}		$('div#li_label').html($('div#leader_label_'+$.currentleader).html());		$('img#li_img').attr('src', $('div#leader_img_'+$.currentleader).html());	});			/**	 * Cетка телевещания	 */	$('#setka_veschaniya table td').filter(':even').addClass('blue');	$('#setka_veschaniya table tr').filter(':even').addClass('odd');	$('#setka_veschaniya div#sv_first table tr').filter(':last').addClass('last');	$('#setka_veschaniya div#sv_second table tr').filter(':last').addClass('last');	$('#setka_veschaniya div#sv_second table td.blue').prev('td').addClass('rightb');        /**         * галерейка отелей         */        $.imagesCount = $('#imageB table tr td').length;        if ($.imagesCount<2) {            $('#btn_scroll_right').css('display', 'none');            $('#btn_scroll_left').css('display', 'none');        }                $('#btn_scroll_right').click(function() {            if ($('#imageB').scrollLeft() == (($('#imageB').width()*$.imagesCount)-$('#imageB').width()) ) {                $('#imageB').scrollLeft(0);            } else {                $('#imageB').animate({scrollLeft: $('#imageB').scrollLeft()+$('#imageB').width()}, '100');            }                    });        $('#btn_scroll_left').click(function() {            if ($('#imageB').scrollLeft() == 0 ) {                $('#imageB').scrollLeft( (($('#imageB').width()*$.imagesCount)-$('#imageB').width())  );            } else {                $('#imageB').animate({scrollLeft: $('#imageB').scrollLeft()-$('#imageB').width()}, '100');            }        });        $.mouseOnButton = false;        $('.expert_small button').hover(function(){$.mouseOnButton = true;},function(){$.mouseOnButton = false});        $('.expert_small').click(function(){            if (!$.mouseOnButton) {                window.location = ($(this).children('div.bottom').children('a').attr('href'));            }        });        });function sign_up_in (way){    if (way == 'up')    {        a_close = 'up';        a_open  = 'in';    }    else    {        a_open  = 'up';        a_close = 'in';    }    $('#sign-' + a_open).removeClass('active-tab');    $('#sign-' + a_close).addClass('active-tab');        $('.form-' + a_open).removeClass('active-tab');    $('.form-' + a_close).addClass('active-tab');}function setAnalytics(){    $.maxBlockId = $('#analytics_data ul').length;    $.randScrollTop = Math.floor(Math.random() * $.maxBlockId);    $('#inf_analytics').each(function () {         id = $('#newsId').val();        $('#inf_analytics_' + id).css('display','none');    });    $('#analytics_scroll').empty().append($('#analytics_data').html());    $.randScrollTop = $.randScrollTop * $('#analytics_scroll ul').height() ;    $('#analytics_scroll').scrollTop($.randScrollTop);}/** * Заполняем информер рейтигна новостей */function setRating(){    //Узнаём колличество групп к показу    $.maxrateId 	= Math.floor(($(".rating_row").length/3)+1);    //Считаем случайную группу к показу    $.currentGroup  = Math.floor(Math.random() * ($.maxrateId - 1) + 1);    for (i=1;i<=$.maxrateId;i++)    {        if (i!=$.currentGroup)        {            //Удаляем все группы не принадлежащие к текущей            $(".show_group_"+i).remove();        }    }    //убираем картинку крутящегося прелоадера    $("#rating_loader").remove();    //показываем все оставшиеся группы    $(".rating_row").removeClass('rating_row');    //разукрашиваем клеточки    $('table#ratinginfo tr').filter(':even').addClass('even');}/** * Фото-галерея */$(function() {   $.offset = 87;   $('.galleryline .one_prev').click( function () {       $('.galleryline .one_prev').removeClass('one_prev_act');       $(this).addClass('one_prev_act');       window.location = $('#gallery_path').html() + '/img' + $(this).children('img').attr('name') + '/scroll' + $('.galleryline').scrollLeft();   });   $('#prev_photo').click(function(){      scrollL = $('.galleryline').scrollLeft();      scrollR = scrollL + $.offset * 6;      prevPhoto = ($('.one_prev_act').children('img').attr('name')*1-1);      if ( (prevPhoto * $.offset) <= scrollL ) {          scrollL = prevPhoto * $.offset;      }      window.location = $('#gallery_path').html() + '/img' + prevPhoto + '/scroll' + scrollL;   });   $('#next_photo').click(function(){      $('.gallery_big_image img').click();   });   $('.gallery_big_image img, .gallery_big_image div, .gallery_big_image').click(function () {      scrollL = $('.galleryline').scrollLeft();      scrollR = scrollL + $.offset * 6;      nextPhoto = ($('.one_prev_act').children('img').attr('name')*1+1);      if ( (nextPhoto * $.offset) >= scrollR ) {         scrollL = nextPhoto * $.offset;      }      if (scrollL+10 >= $('.galleryline').children('table').width() ) {        nextPhoto = 0;        scrollL = 0;      }      window.location = $('#gallery_path').html() + '/img' + nextPhoto + '/scroll' + scrollL;   })    $('.gallery_big_image div').height($('.gallery_big_image img').height());    if ($.browser.msie) {            $.delayForScroller = 5;            $.sizeForScroll = 10;        } else {            $.delayForScroller = 15;            $.sizeForScroll = 2;        }        $('#gallery_scroll_right').hover(function(){        stopMove();        $.timer = setInterval('moveAreaR();', $.delayForScroller);    }, function(){stopMove()} );    $('#gallery_scroll_left').hover(function(){        stopMove();        $.timer = setInterval('moveAreaL();', $.delayForScroller);    }, function(){stopMove()} );        //$('#gallery_scroll_left, #gallery_scroll_right').hover(false, function(){stopMove()} );    $('img.social').hover(        function(){            $.old = $(this).attr('src');            $.url = $.old.substr(0, $.old.length-4) + '_active.gif';            $(this).attr('src', $.url);        },        function (){            $(this).attr('src', $.old);        }    );        });function moveAreaR() {	$('.galleryline').scrollLeft($('.galleryline').scrollLeft()+$.sizeForScroll);        initScrollButtons ();}function moveAreaL() {	$('.galleryline').scrollLeft($('.galleryline').scrollLeft()-$.sizeForScroll);        initScrollButtons ();}function stopMove() {	clearInterval($.timer);        delete $.timer;}function initScrollButtons (){   if ($('.galleryline').scrollLeft() == 0) {       $('#gallery_scroll_left').removeClass('gallery_scroll_left');       stopMove();   } else {       $('#gallery_scroll_left').addClass('gallery_scroll_left');   }      if ($('.galleryline').scrollLeft() == ( $('.galleryline table').width() - $('.galleryline').width() ) ) {       $('#gallery_scroll_right').removeClass('gallery_scroll_right');       stopMove();   } else {       $('#gallery_scroll_right').addClass('gallery_scroll_right');   }}function doVote(form){    a = $(form).find('input:checked').val();    q = $(form).children('input').val();    if (a && q)    {        $.post("/ajax/dovote",            {a: a, q: q},            function(json) {                results_table = $(form).parent().children('table.vote_results');                $(results_table).show();                $(form).remove();                json = eval(json);                count = json.count;                $('#overall'+q).text('Проголосовало всего: '+count);                answers = json.answers;                $('table.vote_results .vote_res_digits').each(function(index, element){                    votes = answers[$(element).attr('for_answer:')];                    percent = ((votes/count*100)+'').replace(/\.\d+/, '');                    $(element).text(percent + '% (' + votes + ')');                    $(element).next().find('div.vote_rate_line').css('width', percent+'%');                })            }, 'json'        );    }    return false;}function doVoteBig(form){    tbl = $(form).parent('table');    q = $(tbl).attr('for:');    a = $(tbl).find('input:checked').val();    if (a && q)    {        $.post("/ajax/dovote",            {a: a, q: q},            function(json) {                tbl.find('.vote_please').hide();                tbl.find('.results').show();                                json = eval(json);                count = json.count;                answers = json.answers;                $(tbl).find('.results b').each(function(index, element){                    votes = answers[$(element).attr('for:')];                    percent = votes/count*100;                    $(element).text(percent.toFixed(2)+'% (' + votes + ')');                    $(tbl).find('#rate_line_big_'+$(element).attr('for:')).css('width', percent.toFixed(0)+'%');                    $('#want_vote_'+q).remove();                    $(tbl).find('.overall').text(count);                    $(tbl).find('.lasttd').append('<div class="results"><strong>(Ваш голос учтен)</strong></div>');                })            }, 'json'        );    }    return false;}$(function(){    $('.dropdownSelector').each(function(index, element){        if ($(element).children('ul').children('li').length < 1)        {            $(element).remove();        }    });    $('.dropdownSelector').hover(function(){        $(this).children('ul').width($(this).parent().width());        if($(this).children('ul').width()<200)        {            $(this).children('ul').width(200);        }        $(this).children('ul').show()    }, function(){        $(this).children('ul').hide();    })    $('.vote_informer .mid_listalka #scroll_right').click(function(){        actBlock = $('.vote_informer').parent().find('.display_block');        $(actBlock).removeClass('display_block');        nextBlock = $(actBlock).next();        if (!$(nextBlock).hasClass('vote_informer')) {            nextBlock = $('.vote_informer').first();        }        $(nextBlock).addClass('display_block');    });    $('.vote_informer .mid_listalka #scroll_left').click(function(){        actBlock = $('.vote_informer').parent().find('.display_block');        $(actBlock).removeClass('display_block');        nextBlock = $(actBlock).prev();        if (!$(nextBlock).hasClass('vote_informer')) {            nextBlock = $('.vote_informer').last();        }        $(nextBlock).addClass('display_block');    });})$(function(){    addAvatarWindow = $('#add_avatar_window').html();    $('body').prepend('<div id="add_avatar_window">'+addAvatarWindow+'</div>');    $('#add_avatar_window .close').click(function(){        $('#add_avatar_window').hide('slow');        $("#avtoriz_bg").toggle();        jcrop_api.destroy();        $('#imgSendSubmit').html('');    });})function submitAvatarForm(){    origAction = $('#reg_form').attr('action');    origTarget = $('#reg_form').attr('target');    $('#reg_form').attr('target', 'imgSendSubmit');    $('#reg_form').attr('action', '/ajax/uploadavatar');    $('#reg_form').submit();    $('#reg_form').attr('target', origTarget);    $('#reg_form').attr('action', origAction);}formValidation = true;function onChangeAvatar(){    disableValidation();    submitAvatarForm();    enableValidation();    echoImgFlg = setInterval(echoImg,500);}function disableValidation(){    formValidation = false;}function enableValidation(){    formValidation = true;}function setCropCoords(coords){        rxGlobal = 100 / coords.w;        ryGlobal = 100 / coords.h;        coordsGlobal = coords;}function cropApply(){    //PreviewSet    $('.avatar_mother img').remove();    $('.avatar_mother').append('<img src="' + $('#cropbox').attr('src') + '" alt="preview" id="avatarCropImg" />');    $('#avatarCropImg').css({            width: Math.round(rxGlobal * $('#cropbox').width()) + 'px',            height: Math.round(ryGlobal * $('#cropbox').height()) + 'px',            marginLeft: '-' + Math.round(rxGlobal * coordsGlobal.x) + 'px',            marginTop: '-' + Math.round(ryGlobal * coordsGlobal.y) + 'px'    });    $('#avatar_x').val(coordsGlobal.x);    $('#avatar_y').val(coordsGlobal.y);    $('#avatar_w').val(coordsGlobal.w);    $('#avatar_h').val(coordsGlobal.h);    $('#avatar_ow').val($('#cropbox').width());    $('#avatar_oh').val($('#cropbox').height());    $('#avatar_name').val($('#cropbox').attr('src'));        $('#add_avatar_window').hide('slow');    $("#avtoriz_bg").toggle();    jcrop_api.destroy();    $('#imgSendSubmit').html('');}function changeDisplayName(){    nick    = $('input[name=nick]').val();    name    = $('input[name=name]').val();    surname = $('input[name=surname]').val();        pos     = $('#display_name').val();    str = '<option value="1" ' + (pos == 1 ? 'selected="selected"' : '') + '>' + nick + '</option>';    if (name != '')        str = str + '<option value="2" ' + (pos == 2 ? 'selected="selected"' : '') + '>' + name + '</option>';        if (surname != '')        str = str + '<option value="3" ' + (pos == 3 ? 'selected="selected"' : '') + '>' + surname + '</option>';        if (surname != '' && name != '')    {        str = str + '<option value="4" ' + (pos == 4 ? 'selected="selected"' : '') + '>' + name + ' ' + surname + '</option>';        str = str + '<option value="5" ' + (pos == 5 ? 'selected="selected"' : '') + '>' + surname + ' ' + name + '</option>';    }        $('#display_name').html(str);}function insNick(val){    if ($('input[name=nick]').val() == '')    {        $('input[name=nick]').val(val);        changeDisplayName();    }}function echoImg(){    sContent = document.getElementById('imgSendSubmit').contentWindow.document.documentElement;    ImageName = $(sContent).contents().find('span').text();    if (ImageName)    {        if (ImageName=='error')        {            clearInterval(echoImgFlg);        } else {            clearInterval(echoImgFlg);            $("#avtoriz_bg").show();            $("#add_avatar_window").css('top', $(window).scrollTop()+130+'px');                        $('#add_avatar_window .img img').remove();            $('#add_avatar_window .img').append('<img src="http://img.ubr.ua/tmp/'+ImageName+'" align="absmiddle" alt="preview" id="cropbox" />');            $('#cropbox').load(function(){                $('#add_avatar_window').show('slow', function(){                    origWidthAvatar = $('#add_avatar_window .img img').width();                    origHeightAvatar = $('#add_avatar_window .img img').height();                    avatar_max_width = $('#add_avatar_window .img').innerWidth();                    avatar_max_height = $('#add_avatar_window .img').innerHeight();                    $('#avatar_resized_koef').remove();                    if ((origWidthAvatar > avatar_max_width) || (origHeightAvatar > avatar_max_height))                    {                       if (origWidthAvatar > origHeightAvatar)                       {                           $('#add_avatar_window .img img').width(avatar_max_width);                           avatar_height = $('#add_avatar_window .img img').height();                           if (avatar_height > avatar_max_height)                           {                               $('#add_avatar_window .img img').height(avatar_max_height);                               $('#add_avatar_window .img img').width('auto');                           }                       }                       else                       {                           $('#add_avatar_window .img img').height(avatar_max_height);                           avatar_width = $('#add_avatar_window .img img').width();                           if (avatar_width > avatar_max_width)                           {                               $('#add_avatar_window .img img').width(avatar_max_width);                               $('#add_avatar_window .img img').width('auto');                           }                       }                                              $('#reg_form').append('<input type="hidden" name="avatar_resized_koef" value="' + origWidthAvatar / $('#add_avatar_window .img img').width() + '" id="avatar_resized_koef" />');                     }                    jcrop_api = $.Jcrop('#cropbox');                    jcrop_api.setOptions({                            bgColor:     'black',                            bgOpacity:   .7,                            aspectRatio: 1,                            minSize: [10, 10],                            onChange: setCropCoords,                            onSelect: setCropCoords                        });                                        $('.jcrop-holder').css('margin-top', ($('#add_avatar_window .img').height()/2 - $('#add_avatar_window .img img').height()/2 ) );                                        jcrop_api.setSelect([ 0, 0, 100, 100 ]);                                                        });                            });        }    }}
