var lastNumber ="";

var a = jQuery.noConflict();

a(document).ready(function(){

    a('.emo .image').cycle({
		fx: 'turnDown',
		speed: 1500,
		timeout:  8000
	});


    a('.navilink').hover(function(){
        a('> ul', this).fadeIn("fast");
        a(this).addClass('navilinkaktiv');
    }, function(){
        a('> ul', this).fadeOut("fast");
        var element = this;
        a(element).removeClass('navilinkaktiv');
    });

    a('.navilinkaktiv').hover(function(){
        a('> ul', this).fadeIn("fast");
    }, function(){
        a('> ul', this).fadeOut("fast");
    });
	
	a('.taglink').toggle(function(){
		a('.tags').css("display","block");
	}, function(){
		a('.tags').css("display","none");
	});
	a('#c226').click(function() {
		a('.tags').css("display","none");
		resetToggle('.taglink');
	});
	
	a('.thumbs div').hover(function() {

		if(a(".rahmen",this).css("display")=="none") {
			a(" .rahmen ").fadeOut(750);
			var number = a(this).attr("rel");
			a(".image img").fadeOut("slow");
			a(".i"+number).fadeIn("slow");
			a(" .rahmen ",this).fadeIn(750);
		}

		//a(" .emostart .image ").css("background","none");
		if(number!="1") {
			//a('.start').fadeOut(450);
		}
	});
	
	a(".produktbox .porder").each(function(i,e){
		a("select option:first",e).attr("SELECTED","selected");
		a("span.artnr",e).html(a("select option:selected",e).val());
		a("select",e).change(function(){
			a("span.artnr",e).html(a("select option:selected",e).val());
			a(".pamount",e).attr("name", "formhandler[" + a("select option:selected",e).val() +"]")
		});	
	});
	
	
});

function resetToggle(selector) {  
	a(selector).each(function() {
		this.lastToggle=0;  
	});  
}  

(function(e) {
	e.fn.customFadeIn = function(speed, callback) {
		e(this).fadeIn(speed, function() {
			if(!e.support.opacity)
				e(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	e.fn.customFadeOut = function(speed, callback) {
		e(this).fadeOut(speed, function() {
			if(!e.support.opacity)
				e(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	e.fn.customFadeTo = function(speed,to,callback) {
		return this.animate({opacity: to}, speed, function() {
			if (to == 1 && jQuery.browser.msie)
				this.style.removeAttribute('filter');
			if (jQuery.isFunction(callback))
				callback();
		});
	};
})(jQuery);

