/*
+-----------------------------+
|   ПОКАЗ ФОРМЫ АВТОРИЗАЦИИ   |
+-----------------------------+
*/
function showFormLogin()
{
	var f = document.forms['flogin'];
	if (document.getElementById && f)
	{
		document.getElementById('form_login').style.display = 'block';
		document.getElementById('form_login').focus();
		f.login.focus();
		return false;
	}
	else return true;
}

function hideFormLogin()
{
	if(document.getElementById('form_login')) document.getElementById('form_login').style.display = 'none';
	return false;
}


function closeForm(obj)
{
    $(obj).parents(".social-popup").remove();
}

function mustBeMember(now)
{
    if ($(now).parent().find(".social-popup").length)
    {
        $(now).parent().find(".social-popup").remove();
    }
    else {
        $(now).after("<div class='social-popup pu-must-member'><a href='#' class='close' onclick='closeForm(this); return false'></a>Вы должны быть <a href='http://door."+cs_domen+"/login' onclick='showFormLogin(); return false'>авторизированы</a> или <a href='http://door."+cs_domen+"/register'>зарегистрированы</a></div>");
    }
}

/*
+--------------------------------------+
|   ПОДТВЕРЖДЕНИЕ НА ПЕРЕНАПРАВЛЕНИЕ   |
+--------------------------------------+
*/
function univ_confirm(theURL, text)
{
	if (confirm(text))
	{
		window.location.href=theURL;
	}
}


function handleFailure(error) {
	error = error || 'Невозможно выполнить асинхронный запрос';
	$.jGrowl(error, {header: 'Ошибка', theme: 'error'});
}

function ajaxLoadHide(now)
{
    $(now).find(".social-popup").addClass('hide');
    $(now).append("<div class='ajax-loading-on'>загрузка</div");
}


function ajaxStop(now)
{
    $(now).find(".ajax-loading-on").remove();
}


jQuery.fn.ajaxLoadLine = function(options){
    var options = jQuery.extend({
    	txt: 'Сохранение'
    }, options);
    return this.each(function()
    {
        jQuery(this).html("<div class='ajax-loading-line2'><span class='txt'>"+options.txt+"</span><span class='ln'></span></div>");
    });
};

jQuery.fn.ajaxLoadLineError = function(options){
    var options = jQuery.extend({
    	txt: 'Ошибка'
    }, options);
    return this.each(function()
    {
        jQuery(this).html("<div class='ajax-loading-line2-error'><span>" +options.txt+ "</span></div>");
    });
};

