﻿$(document).ready(function() {

//** main menu **//

$('ul#main-links li').hover(
			function() { 
			

if ($('ul',this).is(':hidden')) {
    $('ul',this).slideDown(300);
} 			},
			
			
			function() { 
			

if ($('ul',this).is(':visible')) {
    $('ul',this).slideUp(100);
} 			}		
			
			);


/*
carousel
*/
	jQuery('#mycarousel').jcarousel();
	


 //** light box**//

       $('#photo a,#photo-gallery a').lightBox();
       $('#photo_multimedia a').lightBox();



/*
latest news scroller
*/
	var height = 0;
			var to = null;
			var theAnimation;
			var newsScroller;
			$(document)
			.ready(function(){
				newsScroller = $('#newsScroller');
				
				var curSet = newsScroller
				.prev()
					.addClass('ns')
				.end()
				.wrap('<div>')
				.parent()
					.addClass('ns')
				.end()
				.wrap('<div>')
				.children()
				.slice(0,2)
				.each(function(){
					height += $(this).outerHeight(true);
				});
				
				theAnimation = function(){
					if( !newsScroller.is(':animated') ){
						newsScroller.animate({top:-height},1000,function(){
							height = 0;
							curSet = newsScroller
							.append(curSet)
							.css('top',0)
							.children()
							.slice(0,2)
							.each(function(){
								height += $(this).outerHeight(true);
							});
						});
					}
				};
				
				to = setInterval(theAnimation,4000);
							
				newsScroller.bind('mouseenter',function(){
					clearInterval(to);
				})
				.bind('mouseleave',function(){
					to = setInterval(theAnimation,4000);
				});
			});


	
	
});	


 //** slide**//

	$(function() {
	    $('#slide-pics').cycle({fx:'scrollLeft',speed:  900,timeout: 6000,pager:  '#nav',pagerAnchorBuilder: function(idx, slide) {return '#nav li:eq(' + (idx) + ') a';}});
	});
