var stack = new Array();
var maxFaq = 0;
function getRandom(min, max) {
	return min + parseInt(Math.random() * ( max-min+1));
}
function showFaq(index) {	
	var link;
	$(stack[index]).each(function(i){
		$(this).show();
		$(this).find('a.list').toggle(
        function(){
			var classes = $(this).attr("class").split(" ");
			$(this).css('background', 'url(pool/css/img/list_close.gif) 4px 0 no-repeat');
			$('#'+classes[1]).show();
			return false;
	    },
		function(){
            var classes = $(this).attr("class").split(" ");
			$(this).css('background', 'url(pool/css/img/list_open.gif) 4px 0 no-repeat');
      		$('#'+classes[1]).hide();
      		return false;
		}
       )        
    });
}
$(document).ready(function() {
	var current, index;
	if(!maxFaq)maxFaq = 10; 
    $('div.faqListBox').each(function(i){
        index = parseInt(i/maxFaq);
        if(!stack[index])stack[index] = new Array();
        stack[index].push(this);
        $(this).hide();        
    });
    current = getRandom(0,stack.length-1);
    if (location.search.lastIndexOf('all') > 0){
        $(stack).each(function(i){
             showFaq(i);
        });
    } else {
        showFaq(current);
    }
});