var load_callback=false;
function LoadUrl(url,div_id)
{
	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport)
		{
			$(div_id).innerHTML=transport.responseText;
			if(load_callback)
			{
				eval(load_callback);
				load_callback=false;
			}
		},
		onFailure: function(transport)
		{
			//alert('Communication Error: '+transport.responseText);
		}

	});
}

function PingUrl(url)
{
	new Ajax.Request(url, {
		method: 'get'
	});
}



function SubmitForm(obj,div_id)
{
	if($('status_bar'))	$('status_bar').show();
	obj.request({
		onComplete: function(transport){if($('status_bar'))	$('status_bar').hide(); $(div_id).innerHTML=transport.responseText; }
	})
	return false;
}

var return_var='';
function SubmitFormReturn(obj)
{
	if($('status_bar'))	$('status_bar').show();
	obj.request({
		asynchronous: false,
		onComplete: function(transport){

			return_var=transport.responseText;
		}
	})
	return false;
}

function check_empty_onfocus(elem){
	if(elem.value==elem.title){
		elem.value = "";
	}
}
function check_empty_onblur(elem){
	if(elem.value.length==0 || elem.value == elem.title){
		elem.value = elem.title;
	}
}

function setCookie (name,value,monthes)
{
	var exp_date = new Date();
    exp_date.setMonth(exp_date.getMonth()+monthes);
    document.cookie = name+"="+value+";expires="+exp_date.toGMTString;
}

function readCookie (name)
{
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function addbookmark(title, url) {
    if (title == undefined)
        title = document.title;
    if (url == undefined)
        url = top.location.href;
    if (window.sidebar) {
        // Firefox
        window.sidebar.addPanel(title, url, '');
    } else if (window.opera && window.print) {
        // Opera
        alert('Что бы добавить страницу в избранное нажмите CTRL-D.');
    } else if(document.all ) {
        // IE
        window.external.AddFavorite(url, title);
    }
    else {
        //для макинтоша соответственно выводим
        if (this.mac) {
            alert('Что бы добавить страницу в избранное нажмите Command-D.');
        }
        //для PC выводим
        else {
            alert('Что бы добавить страницу в избранное нажмите CTRL-D.');
        }
    }
    return false;
}
/* DROP CLASS FOR DROP ITEMS (MENU, SELECT BOXES)*/
var DropSelect = Class.create({
	initialize: function(div_id)
	{
		this.div_id = div_id;
		this.timeout_var= null;
		this.time= 1000;
		var self = this;
		$(this.div_id).onmouseover=function(){self.prolong();};
		$(this.div_id).onmouseout=function(){self.hide();};
		$A($$('#'+this.div_id+' .drop_hide')).each(function(el){$(el).onmouseout=function(){self.hide();}});
		$A($$('#'+this.div_id+' .drop_prolong')).each(function(el){$(el).onmouseout=function(){self.prolong();}});
	},
	prolong: function()
	{
		clearTimeout(this.timeout_var);
	},
	hide: function()
	{
		this.prolong();
		this.timeout_var=setTimeout('$("'+this.div_id+'").hide()',this.time);
	}
});
 

