$(document).ready(function(){
	clearInputs();
	_acc = $('ul.accordion');
	if(_acc.length > 0 ){
		$(_acc).accordion({
		active: ".selected",
		autoHeight: false,
		header: ".opener",
		collapsible: true,
		event: "click"
	});
	populateVacatureForm();
	}
	initAllebuurten();
	
	$('.visual').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
var tweets = {
  el: '.twitterticker .twitter-stream',
  items: new Array(),
  count: 0,
  total: -1,
  delay: 8000,
  animate: true
};
$(tweets.el+' p').each(function(i) {
  tweets.items[i] = $(this).html();
  tweets.total++;
}).hide();
runTweeter();
function runTweeter() {
  if(tweets.animate == true) {
    if($(tweets.el+' p').length > 0) {
      $(tweets.el).children('p').fadeOut(500, function() {
        $(this).parent(0).empty().append('<p style="display: none;">'+tweets.items[tweets.count]+'</p>').children('p').fadeIn(500);
      });
    } else {
      $(tweets.el).empty().append('<p style="display: none;">'+tweets.items[tweets.count]+'</p>').children('p').fadeIn(750);
    }
  } else {
    $(tweets.el).empty().append('<p>'+tweets.items[tweets.count]+'</p>');
  }
  setTimeout(function() {
    if(tweets.count == tweets.total) {
      tweets.count = 0;
    } else {
      tweets.count++;
    }
    runTweeter();
  }, tweets.delay);
}

});
/*---- clear inputs ---*/
function clearInputs(){
	$('input:text, input:password, textarea').each(function(){
		var _el = $(this);
		var _val = _el.val();
		_el.bind('focus', function(){
			if(this.value == _val) this.value = '';
		}).bind('blur', function(){
			if(this.value == '') this.value = _val;
		});
	});
}

function populateVacatureForm()
{
	if (typeof(vacaturenaam) != "undefined") {
		$(".vacaturenaam").find(":input").val(vacaturenaam);
		$(".vacaturenaam").hide();
	}
}

function initAllebuurten(){
	$(".allebuurten a").mouseover(function(){
		$(this).siblings(".popup-box").css({
			'display': 'block'
		});
	});
	$(".allebuurten a").mouseout(function(){
		$(this).siblings(".popup-box").css({
			'display': 'none'
		});
	});
}
