Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Status of the slider.
- var active = 0;
- //Rest period between each tansition.
- var rest = 0;
- //Position of the current division.
- var position = 0;
- //Total number of divisions.
- var div_total = 7;
- //Current slider number.
- var slide_num = 1;
- //The current divisons name.
- var current_div;
- //The last division used.
- var last_div;
- //The fucntion is used to animate the slider divisions.
- function slidemenus() {
- //Set the current division.
- current_div = "slider" + slide_num;
- //Check if the slider number is greater than one
- //if it is set the last_div variable to slide_num - 1
- if (slide_num > 1) {
- last_div = "slider" + (slide_num - 1)
- //Else if the slider division is not greater than 1
- //set the last_div to 1.
- } else {
- last_div = "slider1";
- }
- //If the slider is active then get the position of the
- //current division and animate it.
- if (active == 1) {
- position = parseInt(document.getElementById(current_div).offsetLeft);
- //If the current divisions left property is less
- //than 0 move it across 10px;
- if (position < 0) {
- position = position + 10;
- document.getElementById(current_div).style.left = position;
- } else {
- //Disable the slider
- active = 0;
- //Increase the slider number if it has
- //not exceeded the div_total.
- if(slide_num <= div_total) {
- slide_num = slide_num + 1;
- //Else if the slide_num has exceeded the
- //div_total reset it to 1 and change the
- //zindexes of the divisions.
- } else {
- document.getElementById("slider1").style.zIndex = 1;
- document.getElementById(last_div).style.zIndex = 2;
- slide_num = 1;
- }
- //Clear the rest interval
- clearInterval(rest);
- rest = setInterval("slidemenus()", 9000);
- }
- //Else if the slider is not active enable it and reset
- //all of the divisions zindexes.
- } else {
- active = 1;
- document.getElementById("slider1").style.zIndex = 1;
- document.getElementById("slider2").style.zIndex = 1;
- document.getElementById("slider3").style.zIndex = 1;
- document.getElementById("slider4").style.zIndex = 1;
- document.getElementById("slider5").style.zIndex = 1;
- document.getElementById("slider6").style.zIndex = 1;
- document.getElementById("slider7").style.zIndex = 1;
- document.getElementById(last_div).style.zIndex = 2;
- document.getElementById(current_div).style.zIndex = 3;
- document.getElementById(current_div).style.left = -600;
- clearInterval(rest);
- rest = setInterval("slidemenus()", 20);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement