$(document).ready(function() {
	//Printen
	$('.btn-print, .btn-print-tips').click(function(){
		printme(); 
		return false;
	})

	//Kleurplaten
	$('.smallplates .images').cycle({
		fx: 	'scrollHorz',
		prev:   '.smallplates .prev',
		next:   '.smallplates .next',
		timeout: 0,
		after: function() {
			var platelink = $(this).attr('alt');
			$('.btn-downloadplate a').click(function(){
				pageTracker._trackPageview(platelink);
			})
			$('.btn-downloadplate a').attr('href',platelink);
		}
	});
	
	//Kiekjes scroller op homepage
	$(".pics .gallery").scrollable({ 
		size: 3,
		clickable : false,
		loop: true
	}).circular();


	//Kiekjespagina scroller 
	$(".pictures .gallery").scrollable({ 
		size: 1,
		loop: true,
		clickable : false,
		onSeek : function() { 
			var first = this.getVisibleItems().eq(0);
			var imagelink = ($(first).find('a').attr('href'));
			$('.static a').attr('href',imagelink);
		}
	}).circular().autoscroll({
		autoplay: true
	});

	//Kiekjes tooltip
	$(".pics img[title]").tooltip('.pics .tooltip'); 

	//Sendfriend tooltip
	$(".btn-mailfriend").tooltip('.details .tooltip'); 

	//Checkboxes
	$(".blockform .check").click(function(){
		if($(this).hasClass('checkon')){
			$(this).removeClass('checkon');
			$(this).find('input').attr('value',0);
		}else{
			$(this).addClass('checkon');
			$(this).find('input').attr('value',1);
		}
	}); 

	//Kleurplaten mousover
	$('.plates .image').hover(
		function(){ $(this).find('.zoom').show(); },
		function(){ $(this).find('.zoom').hide(); }
	)

	//Kleurplaten popup
	$('.plates .image a').click(function(){
		return hs.htmlExpand(this, { objectType: 'iframe', width: 820 } )
	})
	
	//Sendfriend popup
	$('.btn-mailfriend, .btn-mailfriend-tips').click(function(){
		return hs.htmlExpand(this, { objectType: 'iframe', width: 470 } )
	})
	
	//Sluit highslide
	$('.popup .close a').click(function(){ return parent.window.hs.close() })
	$('.popup .closeform a').click(function(){ return parent.window.hs.close() })
	$('.popup .success a').click(function(){ return parent.window.hs.close() })

	//Styling voor input filetype
	$(".file").change(function(){ 
		$(this).parent().parent().parent().find('.filename').attr('value',$(this).val())
	})

	//submit form
	$('#frm_main .submit a').click(function(){
		submit_onclick('frm_main',true);
		return false;
	})
	

	$('#frm_main input, #frm_main textarea').blur(function(){
		if($(this).attr('title')){
			chckField(this,this.title);
		};
	})

	//submit form
	$('#commentform .submit a').click(function(){
		submit_onclick('commentform',true);
		return false;
	})

	$('#commentform input, #commentform textarea').blur(function(){
		if($(this).attr('title')){
			chckField(this,this.title);
		};
	})

	$('.searchbutton a').click(function(){
		submit_onclick('searchform',true);
		return false;
	})

	//forms stylen
	$('.jqtransform').jqTransform({imgPath:THEME_URL + 'img/form/'});	
	
	$.ajax({
		url: PROJECT_URL + 'kalender/' + currentyear + '/' + currentmonth,
		cache: false,
		success: function(html){	$(".smallagenda").html(html); 
		loadCalendar();
		}
	});

})

function loadCalendar() {
	$('.smallagenda .next a, .smallagenda .prev a').click(function(){
		$.ajax({
		  url: $(this).attr('href'),
		  cache: false,
		  success: function(html){	$(".smallagenda").html(html);  
		  loadCalendar();
		  }
		});
		return false;
	});
	

	//Kalender tooltip
	$('.smallagenda .hasevent, .smallagenda .haseventfirst, .smallagenda .todayhasevent, .smallagenda .todayhaseventfirst').hover(
		function(){ 
			$(this).find('.bgballoon').show();
			$(this).find('.balloon').show();
		},
		function(){ 
			$(this).find('.bgballoon').hide();
			$(this).find('.balloon').hide();
		}
	)
}

//Styling voor input filetype
SI.Files.stylizeAll();

//flashheader & footer
var flashvars = {};
var params = {wmode:"transparent"};
var params_footer = {};
var attributes = {};
swfobject.embedSWF(THEME_URL + "flash/header" + menuOnTop + ".swf", "flash", "960", "140", "9.0.0", false, flashvars, params, attributes);
swfobject.embedSWF(THEME_URL + "flash/footer" + menuOnTop + ".swf", "footer", "960", "200", "9.0.0", false, flashvars, params_footer, attributes);


// SIFR
var scalasans = { src: THEME_URL + 'flash/scalasans-bold.swf' };
sIFR.activate(scalasans);
sIFR.replace(scalasans, {
	selector: '.white h1',
	css: '.sIFR-root { color: #ffffff;  }',
	wmode: 'transparent'
});

sIFR.replace(scalasans, {
	selector: '.title h1',
	css: '.sIFR-root { color: #0053a0;  }',
	wmode: 'transparent'
});
sIFR.replace(scalasans, {
	selector: '.tips .block2 .title h2',
	css: [
		  '.sIFR-root { color: #0053a0;  }',
		  '.sIFR-root a { color: #0053a0; text-decoration:none;  }',
		  '.sIFR-root a:hover { color: #0053a0; text-decoration:none;  }'
		  ],
	wmode: 'transparent'
});
sIFR.replace(scalasans, {
	selector: '.tips .block4 .title h2',
	css: [
		  '.sIFR-root { color: #0053a0;  }',
		  '.sIFR-root a { color: #0053a0; text-decoration:none;  }',
		  '.sIFR-root a:hover { color: #0053a0; text-decoration:none;  }'
		  ],
	wmode: 'transparent'
});
sIFR.replace(scalasans, {
	selector: '.title h2, .blockform h2',
	css: [
		  '.sIFR-root { color: #FFFFFF;  }',
		  '.sIFR-root a { color: #FFFFFF; text-decoration:none;  }',
		  '.sIFR-root a:hover { color: #FFFFFF; text-decoration:none;  }'

		  ],
	wmode: 'transparent'
});

function printme() {
	var objOut = document.getElementById("toprint");
	var out = objOut.innerHTML;

	var wh = window.open("","wh","width=640px,height=480px,scrollbars=yes");
	wh.document.open();
	var stylesheet = '<link href="' + THEME_URL + 'css/print.css" rel="stylesheet" type="text/css" />';
	var output = '<html><head>'+stylesheet+'</head><body>'+out.replace('<object','<!--object').replace('/object>','/object-->')+'</body></html>';
	output += '<'+'script type="text/javascript">';
	output += 'setTimeout("window.print()",2000);';	
	output += '</'+'script>';
	wh.document.writeln(output);
	wh.document.close();
}



