// holiday fieberbrunn - gingebaker - klubarbeit.net
window.addEvent("domready", initFieberbrunnHoliday);
var scroll_width = 841;
var timeout_scroll = false;

function initFieberbrunnHoliday() {
	initScroller();
}


function initScroller() {
	if($('fotoSlideContainer')) {
		var tc = $('fotoSlideContainer');
		var cl = $('control_left');
		var cr = $('control_right');
		if(tc.getElements('a').length < 5) {
			cr.setStyle('opacity',0.20);
			cl.setStyle('opacity',0.20);
			return false;	
		}
		
		var myScroll = new Fx.Scroll(tc, {
			duration: 'long',
			transition: Fx.Transitions.Cubic.easeInOut
		});
		cl.setStyle('cursor','pointer');
		cr.setStyle('cursor','pointer');
		cl.setStyle('opacity',0.50);
		cr.addEvent('click',function() {
			if((tc.getScroll().x + scroll_width) >= tc.getScrollSize().x) {
				cl.setStyle('opacity',0.50);
				cr.setStyle('opacity',1);
				myScroll.start(0,0);
			} else {
				new_x = tc.getScroll().x + scroll_width;
				myScroll.start(new_x,0);
				cl.setStyle('opacity',1);
				(new_x + scroll_width) >= tc.getScrollSize().x ? cr.setStyle('opacity',0.50) : cr.setStyle('opacity',1);
			}
			setNewDelayScroller();
			return false;
		});
		cl.addEvent('click',function() {
			new_x = tc.getScroll().x - scroll_width;
			myScroll.start(new_x,0);
			cr.setStyle('visibility','visible');
			cr.setStyle('opacity',1);
			(new_x - scroll_width) <= -scroll_width ? cl.setStyle('opacity',0.50) : cl.setStyle('opacity',1);
			setNewDelayScroller();
			return false;
		});
	}
	setNewDelayScroller();
}

function setNewDelayScroller() {
	if(timeout_scroll)
		$clear(timeout_scroll);
	timeout_scroll = fireScrollEvent.delay(8000);
}

function fireScrollEvent() {
	$('control_right').fireEvent('click')
}

//For Searchbox
  function addzero( value )
   {
      while( value.length<2 ) value = String("0") + value;
      return value;
   }
    
function checkDateOrder(frm, ci_day, ci_month_year, co_day, co_month_year) {
	if (document.getElementById) {
		var frm = document.getElementById(frm);
		// create date object from checkin values
		// set date to 12:00 to avoid problems with one
		// date being wintertime and the other summertime
		var my = frm[ci_month_year].value.split("-");
	    var ci = new Date (my[0], my[1]-1, frm[ci_day].value, 12, 0, 0, 0);

        // create date object from checkout values
	    my = frm[co_month_year].value.split("-");
	    var co = new Date (my[0], my[1]-1, frm[co_day].value, 12, 0, 0, 0);

		// if checkin date is at or after checkout date,
		// add a day full of milliseconds, and set the
		// selectbox values for checkout date to new value
	    if (ci >= co){
    	    co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
	        frm[co_day].value =  co.getDate();
    	    var com = co.getMonth()+1;
	        frm[co_month_year].value = co.getFullYear() + "-" + com;
    	}
	}
}