 function lib_open_img_window(src,width,height){
   if(width==0)
     width=500;
   width+=20;
   if(height==0)
     height=400;
   height+=20;
   if(height>600)
     height=600;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/img_preview.php?src='+src,'info','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }
function open_window(src, id, width, height){
   if(width==0)   width=500;
   width+=20;
   if(height==0)  height=400;
   height+=20;
   if(height>600)  height=600;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/'+src+'?id='+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }


function open_wnd_universal(src, width, height){
   //if(width==0)   width=500;
   width += 20;
   //if(height==0)  height=400;
   height += 20;
   //if(height>600)  height=600;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info = window.open(src,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
}



/**
 * Авторизация пользователя
 */

function membAuthSbmt(){
    var login = $('#loginPopup .login').attr('value');
    var password = $('#loginPopup .password').attr('value');
    var remember = $('#loginPopup .remember').attr('value');

    if ( login != '' && password != '' ){
        /// Передача данных раздела
        $.post(
        '/profile_login.php',
        {
            act: "login_jx",
            login: login,
            password: password,
            rememb: remember
        },
        membAuthSbmtRes
        );
    }
}

/// Вывод пришедших данных
function membAuthSbmtRes(result){
    if ( result == '1' ){
        window.location.replace(window.location);
    }
    else{
        //$('#forum_auth .msg').html(result);
        $('#loginPopup .msg').html('<span class="msg_brdr alert">Неверный логин или пароль.</span>');
    }
}



/**
 * Восстановление пароля
 */

function membRestore(){
    var email = $('#restore_form .email').attr('value');

    if ( email != '' ){
        /// Передача данных раздела
        $.post(
        '/profile_restore.php',
        {
            act: "send_jx",
            email: email
        },
        membRestoreRes
        );
    }
}

/// Вывод пришедших данных
function membRestoreRes(result){
    res_list = result.split("<!--split-->");
    if ( res_list[0] == 'good' ){
        $('#restore_form').html('<span>'+res_list[1]+'</span>');
    }
    else{
        $('#restore_form .msg').html('<span class="msg_brdr alert">'+res_list[0]+'</span>');
    }
}



/**
 *  Форма "Заявка на регистрацию"
 */

function shopQuestion(){
    var name = $('#reg_name').attr('value');
    var company = $('#reg_company').attr('value');
    var city = $('#reg_city').attr('value');
    var email = $('#reg_email').attr('value');
    var phone = $('#reg_phone').attr('value');
    var text = $('#reg_text').attr('value');

    /// Если поле пустое
    if ( name == undefined ){
        name = '';
    }
    if ( company == undefined ){
        company = '';
    }
    if ( city == undefined ){
        city = '';
    }
    if ( email == undefined ){
        email = '';
    }
    if ( phone == undefined ){
        phone = '';
    }
    if ( text == undefined ){
        text = '';
    }

    /// Индикатор
    $('#usersData .ajaxLoader4').show();
    $('#usersData input:submit').hide();
    /// Отправка и обработка данных
    $.post(
    '/parts_shop_question.php',
    {
        act: 'save',
        name: name,
        company: company,
        city: city,
        email: email,
        phone: phone,
        text: text
    },
    function (data){
        res_list = data.split("<!--split-->");
        var good = res_list[0];
        var msg = res_list[1];
        var info = res_list[2];
        if ( good == 'good' ){
            //$('.signUpService').hide();
            $('#usersData').hide();
            $('#shop_question .msg').html(msg);
        }
        else{
            $('#shop_question .msg').html(msg);
        }
        $('#usersData .ajaxLoader4').hide();
        $('#usersData input:submit').show();
    }
    );
}

