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

$(document).ready(function() {

	// BIND EVENTS FOR CLICKABLE ITEMS
	$('.clickable').bind('click', function() {
		var url = $(this).find('a[href]:last').attr('href');
		if(url) {
			if($.data(document, 'notclcikable') == false) {
				window.location.href = url;
			}
		}
	});
	
	// SET VARIABLE FOR NOT CLICKABLE ITEMS
	$('.clickable .notclickable').bind('mouseenter', function() {
		$.data(document, 'notclcikable', true);
	}).bind('mouseleave', function() {
		$.data(document, 'notclcikable', false);
	});
	$.data(document, 'notclcikable', false);

	// BIND EVENTS FOR HOVERABLE ITEMS
	$('.hoverable').bind('mouseenter mouseleave', function() {
		$(this).toggleClass('hover');
	});

	// 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
	// ------------------------------------------------------------------------

	$.getScript(jquery_coreurl+'/include/jquery/easing.latest.js', function() {
	$.getScript(jquery_coreurl+'/include/jquery/cycle.latest.all.js', function() {


		// ADD SIMPLE FADE IN / OUT
		$('.cycle').cycle();

		// ADD HORIZONTAL SLIDER
		$('.cycle.horizontal').cycle({
			fx: 'scrollHorz',
			timeout: 6000
		});

	});
	});


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

	/*$(window).load(function() {

		// CUSTOM CODE

	});*/

});


// ----------------------------------------------------------------------------
// CUSTOM FUNCTIONS | 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');
	});

}*/
