$(document).ready(function() {

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

	// REMOVE ELEMENTS THAT ARE NOT NEEDED
	$('#tpl_articlesearch:empty').remove();
	$('.tpl_categorymenuarticles:empty').remove();
	//$('#tpl_categorymenu:empty').remove();
	$('#tpl_categorymenu:empty').each(function(i) {
		$(this).remove();
		$('#tpl_categorycontent').css('marginLeft','0px');
	});

	// ADD CLASSES
	$('select, input[type=text]').addClass('formline');
	$('input[type=submit]').addClass('formbut');

	// SPECIAL CLASS + EVENT
	$('input[name=lcity]').addClass('textgr textsm').bind('focus blur', function() {
		$(this).toggleClass('textgr');
		$(this).toggleClass('textsm');
	});
	$('input[name=eemail]').addClass('textgr textsm').bind('focus blur', function() {
		$(this).toggleClass('textgr');
		$(this).toggleClass('textsm');
	});

	// BIND COLORED BOXES / OVERLAY
	$('.enlarge').colorbox({
		initialWidth: 40,
		initialHeight: 40,
		speed: 400,
		overlayClose: true,
		opacity: 0.2
	});
	
	$('.enlarge[rel=extendedpictures]').colorbox({
		initialWidth: 40,
		initialHeight: 40,
		speed: 400,
		overlayClose: true,
		opacity: 0.2
	});

	// BIND QTIPS
	$('.qtip').each(function() {
		var html = $(this).attr('qtipcontent');
		$(this).qtip({
			content: {
				text: html
			},
			position: {
				container: $('#tpl_body'),
				type: 'absolute',
				adjust: {
					x: -10,
					y: -10,
					screen: true
				},
				corner: {
					target: 'topRight',
					tooltip: 'bottomLeft'
				}
			},
			style: {
				width: {
					min: 100,
					max: 400
				},
				border: {
					width: 10,
					radius: 10,
					color: '#000000'
				},
				background: '#000000',
				color: '#ffffff',
				padding: 10,
				tip: true
			},
			show: {
				delay: 100,
				solo: true
			},
			hide: {
				delay: 3000
			}
		});
	});
	$('.qtipmouse').each(function() {
		var html = $(this).attr('qtipcontent');
		$(this).qtip({
			content: {
				text: html
			},
			position: {
				container: $('#tpl_body'),
				type: 'absolute',
				target: 'mouse',
				adjust: {
					x: 20,
					y: -20,
					mouse: true,
					screen: true
				},
				corner: {
					target: 'topRight',
					tooltip: 'bottomLeft'
				}
			},
			style: {
				width: {
					min: 100,
					max: 400
				},
				border: {
					width: 10,
					radius: 10,
					color: '#000000'
				},
				background: '#000000',
				color: '#ffffff',
				padding: 10,
				tip: true
			},
			show: {
				delay: 100,
				solo: true
			},
			hide: {
				delay: 100
			}
		});
	});

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

	// ROTATE HEADERS
	$('#tpl_header_cycle').cycle();

	// WINDOWS RESIZE EVENT
	$(window).bind('resize', function() {
		var width_window = $('body').width();
		$('#tpl_body').width(width_window);
	});
	$(window).trigger('resize');

	$(window).load(function() {

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

		// TRIGGER RESIZE
		$(window).trigger('resize');

	});

});
