$(document).ready(
		function() {
			$('form[validate]').each(function() {
				formId = $(this).attr('id');
				$('#' + formId).validate({
					event : $(this).attr('validate')
				});
			});

			$('#pains div').vTicker({
				speed : 1000,
				pause : 3000,
				height : 160,
				showItems : 5,
				direction : 'up'
			});

			$('#news div').vTicker({
				speed : 1000,
				pause : 3500,
				height : 160,
				showItems : 5,
				direction : 'up'
			});

			$('#faq li').click(function() {
				$(this).parent().find('a').css('color', '');
				$(this).parent().find('div').slideUp('slow').fadeOut('slow');
				$(this).find('a').css('color', 'red');
				$(this).find('div:hidden').slideDown('slow').fadeIn('slow');
			});

			// custom css expression for a case-insensitive contains()
			$.expr[':'].Contains = function(a, i, m) {
				return (a.textContent || a.innerText || "").toUpperCase()
						.indexOf(m[3].toUpperCase()) >= 0;
			};

			function listFilter(header, list) {
				var form = $("<form/>").attr({
					"class" : "filterform",
					"action" : "#"
				});
				var input = $("<input/>").attr({
					"class" : "filterinput"
				});
				$(form).append(input).prependTo(header);

				$(input).change(
						function() {
							var filter = $(this).val();
							if (filter) {
								// this finds all links in a list that contain
								// the input,
								// and hide the ones not containing the input
								// while showing the ones that do
								$(list)
										.find(
												"a:not(:Contains(" + filter
														+ "))").parent()
										.slideUp();
								$(list).find("a:Contains(" + filter + ")")
										.parent().slideDown();
							} else {
								$(list).find("li").slideDown();
							}
							return false;
						}).keyup(function() {
					// fire the above change event after every letter
					$(this).change();
				});
			}

			listFilter($("#uq_area"), $("#uq_area ul"));
		});

