var submitForm = {
	
	location: null,
	
	submit: function(location)
	{
		document.location.href = location;
	}
	
}

/* Toggle homepage search-boxes */

var searchForm = {
	
	CONTENT_BOX_CLASS_ZORGVERLENER: 'zoek-zorgverlener',
	CONTENT_BOX_CLASS_APOTHEEK: 'zoek-apotheek',
	
	FORM_CLASS_ZORGVERLENER: 'searchZorgverlener',
	FORM_CLASS_APOTHEEK: 'searchApotheek',
	
	__contentBox: null,
	__currentForm: null,
	
	init: function()
	{
		
		this.__contentBox = $('.zoek-zorgverleners .home-box-content');
		this.__forms = $('.zoek-zorgverleners .home-box-content > form');
		this.__currentForm = this.__contentBox.hasClass(this.CONTENT_BOX_CLASS_APOTHEEK) 
												? $('.' + this.FORM_CLASS_APOTHEEK) 
												: $('.' + this.FORM_CLASS_ZORGVERLENER);
		
		searchForm.hideForm(
			$(this.__forms)
		);
		
		searchForm.openForm(
			$(this.__currentForm)
		);
		
		$('.search-type > input:radio').change(function(){
			$(this).siblings('input:radio').attr('checked', true);
			searchForm.openForm($('.' + this.value));
		});
		
	},
	
	hideForm: function(form)
	{		
		form.each(function(index, item){
			$(item).prev('h1').hide();
			$(item).hide();
		});		
	},
	
	openForm: function(form)
	{		
		searchForm.hideForm(this.__forms);
		searchForm.setActiveForm();
		
		form.prev('h1').show();
		form.show();
	},
	
	setActiveForm: function()
	{		
		if( this.__contentBox.hasClass(this.CONTENT_BOX_CLASS_APOTHEEK) ){
			this.__contentBox.removeClass(this.CONTENT_BOX_CLASS_ZORGVERLENER).addClass(this.CONTENT_BOX_CLASS_APOTHEEK);	
		} else {
			this.__contentBox.removeClass(this.CONTENT_BOX_CLASS_APOTHEEK).addClass(this.CONTENT_BOX_CLASS_ZORGVERLENER);	
		}		
	}
	
}

$(function(){
	searchForm.init();
});
