home *** CD-ROM | disk | FTP | other *** search
Wrap
var activeslide = 1; // stores the number of the activeslide var layers = 0; // stores the total number of slides var obj=0; var ns4, ie4; function init() //initialize all divs. Called onload of body. { ns4 = (document.layers)? true:false; ie4 = (document.all)? true:false; // hide the divload layer // hide all layers except the first layer if (ns4) { layers = document.layers.length -4; } else { var divname; for (i=1;;i++) { divname="div"+i; if (document.all(divname) == null) { break; } } layers= i - 1; } layerHide('divload'); layerShow('div1'); // create the navigation bar for the first time. createNavBar(); } function showNextSlide() //called when the user clicks on the 'Next Slide' Arrow { if (activeslide < layers ) { showSlide((activeslide + 1)); } } function showPrevSlide() //called when the user clicks on the 'Previous Slide' Arrow { if (activeslide > 1) { showSlide((activeslide - 1)); } } function layerHide(layername) // Browser independent implementation for hiding a layer { if (ns4) { document.eval(layername).visibility = "hide"; } else { document.all(layername).style.visibility = "hidden"; } } function layerShow(layername) // Browser independent implementation for showing a layer { if (ns4) { document.eval(layername).visibility = "show"; } else { document.all(layername).style.visibility = "visible"; } } function showSlide(obj) // to show the slide selected from the navigation bar (either by clicking on the slide number) { activeslide = obj; if (activeslide == 1) // If the first slide is active, display the Dummy 'Prev Arrow' { layerShow('divDummyPrev'); layerHide('divDummyNext'); } else if (activeslide > 1 && activeslide < layers) // hide the Dummy 'Prev, Next Arrows' { layerHide('divDummyPrev'); layerHide('divDummyNext'); } else if (activeslide == layers) // If the first slide is active, display the Dummy 'Next Arrow' { layerHide('divDummyPrev'); layerShow('divDummyNext'); } var divname; // loop runs through all the divs and hides them except the one selected by the user for (i=1; i <= layers ;i++) { divname="div"+i; if (i != obj) { layerHide(divname); } else { layerShow(divname); } } createNavBar(); // create the navigation bar as per the current status } function createNavBar() // to create the navigation bar based on the current status of slides. { // navbarHtml stores the HTML for the navigation. The contents of this variable ar written into the divNavBar navbarHtml = '<table border="0" cellpadding="0" cellspacing="0" height="36"><tr>'; navbarHtml = navbarHtml + '<td width="230" align="center" class="slidetext">Slide no: '; var i; // Stores the value of the starting number of the slide to be shown in the nav bar if (activeslide > 3) // to decide the starting slide number in the nav bar. Only 5 number should be displayed in the nav bar. If the active slide is greater than 3 than 2 number on either side of the active slide will be displayed. { if (activeslide < (layers - 2)) { i = (activeslide - 2); } else if (layers > 5) { i = (layers - 4); } else { i= 1; } } else { i = 1; } for (a=1; (i < (layers +1)) && (a < 6); i++, a++) // Loop runs from the starting number set above till 5 numbers after that or till end of slides. This loop construct the numbers to be displayed in the nav bar. { if (i != activeslide) { navbarHtml = navbarHtml + '<span class="active"><a href="javascript:showSlide(' + i + ')">' + i + '</a> </span>'; } else { navbarHtml = navbarHtml + '<span class="inactive">' + i + ' </span>'; } if ((i < layers) && (a < 5)) { navbarHtml = navbarHtml + ' | '; } } // end of loop navbarHtml = navbarHtml + '</td>'; navbarHtml = navbarHtml + '</tr></table> '; // the blank spaces are for IE 5 on Mac. Please do not remove them. // write the contents of navbarHtml into divNavBar. if (ns4) { document.layers["divNavBar"].document.open(); document.layers["divNavBar"].document.write(navbarHtml); document.layers["divNavBar"].document.close(); } else { document.all["divNavBar"].innerHTML = navbarHtml; } }