document.observe("dom:loaded", function() {
	var w = $$('html')[0].getWidth();
	if(w < 1010 && w > 850){
		$('home').setSyle({
			overflowX : "hidden"
		});
	}
	
	$$('.delme').each(function(it) {
		it.observe('focus', function() {
			if ($(this).match('input')) {
				var orival = $(this).getValue();
				$(this).value = "";
			}else{
				var orival = $(this).innerHtml;
				$(this).update("");
			}

			$(this).observe('blur', function() {
				if($(this).match('input')){
					if ($(this).getValue() != "" && $(this).getValue() != orival) {
						$(this).removeClassName('delme').stopObserving('blur').stopObserving('focus');
					}else{
						$(this).value = orival;
					}
				}else{
					if ($(this).innerHtml != "" && $(this).innerHtml != orival) {
						$(this).removeClassName('delme').stopObserving('blur').stopObserving('focus');
					}else if ($.browser.safari && $(this).getValue() != "" && $(this).getValue() != orival) {
						$(this).removeClassName('delme').stopObserving('blur').stopObserving('focus');
					}else{
						$(this).update(orival);
					}
				}
			});
		});
	});
	

	if ($("carousel")) {
		theCarousel = new UI.Carousel("carousel");
		setTimeout('autoScroller(theCarousel)', 7000);
	}
	
});

var autoScroller = function(carousel) {
	elements = carousel.elements.length
	win = 6
	lastIndex = Math.ceil(elements - elements / win)
	if ((carousel.currentIndex() + win) >= lastIndex)
		carousel.scrollTo(0);
	else
		carousel.scrollTo(carousel.currentIndex() + win);
	
	setTimeout('autoScroller(theCarousel)', 7000);
};