//jQuery!
var last_object=null;
$(function(){
    
	//sidebar navigation functions
	$('#nav>li>ul').hide();

    $('#nav>li').mouseover(function(){    
	    // check that the menu is not currently animated
        if ($('#nav ul:animated').size() == 0) {
			if(last_object!=null)
				last_object.removeClass('open');
            // create a reference to the active element (this)
            // so we don't have to keep creating a jQuery object
            $heading = $(this);
			$heading.addClass('open');
			last_object=$heading;
            // create a reference to visible sibling elements
            // so we don't have to keep creating a jQuery object
            $expandedSiblings = $heading.siblings().find('ul:visible');
            if ($expandedSiblings.size() > 0) {
                $expandedSiblings.slideUp(500, function(){
                    $heading.find('ul').slideDown(500);
					
                });
            }
            else {
                $heading.find('ul').slideDown(500);
            }
        }
    });
    
    //PAGINATION FUNCTIONS
    
    //photo galleries
    $('#Photo_Gallery_Pagination').change(function(){
    	window.location("photo-galleries.php?Page="+$(this).val());
    });
    
    //photo album profile
    $('#Photo_Album_Pagination').change(function(){
    	window.location("gallery.php"+$(this).val());
    });
    
    //konami code!
	var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65"; 
		$(document).keydown(function(e) { 
		  kkeys.push( e.keyCode ); 
		  if ( kkeys.toString().indexOf( konami ) >= 0 ){ 
		    $(document).unbind('keydown',arguments.callee); 
		    	$.getScript('http://www.cornify.com/js/cornify.js',function(){
			      cornify_add();
			      $(document).keydown(cornify_add);
	     		});
		  } 
	}); 
});


//kept in for legacy code
//this should go before the final release
function showHide(id) {
	e = document.getElementById(id);

	if (e.style.display == 'none') {
		e.style.display = 'inline';
	} else if (e.style.display == 'inline') {
		e.style.display = 'none';
	}

}
function hideHide(id) {
	e = document.getElementById(id);

	if (e.style.display == 'inline') {
		e.style.display = 'none';
	} 

}


