$(document).ready(function() {

	// ================= HOME SLIDER =====================
	$('#slider').nivoSlider({
		effect:'random',
		directionNav:false,
		controlNavThumbs:true,
		controlNavThumbsFromRel:true,
		afterLoad: function(){
			//var marginLeft = ($('.nivo-controlNav').width() * 8.5) / 2;
			if ($.browser.msie) {
				var marginLeft = parseInt($('.nivo-controlNav').css('width')) / 2;
			} else {
				var marginLeft = (parseInt($('.nivo-controlNav').css('width')) * 8.5) / 2;
			}
			$('.nivo-controlNav').css('margin-left', -marginLeft);
		}
	});
	// ==================================================


	// ================= NAVIGATION =====================
	$('ul.nav').superfish({
		autoArrows: false
	});
	// ==================================================


	// ==================== TABS ========================
	$('.tab_content').hide();
	$('ul.tabs li:first').addClass('active').show();
	$('.tab_content:first').show();

	$('ul.tabs li').click(function() {

		$('ul.tabs li').removeClass('active');
		$(this).addClass('active');
		$('.tab_content').hide();

		var activeTab = $(this).find('a').attr('href');
		$(activeTab).fadeIn();
		return false;
	});
	// ==================================================


	// ================= CATEGORIES =====================
	$('#side-nav ul ul').hide();
	$('#side-nav ul li a').click(function() {
		var checkElement = $(this).next();
		if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			return false;
		}
		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#side-nav ul ul:visible').slideUp('fast');
			checkElement.slideDown('fast');
			$('#side-nav .active').removeClass('active');
			$(this).addClass('active');
			return false;
		}
	});
	// ==================================================
		

	// =============== FANCYBOX MAPS ====================
	$('#maps a').fancybox({
		'padding'			: '0',
		'scrolling'			: 'false',
		'centerOnScroll'	: 'true',
		'overlayColor'		: '#000',
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic'
	});
	// ==================================================


	// ========== FANCYBOX DETAIL PRODUCTS ==============
	//$('.cat .line a').fancybox({
	//	'padding'			: '30',
	//	'centerOnScroll'	: 'true',
	//	'overlayColor'		: '#000'
	//});
	// ==================================================


	// =========== VALIDATE CONTACT FORM ================
	$('#contact-form').validate({
		errorLabelContainer: '#error-box',
		wrapper: 'li'
	});
	// ==================================================


	// =============== IE LAST CHILD ====================
	if ($.browser.msie) {
		$('#copy .container_12 div:last-child').css('text-align', 'right')
		$('#crumbtrail ul li:last-child').css('background', 'none')
	}
	// ==================================================

});

Cufon.replace('ul.nav > li > a', {hover: 'true'});
Cufon.replace('.box h3, h3, h1, th');

