Dynamic Resized Slideshow

Dec 18, 2005

This code dynamically resizes all the images in the slideshow to a static width and height, specified in the Customization section.

Other customization variables are available, as well.

It's useful for when your images are larger than 640x480 and manually resizing them is impractical, and especially if many of your users are on dial-up connections and the delay in preloading/loading "large" or many images would be annoying.

The slide images are displayed in a new, reused, centered window, just large enough to hold the image.

The code uses consecutive integers for the slide image file names, beginning with 1.jpg, etc.
You are not required to code each file by name, just rename your images and set the imgCount variable, in the Customization section, to the number of images in the show.

A .txt file is attached, which if saved as a .bat file, (remember those?), and when executed in folder containing .jpg files, will rename up to 100 of them to the required convention of consecutive integers, so long as the existing file names are at least three characters long.

The code generates a set of "controls," consisting of a Start/Resume button, Pause button, Cancel button, and a set of radio buttons for the user to dynamically select the slide interval from 2 to 10 seconds.


<html>
<head>
<script type="text/javascript">

// -------- Begin Resized Slideshow -------------

//--- Customization ------
var imgCount = 10; // number of images in the show
var textColor = "Blue";
var backColor = "#F0F8FF";
var btnColor = "lightblue"
var dispW = 400; // this is the width for the slide image
var dispH = 300; // this is its height
var imgPath = "Images/"; // use "" if the images are in the current directory
// --- End Customization -------

// --- Do not edit below this line -------
var useWidth = screen.width*.85;
var prevActive = "i5";
var leftStr = Math.round((screen.width-useWidth-36)/2);
var absStr = "Position:Absolute;Bottom:10px;Left:"+leftStr+"";
var userDelay = 0;
var tick = 0;
var count = 0;
var wStr = 0;
var hStr = 0;
var tStr = 0;
var lStr = 0;
var IMGStr = "";
var miscFlag = false;
var cancelFlag = false;
var pauseFlag = false;
var slideWindow = "";

function manageBtns(n){

if (n == 1) //start
{
document.getElementById('startBtn').disabled = true;
document.getElementById('pauseBtn').disabled = false;
document.getElementById('cancelBtn').disabled = false;
document.getElementById('startBtn').value = "Start Slideshow"
}
if (n == 2) //paused
{
document.getElementById('startBtn').disabled = false;
document.getElementById('pauseBtn').disabled = true;
document.getElementById('cancelBtn').disable = false;
document.getElementById('startBtn').value = "Resume Slideshow"
}
if (n == 3) //canceled
{
document.getElementById('startBtn').disabled = false;
document.getElementById('pauseBtn').disabled = true;
document.getElementById('cancelBtn').disabled = true;
document.getElementById('startBtn').value = "Start Slideshow"
}
if (n == 4) // done
{
document.getElementById('startBtn').disabled = false;
document.getElementById('pauseBtn').disabled = true;
document.getElementById('cancelBtn').disabled = true;
document.getElementById('startBtn').value = "Start Slideshow"
}
}

function cancelShow(){

count = imgCount;
cancelFlag = true;
slideWindow.focus();
self.status = "One Moment...";
tick = 0;
if (miscFlag == true){runShow()}
}

function pauseShow(){

slideWindow.focus();
tick = 0;
pauseFlag = true;
miscFlag = true;
}

function waitLoadImage(){

if (slideWindow.document.images[0].complete)
{
if (count < imgCount){countDown()}
else if (cancelFlag == true){runShow()}
}
else {setTimeout("waitLoadImage()",500)}
}

function displayIt(){

if(slideWindow == ""){slideWindow = window.open("","SlideShow","toolbar=0,status=1,"+tStr+","+lStr+","+wStr+","+hStr+"")};
slideWindow.document.open();
slideWindow.document.write(IMGStr);
slideWindow.document.close();
slideWindow.status = "This is " + count + " of " +imgCount;
slideWindow.focus();
IMGStr = "";
waitLoadImage();
}

function getNextimage() {

document.getElementById('nullIMG').src = imgPath + count + ".jpg";
wStr = document.getElementById('nullIMG').width;
offsetW = wStr;
wStr = wStr+20;
wStr = "width="+wStr;
hStr = document.getElementById('nullIMG').height;
offsetH = hStr;
hStr = hStr+20;
hStr = "height="+hStr;
lStr = (screen.width-50-offsetW)/2;
lStr = "left="+lStr;
tStr = (screen.availHeight-90-offsetH)/2;
tStr = "top="+tStr;
IMGStr = document.getElementById('dispIMG').innerHTML;
displayIt();
}

function closeLastImage(){

if (slideWindow.document.images[0].complete)
{
if (cancelFlag == true){isDelay = 1000}
else {isDelay = userDelay*1000}
setTimeout("slideWindow.close();slideWindow=''",isDelay);
count = 0;
}
else {setTimeout("closeLastImage()",500)}
}

function countDown(){

if (tick > 0){self.status = tick}
if (tick == 0 && (pauseFlag == false && cancelFlag == false)){self.status = "Loading Next Image...";}
if (tick >= 0)
{
setTimeout("countDown()", 1000);
tick--
}
else {runShow()}
}

function runShow() {

manageBtns(1);
tick = userDelay-1;
if (count < imgCount && pauseFlag == false)
{
count++;
getNextimage();
miscFlag = false;
}
if (pauseFlag == true)
{
self.status="Slideshow Paused at Image "
+count + " of " +imgCount + "."
pauseFlag = false;
manageBtns(2);
}
if (count == imgCount && cancelFlag == false)
{
self.status = "Slideshow Is Complete."
manageBtns(4);
closeLastImage();
}
if (count == imgCount && cancelFlag == true)
{
self.status = "Slideshow is Canceled."
closeLastImage();
cancelFlag = false;
pauseFlag = false;
miscFlag = false;
manageBtns(3);
}
}

function updateInterval(Active) {

next = "i"+Active;
next = next.toString();
document.getElementById(prevActive).bgColor="#F0F8FF";
document.getElementById(next).bgColor="darkorange";
prevActive = next;
userDelay = Active;
tick = userDelay-1;
if (slideWindow != ""){slideWindow.focus()}
}

function buildSupport(){

var divStr = "<Div style='Position:Absolute;Top:-2000' id='dispIMG'><IMG Src='"+imgPath+"1.jpg' width="+dispW+" height="+dispH+" ID='nullIMG'></Div>"
document.write(divStr);
}

function buildBox(){

var styleStr = "<Style type='text/css'>.cDiv {"+absStr+";Height:54pt;Padding-Left:0px; Padding-Right:0px;Padding-Top:6px;Padding-Bottom:6px;Margin-Right:4px;Margin-Left:6px;Margin-Top:0px;Margin-Bottom:0px;Text-Indent:0px;Text-Align:None;width:"+useWidth+";Border-Top:#C0C0C0 1px solid;Border-Left:#C0C0C0 1px solid;Border-Bottom:Black 1px solid;Border-Right:Black 1px solid;background-color:"+backColor+";}.iBox {Line-Height:Normal;Font-Style:Normal;Letter-Spacing:normal;Font-Weight:normal;Text-Align:Center;Text-Decoration:none;Text-Indent:0px;Font-Family:Tahoma,Arial,Veranda;Font-Size:13pt;Color:"+textColor+";Background-Color:none;Border-Top:Black 1px Solid;Border-Bottom:Black 1px Solid;Border-Left:Black 1px Solid;Text-Transform:none;Padding-Left:5px;Padding-Right:3px;Padding-Top:2px;Padding-Bottom:2px;Margin-Left:0px;Margin-Right:0px;Margin-Top:0px;Margin-Bottom:0px;} .nBox {Line-Height:Normal;Font-Style:Normal;Letter-Spacing:normal;Font-Weight:normal;Text-Align:Center;Text-Decoration:none;Text-Indent:0px;Font-Family:Tahoma,Arial,Veranda;Font-Size:13pt;Color:"+textColor+";Background-Color:none;Border-Top:Black 1px Solid;Border-Bottom:Black 1px Solid;Border-Left:Black 1px Solid;Text-Transform:none;Padding-Left:0px;Padding-Right:5px;Padding-Top:2px;Padding-Bottom:2px;Margin-Left:0px;Margin-Right:0px;Margin-Top:0px;Margin-Bottom:0px;}.nxBox {Line-Height:Normal;Font-Style:Normal;Letter-Spacing:normal;Font-Weight:normal;Text-Align:Center;Text-Decoration:none;Text-Indent:0px;Font-Family:Tahoma,Arial,Veranda;Font-Size:13pt;Color:"+textColor+";Background-Color:none;Border-Top:Black 1px Solid;Border-Bottom:Black 1px Solid;Border-Left:Black 1px Solid;Border-Right:Black 1px Solid;Text-Transform:none;Padding-Left:0px;Padding-Right:5px;Padding-Top:2px;Padding-Bottom:2px;Margin-Left:0px;Margin-Right:0px;Margin-Top:0px;Margin-Bottom:0px;} .cBtns{Line-Height:Normal;Font-Style:Normal;Letter-Spacing:normal;Font-Weight:normal;Text-Align:Center;Text-Decoration:none;Text-Indent:0px;Font-Family:Tahoma,Arial,Veranda;Font-Size:13pt;Color:"+textColor+";Background-Color:"+btnColor+";Border-Right:Black 1px solid;Border-Top:White 1px Solid;Border-Left:White 1px Solid;Border-Bottom:Black 1px Solid;Cursor:Pointer;}</Style>";

var controlStr = "<Table cellspacing=&#390;'><TD class='iBox' bgColor='moccasin'>SlideShow Interval:<TD class=nBox id =i2><input type='radio'name='interval' onclick='updateInterval(2)'>2</TD><TD class=nBox id =i3><input type='radio'name='interval' onclick='updateInterval(3)'>3</TD><TD class=nBox id =i4><input type='radio'name='interval' onclick='updateInterval(4)'>4</TD><TD class=nBox id =i5 bgcolor='darkorange'><input type='radio' name='interval' checked onclick='updateInterval(5)'>5</TD><TD class=nBox id =i6><input type='radio'name='interval' onclick='updateInterval(6)'>6</TD><TD class=nBox id =i7><input type='radio' name='interval' onclick='updateInterval(7)'>7</TD><TD class=nBox id =i8><input type='radio'name='interval' onclick='updateInterval(8)'>8</TD><TD class=nBox id =i9><input type='radio' name='interval' onclick='updateInterval(9)'>9</TD><TD class=nxBox id =i10><input type='radio'name='interval' onclick='updateInterval(10)'>10</TD></Table><Table><TD><input type='button' id='startBtn' class='cBtns' value='Start Slideshow' onClick='runShow()'></TD><TD><input type='button' id='pauseBtn' class='cBtns' value='Pause Slideshow' onClick='pauseShow()'></TD><TD><input type='button' id='cancelBtn' class='cBtns' value='Cancel Slideshow' onClick='cancelShow()'></TD></Table>"

var tblStr = "<DIV id='isFloat' class='cDiv' align='center'>"+controlStr+"</DIV>"

document.write(styleStr);
document.write(tblStr);
}

function initControls(){

buildBox();
buildSupport();
updateInterval(5);
document.getElementById('pauseBtn').disabled = true;
document.getElementById('cancelBtn').disabled = true;
}

// ---- End Resized Slideshow ---------

</script>
</head>
<body>
<h3 align='center'>Resized Image Slideshow</h3>

<!-- Keep the following line as the LAST line in the BODY -->
<script type="text/javascript"> initControls()</script>
</body>
</html>

View 4 Replies


ADVERTISEMENT

How To Make A Slideshow Dynamic

May 2, 2010

I am javascript newbie. I have a slideshow on my site and it works fine if I type in the images for it to display, however I want to get the image files path from my database, so it shows all the photos.

Here is the code I am working with. I want to make all the image paths "images/photos/2.jpg" come from my database. I have tried adding php into it but it doesn't work.

[Code]...

View 5 Replies View Related

JQuery :: Slideshow To Navigate Images With Ajax Dynamic Content

Oct 13, 2011

I've built this webpage : [URL]. Now, I want the slideshows (Jquery Cycle) to have a pager to navigate the images instead of previous and next [URL].

My code looks like this :
function ajaxpage(url, containerid) {
var $container= $('#' + containerid);
$container.hide().load(url, function() {
$container.fadeIn();
$('.slideshow')
.cycle({
next: '#next2',
prev: '#prev2',
fx: 'blindX', speed:'1500',
timeout: 0, .....
after: function() {
var alt = $(this).attr('alt');
// do something with alt text
$('#someElement').html(alt);
}});
});}

The code I need to implement looks like this :
$
('#slideshow'
).before('<ulid="nav">'
).cycle({fx:'turnDown'
,speed:'fast'
,timeout:0
,pager:'#nav'
,//callbackfnthatcreatesathumbnailtouseaspageranchor
pagerAnchorBuilder:function
(idx,slide){return
'<li><ahref="#"><imgsrc="'
+slide.src+'"width="50"height="50"/></a></li>'
;}});
How to do this successfully?

View 2 Replies View Related

Text Resized Event?

Jan 15, 2004

Is there any way I can call a javascript function when the user resizes his text in the browser?

View 2 Replies View Related

Add Script To Page That Has To Be Resized?

Mar 17, 2010

Is there a way to force a window to open in a predefined size by adding HTML or Javascript code on the page you want to be resized, not the page that has the link the takes you to the resized wondow. Theres a page that has a link on it that I need opened to a certain size and I don't have access to it, so what I can do is add a javascript to the page that the link is going to.

View 4 Replies View Related

JQuery :: Create A Panel That Can Be Resized ?

Oct 25, 2010

I am trying to create a panel that can be resized, its all working however if I resize the panel then try to resize the browser the panel doesn't resize to the browser width: [url]

View 2 Replies View Related

Opening A Popup Then Preventing It From Being Resized?

Jun 30, 2011

I am trying to make a popup window with Javascript that will let a user choose either a Yes or No button and then be sent to a page after that.I really do not want this popup to be resizable. I have read that is not really possible in current browsers, but that you can prevent it form happening with resizeTo().I am not sure I'm doing this right though:

<input type='button' value="DELETE GROUP" onclick="javascript:Popup('deleteGroupWarning.html')" />
var stile = "top=10, left=10, width=300, height=300 status=no, menubar=no, toolbar=no

[code]....

View 1 Replies View Related

Detect If Browser Content Has Been Resized?

Jan 5, 2010

I have an accordion style navigation bar which works fine, except when the user enlarges the screen with, for example, Ctrl and Plus.You can see what I'm talking about here:http://www.ruhr-uni-bochum.de/igsn/example/Is there any way using JavaScript to detect when the user enlarges the screen?Is it even good style to do this?I've found the offending css rule which makes the menu slow to a crawl in anything but its original resolution, but as this is a template that I have to use, there is not much scope to change things.

View 10 Replies View Related

Increase The Height Of A Div When Window Resized

Mar 31, 2011

soloution that will enable me to set a divs min-height to 350px then when the window is resized it will increase over that 350 this supose to allow people with larger resoloutions to see more of the content.

View 4 Replies View Related

Drop Down Menu Repositions When I Resized Browser

Jul 23, 2005

I have created a web site, where I use a dropdown menu when the mouse
goes over an image.

My problem is that when I resize the browser, the menu's position
changes relatively and goes way to the left.

I am stuck I don't know which parameter to change exactly so that the
menu behaves properly....

View 2 Replies View Related

Autoresize Script Worked Well But Top Banner Also Resized

May 14, 2010

My community runs a set of forums, (phpbb with the Brushed Metal template, if that is important.) and people often use large images in their posts. This ends up cutting off the majority of the image, so we thought we'd install an auto-resize script, to resize anything wider than 600 px. It works too well, it also resizes the banner at the top of the screen. A bunch of us hacked at it trying to get it to work, but none of us know anything about javascript, so it's not going so well. Either the script still resizes everything, or it does nothing at all.

Here's the earliest version I could find. It's not the original script, however...
<script>
onload_functions.push('resizeimg();');
function resizeimg() {
if (document.getElementsByTagName) {
for (i=0; i<document.getElementsByTagName('img').length; i++) {
im = document.getElementsByTagName('img')[i];
if (im.source == '[URL]')
/*PATH TO TOP BANNER THAT SHOULD NOT BE RESIZED*/
{ continue; }
if (im.width > 600) {
im.style.width = '600px';
eval("pop" + String(i) + " = new Function("pop = window.open('" + im.src + "','phpbbegypt ','fullscale','width=400,height=400,scrollbars=1,resizable=1'); pop.focus();")");
eval("im.onclick = pop" + String(i) + ";");
if (document.all) im.style.cursor = 'hand';
if (!document.all) im.style.cursor = 'pointer';
im.title = 'Click Here To See Image Full Size ';
}}}}
</script>
We're stuck, we have no idea what to do.

View 3 Replies View Related

Can DIV Located In The MasterPage Be Resized Depending On The Screen Resolution??

Aug 19, 2010

Can DIV located in the MasterPage be resized depending on the screen resolution?

<tr style="vertical-align: top;"><td>
<div id="mainArea">
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server" />
</div></td></tr>

I've tried unsuccessfully -

var height = screen.height;
var area1 = document.getElementById('ctl00_mainArea');
if (height == 1024) {[code].....

View 6 Replies View Related

JQuery :: Create A Slideshow With Thumbnails The User Scroll Through And Use To Navigate The Slideshow?

Aug 18, 2010

So Im trying to create a slideshow with thumbnails the user can scroll through and use to navigate the slideshow. I'm a big fan of cycle so I wanted to use that as my main slideshow component and was planning on using jcarousel for the pager. So far it works great in Firefox, Chrome, and Safari, yet in IE the thumbnails are not loading. I'm guessing it has something to do with how the images in the pager are generated and then jcarousel just isnt proccessing that in IE but I 'm not sure. I feel like I'm very close to getting this slideshow to work, yet I need to figure out why it is failing in IE.

[Code]...

View 2 Replies View Related

Jquery :: Simple Prototype Slideshow And A More Comprehensive Slideshow On Website?

Nov 25, 2009

I am using a simple prototype slideshow and a more comprehensive jquery slideshow on my website.When these are used on the same webpage on my website there appears to be a collision: (For example)Code:element.attachEvent is not a function[Break on this error] element.attachEvent("on" + actualEventName, responder); How can I avoid the conflict without reverting to a new slideshow?

View 1 Replies View Related

JQuery :: Add Text Slideshow To Image Slideshow?

Jun 1, 2011

i have a small image slideshow i want add a text slideshow to image slideshow. how is it?

my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>

[Code]....

View 7 Replies View Related

Variable Scope And Crossing Functions - Resize Plugin In Order To Obtain The Varying Computed Width Of An Element When The Window Is Resized

Mar 23, 2010

I am using Ben Alman's JQuery resize plugin in order to obtain the varying computed width of an element when the window is resized (the element in question is a page wrapper that exhibits the expand-to-fit behavior of a block box, and it's computed width is obviously influenced by the resizing of the window. Essentially, what I need to be able to do, is to reference a variable that is defined in a .resize() function ('width_page') in a seperate .each() function.

[Code]...

I now understand that variables can't cross boundaries like in the example above, which leaves me a little stuck. I also understand that this is specific to the context of the .resize() function, and that it can't be taken out of it without using an element selector. Is there some way I can call the .resize() function in my .each() function?

View 3 Replies View Related

InnerHeight Property - Photos To Be Resized Depending On The InnerWidth And InnerHeight Of The Browser

Apr 26, 2011

I have a website which displays photos. I want the photos to be resized depending on the innerWidth and innerHeight of the browser. I have my resolution set to 1024x768. So if you go to [URL] and click on 'Commissions' my 'w' variable in the URL contains 1024 but for some reason the 'h' variable displays 50. If I click on 'Commissions' one more time then it correctly displays h=602.

View 9 Replies View Related

JQuery :: All Images Must Be Resized If Width Exceeds Max Width?

May 5, 2010

I currently have a website where i share thoughts with my friends (some kind of forum) and within this 'forum' people can post pictures they made but most of the time these pictures exceed the max width of my website so my website gets all streched out!So this is what i want: all images on the page must run thru some sort of function which checks if the image image width exceeds the max_width. if it does then the script must calculate how many pixels the current width exceeds the max_width and get this number so that the script does: current_width = current_width - (max_width - current_width)

View 1 Replies View Related

JQuery :: Populate A Dynamic Dropdown List Based On Another Dynamic Drop Down Selection?

Jun 29, 2010

how to populate a dropdown based on Another dropdown selection. This all should be a dynamic. Eg: I have two text boxes one is TechID and other is JOB ID. When I start typing Tech ID it suggests me the list of IDs which start with the input string i have put in Tech textbox. When i select the Tech ID the jobs associated to that Tech ID should be displayed in JOB ID text box as a dropdown list.

View 1 Replies View Related

A Nested Dynamic Checkbox Inside My Dynamic Form.

Jul 23, 2005

I am having a problem with the last results. I can't seem to be able to
get the input2A and input3A to appear. I don't seem to have a problem
with the show and hide after a number is entered and submitted. If
anyone can answer my problem I will be greatly appreciated with a
prize. I actually have submitted it more than once and I haven't had
anyone been able to answer it yet. Code:

View 5 Replies View Related

Dynamic Function With Dynamic Parameter On The Right Operand?

Jul 1, 2011

i was trying for some days now to find a solution for this. had a look at different posts and forums online, but no luck so far...is it possible to auto-create this with a loop???:

Code:
T$('infowindow1').onclick = function(){ setInfobox('1'); }
T$('infowindow2').onclick = function(){ setInfobox('2'); }

[code]....

View 5 Replies View Related

Dynamic Drop-down List - Create A Dynamic Menu Where A User Selects One Item And Another Select List Is Shown

Jun 30, 2009

I've been beating my head against a wall for a few days trying to get this working. I'm trying to create a dynamic menu where a user selects one item and another select list is shown, then another and another (and so on). Here is my JS, it *should* be taking the ID of the div, comparing it to the selected value and then showing another div by settings it's class property to visible:

[Code]...

View 1 Replies View Related

Dynamic Calculation For Dynamic Form

Oct 25, 2010

I have made a script where you can add extra fields, and next to the row is a span that automatically displays the outcome from a calculation of three fields in that row. i.e. Q x (B - A) = total. Here is the bit that does the calculation:

function advCalc(selected) {
var result = Number(document.formmain.elements["quantity"+selected].value) * (Number(document.formmain.elements["provideamount"+selected].value) - Number(document.formmain.elements["supplyamount"+selected].value)) ;
[Code]....

View 23 Replies View Related

JQuery :: Validation Dynamic Rules - Add In Rules Dynamically Through The Rules(add) Function After Adding Some Dynamic Fields Through The User Inputs

Sep 6, 2011

I will like to know if there is anyway to view all the rules that I have currently in the Jquery validation plugin. Currently, I am trying to add in rules dynamically through the rules(add) function after adding some dynamic fields through the user inputs. the rules are added in this manner.

[Code]...

View 2 Replies View Related

IE8 Slideshow All Other Browsers?

Mar 22, 2011

I have an Issue with a Javascript slideshow. If you see link below it is obvious :)[URL]... I only get the Issue in Internet Explorer 8

View 4 Replies View Related

SlideShow Class

Jan 7, 2003

*****************************************************************

SlideShow javascript class by Peter Bailey - Copyright (c) 2003
Contact: me@peterbailey.net
Website: http://www.peterbailey.net/slideshow/

Main Features:
- OO design means low namespace consumption and allows for
multiple SlideShow instances per page
- Auto-creation of SELECT navigation widget
- Can preload images (but doesn't have to)
- Toggle start/end looping
- Slideshow data can be used between shows

Compatibility:
- Tested on IE6 and Mozilla 1.1
- DOM compliant browsers only

Note: This document was created with a tab-spacing of four (4)

******************************************************************/

function SlideShow( imgId, capId, stsId, root, data, pre, loop )
{
this.img = document.images[imgId];
this.cap = ( capId != '' );
this.sts = ( stsId != '' );
this.root = root;
this.slide = 0;
this.data = window[data];
this.pre = pre;
this.loop = loop;

if ( this.cap ) this.capObj = document.getElementById( capId );
if ( this.sts ) this.stsObj = document.getElementById( stsId );
if ( this.pre ) this.preload();
else this.imgsDone = true;

this.img.src = "/images/blank.gif";
if ( this.capObj ) this.capObj.firstChild.nodeValue = "Loading";
this.go(1);
}

SlideShow.prototype.preload = function()
{
var o = this;
this.img.setAttribute( "alt", "Preloading Images...Please Wait" );
this.imgs = new Array();
for ( var i = 0, l = this.data.length; i < l; i++ )
{
this.imgs[i] = new Image();
this.imgs[i].src = this.root + this.data[i][0];
}
this.imgs[--i].onload = function ()
{
o.img.setAttribute( "alt", o.data[o.slide][1] );
o.imgsDone = true;
}
}

SlideShow.prototype.next = function()
{
this.go('next');
}

SlideShow.prototype.prev = function()
{
this.go('prev');
}

SlideShow.prototype.go = function( v )
{
switch ( v )
{
case 'prev':
case 'back':
this.slide--; break;
case 'next':
case 'foward':
this.slide++; break;
default:
this.slide = v - 1;
}
if ( this.slide == -1 ) // Loop from beginning to end
this.slide = ( this.loop ) ? parseInt( this.data.length - 1 ) : 0;
if ( this.slide == this.data.length ) // Loop from end to beginning
this.slide = ( this.loop ) ? 0 : this.slide = this.data.length - 1;

this.img.src = ( this.pre ) ? this.imgs[this.slide].src : this.root + this.data[this.slide][0];
if (this.imgsDone) this.img.setAttribute( "alt", this.data[this.slide][1] );
if (this.cap) this.capObj.firstChild.nodeValue = this.data[this.slide][1];
if (this.sts) this.stsObj.firstChild.nodeValue = "Slide " + ( this.slide + 1 ) + " of " + this.data.length;
if (this.sel) this.sel.selectedIndex = this.slide;
}

SlideShow.prototype.makeSelect = function( containerId, useCaps )
{
var ssObj = this;
var s = document.createElement( "select" );
this.sel = document.getElementById( containerId ).appendChild( s );
if ( document.all )
this.sel.attachEvent( "onchange", function () { changeHandler( event.srcElement, ssObj ) } );
else
this.sel.addEventListener( "change", function ( e ) { changeHandler( e.target, ssObj ) }, false );
this.addOptions( useCaps );

function changeHandler( sel, ss )
{
ss.go( parseInt( sel.options[sel.selectedIndex].value ) + 1 );
}
}

SlideShow.prototype.addOptions = function( useCaps )
{
var o;
for ( var i = 0, len = this.data.length; i < len; i++ )
{
o = document.createElement( "option" );
t = document.createTextNode( ( useCaps ) ? this.data[i][1] : "Picture " + ( i + 1 ) );
o.setAttribute( "value", i );
o.appendChild( t );
this.sel.appendChild( o );
}
}

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved