/*Original Design by Nettuts.com
**
** Modified by Patrick Eisenmann for support for lightbox.
** peisenmann@gmail.com
**
** To get it to work, your call to this file (as well as jquery.js and jquery.history.js) should be:
** <script type="text/javascript" src="js.js">var $ = jQuery.noConflict();</script>
** Change src="js.js" to whichever file you are calling.
**
**
** Modified by Andre Bluehs for support for .php.
**	contagious@gatech.edu
*/
$(function()
{
	$('.scroll-pane').jScrollPane();
	$('a.media').media( {width: 280, height: 175, autoplay: true} );
	var gallery = $('#gallery').galleriffic('#navigation', {
			delay:                3000,
			numThumbs:            20,
			preloadAhead:         40, // Set to -1 to preload all images
			enableTopPager:       true,
			enableBottomPager:    true,
			imageContainerSel:    '#kidz_coloringbook_main',
			controlsContainerSel: '#gallery_page_nav',
			titleContainerSel:    '',
			descContainerSel:     '#kidz_coloringbook_description',
			downloadLinkSel:      '#kidz_coloringbook_download',
			renderSSControls:     true,
			renderNavControls:    true,
			playLinkText:         'Play',
			pauseLinkText:        'Pause',
			prevLinkText:         'Previous',
			nextLinkText:         'Next',
			nextPageLinkText:     'Next &rsaquo;',
			prevPageLinkText:     '&lsaquo; Prev'
			});
	

});		

$(document).ready(function() {
						   
	reinitialiseScrollPane = function()
		{
	        $('a.media').media( {width: 280, height: 175, autoplay: true} );
			$('.scroll-pane').jScrollPane();
			var gallery = $('#gallery').galleriffic('#navigation', {
			delay:                3000,
			numThumbs:            20,
			preloadAhead:         40, // Set to -1 to preload all images
			enableTopPager:       true,
			enableBottomPager:    true,
			imageContainerSel:    '#kidz_coloringbook_main',
			controlsContainerSel: '#gallery_page_nav',
			titleContainerSel:    '',
			descContainerSel:     '#kidz_coloringbook_description',
			downloadLinkSel:      '#kidz_coloringbook_download',
			renderSSControls:     true,
			renderNavControls:    true,
			playLinkText:         'Play',
			pauseLinkText:        'Pause',
			prevLinkText:         'Previous',
			nextLinkText:         'Next',
			nextPageLinkText:     'Next &rsaquo;',
			prevPageLinkText:     '&lsaquo; Prev'
			});

			

		}
					   
	$('#kidz_content').wrap('<div id="content-wrapper"></div>');
						   
	function pageload(hash) {
		if(hash.substr(hash.length-3, hash.length) == "asp") {
			$("#content-wrapper").load(hash.substr(0,hash.length-3) + ".asp #kidz_content",'',function(){
				$('#content-wrapper').fadeIn('normal');
				$('#load').fadeOut('normal');
				reinitialiseScrollPane();

			});
	}


		
/*		To add support for more file types, uncomment below, and change ...HERE...
**		to whatever you want to support. Also change ...NUMBER... to the length of
**		the name of the file type. i.e. php = 3, html = 4.
** 
**		else if(hash.substr(hash.length-...NUMBER..., hash.length) == "...HERE...") {
**			$("#content-wrapper").load(hash.substr(0,hash.length-...NUMBER...) + "...HERE... #content",'',function(){
**				$('#content-wrapper').show('normal');
**				$('#load').fadeOut('normal');												   
**			});
**	}
*/


		else if(hash) {
			$("#content-wrapper").load(hash + ".html #kidz_content",'',function(){
				$('#content-wrapper').fadeIn('normal');
				$('#load').fadeOut('normal');
				reinitialiseScrollPane();
				
			});
		} 
		
		else {
			$("#content-wrapper").load("kidz.asp #kidz_content", '', function(){
				reinitialiseScrollPane();

			}); //default
		}
	}
	
	$.historyInit(pageload);			   

	$('#kidz_nav a').click(function(){
								  
		var hash = $(this).attr('href');
		hash = hash.replace(/^.*#/, '');
		
		if (hash.substr(hash.length-3, hash.length) == "asp") {
			hash = hash.substr(0, hash.length-4) + "asp";
		}
/*		To add support for more file types uncomment below and change ...HERE...
**		to whatever you wish to support. also change ...NUMBER... to the length of 
** 		the name of the file type. i.e. php = 3, html = 4.
**
**		else if (hash.substr(hash.length-...NUMBER..., hash.length) == "...HERE...") {
**			hash = hash.substr(0, hash.length-...NUMBER...+1) + "...HERE...";
**		}
*/	
		
		else {
			hash = hash.substr(0,hash.length-5);
		}

		$('#content-wrapper').fadeOut('fast',function(){$.historyLoad(hash)});
		$('#load').remove();
		$('#sub_header').prepend('<span id="load">LOADING...</span>');
		$('#load').fadeIn('fast');
		return false;
		
	});
	
	// Plate Shaker 
	var in_hover = 0;
	
	$('.plate').hover(
		function(){
			if (!in_hover) {
			in_hover = 1;
			  $(this).effect("shake", { times: 1, distance : 5, direction: 'right' }, 100);
			}
			},//over
		function(){
			if (in_hover) {
			in_hover = 0;
		}

	}); //out

	

});

