// Add event function
function addEvent(elm, evType, fn, useCapture) {
	if(elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
		}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
		}
	else {
		elm['on' + evType] = fn;
		}
	}

// jQuery functions
$(document).ready(function(){

	// Bind facebox links
	$('a[rel*=facebox]').facebox();


	// Only bind subscription form when facebox is revealed
	$(document).bind('reveal.facebox', function() { 

		// Subscription form - Check it exists first
		if ( $("#frmSubscribeToList").length > 0 ) { 
	
			// Hide subscription response 
			$('#subscribeResponse').hide();
		
			// bind form using ajaxForm 
			$('#frmSubscribeToList').ajaxForm({ 
				// target identifies the element(s) to update with the server response 
				target: '#subscribeResponse', 
		
				beforeSubmit: function() {
					// Hide subscription response 
					$('#subscribeResponse').hide();
				},
					
				// success identifies the function to invoke when the server response 
				// has been received; here we apply a fade-in effect to the new content 
				success: function() { 
					// Show response
					$('#subscribeResponse').fadeIn('slow'); 
				}
			}); 
		}
	});


	$(".helpButton").click(function() {
		$("#content").addClass("helpPanel")
		$('#helpPanel').show('slow')
		return false;
	});

	$("#helpPanelTitle").click(function() {
		$('#helpPanel').hide('slow');
		$("#content").removeClass("helpPanel")
		return false;		
	});		
			   

	// Use the 'example' plugin on the search box
	$("#sSearchString").example('Search...');	

	// Use the 'example' plugin to convert hint text
		// Loop through all inputs on the page
		$("input").each(function() {
			// If a 'hint' element has been defined, apply the example plugin
			if ( $(this).siblings("span.hint").length > 0 ) {
				// Apply example plugin
				$(this).example(function() {
					// Fill example plugin with contents of the hint element
					return $(this).siblings("span.hint").html(); 
				})
			}
		});


});



