function initWait() {
	if (!document.getElementsByTagName)	{ 
		return; 
	}
	if(document.getElementById("upload") != null) {
		$("upload").onclick = function () { 
			$("submit_imgupload").className = "hidden"; 
			$("wait").className = "show";
		}
	}
	if(document.getElementById("horizontal_carousel") != null) {
		
		var cookieName = $("horizontal_carousel").className;
		var position = readCookie(cookieName);
		
		var carousel = new UI.Carousel("horizontal_carousel").observe('scroll:ended', function(event) {
			if (cookieName != 'suchen') {
				createCookie(cookieName, carousel.currentIndex(), 0);
			}
		});
		
		if (position && (position >= 1)) {
			carousel.scrollTo(position);
		}
		
	}
} 

Event.observe(window, 'load', initWait, false);

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

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}