function changeDayNightClass(newClass, duration) {
	if (typeof(duration)=='undefined') duration = 1000;
	var current = jQuery('#container_wrap').attr('class');
	if (current == newClass) return;

	if (typeof(localStorage)=='undefined') {
		jQuery('#container_wrap').attr('class',newClass);
	} else {
		jQuery('#container_wrap').switchClass(current, newClass, duration);
	}
}

function storeDayNightStatus(status) {
	//jQuery('#container_wrap').attr('class',status);
	changeDayNightClass(status);
	if (typeof(localStorage)=='undefined') return;
	localStorage.setItem('DayNightStatus', status);
}

function timerDayNight() {
	var curdate = new Date();
	var hours = curdate.getHours();
	if (hours >= 7 && hours < 18) storeDayNightStatus('white');
	else storeDayNightStatus('black');
}

function initDayNight() {
	if (typeof(localStorage)=='undefined') return;
	var status = localStorage.getItem('DayNightStatus');
	//if (status) jQuery('#container_wrap').attr('class',status);
	if (status) changeDayNightClass(status, 0);
	setInterval("timerDayNight()",300000);
}


(function($) {
	jQuery(function($) {
		initDayNight();
	});
})(jQuery);

