// JavaScript Document
$(document).ready(function(){
// preload						   
image1 = new Image();
image1.src = "css/img/throbber.gif";						   
// END PRELOAD						   
						   
// SLIDER
	$("#thema-buttons").jFlow({
		slides: "#thema-slides",
		controller: ".thema-nav", // must be class, use . sign
		slideWrapper : "#slides", // must be id, use # sign
		selectedWrapper: "thema-button-sel",  // just pure text, no sign
		width: "600px",
		height: "270px",
		easing: "easeInOutBack",
		duration: 500,
		prev: ".slider_prev", // must be class, use . sign
		next: ".slider_next" // must be class, use . sign
	});

// EINDE SLIDER

//SNEAKY TEXT 

$('input#captcha').sneakytext( 'neem het nummer over' );
$('input#search').sneakytext( 'Zoeken' );

// EINDE SNEAKYTEXT

// FANCYBOX

$("a#iframe").fancybox({
		'hideOnContentClick'	: false,
		'zoomOpacity'			: true,
		'overlayShow'			: true,
		'overlayOpacity'		: 0.6,
		'zoomSpeedIn'			: 600,
		'zoomSpeedOut'			: 500,
		'easingIn'				: 'easeOutBack',
		'easingOut'				: 'easeInBack',
        'overlayColor'          : '#000',
        'transitionIn'      : 'elastic',
        'transitionOut'     : 'elastic'
	});

$("a.inline").fancybox({
		'hideOnContentClick'	: false,
		'zoomOpacity'			: true,
		'overlayShow'			: true,
		'overlayOpacity'		: 0.6,
		'zoomSpeedIn'			: 600,
		'zoomSpeedOut'			: 500,
		'easingIn'				: 'easeOutBack',
		'easingOut'				: 'easeInBack',
        'overlayColor'          : '#000',
        'transitionIn'      : 'elastic',
        'transitionOut'     : 'elastic',
		'titleShow'				: 'false'
	});


// EINDE FANCYBOX

// ACCORDION

$("#acc_foto").hoverAccordion({
      activateitem: '1',
      speed: 'slow'
   });
$("#acc_info").hoverAccordion({
      activateitem: '1',
      speed: 'slow'
   });

//EINDE ACCORDION

//TOOLTIP
$('a[title]').qtip({   
   show: 'mouseover',
   hide: 'mouseout',
   style: {color: 'darkblue',name: 'blue',tip: 'bottomMiddle'},
   position: {
      corner: {
         target: 'topMiddle',
         tooltip: 'bottomMiddle'
      }
   },
   show: {
   	   delay: '0',			
	   effect: {
		   type: 'fade',
		   length: '500'
	   }
   },
   hide: {
   	   delay: '0',			
	   effect: {
		   type: 'fade',
		   length: '500'
	   }
   }
})

});

$(function(){

 $("#extruderTop").buildMbExtruder({
          positionFixed:false,
          width:500,
          sensibility:800,
          position:"top",
          extruderOpacity:1,
          flapDim:100,
          textOrientation:"bt", // or "bt" (top-bottom or bottom-top)
          onExtOpen:function(){},
          onExtContentLoad:function(){},
          onExtClose:function(){},
          slideTimer:300
      });
});

$(function(){

  $("#extruderLeft1").buildMbExtruder({
	position:"left",
	width:300,
	flapDim:100,
    flapMargin:50,
	extruderOpacity:1,
	onClose:function(){},
	onContentLoad: function(){}
  });
});

$(function(){

  $("#login").buildMbExtruder({
	position:"left",
	width:300,
	flapDim:100,
	extruderOpacity:1,
	onClose:function(){},
	onContentLoad: function(){}
  });
});

$(function(){

  $("#loguit").buildMbExtruder({
	position:"left",
	width:300,
	flapDim:140,
	extruderOpacity:.8,
	onClose:function(){},
	onContentLoad: function(){}
  });
});

  $(document).ready(function() { 
    $("#autostart").fancybox({
							 'overlayShow':true,
							 frameWidth: 838,
							 frameHeight:540
							 }).trigger('click'); 
  }); 
  
  
function get_fotos(div, year, day, path) {
	$.ajax({
		url: path+"fotos_overzicht.php?year="+year+"&day="+day,
		cache: false,
		success: function(html){
			$(div).html(html);
		}
	});
}

/* FORM VALIDATION */

 $(document).ready(function(){
    $("#ideeenbus").validate();
    $("#check_login").validate();
    $("#register").validate();
	$("#krabbel").validate();
  });

function confirmation() {
	var answer = confirm("Je staat op het punt de gegevens te verzenden naar JOL Jeugdstad, weet je zeker dat alle gegevens allemaal goed zijn ingevuld?!")
	if (answer){form.submit}
}

$(function(){
	$("#krabbel").validate();
	$("#voorinschrijven").validate({
	   submitHandler: function(form) {
		   confirmation();
	   }
	});
	
});

/* COUNTDOWN */

dateFuture = new Date(2011,7,22,9,30,0);

function GetCount(){

	dateNow = new Date();									
	amount = dateFuture.getTime() - dateNow.getTime();		
	delete dateNow;

	if(amount < 0){
		document.getElementById('countbox').innerHTML="";
	}
	else{
		days=0;hours=0;mins=0;secs=0;out="";

		amount = Math.floor(amount/1000);

		days=Math.floor(amount/86400);
		amount=amount%86400;

		hours=Math.floor(amount/3600);
		amount=amount%3600;

		mins=Math.floor(amount/60);
		amount=amount%60;

		secs=Math.floor(amount);
	
		if(days != 0){out += "<b>" + days + "</b>" +((days==1)?" dag":"")+((days!=1)?" dagen":"")+", ";}
		if(days != 0 || hours != 0){out += "<b>" + hours + "</b>" +((hours==1)?" uur":"")+((hours!=1)?" uren":"")+", ";}
		if(days != 0 || hours != 0 || mins != 0){out += "<b>" + mins + "</b>" +((mins==1)?" minuut":"")+((mins!=1)?" minuten":"")+", ";}
		out += "<b>" + secs + "</b>" +((secs==1)?" seconde":"")+((secs!=1)?" seconden":"");
		document.getElementById('countbox').innerHTML="Nog "+out;

		setTimeout("GetCount()", 1000);
	}
}

window.onload=GetCount;
/* END COUNTDOWN */


/* MASKED INPUT */
jQuery(function($){
	$("#datum").mask("99-99-9999");
	$("#tijd").mask("99:99");			
	$("#date").mask("99-99-9999");		
	$("#postcode").mask("9999 aa");
	$("#phone").mask("9999999999");
	$("#hutnummer").mask("99");
	});


/* END MASEKD INPUT */

/* THROBBER */

 $(document).ready(function(){

	$(".acc_lev2").throbber({parent: "#foto_holder"});
});

/* END THROBBER */


/*SMILEYS*/
function emoticon(text) {
  text = ' ' + text + ' ';
  if (document.krabbel.tekst.createTextRange && document.bericht.tekst.caretPos) {
   var caretPos = document.bericht.tekst.caretPos;
   caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
   document.bericht.tekst.focus();
  } else {
	document.bericht.tekst.value  += text;
	document.bericht.tekst.focus();
  }
}

/*END SMILEYS*/
