$(function(){
		
	//ie only
	
	
	if($.browser.msie && $.browser.version < 9){
		$('.orange_button, #header_search, .small_button')
			.append('<span class="lt"></span><span class="rt"></span><span class="lb"></span><span class="rb"></span>')
			.css('position' ,'relative');
	}
	
	
	$(function() {
		$( "#calendar_button" ).datepicker({
			showOn: "button",
			buttonImage: "failid/Project/calendar.png",
			buttonImageOnly: true
		});
	});
	
	
	updateClock();
	setInterval('updateClock()', 1000);
   
   $('#footer .footer_content section:last').addClass('last');

});

function updateClock ()
{
	$.post('time.php',function(time){
	var currentTime = new Date (time);
	var currentHours = currentTime.getHours ( );
	var currentMinutes = currentTime.getMinutes ( );
	var currentSeconds = currentTime.getSeconds ( );
 
	// Pad the minutes and seconds with leading zeros, if required
	currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
	currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
 
	// Choose either "AM" or "PM" as appropriate
	var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
 
	// Convert the hours component to 12-hour format if needed
	currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
 
	// Convert an hours component of "0" to "12"
	currentHours = ( currentHours == 0 ) ? 12 : currentHours;
 
	// Compose the string for display
	var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
 
	$("#clock strong").html(currentTimeString);
	});
}

function equal_height(elem)
{
	var maxHeight=0;
	elem = $(elem);
	elem.css('height', 'auto');
    elem.each(function(){
		var sub_elem = $(this);
        if(sub_elem.height()>maxHeight)
            maxHeight=sub_elem.height();
    });
	elem.css('height', maxHeight);
} 

$(window).load(function() {
	equal_height('.ama_osakond .tootaja');
});
