
	 
	var playing;		// current playback status
	var wasPlaying;		// status prior to opening a modal
	var currentLayout = "vert";
	
	// document load method
	$(document).ready(function() 
	{
        // set ajax navigation triggers
        $('#homeLink').click(function() {return(LoadContent(true, 'index.html'));});
        $('#screenshotLink').click(function() {return(LoadContent(false, 'screenshots.html'));});
        $('#aboutLink').click(function() {return(LoadContent(false, 'about.html'));});
        $('#howLink').click(function() {return(LoadContent(false, 'how.html'));});
        $('#whyLink').click(function() {return(LoadContent(false, 'why.html'));});
        $('#getLink').click(function() {return(LoadContent(false, 'get.html'));});
        $('#updatesLink').click(function() {return(LoadContent(false, 'updates.html'));});
                
        // start the content cycling for this page's currently loaded slides
        LoadContent('', '');
    });
	
	
	function RotateScreenshots()
	{
		PausePlayback();
		$('#'+currentLayout+'Holder').fadeOut(1000, function()
		{
			if (currentLayout == "vert")
			{
				width = "190px";
				height = "105px";
				currentLayout = "horiz";
			}
			else
			{
				width = "105";
				height = "190";
				currentLayout = "vert";
			}
			
			$("#tdPhone").animate({"width": width}, "slow").animate({"height": height}, "slow");
			setTimeout(function()
			{
				$("#"+currentLayout+"Holder .lightbox:first").css('display','inline');
				$("#"+currentLayout+"Holder").fadeIn(1000);
				setTimeout(StartScreenshotLoop, 1000);
			}, 1500);
		});
	}

	// pauses the slide playback when a lightbox is opened
	function PauseOnOpen()
	{
		wasPlaying = playing;
		PausePlayback();
	}
	
	// resumes the slide playback (where applicable) when a lightbox is closed
	function PlaybackOnClose()
	{
		if (wasPlaying) {ResumePlayback();}
	}

	// pauses slide playback
	function PausePlayback(){
		playing = false;
        $('#'+currentLayout+'Holder').cycle('pause'); 
        $('#resumeButton').css('display', '');  
        $('#pauseButton').css('display', 'none');
	}

	// resumes slide playback
	function ResumePlayback()
	{
		playing = true;
        $('#'+currentLayout+'Holder').cycle('resume'); 
        $('#resumeButton').css('display', 'none');  
        $('#pauseButton').css('display', '');
	}
    
    // starts the slide loop
    function StartScreenshotLoop()
    {
        $('#'+currentLayout+'Holder').cycle({ 
            fx:         'fade', 
            speed: 		3500,
            sync:       0,
            timeout:    7000,
            prev:       '#prevButton',
            next:       '#nextButton'
        });
 
        $("#pauseButton").css('display', '');
        $("#resumeButton").css('display', 'none');
        
        playing = true;
    }

    // loads a specified page's content into the page (optional!) then kicks off the loop.
    function LoadContent(showHelp, page)
    {
    	if (page != '')
    	{
    		$('#slideHolder').fadeOut(1000);
    		$.post('./Helpers/getContent.php?page=' + page + '&help=' + showHelp, '', function(data) 
    		{
    			$('.contentHolder').html(data);
    			$('#slideHolder').fadeIn(1000);
    			
    			// initialize the lightbox component (if necessary)
    			$('.lightbox').lightbox({fitToScreen: true, onStart: PauseOnOpen, onClosing: PlaybackOnClose});
    			
    			// if the download/help link on the right is shown, append the click event
    			if (showHelp)
    			{
    				$('#helpLink1').click(function() {return(LoadContent(false, 'get.html'));});
    	        	$('#helpLink2').click(function() {return(LoadContent(false, 'get.html'));});
    			}
    		});
    	}
    	else
    	{
        	$('#slideHolder').fadeIn(1000, function()
        	{
        		// initialize the lightbox component (if necessary)
        		$('.lightbox').lightbox({fitToScreen: true, onStart: PauseOnOpen, onClosing: PlaybackOnClose});
        	});
    	}
    	return(false);
    }
    
    function ShowDemo()
  	{
  		window.open("demo.html","demo","location=1,status=1,scrollbars=1,width=740,height=740");
      	return(false);
  	}
 