function $(id)	{
	return document.getElementById(id);
}

function $body()   {
	return document.body;
}

function _win(aText) {
	window.alert(aText);
}	

function _onFail(aGettedResult) {
	_win('Ошибка при обращении к серверу');
}

function _getParamGetByName(aName) {
	var _RegExp = new RegExp('.*[?&]' + aName + '=(.+)', 'i');
			
	if(_RegExp.exec(window.location.toString())) 		
		return RegExp.$1;
	else
		return '';
}

function _getFileName(aSrc) {
	var _RegExp = new RegExp('.*/(.+)', 'i');
			
	if(_RegExp.exec(aSrc)) 		
		return RegExp.$1;
	else
		return '';
}

function getDocumentSize(doc) { 
	var r = { width: 0, height: 0 };
 
	var width1=0, width2=0, width3=0, width4=0, maxWidth=0;
	var height1=0, height2=0, height3=0, height4=0, maxHeight=0;
  
  
	if (doc.width) maxWidth = doc.width; 
	if (doc.body) { 
		if (doc.body.scrollWidth) width1 = doc.body.scrollWidth;
		if (doc.body.offsetWidth) width2 = doc.body.offsetWidth; 
	}
	if (doc.documentElement) {
		width3 = doc.documentElement.scrollWidth; 
		width4 = doc.documentElement.clientWidth;
	} 
  
	maxWidth = Math.max(Math.max(Math.max(width1, width2), Math.max(width3, width4)),maxWidth);
  
	if (doc.height) maxHeight = doc.height;
	if (doc.body) {
		if (doc.body.scrollHeight) height1 = doc.body.scrollHeight;
		if (doc.body.offsetHeight) height2 = doc.body.offsetHeight;
	}
	if (doc.documentElement) {
		height3 = doc.documentElement.scrollHeight;
		height4 = doc.documentElement.clientHeight;
	}
	maxHeight = Math.max(Math.max(Math.max(height1, height2), Math.max(height3, height4)),maxHeight);
  
	r.width = maxWidth;
	r.height = maxHeight;
  
	return r;
}

function SetCookie(aName, aValue) {			
	document.cookie = aName + '=' + aValue + ';';			
}

function GetCookie(aName) {
	var _RegExp = new RegExp('.*' + aName + '=(.+?)(;|$)', 'i');

	if(_RegExp.exec(document.cookie)) 		
		return RegExp.$1;
	else
		return '';
}

var timerSmoothShow = null, timerSmoothHide = null;
 
function SetOpacity(aId, aValue) {
	var _opacityProp = getOpacityProperty();

	if (!$(aId) || !_opacityProp) return; 
  
	if (_opacityProp == "filter") {
		aValue *= 100;
			
		var _Alpha = $(aId).filters['DXImageTransform.Microsoft.alpha'] || $(aId).filters.alpha;
		if (_Alpha) 
			_Alpha.opacity = aValue;
		else 
			$(aId).style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=" + aValue + ")"; 
	}
	else 
		$(aId).style[_opacityProp] = aValue;
}

function getOpacityProperty() {
	if (typeof document.body.style.opacity == 'string') 
		return 'opacity';
	else if (typeof document.body.style.MozOpacity == 'string')
		return 'MozOpacity';
	else if (typeof document.body.style.KhtmlOpacity == 'string')
		return 'KhtmlOpacity';
	else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) 
		return 'filter';
	
	return false;
}
   
function SmoothShow(aTargetID, aValue) { 
	
	if(aValue > 1 || aValue < 0) return;
	
	var _opacity = ($(aTargetID).style.opacity)?parseFloat($(aTargetID).style.opacity):parseInt($(aTargetID).style.filter)/100; 
	     
	if(_opacity < aValue) { 		
		_opacity += 0.05; 		
		SetOpacity(aTargetID, _opacity); 		
		timerSmoothShow = setTimeout('SmoothShow(\'' + aTargetID + '\', ' + aValue + ')', 50); 
	} 
	else {
		if(timerSmoothShow) {
			clearTimeout(timerSmoothShow);
			timerSmoothShow = null;
		}	
	}
} 
	    
function SmoothHide(aTargetID, aValue) { 
	
	if(aValue > 1 || aValue < 0) return;
	
	var _opacity = ($(aTargetID).style.opacity)?parseFloat($(aTargetID).style.opacity):parseInt($(aTargetID).style.filter)/100; 
	     
	if(_opacity > aValue) { 
		_opacity -= 0.05; 
		SetOpacity(aTargetID, _opacity); 
		timerSmoothHide = setTimeout('SmoothHide(\'' + aTargetID + '\', '+ aValue + ')', 50); 
	} 
	else {
		if(timerSmoothHide) {
			clearTimeout(timerSmoothHide);
			timerSmoothHide = null;
		}
	}
}
