jQuery.noConflict();

jQuery(document).ready(function() {

	// IE6 CACHE BACKGROUND IMAGES / NO FLICKER
	if(jQuery.browser.msie) {
		try {
			//document.execCommand("BackgroundImageCache", false, true);
		} catch(err) {}
	}

});

function jquery_include(siteurl) {
	// MENU1 HOVER ACTION
	jQuery('.menu1').bind('mouseenter mouseleave', function() {
		jQuery(this).toggleClass('menu1selected');
	});

	// INPUT HOVER ACTION
	jQuery('.formline').bind('focus blur', function() {
		jQuery(this).toggleClass('formlineover');
	});

	// TEXTAREA HOVER ACTION
	jQuery('.formarea').bind('focus blur', function() {
		jQuery(this).toggleClass('formareaover');
	});

	// SELECT HOVER ACTION
	jQuery('.formselect').bind('focus blur', function() {
		jQuery(this).toggleClass('formselectover');
	});

	// BUTTONS HOVER ACTION
	jQuery('.formbut').bind('mouseenter mouseleave', function() {
		jQuery(this).toggleClass('formbutover');
	});
	jQuery('.formbutback').bind('mouseenter mouseleave', function() {
		jQuery(this).toggleClass('formbutbackover');
	});

	// WEBSHOP MENU EXPAND
	jQuery('.menu2hover').addClass('menu2hoverover').bind('mouseenter', function() {
		jQuery(this).toggleClass('menu2hoverover');
		jQuery(this).addClass('menu2hoverset');
	}).bind('mouseleave', function() {
		jQuery(this).toggleClass('menu2hoverover');
		jQuery(this).removeClass('menu2hoverset');
	});
	jQuery('.menu2hover ul:empty').remove();

	// WEBSHOP FRONTPAGE CATEGORYS
	jQuery('.shopcategory[rel=shoplevel1]').bind('mouseenter', function() {	
		jQuery(this).addClass('shopcategoryover');
		jQuery(this).find('.shopcategoryitem').addClass('shopcategoryitemover');
		jQuery('.shopcategoryitemover .shopcategoryimgicon').fadeTo(0, 1);
		jQuery('.shopcategoryitemover .shopcategoryimgicon').fadeOut('fast');
	}).bind('mouseleave', function() {
		jQuery('.shopcategoryitemover .shopcategoryimgicon').fadeIn('fast');
		jQuery(this).removeClass('shopcategoryover');
		jQuery(this).find('.shopcategoryitem').removeClass('shopcategoryitemover');
	});

	// WEBSHOP FRONTPAGE CATEGORYS
	jQuery('.shopcategory[rel=shoplevel2]').bind('mouseenter', function() {														 
		jQuery(this).addClass('shopcategoryover');
	}).bind('mouseleave', function() {
		jQuery(this).removeClass('shopcategoryover');
	});

	// PRODUCT ACTION CAROUSEL
	jQuery('#carousel_productaction').jcarousel({
		auto: 4,
		animation: 600,
		easing: 'easeInOutExpo',
		wrap: 'both',
		scroll: 1,
		initCallback: carousel_initcallback,
		itemVisibleInCallback: {
			onBeforeAnimation: carousel_setnumber,
			onAfterAnimation: carousel_setnumber
		}
	});

	// FRONTPAGE ANIMATION CAROUSEL
	/*jQuery('#tpl_front_animation').jcarousel({
		auto: 4,
		animation: 600,
		easing: 'easeInOutExpo',
		wrap: 'both',
		scroll: 1
	});*/
	//jQuery('#tpl_front_animation').cycle();
	i = 1;
	jQuery('#tpl_front_animation li').each(function() {
		jQuery(this).attr('id', 'frontpagenaimationdia'+i);
		jQuery(this).bind('mouseenter', function() {
			jQuery(this).find('.tpl_front_animation_box').show().css('top', 100).css('display', 'block');
			jQuery(this).find('.tpl_front_animation_name').show();
			jQuery(this).find('.tpl_front_animation_text').show();
			frontpageanimationsover = true;
		});
		jQuery(this).bind('mouseleave', function() {
			jQuery(this).find('.tpl_front_animation_box').hide().css('top', 200).css('display', 'none');
			jQuery(this).find('.tpl_front_animation_name').hide();
			jQuery(this).find('.tpl_front_animation_text').hide();
			frontpageanimationsover = false;
		});
		i = i + 1;
		jQuery(this).hide();
	});
	jQuery('#tpl_front_animation li:first').show();
	setInterval(frontpageanimation_next, 4000);
	jQuery('#tpl_front_animation div:empty').remove();
	jQuery('#tpl_front_animation li').each(function() {
		if(jQuery(this).find('.tpl_front_animation_name').length == 1) {
		} else {
			if(jQuery(this).find('.tpl_front_animation_text').length == 1) {
			} else {
				jQuery(this).find('.tpl_front_animation_box').remove();
			}
		}
	});

	// SHOPARTICLE
	jQuery('.shoparticleextendedthumbs .shoparticleextendedthumb:first').addClass('selected');

	// FIX MENU 3 REGULAR PAGES
	jQuery('#tpl_submenu .menu3').each(function() {
		var html = '- ' + jQuery(this).html();
		jQuery(this).html(html);
	});
	jQuery('#tpl_submenu .menu3selected').each(function() {
		var html = '- ' + jQuery(this).html();
		jQuery(this).html(html);
	});

	// BUILD QUICK ORDER TAB MENU (REVERSE)
	quickordermenu_fixrows();
}

function carousel_setnumber(carousel, item, idx, state) {
	var cmax = jQuery('#carousel_productaction li').length;
	var ccur = idx;
	jQuery('.tpl_actionbox_current').html(ccur+'/'+cmax);
}

function carousel_initcallback(carousel) {
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};

function shoparticleextendedthumb() {
	jQuery('.shoparticleextendedthumbs .shoparticleextendedthumb.selected').removeClass('selected');
	jQuery('.shoparticleextendedthumbs .shoparticleextendedthumb.jqueryselected').removeClass('jqueryselected').addClass('selected');
}

function quickordermenu_fixrows() {
	jQuery('.quickordermenu li').each(function() {
		var pos = jQuery(this).position();
		jQuery(this).attr('posleft', pos.left);
		jQuery(this).attr('postop', pos.top);
	});
	jQuery('.quickordermenu li').each(function() {
		var posleft = jQuery(this).attr('posleft');
		var postop = jQuery(this).attr('postop');
		jQuery(this).css('position', 'absolute');
		if(postop == 0) {
			jQuery(this).css('left', posleft+'px');
			jQuery(this).css('bottom', 0+'px');
			jQuery(this).css('z-index', 200);
		} else {
			posleft = parseInt(posleft);
			posleft = parseInt(posleft + 20);
			jQuery(this).find('a').addClass('row2');
			jQuery(this).css('left', posleft+'px');
			jQuery(this).css('top', 0+'px');
			jQuery(this).css('z-index', 100);
		}
	});
}

var frontpageanimationscurrent = 2;
var frontpageanimationscount = 0;
var frontpageanimationsover = false;
function frontpageanimation_next() {
	//alert(jQuery('#tpl_front_animation .tpl_front_animation_box').css('top'));
	if(frontpageanimationscount == 0) {
		frontpageanimationscount = parseInt(jQuery('#tpl_front_animation li').length);	
	}
	jQuery('#tpl_front_animation .tpl_front_animation_box').hide().css('top', 200).css('display', 'none');
	jQuery('#tpl_front_animation .tpl_front_animation_name').hide();
	jQuery('#tpl_front_animation .tpl_front_animation_text').hide();
	jQuery('#tpl_front_animation li').css('z-index', 1000).fadeOut('fast');
	if(frontpageanimationsover) {
		jQuery('#tpl_front_animation .tpl_front_animation_box').show().css('top', 100).css('display', 'block');
		jQuery('#tpl_front_animation .tpl_front_animation_name').show();
		jQuery('#tpl_front_animation .tpl_front_animation_text').show();
	}
	jQuery('#frontpagenaimationdia' + frontpageanimationscurrent).css('z-index', 2000).fadeIn('fast');
	//alert(frontpageanimationscurrent);
	frontpageanimationscurrent = parseFloat(frontpageanimationscurrent + 1);
	if(frontpageanimationscurrent > frontpageanimationscount) {
		frontpageanimationscurrent = 1;
	}
}