
jQuery(document).ready(function(){
	// tooltips
	//$('a.custom-width').cluetip({width: '200px', showTitle: false});
	/* $('a.title').cluetip({splitTitle: '|'});
	$('a.basic').cluetip();
	$('a.custom-width').cluetip({
		width: '250px', 
		showTitle: false,
		cluetipClass: 'jtip', 
		arrows: true, 
		dropShadow: false
	}); */
	
	/* warenkorb bei seitenaufruf aktualisieren  */
	var initcart = "/cart.v2.php?cmd=init";
	$("#preview").load(initcart);
	
	
	// detailseite produktgalerie
	
	$("#thumbs a.gal").mouseover(function(){
		var pfad = new Array();
		pfad[1] = "http://img2.dogtower.de/artikel/l/";
		pfad[2] = "http://img2.dogtower.de/kunden/m/";
	
		var thelink = $(this).attr("href");
		var part1 = thelink.split("#");
		var part2 = part1[1].split(",");
		var pfadid = part2[0];
		var bild = part2[1];

		bild = pfad[pfadid]+bild;
	
		var theimg = new Image();
	
		$(theimg).load(function () {
			$(this).hide();
			$("#produktbild div").empty();
			$("#produktbild div").append(this);
			$(this).fadeIn();
		}).attr('src', bild);
	});

	$("#thumbs a.gal").click(function(){	
		return false;
	});
	
	// detailseite select felder
	
	$('#menge, #artikel').sSelect({ddMaxHeight: '120px'});
	
	// modale popups (z.B. warenkorb, größeninfos, ...)

	$.nyroModalSettings({
		bgColor: '#ffffff',
      zIndexStart: 100000,
      height: null,
     // closeButton: '',
      minHeight: 150
	});
	
	$("a.na, a.size, a.agblink").nyroModal();

	$('#multicart').submit(function(e) {
		e.preventDefault();
		if ($("#artikel").val() != 'oops') {
			$('#multicart').nyroModalManual({
      		bgColor: '#ffffff',
      		zIndexStart: 100000,
      		height: null,
      		closeButton: '',
      		minHeight: 150
    		});
    	} else {
      	alert("Bitte wählen Sie eine Produktvariante aus.\nAlternativ können Sie auch ganz nach unten zur detaillierten Produkttabelle scrollen.");
    	}
    	return false;
	});
  
	$('#produkttabelle form').submit(function(e) {
		e.preventDefault();
		var qwe = "#"+this.id+" .anzahl";
		var qweval = $(qwe).val();
		if (qweval != 0) {
			$("#"+this.id).nyroModalManual({
      		bgColor: '#ffffff',
      		zIndexStart: 100000,
      		height: null,
      		closeButton: '',
      		minHeight: 150
			});
		} else {
      	alert("Sie müssen den Artikel min. 1x in den Warenkorb legen.");
    	}
    	return false;
	});
	
	// detailseiten fader/slider f. kundenbilder
	
	$('ul#kunden').innerfade({
		// animationtype: 'slide',
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '180px'
	});
	
	$('ul#regenjacken').innerfade({
		// animationtype: 'slide',
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '180px'
	});
	
	// "roundabout" slider
	 
	var interval;
	$('#roundabout ul')
		.hover(
			function() {clearInterval(interval);},
			function() {interval = startAutoPlay();}
		)
		.roundabout({
			btnNext: '#next'
		});
	interval = startAutoPlay();
   
	
});

// ---------------------------------- //

function startAutoPlay() {
	return setInterval(function() {
		$('#roundabout ul').roundabout_animateToNextChild();
	}, 3000);
}

