function updateClock ()
{
  var currentTime = new Date ();

  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;



  // 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 ;

  // Update the time display
  $('.dro').html(currentTimeString);
  
  
  
}

    


$(document).ready(function(){
	
	$('.dro').hide();
	setInterval('updateClock()',1000);
	$('.dro').fadeIn(1000);





	/**
	 * menius scroli
	 */
	$(window).scroll(function(e){
		scrollFromTop = $(window).scrollTop();
		
		if(scrollFromTop >= 101) {
			$("#TopMenu").css({'position':'fixed'})
			$("#TopMenu").stop().css({"top": "0px",'z-index':'9999'});
		} else {
			$("#TopMenu").css({'position':''})
		}
	});
	
	
	
	/**
	 * Fade OnSlide Buttons
	 */
	$('#OnSlideRight').fadeIn(3500);


    
    
    
    
    /**
     * Sub Menus Script ON Top Menu
     */
    $('#TopMenu ul.LeftSide li.sub').hover(function() {
    	$(this).find('ul').slideDown();
    });
    
    
    
    
    /*
     * Make Left And Right Collumnes Always Same Height
     */
    pageCenterHeight = $('.Page_Center').height();
    pageRightHeight = $('.Page_Right').height();
    
    
    console.log("Right: " + pageRightHeight);
    console.log("Center: " + pageCenterHeight);
    
    if(pageCenterHeight > pageRightHeight) {
    	$('.Page_Right').height(pageCenterHeight);
    }
    
    
    
    /**
     * Sub Menu Script On Right Menu
     */
    $('.Page_Right ul.RightMenu li.rightsub a:not(.subsub)').toggle(function(e) {
    	e.preventDefault()
    	parentLi = $(this).parent('li');
    	
    	parentLi.addClass('active');
    	parentLi.find('ul').stop(true,true).slideDown(300);
    },function(e) {
    	e.preventDefault();
    	parentLi = $(this).parent('li');
    	parentLi.find('ul').stop(true,true).slideUp(300,function() {
    		$(this).parent('li').removeClass('active')
    	});
    });
    
    
    $('.Page_Center .PageContent .Galery ul li.active:last-child').css({'margin-right':'0px'});
    
    
    
    // $('#NextSlide').click(function() {
//     	
    	// firstActive = $('.Galery ul li.first').index();
    	// lastActive = $('.Galery ul li.last').index();
//     	
//     	
    	// nextFirst = firstActive + 1;
    	// nextLast = lastActive + 1;
//     	
    	// $('.Galery ul li').eq(firstActive).hide().removeClass('first');
    	// $('.Galery ul li').eq(nextFirst).addClass('first');
//     	
    	// $('.Galery ul li').eq(lastActive).removeClass('last');
    	// $('.Galery ul li').eq(nextLast).show().addClass('last');
//     	
    // });
    
    
    
    // $('#PrevSlide').click(function() {
    	// firstActive = $('.Galery ul li.first').index();
    	// lastActive = $('.Galery ul li.last').index();
//     	
//     	
    	// nextFirst = firstActive - 1;
    	// nextLast = lastActive - 1;
//     	
    	// $('.Galery ul li').eq(firstActive).hide().removeClass('first');
    	// $('.Galery ul li').eq(nextFirst).addClass('first');
//     	
    	// $('.Galery ul li').eq(lastActive).removeClass('last');
    	// $('.Galery ul li').eq(nextLast).show().addClass('last');
//     	
    // });
    
    
    
    
    
    /**
     * SEARCH INPUT
     */
			oldValue = $('#searchKey').val();
			$('#searchKey').focus(function() {
			    sityva = $(this).val();
			    if(oldValue == sityva) {
			        $(this).val("");
			    }
			}).blur(function() {
				if($(this).val() == "") {
					$(this).val(oldValue);
				}
			});
    

    
  
    
    


$('li.sub').hover(function() {
 $(this).find('ul').slideDown(500);
},function() {
$(this).find('ul').stop(true,true).slideUp(500);
});

        
    
    
    

	
});

