/**
 * @project: IBC
 * @location: Wax Interactive - www.wax.be
 * @date: 08.07.2010
 * @author: Jan De Wilde
 * @description: Core logic
 */ 

if(typeof $.IBC == "undefined") {
	$.IBC = Object;
}

$.IBC.system = {
	
	construct		:		function() {
		this.buildscriptroot();
	},
	
	scriptroot		:		null,
	
	buildscriptroot	:		function() {
		$("script").each(function(){
			if(this.src.toString().match(/ibc.*?js$/)){
				$.IBC.system.scriptroot = this.src.toString().replace(/ibc.js$/,"");
				return false;
			}
		});
	}
	
}

$.IBC.header = {
	
	construct		:		function() {
		this.chooselife();
		this.rotator();
	},
	
	chooselife		:		function() {
		var chooseStrong = $('#chooseLife strong');
		var chooseUL = $('#chooseLife ul');
		chooseStrong.bind('click',function() {
			if(chooseUL.hasClass('active')) {
				chooseStrong.removeClass('active');
				chooseUL.slideUp("fast").removeClass('active');
			} else {
				chooseStrong.addClass('active');
				chooseUL.slideDown("slow").addClass('active');
			}
		});
	},
	
	rotator			:		function() {
		$('#imagerotator').cycle()
	}
	
}

$.IBC.forms = {
	
	construct		:		function() {
		this.contact();
		this.leden();
	},
	
	contact			:		function() {
		$('#contact #submit').bind('click',function(event){
			formChecker.checkSpecialForm(document.getElementById('contact'));
		});
	},
	
	leden			:		function() {
		$('#reset').bind('click',function(){
			var result = confirm("Bent u zeker?");
			if(!result){
				return false;
			}
		});
		
		$('#resetInschrijvingen').bind('click',function(){
			var result = confirm("Bent u zeker?");
			if(!result){
				return false;
			}
		});
	}
	
}

$.IBC.albums = {
	
	construct		:		function() {
		$('a.photo,a[rel="lightbox"]').lightBox({
			imageLoading: $.IBC.system.scriptroot+'../images/lightbox/loading.gif',
			imageBtnPrev: $.IBC.system.scriptroot+'../images/lightbox/prev.gif',
			imageBtnNext: $.IBC.system.scriptroot+'../images/lightbox/next.gif',
			imageBtnClose: $.IBC.system.scriptroot+'../images/lightbox/close.gif',
			imageBlank: $.IBC.system.scriptroot+'../images/lightbox/blank.gif',
			txtImage: 'Afbeelding',
			txtOf: 'van'
		});
	}
	
}

$(document).ready(function(){
	$.IBC.system.construct();
	$.IBC.header.construct();
	$.IBC.albums.construct();
	$.IBC.forms.construct();
	$('#mainNav').superfish();
});
