function myInit() {
	
	/*
	$("#navigation > ul > li").hover( function () {		
		$("#navigation ul > li").removeClass('hover');
		$(this).addClass('hover');
		},function () {
		//$(this).removeClass('hover');
		}
		);
	*/
	
	$("a[href^='http:']").not("[href*='musicastherapy.org']").attr('target','_blank');
	
	$('#navigation ul li:has(li.selected)').addClass('selected');
	
	$('#navigation > ul > li.selected > ul > li:last').addClass('last');
	
	$('#content #gallery img').hover( function () {				
		src = $(this).attr("src");
		newsrc = src.replace("t1_","");		
		$('#content #gallery #mainImage img').attr("src",newsrc);
		},function () {		
		}
		);

	$('#faq h3 a').click( function() {			
		$('#content div#faq div.faq').hide();
		$('#faq .on').removeClass('on');
								
		var theId = this.id;
		theDiv = theId.replace("q","a");		
		$('#'+theDiv).show();
		$(this).parent().addClass('on');
			
		return false;
		});
	
	$("#content div#faq div.faq").hide();
	
	
	$('#galleryScrollLeft').click( function() {
		galleryScrollLeft();
		return false;
		});
	
	$('#galleryScrollRight').click( function() {
		galleryScrollRight();
		return false;
		});
	
	$('.thumbnail').click( function() {
		imageId = this.id;
		imageId = imageId.replace('thumb_','');
		loadImage(imageId);
		return false;
		});
	
	$('#imageLarge').click( function() {
		loadImage(nextId);
		return false;
		});
	
	$('#slideshow').show().innerfade({ 
		speed: 600, 
		timeout: 4000, 
		type: 'sequence', 
		containerheight: '183px'
		});
	
	}


function loadImage(imageId) {
	
	if (!imageId) {
		return;
		}
		
	$('#imageLarge').fadeOut(200, function () {		
		$.ajax({
			type: "POST",
			url: "/loadImage.php",
			data: "imageId="+imageId,
			success: function(returned){	
				myData = returned.split("~");					
				$('#imageLarge').html(myData[0]);
				nextId = myData[1];
				$('#imageLarge').fadeIn(200, function () {				
					// scroll thumbnail into view
					//scrollThumbnails(myData[1]);
					
					});				
				}
			});			
		});	
	}


function galleryScrollLeft() {		
	if (scrollToInt > 0) {
		scrollToInt = parseInt(scrollToInt) - parseInt(scrollIncrement);
		scrollThumbnails(scrollToInt);
		}
	}
function galleryScrollRight() {	
	if (scrollToInt < (maxWidth-paneWidth)) {
		scrollToInt = parseInt(scrollToInt) + parseInt(scrollIncrement);
		scrollThumbnails(scrollToInt);
		} 
	}

function scrollToImage(imageId) {
	
	containerOffset = $('#thumbnails').offset();	
	thumbOffset = $('#thumb_'+imageId).offset();	
	scrollPixel = thumbOffset.left - containerOffset.left;	
	scrollThumbnails(scrollPixel)
	
	}
	
function scrollThumbnails(scrollPixel) {	
	
	if (scrollPixel < 0) {
		scrollPixel = 0;
		}
		
	$('#thumbnails').scrollTo(  scrollPixel, { axis:'x', duration:1000 } );	
	scrollToInt = parseInt(scrollPixel);	
	if (scrollPixel >= (maxWidth-paneWidth)) {
		$('#galleryScrollRight').addClass('disabled');
		}
	if (scrollPixel > 0) {
		//$('#scrollUp').fadeIn('normal');
		$('#galleryScrollLeft').removeClass('disabled');
		}
	if (scrollPixel < (maxWidth-paneWidth)) {
		//$('#scrollDown').fadeIn('normal');
		$('#galleryScrollRight').removeClass('disabled');
		}
	if (scrollPixel == 0) {
		//$('#scrollUp').fadeOut('normal');
		$('#galleryScrollLeft').addClass('disabled');
		}
	}