// 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;
		}
	}

// Open / Close help panel (jQuery)
$(document).ready(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;		
	});		

	// Thumbnail mouseover
    $('#thumbnails img.thumbnail').hover(
		function(){
			$(this).css('z-index', '99').animate({width:'58px', height:'58px', left:'-10px'},200);
		},
		function(){
			$(this).css('z-index', '1').animate({width:'38px', height:'38px', left:'0px'},200);
		}
	);

	// Image info
	$('#imageInfo').hide();
    $('#mainImage').hover (
	function(){
		$('#imageInfo').fadeIn('fast');
    },
	function(){
		$('#imageInfo').fadeOut('slow');
    });
});

// Use window load for lavalamp menu
$(window).load(function () {
	
	// Lavalamp menu
	$("#navigation ul").lavaLamp({
		speed: 300
	});

});



