// ----------------------------------------------------------------------------
// SETTINGS
// ----------------------------------------------------------------------------

$.fx.interval = 13; // 77 FPS
//$.fx.interval = 20; // 50 FPS


// ----------------------------------------------------------------------------
// DOM READY
// ----------------------------------------------------------------------------

$(document).ready(function() {

	// BIND EVENTS
	$('.formline, .formarea, .formselect').bind('focus blur', function() {
		$(this).toggleClass('focus');
	});
	$('.formbut').bind('mouseenter mouseleave', function() {
		$(this).toggleClass('hover');
	});

	// SET HEIGHT OF FADE
	$('#tpl_header').trigger('resize');


	// ------------------------------------------------------------------------
	// LOAD EXTERNAL SCRIPTS / PLUGINS
	// ------------------------------------------------------------------------

	$.getScript(jquery_coreurl+'/include/jquery/getcss.latest.js', function() {
	$.getCSS(jquery_siteurl+'/css/jquery.colorbox.css', function () {
	$.getScript(jquery_coreurl+'/include/jquery/easing.latest.js', function() {
	$.getScript(jquery_coreurl+'/include/jquery/colorbox.latest.js', function() {
	$.getScript(jquery_coreurl+'/include/jquery/cycle.latest.all.js', function() {
	
		// ADD COLORBOX LOADED
		$('.overlay').colorbox({
			initialWidth: 40,
			initialHeight: 40,
			speed: 400,
			overlayClose: true,
			opacity: 0.80
		});
		
		$('.overlayyoutube').colorbox({
			initialWidth: 40,
			initialHeight: 40,
			speed: 400,
			overlayClose: true,
			opacity: 0.80,
			iframe: true,
			innerWidth: 700,
			innerHeight: 495
		});

		// CYCLE ANIMATION
		$('.tpl_header_animation').cycle({
			fx: 'scrollHorz',
			timeout: 8000,
			speed: 2000,
			easing: 'easeInOutExpo',
			pager: '#tpl_header_pager',
			pause: true
		});

	});
	});
	});
	});
	});


	// ------------------------------------------------------------------------
	// ONLOAD / LOAD COMPLETE
	// ------------------------------------------------------------------------

	$(window).load(function() {

		// SET HEIGHT OF FADE
		$('#tpl_header').trigger('resize');

	});

});


// ----------------------------------------------------------------------------
// CUSTOM FUNCTIONS | CALLED BEFORE DOM READY FROM INSIDE TEMPLATE
// ----------------------------------------------------------------------------

function jquery_include_header() {

	// SET WIDTH OF TEXT BLOCK
	$('#tpl_header_bg:empty').each(function() {
		$('#tpl_header_text').attr('id', 'tpl_header_text_wide');
	});

	// REMOVE EMPTY ELEMENTS
	$('#tpl_header_text_description:empty, #tpl_header_text_link:empty').remove();

	// SET HEIGHT OF FADE
	$('#tpl_header').bind('resize', function() {
		$('#tpl_header_fade img').height($(this).height());
	});
	$('#tpl_header').trigger('resize');

}

function jquery_include_content() {

	// REMOVE SUBMENU
	$('#tpl_submenu:empty').remove();

	// REMOVE EXTRA COLUMN
	$('#tpl_extracolumn:empty').remove();

	// SET CONTENT ID / WIDTH
	if($('#tpl_submenu').length == 0) {
		$('#tpl_content').attr('id', 'tpl_content_wide');
	}
	if($('#tpl_extracolumn').length >= 1) {
		$('#tpl_content').attr('id', 'tpl_content_tiny');
		$('#tpl_content_wide').attr('id', 'tpl_content');
	}

	// ADD CLASS TO LAST MENU3
	$('.menu2divselected').prev().addClass('prev');

}

function jquery_include_twitter() {

	// ADD LATEST TWEET
	$.getScript(jquery_coreurl+'/include/jquery/tweet.latest.js', function() {
		$('#tpl_twitter_latest').tweet({
			username: 'JosMittelmeijer',
			count: 1,
			lang_about: '{text}'
		});
	});

}
