$(document).ready(function() {

	$(function(){
		var path = location.pathname.substring(1);
		newpath = path.split("/", 1)

		if (newpath == '') { //check for homepage
			$('.ddsmoothmenu a[href$="/"]').addClass('selected')
		} else {
			$('.ddsmoothmenu a[href$="' + newpath + '"]').addClass('selected')
		}
	});

	$('#btnSearch').click(function() {
		if ($("#mySearch").valid()) {
			return true;
		}
		return false;
	});

	// Bookmark site
	if(window.opera) {
		if ($("a.bookmark").attr("rel") != ""){
			$("a.bookmark").attr("rel","sidebar");
		} 
	}

	$("a.bookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;

		if (window.sidebar) { 
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { 
			window.external.AddFavorite( url, title);
		} else if(window.opera) { 
			return false; 
		} else { 
			 alert('Sorry, your browser does not support the requested action,'
			 + ' please add this page manually to your bookmarks.');
		}
	});

	// headline scroll content
	var headline_count;
	var headline_interval;
	var old_headline = 0;
	var current_headline = 0;
	headline_count = $("div.headline").size();
	$("div.headline:eq("+current_headline+")").css('top','2px');
	headline_interval = setInterval(headline_rotate,10000); //time in milliseconds
	
	function headline_rotate() {
		current_headline = (old_headline + 1) % headline_count; 
		$("div.headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
		$(this).css('top','210px');
		});
		$("div.headline:eq(" + current_headline + ")").show().animate({top: 2},"slow");  
		old_headline = current_headline;
	}

	$('#slideshow').jqFancyTransitions({
		width: 720,
		height: 191,
		effect: "zipper", // wave, zipper, curtain
		position: "curtain", // top, bottom, alternate, curtain
		strips: 40, // number of strips
		delay: 5000, // delay between images in ms
		stripDelay: 50, // delay beetwen strips in ms
		titleSpeed: 1000, // speed of title appereance in ms
		titleOpacity: 0.7, // opacity of title
		direction: "fountain", // left, right, alternate, random, fountain, fountainAlternate
		navigation: false, // prev and next navigation buttons
		links: true // show images as links
	});

	$("#subForm").validate();
	$('#panel').show();
	
	if ($('#blog-panel').length) {
		$('#panel').empty();
		$('#blog-panel').prependTo($('#panel'));
		$('#blog-panel').show();
	}

	$('.search').focus(function() {
		if (this.value == 'Search') { this.value=''; };
	});

	$('.photo a').fancyZoom({scaleImg: true, closeOnClick: true});

	$('#panel-1').hover(
		function(){
			$('p.overlay').slideDown("slow");
		}, function() {
			$('p.overlay').slideUp("slow");
		}
	);

});

Cufon.replace('h1')('h2')('h3')('.h1')('.h3')('div .cal-day');
