var teaser = 1;
var tnum = 0;

window.addEvent('load', function() {
	tnum = $$('.mslider-mask div.mslider-teaser').length;
	if(tnum>0 && ms && ms == -1) setCur(teaser-1); // Variabel ms wird im Slider-Script gesetzt
//	if(num>0) setCur(teaser-1); // Variabel ms wird im Slider-Script gesetzt
});

function slideTo(toteaser) {
	// Variabel teaserwidth wird im Slider-Script gesetzt
	var x = ((toteaser - 1) * -teaserwidth);
	var folioChange = new Fx.Tween('folio', {
		duration: 500
	});
	folioChange.start('left', x);
	setCur(toteaser-1);
	teaser=toteaser;
}

function slideTeaser(act) {
	toteaser = teaser + act;
	if(toteaser > tnum) {
		toteaser = 1;
	} else if(toteaser < 1) {
		toteaser = tnum;
	}
	slideTo(toteaser)
}

function setCur(curteaser) {
	$$('.mslider-thumbs a').each(function(item) {
		item.removeClass('cur');
	});
	
	$$(".mslider-thumbs .t-"+curteaser).each(function(item) {
		item.toggleClass('cur');
	});
	
}

function ShowSlideTip(bild,text) {

	$('mslider-tiptext').innerHTML=text;
	$('mslider-tip').position({
    relativeTo: $(bild),
    position: 'centerTop',
    edge: 'centerBottom'
	});
	$('mslider-tip').style.display='block';
}

function HideSlideTip() {
	$('mslider-tip').style.display='none';
}


// Slide in Slide Bilder
function NextImg(obj) {
  var msimgno = 0; // Anzahl
  
	var objid = obj.id;
  var objdata = objid.split('_');

	var parentid = objdata[0];
	var parentlen = parentid.length + 1;
	// alert('parentid: '+parentid);

	var objno = parseInt(objdata[1]);
	// alert('objno: '+objno);

  msimgno = $$('div#'+parentid+' a.mslider-a').length;
	// alert('msimgno: '+msimgno);

	if(msimgno > 1) {
		if(objno == msimgno) var nextno = 1;
		else var nextno = objno + 1;
		// alert('objno: '+objno+ ' - nextno: '+nextno);
		// alert('parentid: '+parentid);


		for(var i = 1; i <= msimgno; i ++) {
			if(i == objno) {
				$$('div#'+parentid).getElementById(parentid+'_'+i).removeClass('show');
			}

			if(i == nextno) {
				$$('div#'+parentid).getElementById(parentid+'_'+i).addClass('show');
				$$('div#'+parentid+' p#'+parentid+'_imgtxt').set('text', 'Bild '+i+' von '+msimgno);
			}
		}
	}
}