$(document).ready(function(){

	var updateTime = function()
	{
		var now = new Date();
		var hours = now.getHours();	
		var minutes = now.getMinutes();
		var seconds = now.getSeconds();
		hours = (hours < 10) ? '0'+hours : hours;
		minutes = (minutes < 10) ? '0' + minutes : minutes;
		seconds = (seconds < 10) ? '0' + seconds : seconds;
		$('#liveTime').html(hours+':'+minutes+':'+seconds+'&nbsp;');
		setTimeout(updateTime, 1000);
	}

  updateTime();
  $('#header ul li ul li:last-child').addClass('last-child');
  $('#header ul ul').hide();
  var menuTimeout = null;
  var currentMenu;
  
  $('#header>ul>li').hover(function(){

      currentMenu = this;
      clearTimeout(menuTimeout);
      menuTimeout = setTimeout(function() {
				$(currentMenu).addClass('hover');
				$('#header ul li.hover ul').fadeIn(300);
			}, 300);
    
    },function(){
			clearTimeout(menuTimeout);
      $('#header ul li.hover ul').fadeOut(300); $('#header>ul>li').removeClass('hover');
    });
  $('#header ul').hover(function(){ }, function(){ clearTimeout(menuTimeout); });
  
 var imageId = 0;
  

 var roundImages = function(){
      //console.log('On load event fired.');
      imageId ++;;
      
      $(this).parent().append('<div class="rounded_image_' + imageId + '" style="width: ' + $(this).width() + 'px; height: ' + ($(this).height() - 30) + 'px; background-image: url(' + $(this).attr('src') + ');"></div>');
      $(this).remove(); 
      
      
      var settings = {
        tl: { radius: 15 },
        tr: { radius: 15 },
        bl: { radius: 15 },
        br: { radius: 15 },
        antiAlias: true,
        autoPad: true,
        validTags: ["div"]
      };        
      
      
      var myBoxObject = new curvyCorners(settings, "rounded_image_" + imageId);
      myBoxObject.applyCornersToAll();
      
    };
 
    $('#keyimages img, .imageright img').load(roundImages);
    //setTimeout(function(){ $('#keyimages img, .imageright img').each(roundImages); }, 100);
    
    
    $.datePicker.setDateFormat('ymd','-');
    $('.dateSelector').datePicker({startDate:'05/03/2006'});
    
});