$(document).ready(function(){
	if($('#ixp').val() != '1'){
		$('#hide_flug').css('display', 'block');
	}else{
		$('#hide_flug').css('display', 'none');
	}

	loadScroll();

	$.ajax({
		url: "ajax/dsi.php?region="+region+"&dsi="+dsi,
		type: "GET",
		dataType: "text",
		success: function(msg){
			$('#dsia').html(msg);
		}
	});

	$('#search_hidden_btn').click(function(){
		if($('.search_hidden').css('display') == 'none'){
			$(this).attr('src', 'templates/oneholiday/details_ausblenden.gif');
			$('.search_hidden').css('display', 'block');
		}else{
			$(this).attr('src', 'templates/oneholiday/details_einblenden.gif');
			$('.search_hidden').css('display', 'none');
		}
	});

	$('#dsi').change(function(){
		$.ajax({
			url: "ajax/dsi.php?region="+$(this).val(),
			type: "GET",
			dataType: "text",
			success: function(msg){
				$('#dsia').html(msg);
			}
		});
	});

	// -> Flug -> nur Flug
	$('#ixp').change(function(){
		if($(this).val() != '1'){
			$('#hide_flug').css('display', 'block');
		}else{
			$('#hide_flug').css('display', 'none');
		}
	});
});

var ol = false;

function layer(open){
	if(ol != false){
		$('#'+ol).css('display', 'none');
	}
	
	if(ol != open){
		$('#'+open).css('display', 'block');
		ol = open;
	}else{
		$('#'+ol).css('display', 'none');
		ol = false;
	}
}

// -> Top Angebot:
var position = 0;
var lod = 1;

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_scroller');
	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';
		}
	}
}