window.addEvent('domready', function()
{
	if($('frmCoupon')) {
		$('frmCoupon').addEvent('submit', function(e) {
			var reg = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
			if(!$('password').value || !$('email').value || $('password').value!='schneeflockerl' || !reg.test($('email').value)) { 
				alert('Please enter a valid email and password.');
				return false;
			} 
		});
	}

	if($('menu_winter')) {
		$('menu_winter').addEvent('click', function(e) {
			e.stop();
		});
	}

	if($('menu_summer')) {
		$('menu_summer').addEvent('click', function(e) {
			e.stop();
		});
	}
	
	//contest
	if($('sbtContest')) { 
		$('ContestName').addEvent('focus', function(e) { if(this.value==this.defaultValue) this.value=''; }); 
		$('ContestEmail').addEvent('focus', function(e) { if(this.value==this.defaultValue) this.value=''; }); 
		$('sbtContest').addEvent('click', function(e) {
			e.stop();
			var reg = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
			if(!$('ContestName').value || !$('ContestEmail').value || !$('ContestSpam').value || !reg.test($('ContestEmail').value)) { 
				alert('Please complete all fields.');
				return false;
			} else {
				var req = new Request.HTML({ 
					method: 'post',
					data: $('frmContest'),
					url: "../inc/contest.php",
					update: $('msg')
				}).send(); 
			}
		}); 
	}

	//news ticker
	autoScroll('newsslider','newssection',5,true);

	//Popups
	MochaUI.Desktop = new MochaUI.Desktop();
	MochaUI.Dock = new MochaUI.Dock();

	MochaUI.PopUp = function(id) { 
		new MochaUI.Window({
			id: 'VideoPopup',
			type: 'window',
			title: 'Video',
			loadMethod: 'xhr',
			contentURL: '../inc/video.php?id=' + id,
			width: 500,
			height: 350,
			headerStartColor: [0,139,121],
			headerStopColor: [149,197,190],
			footerHeight: 10
		});
	}

	MochaUI.MapPopup = function(id) { 
		new MochaUI.Window({
			id: 'MapPopup',
			type: 'window',
			title: 'Map',
			loadMethod: 'xhr',
			contentURL: '../inc/map.php?id=' + id,
			width: 500,
			height: 350,
			headerStartColor: [0,139,121],
			headerStopColor: [149,197,190],
			footerHeight: 10
		});
	}

	$$('a').each(function(el) {  
		if(el.href.indexOf('videos')!=-1) { 
			el.addEvent('click', function(e){
				new Event(e).stop();
				MochaUI.PopUp(el.id);
			}.bind(el));
		}
	});

	$$('a.map').each(function(el) {  
		el.addEvent('click', function(e){
			new Event(e).stop();
			MochaUI.MapPopup(el.id);
		}.bind(el));
	});



});