var tpl = 'oneholiday';
var position = 0;
var lod = 1;

function newsletter(val){
	if(val == "Ihre Email-Adresse"){
		document.getElementById('newsletter').value = "";
	}else{
		if(val == ""){
			document.getElementById('newsletter').value = "Ihre Email-Adresse";
		}
	}
}

function loadScroll(){
	starter = setTimeout("startScroll(1)", 7000);
}

function startScroll(stp){
	stp+=1;
	if(stp > 6) stp = 1;
	offerScroller(stp);
	doScroll = setTimeout("startScroll("+stp+")", 7000);
}

function stopScroll(){
	clearTimeout(starter);
	clearTimeout(doScroll);
}

function offerScroller(stp){
	var table = document.getElementById('top_offer');
	var height = table.offsetHeight;
	if($.browser.msie && $.browser.version <= 7){
		var rowh = 241;
	}else{
		var rowh = 210;
	}
	var nh = 0;

	if(position == 0){
		nh = rowh*stp;
	}else{
		nh = (rowh*stp)-rowh;	
	}

	if(lod < stp){
		if(position >= nh){
			clearTimeout(scroller);
			lod = stp;
			if($.browser.msie && $.browser.version <= 7){
				table.style.marginTop = -((lod-1)*rowh)+'px';
			}
		}else{
			position += 30;
			evilCufon(stp);
			scroller = setTimeout("offerScroller("+stp+")", 50);
			// if(position > nh) position += 4;
			table.style.marginTop = ((position)*(-1))-((stp-1)*2)+'px';
		}
	}else{
		if(position <= nh){
			clearTimeout(scroller);
			lod = stp;
			if($.browser.msie && $.browser.version <= 7){
				table.style.marginTop = -((lod-1)*rowh)+'px';
			}
		}else{
			position -= 30;
			evilCufon(stp);
			scroller = setTimeout("offerScroller("+stp+")", 50);
			// if(position < nh) position -= 4;
			table.style.marginTop = ((position)*(-1))-((stp-1)*2)+'px';
		}
	}
}

function evilCufon(stp, rowh, position){
	if($.browser.msie && $.browser.version <= 7){
		for(var i = 1 ; i!=7 ; i++){
			if(i == stp){
				$('#top_angebot_'+i+' cufon').css('visibility', 'visible');	
			}else{
				$('#top_angebot_'+i+' cufon').css('visibility', 'hidden');
			}
		}
	}
}
