var TVnotify = {
	search_for_value: 'TV Show'
}

Event.observe(window, "load", function() { 
	if ($('for')){
		if ($('for').value=='') { $('for').value = TVnotify.search_for_value }
		Event.observe($('for'), "focus", function() {if ($('for').value==TVnotify.search_for_value) { $('for').value = '' }});
		Event.observe($('for'), "blur", function() {if ($('for').value=='') { $('for').value = TVnotify.search_for_value }});
	}
	
	TVnotify.checkboxes = $$('.checkbox');
	for (var i=0; i < TVnotify.checkboxes.length; i++) {
		var checkbox = TVnotify.checkboxes[i].getElementsByTagName('input')[0]
		Event.observe(checkbox, "change", function () {
			var fieldset = this.parentNode.getElementsByTagName('fieldset')[0];
			console.log(this)
			if (this.checked) {
				if(fieldset){fieldset.show()}
			} else {
				if(fieldset){fieldset.hide()}
			}
		})
		var fieldset = TVnotify.checkboxes[i].getElementsByTagName('fieldset')[0]
		if (checkbox.checked) {
			if(fieldset){fieldset.show()}
		} else {
			if(fieldset){fieldset.hide()}
		}
	};
	setTimeout(function() {
		TVnotify.notices = $$('.notice')
		TVnotify.errors = $$('.error')
		for (var i=0; i < TVnotify.notices.length; i++) {
			new Effect.Fade(TVnotify.notices[i], {duration: 2})
		};
		for (var i=0; i < TVnotify.errors.length; i++) {
			new Effect.Fade(TVnotify.errors[i], {duration: 2})
		};
	}, 1200);
});