// JavaScript Document

function showMedia(id) {
	$("#media-detail").load("/media.php?item_id="+id, function(){ Shadowbox.setup("a[rel='shadowbox']") });
}

function changeCal(timestamp) {
	$("#calendar").load("/calendar.php?month_select="+timestamp);
}

/*
function printDiv()
{
	var prtContent = document.getElementById('list');
	var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
	WinPrint.document.write(prtContent.innerHTML);
	WinPrint.document.close();
	WinPrint.focus();
	WinPrint.print();
	WinPrint.close();
	prtContent.innerHTML=strOldOne;
}
*/

		
$(document).ready(
									
	function()
	{
		
		$("#print-button").click(
			function() {
				$("#left").jqprint({printContainer:true});
			}
		);
		
		Shadowbox.init({
			enableKeys: false
		});
		
		$("#friend-button").click(
			function() {
				Shadowbox.open({
					content:    '<div id="friend" style="padding:100px 120px;color:white;"></div>',
					player:     "html",
					title:      "Mail deze pagina naar een vriend",
					height:     300,
					width:      500
					/*
					onFinish:   function() {
						$("#friend").load("/friend.php?a=show&page="+window.location);
					}
					*/
				});
				setTimeout(function() { $("#friend").load("/friend.php?a=show&page="+window.location); }, 1500);
			}
		);
		
		/*
		$("#facebook-button").attr({
			href: "http://www.facebook.com/sharer.php?u="+window.location+"&t=Moussem"
		});
		*/

		$("#search-button").click(
			function() {
				var search_term = $("#search-term").val();
				if(search_term) {
					$("#search-form").submit();
				}
			}
		);
		
		/* form validation register newsletter */
		$("#register_form").validate({
			//errorLabelContainer: ".error_message",
			rules: {
				email: {
					required: true,
					email: true, 
					remote: {
						url: "/ajax_check_email.php",
						type: "post",
						data: {
							volunteer: function() {
								return $("#volunteer").val();
							}
						}
					}
				}
			},
			messages: {
				email: {
					required: "Gelieve een e-mailadres in te voeren.<br />",
					email: "Gelieve een geldig e-mailadres in te voeren.<br />", 
					remote: "Dit e-mail adres is al ingeschreven.<br />"
				}
			}
		});
		
	}
);
