var slideshow_stop = 1;

var current_feature = 0; // Variable for determining which element of the features array will show, also initially determines which feature displays upon the page loading

var slideshow_speed = 4000; // Sets the speed at which the slide show displays each feature

var features = new Array(); // Create an array with each element having a different feature

features[0] = '<div class="function_header_01"><h3>SAFETY CHAIN AND CLIPS</h3></div><div class="function_body_01">All Work Platform Ladders come with strong fully welded safety chains and clips which cannot be removed by hand. Clip fixing locations do not protrude into the platform area or interfer with the use of the handrail.<br /><img src="images/features/safety_clip_01.jpg" alt="Safety Clip" /><img src="images/features/safety_clip_05.jpg"/></div>';

features[1] = '<div class="function_header_01"><h3>HANDRAIL</h3></div><div class="function_body_01">Seamless fully welded 900mm high handrail with midrail to ladder and platform.<br /><img src="images/features/hand_rails_01.jpg" alt="Hand Rails" /><img src="images/features/hand_rails_02.jpg" alt="Hand Rails" /><img src="images/features/hand_rails_03.jpg" alt="Hand Rails" /></div>';

features[2] = '<div class="function_header_01"><h3>SAFETY GATE</h3></div><div class="function_body_01">Work Platform Ladders over 2 metres in height have an inward opening safety gate which can be locked in the open or closed position. This provides a kickplate all around the platform as required by the Australian standards.<br /><img src="images/features/safety_gate_01.jpg" alt="Safety Gate" /><img src="images/features/safety_gate_02.jpg" alt="Safety Gate" /></div>';

features[3] = '<div class="function_header_01"><h3>FRAME DESIGN</h3></div><div class="function_body_01">Unique design allows the Work Platform Ladders to be flat packed for easy cost effective transport and storage. Each Work Platform Ladder comes with easy step by step installation instructions.<br /><img src="images/features/frame_01.jpg" alt="Frame Design" /><img src="images/features/frame_02.jpg" alt="Frame Design" /></div>';

features[4] = '<div class="function_header_01"><h3>TOOL TRAY</h3></div><div class="function_body_01">Keep tools and equipment dry and clean using the included tool tray.<br /><img src="images/features/tool_tray_01.jpg" alt="Tool Tray" /><img src="images/features/tool_tray_02.jpg" alt="Tool Tray"  alt="Tool Tray" /><img src="images/features/tool_tray_03.jpg" alt="Tool Tray" /></div>';

features[5] = '<div class="function_header_01"><h3>CASTORS</h3></div><div class="function_body_01">Heavy duty nylon castors allow the Work Platform Ladders to be easily moved around similar to a wheelbarrow. Bolt fixing allows the castor assembly to be replaced if damaged or easily changed to other castor styles and materials to suit different applications.<br /><img src="images/features/castor_01.jpg" alt="Castors" /><img src="images/features/castor_02.jpg" alt="Castors" /></div>';

features[6] = '<div class="function_header_01"><h3>CLEARANCE</h3></div><div class="function_body_01">Clearance of 200mm all around to allow access over equipment, tools and other obstacles.<br /><img src="images/features/clearance_01.jpg" alt="Clearance" /><img src="images/features/clearance_02.jpg" alt="Clearance" alt="Clearance" /><img src="images/features/clearance_03.jpg" alt="Clearance" /></div>';

features[7] = '<div class="function_header_01"><h3>C-SECTION</h3></div><div class="function_body_01">Specially designed lightweight "C" section provides high strength and torsional resistance. It also allows all fixings to be concealed and not protrude where they can cause injuries or damage.<br /><img src="images/features/c_section_01.jpg" alt="C Section" /><img src="images/features/c_section_02.jpg" alt="C Section" alt="C Section" /><img src="images/features/c_section_03.jpg" alt="C Section"/></div>';

features[8] = '<div class="function_header_01"><h3>FEET</h3></div><div class="function_body_01">Large feet with non slip PE (Polyethylene) mouldings to provide a stable footing.<br /><img src="images/features/feet_01.jpg" alt="Feet" /><img src="images/features/feet_02.jpg" alt="Feet" /></div>';

features[9] = '<div class="function_header_01"><h3>LIFTING HANDLES</h3></div><div class="function_body_01">Conveniently placed lifting handles allows the unit to be moved around easily.<br /><img src="images/features/lifting_handles_01.jpg" alt="Lifting Handles" /><img src="images/features/lifting_handles_02.jpg" alt="Lifting Handles" /><img src="images/features/lifting_handles_03.jpg" alt="Lifting Handles" /></div>';

features[10] = '<div class="function_header_01"><h3>TREADS</h3></div><div class="function_body_01">Special non slip extrusion section that is lightweight yet strong and will retain grip even with the dirtiest work boots.<br /><img src="images/features/treads_01.jpg" alt="Treads" /><img src="images/features/treads_02.jpg" alt="Treads" /></div>';

features[11] = '<div class="function_header_01"><h3>HEAVY DUTY PLATFORM</h3></div><div class="function_body_01">Non slip surface with 4.5mm thick plate for added strength and durability.<br /><img src="images/features/platform_01.jpg" alt="Heavy Duty Platform" /><img src="images/features/platform_02.jpg" alt="Heavy Duty Platform" /></div>';

var image = new Array(); // Create an array with each element having a different image

image[0] = '<img src="images/applications/app_01.jpg" alt="Steprite Application" />';
image[1] = '<img src="images/applications/app_02.jpg" alt="Steprite Application" />';
image[2] = '<img src="images/applications/app_03.jpg" alt="Steprite Application" />';
image[3] = '<img src="images/applications/app_04.jpg" alt="Steprite Application" />';
image[4] = '<img src="images/applications/app_05.jpg" alt="Steprite Application" />';
image[5] = '<img src="images/applications/app_06.jpg" alt="Steprite Application" />';

function showSelectedImage(x) {
  document.getElementById('main_image').innerHTML = image[x];
}

function showSelected(x) { // This function shows the selected feature that was clicked on
  slideshow_stop = 1; // Comment out these two lines to keep the slideshow running (if already turned ON) when the link is clicked
  document.getElementById('slideshow_span').innerHTML = '<a id="slideshow_link" class="black_01" href="#" onclick="startSlideshow()">Slideshow On</a>';
  document.getElementById('function_text').innerHTML = features[x];
}

function showPrevious() {
  slideshow_stop = 1; // Comment out these two lines to keep the slideshow running (if already turned ON) when the previous link is clicked
  document.getElementById('slideshow_span').innerHTML = '<a id="slideshow_link" class="black_01" href="#" onclick="startSlideshow()">Slideshow On</a>';
  
  current_feature -= 1; // Sets the new feature variable
  if (current_feature == -1){ // If the variable is below 0 (ie not a valid array element) then find the last element of the array and display it
    current_feature = features.length - 1 // finds the amount of elements in the array and take one to properly reference the new array element
    document.getElementById('function_text').innerHTML = features[current_feature];
  } else {
    document.getElementById('function_text').innerHTML = features[current_feature];
  }
}

function showNext() {
  slideshow_stop = 1; // Comment out these two lines to keep the slideshow running (if already turned ON) when the next link is clicked
  document.getElementById('slideshow_span').innerHTML = '<a id="slideshow_link" class="black_01" href="#" onclick="startSlideshow()">Slideshow On</a>';
  
  current_feature += 1; // Sets the new feature variable
  if (current_feature == features.length){ // If the variable is higher than the last array element (.length displays the amount of elements but referencing array elements starts at 0) then display the first array element (at 0)
    current_feature = 0;
    document.getElementById('function_text').innerHTML = features[current_feature];
  } else {
    document.getElementById('function_text').innerHTML = features[current_feature];
  }
}

function slideShow() {
  if (slideshow_stop == 0){ // If the slide show is turned on (slideshow_stop is set to 0) then display each feature array element
    current_feature += 1; // Sets the new feature variable
    if (current_feature == features.length){ // If the variable is higher than the last array element (.length displays the amount of elements but referencing array elements starts at 0) then display the first array element
      current_feature = 0;
      document.getElementById('function_text').innerHTML = features[current_feature];
      setTimeout("slideShow()", slideshow_speed); // Starts the function again after the time limit
    } else {
      document.getElementById('function_text').innerHTML = features[current_feature];
      setTimeout("slideShow()", slideshow_speed); // Starts the function again after the time limit
    }
  } else {
    
  }
}

function startSlideshow() {
  slideshow_stop = 0; // Sets the variable to 0 which tells the slideShow function that the slide show is turned ON
  setTimeout("slideShow()", slideshow_speed); // Starts the slideShow function after set time period
  document.getElementById('slideshow_span').innerHTML = '<a id="slideshow_link" class="black_01" href="#" onclick="stopSlideshow()">Slideshow Off</a>'; // Replaces the Slideshow On button with a Slideshow Off button
}

function stopSlideshow() {
  slideshow_stop = 1; // Sets the variable to 1 which tells the slideShow function that the slide show is turned OFF
  document.getElementById('slideshow_span').innerHTML = '<a id="slideshow_link" class="black_01" href="#" onclick="startSlideshow()">Slideshow On</a>'; // Replaces the Slideshow Off button with a Slideshow On button
}