var screens=[{src:"apps/gmaths/images/screenA3.png",alt:"gMaths - Sine Graphs",title:"gMaths"},{src:"apps/gmaths/images/screenA4.png",alt:"gMaths - Pie Chart",title:"gMaths"},{src:"apps/gmaths/images/screen13.png",alt:"gMaths - Quadratic Graphs",title:"gMaths"},{src:"apps/gmaths/images/screenA7.png",alt:"gMaths - Histogram",title:"gMaths"},{src:"apps/gmaths/images/screenA8.png",alt:"gMaths - Grouped Data",title:"gMaths"},{src:"apps/amaths/images/screen1.png",alt:"AMaths - Simultaneous Quadratic Equations",title:"AMaths"},{src:"apps/amaths/images/screen10.png",alt:"AMaths - Solving Trigonometric Equations",title:"AMaths"},{src:"apps/amaths/images/screenq8.png",alt:"AMaths - Differentiation",title:"AMaths"},{src:"apps/amaths/images/screen7.png",alt:"AMaths - Area Under a Curve",title:"AMaths"},{src:"apps/amaths/images/screen2.png",alt:"AMaths - Quadratic Inequalities",title:"AMaths"},{src:"apps/gphysics/images/screen1.png",alt:"gPhysics - Speed, Velocity and Acceleration",title:"gPhysics"},{src:"apps/gphysics/images/screen2.png",alt:"gPhysics - The Motion of an Object",title:"gPhysics"},{src:"apps/gphysics/images/screenS12.png",alt:"gPhysics - Gravity Simulation",title:"gPhysics"},{src:"apps/gphysics/images/screen5.png",alt:"gPhysics - Density",title:"gPhysics"},{src:"apps/mathengine/images/screen4.png",alt:"MathENGINE - Calculations and Graph",title:"MathENGINE"},{src:"apps/mathengine/images/screen7.png",alt:"MathENGINE - Calculations",title:"MathENGINE"},{src:"apps/mathengine/images/screen5.png",alt:"MathENGINE - Calculations and Graphs",title:"MathENGINE"},{src:"apps/mathengine/images/screen8.png",alt:"MathENGINE - Trigonometric Calculations",title:"MathENGINE"},{src:"apps/mathengine/images/screen2.png",alt:"MathENGINE - Quadratic and Reciprocal Graphs",title:"MathENGINE"},{src:"apps/geoact/images/screen1.png",alt:"Geometry In Action - Circle Theorems",title:"Geometry In Action"},{src:"apps/geoact/images/screen4.png",alt:"Geometry In Action - Circles and Angles",title:"Geometry In Action"},{src:"apps/geoact/images/screen7.png",alt:"Geometry In Action - Circles and Angles",title:"Geometry In Action"},{src:"apps/gict/images/screen1.png",alt:"gICT - CPU",title:"gICT"},{src:"apps/logo/images/screen11.png",alt:"Logo - Triangle and Square",title:"Logo"},{src:"apps/logo/images/screen4.png",alt:"Logo - Cosine Curve",title:"Logo"},{src:"apps/designpoint/images/screen1.png",alt:"DesignPoint - Lightbulb",title:"DesignPoint"},{src:"apps/designpoint/images/screen5.png",alt:"DesignPoint - Porch",title:"DesignPoint"},{src:"apps/pendraw/images/screen1.png",alt:"PenDraw - Flowers",title:"PenDraw"},{src:"apps/pendraw/images/screen2.png",alt:"PenDraw - Apples",title:"PenDraw"}];var prevButtonImageUrl="images/button_prev.png";var prevButtonImageOverUrl="images/button_prev_over.png";var nextButtonImageUrl="images/button_next.png";var nextButtonImageOverUrl="images/button_next_over.png";var fadeOutDuration=500;var fadeInDuration=1000;var fadedOpacity=0.5;var curIndex=0;var curDirection=0;var nextImage;var waitingOnLoad=false;function initShowcase(){shuffleScreens();setupNavigatorButtons();preloadImage(screens[1].src);animateScreen()}function shuffleScreens(){for(var a=0;a<screens.length-1;a++){var b=Math.floor(Math.random()*(screens.length-1));var c=screens[a];screens[a]=screens[b];screens[b]=c}}function setupNavigatorButtons(){$("#next").mouseenter(function(){$("#next").attr("src",nextButtonImageOverUrl)}).mouseleave(function(){$("#next").attr("src",nextButtonImageUrl)}).click(function(){$("#showcaseContainer").stop(true);curIndex=(curIndex+1)%screens.length;animateScreen()});$("#prev").mouseenter(function(){$("#prev").attr("src",prevButtonImageOverUrl)}).mouseleave(function(){$("#prev").attr("src",prevButtonImageUrl)}).click(function(){$("#showcaseContainer").stop(true);curIndex--;if(curIndex==-1){curIndex=screens.length-1}animateScreen()})}function animateScreen(){$("#showcaseContainer").css("background-image","url('"+screens[curIndex].src+"')");$("#showcaseContainer").css("background-position","0 0");$("#showcaseContainer").css("background-position-val",0);$("#showcaseContainer").removeAttr("background-position-val");$("#showcaseTitle").html(screens[curIndex].alt);$("#showcaseContainer").animate({"background-position-val":-460},{duration:5000,step:function(a,b){switch(curDirection){case 0:$("#showcaseContainer").css("background-position",a.toString()+"px 0px");break;case 1:$("#showcaseContainer").css("background-position","0px "+a.toString()+"px");break;case 2:$("#showcaseContainer").css("background-position",a.toString()+"px "+a.toString()+"px");break}},complete:function(){curDirection=(curDirection+1)%3;curIndex=(curIndex+1)%screens.length;if(nextImage.complete){fadeOutScreen()}else{waitingOnLoad=true}}})}function fadeOutScreen(){preloadImage(screens[(curIndex+1)%screens.length].src);$("#showcaseContainer").animate({opacity:fadedOpacity},{duration:fadeOutDuration,complete:function(){showScreen()}})}function showScreen(){$("#showcaseContainer").css("background-image","url('"+screens[curIndex].src+"')");$("#showcaseContainer").css("background-position","0 0");$("#showcaseContainer").css("background-position-val",0);$("#showcaseContainer").removeAttr("background-position-val");$("#showcaseTitle").html(screens[curIndex].alt);$("#showcaseContainer").animate({opacity:1},{duration:fadeInDuration,complete:function(){animateScreen()}})}function preloadImage(a){nextImage=new Image();nextImage.src=a;nextImage.onload=function(){if(waitingOnLoad){waitingOnLoad=false;fadeOutScreen()}}};
