// Class of the elements you wish to hide
var questionClass = "QuestionList";

// Collapse all elements
function collapseAll() {
    // Get all lists on the page
    var allSections = document.getElementsByTagName("UL");

    // For each list...
    for (i=0; i<allSections.length; i++) {
        // ... Make sure it is a QuestionList ...
        if (allSections[i].className == questionClass) {
            // ... If it is, set the display to none (hidden)
            allSections[i].style.display = "none";
        }
    }
}

// Expand a certain element
function expand(name) {
    // Collapse any shown elements
    collapseAll();

    // Is the element hidden?  If so show it.  If not, hide it.
    var newStyle = "";
    if (document.getElementById(name).style.display != "block") {
        // Show the element
        newStyle = "block";
    } else {
        // Hide the element
        newStyle = "none";
    }
	
    // Set the new style
    document.getElementById(name).style.display = newStyle;
}

// Easing equation, borrowed from jQuery easing plugin  |  http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; };

$(document).ready(function() {

// dropdown nav hover
	$('a.dropdown, .nav_hovered').hover(function() { 
		$('a.dropdown').css({ background: '#A4B9DD' });
		$('.nav_hovered').css({ display: 'block' });
	}, function() {
		$('.nav_hovered').css({ display: 'none' });
		$('a.dropdown').css({ background: 'transparent' });
	});
	
	$('#tombstoneScroller').serialScroll({
        items:'li',
        prev:'a.prev',
        next:'a.next',
        offset:-215, //when scrolling to photo, stop 230 before reaching it (from the left)
        start:1, //as we are centering it, start at the 2nd
        duration:1200,
        force:true,
        stop:true,
        lock:false,
        cycle:true, //don't pull back once you reach the end
        easing:'easeOutQuart', //use this easing equation for a funny effect
        jump: false //click on the images to scroll to them
    });

/* TOMBSTONE, FUNCTION VERSION */
	$('a[class|="clickPopOver"]').unbind();
	$('a[class|="clickPopOver"]').bind('click', function(e) {
		var tombstoneNum = $(this).parent('li').index() + 1;		
		// alert(tombstoneNum);
		
		e.preventDefault();
		$('#popOver').load('transactionsdetails.html #tombstone-' + tombstoneNum, function(){			
			$('#popOverContainer').css({ zIndex: '9997' });
			$('#mask').stop().animate({ opacity: '0.65' }, 250);
			$('#popOver').stop().animate({ opacity: '1' }, 500);
		});
	});
	$('#mask, .closeBtn').live('click', function(e) {
		e.preventDefault();
		$('#popOver').stop().animate({ opacity: '0' }, 250);
		$('#mask').stop().animate({ opacity: '0' }, 500);
		$('#popOverContainer').css({ zIndex: '-1' });
	});
	
});
