/**
 * Shows the hidden divs that need to be displayed based on
 * what the current page is.
 */
function activateDocPage() {
	var currentElement = $('#currentHelpItem'); 
        currentElement.show(); 
        var ancestors = currentElement.parents();
	for (i=0; i<ancestors.length; i++) {
		if (!$(ancestors[i]).is(':visible')) {
			$(ancestors[i]).show();
		} 
	} 
}

/**
 * Used to make outputting to the FireBug window easier :)
 * @param string What to output
 */
function debug(message)
	{
	if (typeof console != 'undefined' && typeof console.debug != 'undefined')
		{
		console.info(message); 
		}
	}

function initHome() {
    $(document).ready(function() {
	
        // Load remaining images
        var imagePaths = [
            pb.template_url + '/images/homePage/slide-2.jpg',
            pb.template_url + '/images/homePage/slide-3.jpg',
            pb.template_url + '/images/homePage/iPhone.png',
            pb.template_url + '/images/homePage/pinkSimplicity.jpg'
        ];
        
        for (i=0; i<imagePaths.length; ++i) {
            $('.homeImage').append('<img src="' + imagePaths[i] + '">'); 
        }
        
        // Takes care of not running the slideshow if there's only one image
        if ($('.homeImage').children().length < 2) {
            return; 
        }
        
        // Slideshow script
        $('.homeImage img:gt(0)').hide(); 
	setInterval(function() {
		$('.fadein :first-child').fadeOut(2500)
			.next('img').fadeIn(2500)
			.end().appendTo('.fadein');},
		10000);
    });
}

function initDownload() {
    $(document).ready(function() {
        $('a.linkDownload').click(function() {
            _gaq.push(['_trackEvent', 'Files', 'Download', $(this).attr('data-version')]);
        });
    });
}

/** functions that need to run on every page */
function initMain() {
    
    // Attach analytic events to anything with an evt class
    $('.evt').click(function() {
        _gaq.push(['_trackEvent', $(this).attr('data-category'), $(this).attr('data-action'), $(this).attr('data-label')]);
    });
}
