/* JS functions
    
	index -> 	
				section nav
				gallery
				
*/
// =section-nav collapse menu
$(document).ready(function() {
	
	// ordered list extra styling
	$("ol > li").wrapInner(document.createElement("span"));
	
	// table striping
	$('table tr:gt(1):even').addClass('odd');


	// =section nav
	// Expand only the active menu, which is determined by the class name
	$("#section-nav > ul > li > a[@class=expanded] ").find("+ ul").slideToggle("1000");

	// add class 'nested' if li has children
	$("#section-nav > ul > li:has(ul)").addClass("nested");

        // check if menu is already open (php), add li 'active' class for this element
        $("#section-nav > ul > li > a").each(function(i){
            if( $(this).hasClass("expanded") && $(this).parent().hasClass("nested") ) {
               $(this).parent().addClass("active"); ;
            }
        });



	// Toggle the selected menu's class and expand or collapse the menu
	$("#section-nav > ul > li > a").click(function() {
		$(this).toggleClass("expanded").toggleClass("collapsed").find("+ ul").slideToggle("medium");
		if($(this).parent().hasClass("nested")) {
			$(this).parent().toggleClass("active");
                        return false;
		}
	});
	
	
	// =gallery
	$('#large-format')
	.after('<ul id="thumbs">')
	.cycle({ 
	    fx:     'fade', 
	    speed:   2000, // speed of transition
	    timeout: 5000, // auto slideshow 
	    pause:   0,
		pager: "#thumbs",
		pauseOnPagerHover: 1
	});
	
	// =lightbox
	$(function() {
		$('a.lightbox').lightBox({
			fixedNavigation:true,
			overlayOpacity: 0.5,
			imageBtnClose: 'http://www.luxurymarketing.com.au/public/img/lightbox-btn-close.gif'
		}); // Select all links with lightbox class
	});
	
	// hover overlay
	$(".overlay").hover(
	function() {
		$(this).parent().addClass("active");
		},
	function() {
		$(this).parent().removeClass("active");
		}
	);

	$(".overlay").click(function() {
    	window.location=$(this).find("a").attr("href"); return false;
	});
	
// end jquery functions
});
	