Date.format = 'dd-mm-yyyy';

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

$(document).ready(function(){

if($( "#auto_fill" ).height() > 0){
	
	var get_from = $("#get_from").val();
	$( "#auto_fill" ).autocomplete({
		dataType: "json",
		source: 'http://www.klokgebouw.nl/auto_aanvullen.php?get_from='+ get_from + '&term=' + $("#auto_fill").val() + ''
	});
  }



  Cufon.replace('#subleft .crop_url a, #subleft span.cufon, #agenda h1 a.homepage_title , p.moreevents, #social .topicblack A ,.topicblack_zoek a , .right-block .title a', {hover: true});
  Cufon.replace('.right-block .title a, p.right-title, #nav A, #anounce, #agendainnerhdr, #anounce A, #social .topicblack,  #social .topicblack A, #agenda h1, #social .cfn, #leftcolumn H1, #subleft A, #subleft LI div,  #subleft LI span.cufon,  .maandhdr, #greyblock, #leftcolumn .carouselgrad, .agendameerinfo1, .maand_dag .title,.crumb,#footer,#bestel', { fontFamily: 'Neutraliser' });

  Cufon.replace('.nocufon, .nocufon A , #subleft ul li span.nocufon ', { fontFamily: 'NONE' });

  $("#anounce a").click(function() {
     $("#anounce a").toggle("fast");
	 $("#anounce span").toggle("slow");
  });

  //Put footer cols to the bottom!
//  if($("#footer-content .col").height()){
//	$("#footer-content .col").height($("#footer-content").height() + 'px')
//
//  }

  $(".huurderitem a.lees_meer").click(function() {
	
     $(this).parent().hide();
	 $(this).parent().parent().find('.hidden').show();

  });

  $(".huurderitem a.lees_minder").click(function() {
	
	 $(this).parent().parent().parent().find('.lees_meer').parent().show();	
	 $(this).parent().parent().parent().find('.hidden').hide();

  });
  
  if (($("#nieuws").length) && ($("#agenda").length)) {
	  h1 = $("#nieuws").height();
	  h2 = $("#agenda").height();
	  h3 = $("#social").height();
	  
	  //$("#nieuws").css({ "min-height": h3 + "px" });
	  //$("#agenda").css({ "min-height": h3 + "px" });
	  
	  //if (h1 > h2) 
	    //$("#nieuws").css({ "height": (h2 + 5) + "px" });
	  //else
	    //$("#agenda").css({ "height": (h1 - 7) + "px" });
  }

  $('.date-pick').datePicker({clickInput:true});


if($('.slideshow').height() > 0 && $('.slideshow').children().size() > 1){

  $('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 4000,
		speed: 2000,
		random: 1
  });
}

	$("#scroller").simplyScroll({
		className: 'scroller',
		autoMode: 'loop',
		speed: 4
	});

	$("a[rel^='prettyPhoto']").prettyPhoto({
		show_title: false,
		social_tools: '<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" data-text="Bekijk de gallery van het Klokgebouw " class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?locale=en_US&href='+location.href+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:23px;" allowTransparency="true"></iframe></div></div>' /* html or false to disable */

	});
});
