function openPopup() {
	var url = this.href;
	window.open(url, "popup_id", "scrollbars,resizable,width=700,height=600");
	return false;
}

function onAfter(current, next, opts){
	// Set the slide number as a hash
	window.location.hash = '#' + opts.currSlide;
	$('#nav_top a').removeClass('active');
	$('#nav_top a#link'+opts.currSlide).addClass('active');
}

$(function(){
	$('.popup').click(openPopup);

	// Set starting slide to 1
	var startSlide = 0;
	// Get slide number if it exists
	if (window.location.hash) {
		startSlide = window.location.hash.replace('#','');
	}

	$('#slides_container').cycle({
		fx: 'fade',
		timeout: 8000,
		speed: 1500,
		startingSlide: startSlide,
		after: onAfter,
		fastOnEvent: 1
	});
	$('#nav_top a').click(function(){
		nr = $(this).attr('href').match('[^#/]+$');// - 1;
		//alert("goto"+nr);
		//$cycleshow.cycle(nr);
		$('#slides_container').cycle(Number(nr));
		return false;
	});
	$('#nav li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(200);

		}, 
		function () {
			//hide its submenu
			$('ul', this).slideUp(200);			
		}
	);
	$('#kidsbox').hover(
		function () {
			//show its submenu
			$('#tooltipbox', this).slideDown(200);

		}, 
		function () {
			//hide its submenu
			$('#tooltipbox', this).slideUp(200);			
		}
	);
	
});
