	var timeColon = null;
	var timeWeekday = null;
	var timeDay = null;
	var timeMonth = null;
	var timeHours = null;
	var timeMinutes = null;
	var timeColonColor="";
	var deltaServerClientTime = 0;
	var DayOfWeek = ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'];
	var MonthOf = ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'];

	function updateTime() {
		// Мигаем точками)
		if (timeColonColor=="") timeColonColor="#FFF"; else timeColonColor="";
		timeColon.style.color = timeColonColor;

		clientDate = new Date();
		currentTimeStamp = clientDate.getTime() + deltaServerClientTime; 
		currentDate = new Date(currentTimeStamp);

		timeWeekday.innerHTML = DayOfWeek[currentDate.getDay()]+',';
		timeDay.innerHTML = currentDate.getDate();
		timeMonth.innerHTML = MonthOf[currentDate.getMonth()];

		if (currentDate.getDay()==0)
			redDay = "#DF1919";
		else 
			redDay = "";

		timeWeekday.style.color = redDay;
		timeDay.style.color = redDay;
		timeMonth.style.color = redDay;

		hours = currentDate.getHours()
		hours = (hours<10?"0"+hours:hours);
		timeHours.innerHTML = hours;

		minutes = currentDate.getMinutes()
		minutes = (minutes<10?"0"+minutes:minutes);
		
		timeMinutes.innerHTML = minutes;
	}

	function runClock(serverDate) {
		clientDate = new Date();
		deltaServerClientTime = serverDate - clientDate.getTime(); 
		timeWeekday = document.getElementById('mweekday');
		timeDay = document.getElementById('mday');
		timeMonth = document.getElementById('mmonth');
		timeHours = document.getElementById('timehours');
		timeColon = document.getElementById('timecolon');
		timeMinutes = document.getElementById('timeminutes');
		setInterval("updateTime()",1000);
	}

	function initClock() {
		getTimeUrl = 'http://mir45.ru/system/gettime.php?'+ Math.random();;
		$.get(getTimeUrl, function(data){
			runClock(data);
		});
	}

	function initModal() {
		$('body').append('<div id="overlay"></div>'+
			'<div id="modalwindow">'+
			    '<div id="loadmessage">'+
				'<p class="modcenter"><img style="border:none" src="/static/wait.gif" alt="" /></p>'+
			    '</div>'+
			'</div>');
	}

	function initGallery() {
	    $('#gallery a').click(
		function() {
		    $('#gallery a').removeClass('active');
		    this.className='active';
		    $('#bigphoto img')[0].src = $(this).attr("href");
		    return false;
		}
	    );
	}
	
	$.preloadImages = function() {
	    for (var i = 0; i<arguments.length; i++)
	    $("<img />").attr("src", arguments[i]);
	}

	$(document).ready(function(){
		initModal();
		initClock();
		initGallery();
	});
