function login(el_login, el_pass){
	var login = $('#'+el_login).val();
	var pass = $('#'+el_pass).val();
	if(login == '' || pass == ''){
		errAlert(el_login, 'Заполните оба поля');
		return;
	}
	var input_data = {'login':login,
					'pass':pass,
					'action':'login'};
	
	$.post('/ajax/user/login.html', input_data, function(data){
		if(data.result){
			//document.location.href = data.href;
			document.location.reload();
		} else{
			errAlert(el_login, 'Неверный логин или пароль');
		}
	}, 'json');

}

function errAlert(el_id, mess){
	var diff_top = -35;
	var obj = $(el_id);
	if(obj.offset().top == 0)
		obj = $('#'+el_id);
	
	var top = obj.offset().top + diff_top;
	var left = obj.offset().left;
	var div = '<div id="errAlert" style="z-index: 3; position: absolute; left:'+left+'px; top:'+top+'px">';
	div += '<table cellpadding="0" cellspacing="0"><tr><td style="background: url(\'/images/ea1.gif\'); width:6px; height:30px;"></td>';
	div+='<td style="background: url(\'/images/ea2.gif\') repeat-x; vertical-align: middle; color: #FFF;">'+mess+'</td><td style="background: url(\'/images/ea3.gif\'); width:6px;"></td></tr></table>';
	div+='</div>';
	$('body').append(div);
	setTimeout(function(){$('#errAlert').remove()}, 1500);
}

function drawSelector(items, selector_id, callback){
	var out_html = '<select id="'+selector_id+'">';
	for(i in items){
		out_html += '<option '+(items[i].key == $('#'+selector_id).val()?'selected':'')+' value="'+items[i].key+'">'+items[i].value+'</option>';
	}
	out_html += '</select>';
	
	$('#'+selector_id).parent().html(out_html);
	$('#'+selector_id).change(function(){
		if(callback){
			callback($(this).val());
		}
	});
}
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){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
};