function listenPanelAdvance() { $("#advance li").click( function(){ var slidecount = 2; if ($(this).attr("id") == "next_panel") { // if the last slide is on display, show the first slide if ($("#panel"+slidecount).css("z-index") == "3") { $("#tiny_panel"+slidecount).removeClass("curr_panel"); $("#tiny_panel1").addClass("curr_panel"); $("#panel1 embed").css("display","none"); $("#panel1").css("z-index","2").css("display","block"); $("#panel"+slidecount+" embed").css("display","none"); $("#panel"+slidecount).animate( {"left": "-=1000px"}, "slow", function(){ $("#panel1 embed").css("display","block"); $("#panel1").css("z-index","3"); $("#panel"+slidecount).css("z-index","1").css("left","0").css("display","none"); } ); } else //otherwise determine which slide is on display and increment to the next one { for (i=slidecount-1;i>0;i--) { if ($("#panel"+i).css("z-index") == 3) { var current_slide = i; $("#tiny_panel"+current_slide).removeClass("curr_panel"); $("#tiny_panel"+(current_slide+1)).addClass("curr_panel"); $("#panel"+(current_slide+1)+" embed").css("display","none"); $("#panel"+(current_slide+1)).css("z-index","2").css("display","block"); $("#panel"+current_slide+" embed").css("display","none"); $("#panel"+current_slide).animate( {"left": "-=1000px"}, "slow", function(){ $("#panel"+(current_slide+1)+" embed").css("display","block"); $("#panel"+(current_slide+1)).css("z-index","3"); $("#panel"+current_slide).css("z-index","1").css("left","0").css("display","none"); } ); } } } } else { //find clicked slide for (i=1;i<=slidecount;i++) { if ($(this).attr("id") == "tiny_panel"+i) var clicked_panel = i; if ($("#panel"+i).css("z-index") == 3) var current_panel = i; } if (current_panel != clicked_panel) { $("#tiny_panel"+current_panel).removeClass("curr_panel"); $("#tiny_panel"+clicked_panel).addClass("curr_panel"); $("#panel"+clicked_panel+" embed").css("display","none"); $("#panel"+clicked_panel).css("z-index","2").css("display","block"); $("#panel"+current_panel+" embed").css("display","none"); $("#panel"+current_panel).animate( {"left": "-=1000px"}, "slow", function(){ $("#panel"+clicked_panel+" embed").css("display","block"); $("#panel"+clicked_panel).css("z-index","3"); $("#panel"+current_panel).css("z-index","1").css("left","0").css("display","none"); } ); } } }); } $(document).ready(function(){ listenPanelAdvance(); });