var showColon = false;

function displayCurrentTime(){
	  var date_obj = new Date();
	  var H = $('#curHour').val();
	  H = (H.length < 2) ? '0' + H : H;
	  var M = '' + date_obj.getMinutes();
	  M = (M.length < 2) ? '0' + M : M;
	  var clock = H + ((showColon) ? '<span>:</span>' : '<span style="visibility:hidden">:</span>') + M;
	  $('#hr1').html(clock);
	  showColon = !showColon;
	  setTimeout(displayCurrentTime, 1000);
}


function getTemperature(){

		$.simpleWeather({
			location: 'Omsk, Russia',
			unit: 'c',
			success:function(weather){
				var currentTemp = '<a href="http://pogoda.yandex.ru/28698/" title="" target="_blank" style="color:#4777ad">' + weather.temp + '˚C ' + '</a>';
                currentTemp += '<a href="http://pogoda.yandex.ru/28698/" target="_blank" title="" style="color:#4777ad">' + '<span style = "font-size:15px">' + '(' + weather.low + '˚  … '  + weather.high + '˚)' + '</span>' + '</a>';
				$('#hr2').html(currentTemp);
			}
		});
	}


$(window).load(function(){

	$(document).ready(function(){
		displayCurrentTime();
		getTemperature();
	});



	// обработка времени
	$("#timein, #timeout, #timein2, #timeout2").keyup( function(){

		 var time_ = $(this).val().replace(/[^\d\:]/g, "");
		 if ( time_.substr(0,2) < -1  ||  time_.substr(0,2) > 23 ) time_ = '00';
		 if ( time_.length == 2 ) time_ = time_+':';
		 if ( time_.substr(3,1) == ':' ) time_ = time_.substr(0,2)+time_.substr(3,2);
		 if ( time_.substr(3,2) < -1  ||  time_.substr(3,2) > 59 ) time_ = time_.substr(0,3)+'00';
		 $(this).val(time_);

	});

	$("#changevkladka1").click(function(e){

		$('#confbron').hide();$('#roombron').show();
		//return false;
		//$("#changevkladka1").attr('class', 'cleft');
		//$("#changevkladka2").attr('class', 'cright');
		$("#changevkladka1").addClass('switch');
		$("#changevkladka2").removeClass('switch');

	});

	$("#changevkladka2").click(function(e){

		$('#roombron').hide();$('#confbron').show();
		//return false;
		//$("#changevkladka2").attr('class', 'cleft');
		//$("#changevkladka1").attr('class', 'cright');
		$("#changevkladka2").addClass('switch');
		$("#changevkladka1").removeClass('switch');

	});

});













