$(document).ready(function(){
    // loads rollover script
   // SwapImage.rollover.init();
	
	_global.init();

    
    $('#overlay').hide().height($(document).height()).addClass('overlayWithJs');
    
    $('#oClose').click(function() {
        $('#overlay').fadeOut('fast');
        showing = false;
        return false;
    });
    
    $('#oWrap').hover(function() {
        hoverLay = true;
    }, function() {
        hoverLay = false;
    });
    
    $('#overlay').click(function() {
        if(!hoverLay) {
            $('#overlay').fadeOut('fast');
            showing = false;
            return false;
        }
    });
    
    $('.donate').click(function() {
       overlay(); 
       return false;
    });
    
// tabs

    if($('#tabNav').length) {
        
        function GetSiblingNumber(oElement) {
            return $(oElement).parent().children(oElement.nodeName).index(oElement);
        }
        
        $('.tabBox').each(function(i){
            $(this).attr("boxNo", i);
            //console.log($(this).attr('boxNo'));
            
            
        }).not(':first').hide();
        
        
        $('#tabNav li span a').each(function(i) {
            $(this).attr('tabNo', i);
        }).click(function() {
            theNo = $(this).attr('tabNo');
            $('.tabBox').hide().filter(':eq(' + theNo + ')').show();
            $(this).parent().parent().siblings().removeClass('on').end().addClass('on');
            return false
        });
        
    }
    
// contributors
    if($('.contributor').length) {
        
        
        $('.contribMore').hide();
        
        $('.rightBox').not('.noHover').hover(function() {
            $(this).addClass('rightBoxHover');
        }, function() {
            $(this).removeClass('rightBoxHover');
            
        }).click(function() {
            moreBox = $(this).children().children('.contribMore');
            
            if(!$(moreBox).is(':visible')) {
                $(moreBox).slideDown('fast');
                $(this).children().children('.plus').addClass('cross');
                
            } else {
                $(moreBox).slideUp('fast');
                $(this).children().children('.plus').removeClass('cross');
            }
            return false
        });
        
    }

// Remembrance Wall	

	if($('#mainSpeech')) {
		
		addOffset = $('#rightMove').offset().top;
		
		$(window).scroll(function() {
			
			if($(document).scrollTop() == addOffset) {
				
			}
	
		});	
		
	}
	
// shop

	if($('#shop')) {
		
		$('.sMore').hide();
		$('.sTitle a').click(function() {
			theBox = $(this).parent().next();
			
			if(theBox.is(':visible')) {
				theBox.slideUp('fast');
			} else {
				theBox.slideDown('fast');
				
			}
			return false;
		});
		
		

		   $(".sMainImage").fancybox({
	        'zoomSpeedIn': 200,
	        'zoomSpeedOut': 200,
	        'overlayShow': true,
	        'overlayOpacity': 0
	    });
	}
    
});

_global = function() {
	
	function init() {
		dropDowns();
	}
	
	function dropDowns() {
		$('#header ul li ul').hide().addClass('jsHover');
		
		$('#header ul li').hover(function() {
			$(this).children('ul').stop(false,true).fadeIn('fast');
		}, function () {
			$(this).children('ul').stop(false,true).fadeOut('fast');
			
		});
	}
	
	return {
		init: init
	}
	
}();


function resizeGallery(size) {
    $('#galleryFlash').css('height', size);
    //$('#galleryWrap').animate({ height: size }, 1000)
}

//overlay
showing = false;
hoverLay = false;

function overlay() {
    if(showing) {
        $('#overlay').fadeOut('fast');
        showing = false;
    } else {
        $('#oWrap').css('top', $(document).scrollTop()+40 + "px");        
        $('#overlay').fadeIn('fast');
        showing = true;
    }
}

// image rollovers


// fonts we're using

var ll = {
   src: '/assets/swf/LLCharlotte.swf',
   selectable: true
 };
 


//activate them

sIFR.activate(ll);

//target elements to replace



sIFR.replace(ll, {
   selector: '.mainBlue, #homeLeft h1, #mainTitle, #eventHead h1, #eRight h1'
   ,css: [
     '.sIFR-root { color: #2d2b75; font-size: 36px; }'
     
   ],
   wmode: 'transparent'
});

sIFR.replace(ll, {
   selector: '#share p'
   ,css: [
     '.sIFR-root { color: #2d2b75; font-size: 28px; }'
     
   ],
   wmode: 'transparent'
});

sIFR.replace(ll, {
   selector: '.widget h3'
   ,css: [
     '.sIFR-root { color: #ffffff; font-size: 27px; }'
     
   ],
   wmode: 'transparent',
   tuneHeight: -4
});



