Date.prototype.cutTime = function() {
    var new_date = new Date(this.getFullYear(), this.getMonth(), this.getDate());
    this.setTime(new_date.getTime());
    return this;
}
Date.parseAWADString = function(date) {
    var arrDate = date.split('.');
    ResultDate = new Date(arrDate[2], arrDate[1] - 1, arrDate[0]);
    return ResultDate;
}
Date.prototype.toAWADString = function() {
    var tempDate = this.getDate();
    var tempMonth = this.getMonth() + 1;
    
    if (tempDate < 10)
        tempDate = '0' + tempDate;
    if (tempMonth < 10)
        tempMonth = '0' + tempMonth;
    return tempDate + "." + tempMonth + "." + this.getFullYear();
}


function getPosition(oNode) {
    var iLeft = 0;
    iLeft += $(oNode).offset().left - oNode.scrollLeft;
    var iTop = 0;
    iTop += $(oNode).offset().top - oNode.scrollTop;
    return new Array(iTop, iLeft);

}

//Cookie переніс в main.js    
    
function collapseCallendar() {
    $('#CalendarHeader').toggle();
    $('#CalendarBody').toggle();
    //
    var text = $('#calendar a.expandCollapse').html();
    if (text == '<em></em>' + MO_collapse){
        text = '<em></em>' + MO_expande;
    }
    else
    {
        text = '<em></em>' + MO_collapse;
    }
        
    $('#calendar a.expandCollapse').html(text);
    DirectionBalloon.hide();
}


function fixedScroll (el, el_forFixed, XY, use_jquery) {
	var elTop = (use_jquery) ? parseInt(el.css("top")) : parseInt(el.style.top),
		def   = 0;

	def = $(el_forFixed).offset().top - XY[0];
	if (def < 0) {
		def = 0;
	}
	
   	$(el).css({
   		top: elTop + def
   	});
   	
    $(window).scroll(function(){
   		def = $(el_forFixed).offset().top - XY[0];
		$(el).css({
			top: elTop + def
		})
    }); 
}

function namespace (obj, string) {
	var parts = string.split('.'),
		i;
	
	for (i = 0; i < parts.length; i += 1) {
		if (typeof obj[parts[i]] === 'undefined') {
			obj[parts[i]] = {};
		}
		obj = obj[parts[i]];
	}
	return obj;
}
