Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

<body>

<head>
<!-- javascript image roller w/centering for any screen size.
this image roller will center your images in the usable section of your
screen. it does this by calculating
the height and width of your screen display area, then dividing that by 2
and subtracting half of the image
height and width from that to place the image in a position that is as close
to center as possible.
-->

<script>
// your images. you may add as many images as you like.
var imgname=new
array(http://images3.orkut.com/images/album/8/285/34169285.jpg,"http://jdstiles.co
m/java/clock2.jpg","banner")

// your images width. you may add as many images as you like.
var imgw=new array("1000","480","232")

// your images height. you may add as many images as you like.
var imgh=new array("1000","280","73")

//place your pictures page here. the pound symbol allows the use of the anchor
name feature.
//so that the image can be brought forward when clicked on.
var imgurl="pics.html#"

//this array preloads the images so that they rotate at the proper speed on the
page.
var imgpreload=new array()
for (i=0;i<=imgname.length-1;i++) {
imgpreload[i]=new image()
imgpreload[i].src=imgname[i]
}

//declare any needed variables here.


var i_image=0 //i_image is used for the array of images to be accessed later.
var screenheight=0 //screenheight is for usable height of the display area ie
567px if your height is 600px
var screenwidth=0 //screenwidth is for the usable width of the display area
ie 800px if your width is 800px
var x_finalpos=0 //x_finalpos is for the final position when placing the
image on the screen in the scroller.
var y_finalpos=0 //y_finalpos is for the final position when placing the
image on the screen in the scroller.
var imgheight=0 //used to calculate the final position of the image in the
scroller you load the image height here.
var imgwidth=0 //used to calculate the final position of the image in the
scroller you load the image width here.

/*this function finds the location on the screen for the image scroller. it
does this by calculating the screen height
and width that is usable then dividing this by 2 so that the image will
center. it then subtracts half of the image
from the usable height and width of the screen and adds 20 to the height for
placement purposes.*/
function picturepos() {
imgheight=imgh[i]
imgwidth=imgw[i]
x_finalpos=((document.body.clientheight/2)-(imgheight/2)+20)
y_finalpos=((document.body.clientwidth/2)-(imgwidth/2))
}

//this function sets the timer on the image roller.and calls another function to
roll the image
function initiate() {
var timer=setinterval("swapimg()",2000)
}

//this function provides the names of the images that are being used by the
roller.
function swapimg(){
eval("document.all.div"+i_image+".style.display='none'")
if (i_image++>imgname.length-2) {i_image=0}
eval("document.all.div"+i_image+".style.display=''")
return(false)
}
</script>
</head>

</body>

You might also like