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

$(document).ready(function() {

	// BIND EVENT FOR WINDOW RESIZE
	$(window).bind('resize', function() {
		var height_content = $('#tpl_content').height();
		var height_intro = $('#tpl_intro').height();
		var height_intro_assoc = $('#tpl_intro_assoc').height();
		var height_menu = $('#tpl_menu').height();
		if($('#tpl_intro_assoc').length>0) {
			if(height_menu<(height_content+height_intro_assoc)) {
				$('#tpl_menu').height((height_content+height_intro_assoc));
			}
		} else {
			if(height_menu<(height_content+height_intro)) {
				$('#tpl_menu').height((height_content+height_intro));
			}
		}
	});
	$('#tpl_content, #tpl_menu').bind('resize', function() {
		$(window).trigger('resize');
	});
	$(window).trigger('resize');

	// BIND EVENT FOR CLICKABLE ITEMS
	$('.clickable').bind('click', function() {
		var url = $(this).find('a[href]:first').attr('href');
		if(url) {
			window.location.href = url;
		}
	});

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


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

	if($('#tpl_header_logo, #tpl_header_assoc_logo').length > 0) {
		$.getScript(jquery_coreurl+'/include/jquery/cycle.latest.lite.js', function() {
			$('#tpl_header, #tpl_header_assoc').cycle();
		});
	}


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

	$(window).load(function() {

		// CALL WINDOW RESIZE EVENT
		$(window).trigger('resize');

	});

});


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

/*function jquery_include_submenu() {

	// REMOVE EMPTY SUBMENU
	$('#tpl_submenu ul:empty').each(function() {
		$('#tpl_submenu').remove();
		$('#tpl_content').attr('id', 'tpl_content_wide');
	});

}*/
