/* This code was added in nov 2010 by Rein */
/* only jQuery here please */
$(document).ready(function(){
	
	$('#datepicker').datepicker({
		onSelect: function(dateText, inst){ /* Event does not want to run?! */
			$('.strikeonselect').css('text-decoration','line-through');
		}
	});
	
	$('#datepicker').change(function(){
		if($(this).val()=='')
		{
			$('.strikeonselect').css('text-decoration','none');
		}
	});
	
	setVars();
	overlayBox();
	initBookmarkLinks('a.bookmarkthis');
	
});

/* Overlay box functions */

function selectedDate(){
	alert('so far so good');
}

function setVars(){ /* Vars must be public because they are set in the scope of this function */
	body		= $('body');
	overlay		= $('.overlay');
	box 		= $('.overlaybox');
	langChoices	= box.find('ul.langchoices>li>a');
}

function overlayBox(){
	
	if(box.size()>0){
		body.addClass('noscroll');
	}
	
	function closeBox(){
		overlay.hide();
		box.hide();
		body.removeClass('noscroll');
	}
	
	function isBoxOpen(){
		if(box.is(':visible')){return true;}else{return false;}
	}
	
	langChoices.click(function(){
		closeBox();
	});
	
}

/* Bookmark link functions */

function initBookmarkLinks(selector){
	var element = $(selector);
	element.click(function(){
		
		var link	= $(this);
		var url 	= link.attr('href');
		var title	= link.attr('title');
		var dragMsg	= link.children('span').html();
	
		if($.browser.mozilla){window.sidebar.addPanel(title, url, title);} /* Firefox */
		else if($.browser.msie){window.external.AddFavorite(url, title);} /* Internet Explorer */
		else if($.browser.webkit){alert(dragMsg);} /* Webkit */
		else if($.browser.opera){return true;} /* Opera */
		
		return false;
	});
}
