/*
	slideshow.js
	------------
	
	The flash slideshow we previously used to use proved too hard for me to update, so I re-did it in JavaScript.
	
	This is now done similarly to a regular JavaScript rotation file.
	
	Where we'd normally just concatenate all the various parts of the rotation into one big variable and document.write() it to the page, in this case, we use code from Dynamic Drive (see their copyright notice below) to handle writing one image on a canvas, loading the next behind it, and fading the first out and the next in.
	
	The only weird thing we need to add here it to make any transparent GIFs opaque (since we're loading the next image behind the first in order to get that nice fade effect). So we do one document.write immediately below this note that writes some CSS that makes the background of the images opaque.
	
	Hopefully changes to this file will be as simple for you as swapping out the items in the newyork_slideshow_img array. Remember to set the slideshow_width, slideshow_height and pause variables around line 130.

*/
	
	var slideshow_css = '';
	slideshow_css += "	<style type='text/css'>";
	slideshow_css += "		#canvas0, #canvas1 {";
	// put any additional styles in here
	slideshow_css += "			background: #303030;";
	slideshow_css += "			z-index: 0;";
	slideshow_css += "		}";
	slideshow_css += "	</style>";
	document.write(slideshow_css);




	// Initialize the arrays:
	var newyork_slideshow_img = new Array();
	var newyork_slideshow_preloader = new Array();
	
	// Declare variables for use as the beginning and close of the image source paths:
	var newyork_slideshow_img_path = "/newyork/images/slideshow/header-slideshow/";
	var newyork_slideshow_img_ext = ".jpg"; // this is case-sensitive
	
	// This will be incremented and used as the number of the array elements that follow:
	var x = 0;
	
	newyork_slideshow_img[x] = "a1";
	newyork_slideshow_preloader[x] = new Image(310,170); // width, then height
	x = x + 1;
	
	newyork_slideshow_img[x] = "a2";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	newyork_slideshow_img[x] = "a3";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	newyork_slideshow_img[x] = "a4";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	newyork_slideshow_img[x] = "a5";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	newyork_slideshow_img[x] = "a6";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	newyork_slideshow_img[x] = "a7";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	// newyork_slideshow_img[x] = "a8";
	// newyork_slideshow_preloader[x] = new Image(310,170);
	// x = x + 1;
	
	newyork_slideshow_img[x] = "a9";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	//newyork_slideshow_img[x] = "a10";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a11";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	newyork_slideshow_img[x] = "a12";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	newyork_slideshow_img[x] = "a13";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	//newyork_slideshow_img[x] = "a14";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a15";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a16";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	newyork_slideshow_img[x] = "a17";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	newyork_slideshow_img[x] = "a18";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	//newyork_slideshow_img[x] = "a19";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a20";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a21";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	// newyork_slideshow_img[x] = "a22";
	// newyork_slideshow_preloader[x] = new Image(310,170);
	// x = x + 1;
	
	//newyork_slideshow_img[x] = "a23";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a24";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a25";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a26";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	//newyork_slideshow_img[x] = "a27";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	
	newyork_slideshow_img[x] = "a28";
	newyork_slideshow_preloader[x] = new Image(310,170);
	x = x + 1;
	
	//newyork_slideshow_img[x] = "a29";
	//newyork_slideshow_preloader[x] = new Image(310,170);
	//x = x + 1;
	


	// We need to pre-load the images in the array above, to minimize delays in display.
	// 
	// Since newyork_slideshow_preloader[0].src will be exactly the same as newyork_slideshow_preloader[100].src with the exception 
	// of the number of the array (0 vs. 100 in the example), we can use the following loop to write this 
	// entire section of the array for us.
	// 
	for (i=0; i<newyork_slideshow_preloader.length; i++) {
		newyork_slideshow_preloader[i].src = newyork_slideshow_img_path + newyork_slideshow_img[i] + newyork_slideshow_img_ext;
	}
	
	
	
	
	
	
	/***********************************************
	* Fade-in image slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
	* This notice MUST stay intact for legal use
	* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
	***********************************************/
	
	var slideshow_width='310px' //SET IMAGE WIDTH
	var slideshow_height='170px' //SET IMAGE HEIGHT
	var pause=5000 //SET PAUSE BETWEEN SLIDE (3000=3 seconds)
	//var slideshow_url = '';
	var slideshow_styles = 'border: 1px solid white;'; // This is any additional styles you have trouble getting to work except for inline. Styles are applied to the div which contains the slideshow image.
	
	var fadeimages=new Array()
	//SET IMAGE PATHS. Extend or contract array as needed
	for (i=0; i<newyork_slideshow_preloader.length; i++) {
		fadeimages[i] = newyork_slideshow_img_path + newyork_slideshow_img[i] + newyork_slideshow_img_ext;
	}
	
	
	


	////NO need to edit beyond here/////////////
	

	
	var ie4=document.all
	var dom=document.getElementById
	

	
	
	
	if (ie4||dom)
	document.write('<div style="'+slideshow_styles+'position:relative;width:'+slideshow_width+';height:'+slideshow_height+';overflow:hidden"><div id="canvas0" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10;opacity:10"></div><div id="canvas1" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10;opacity:10;"></div></div>')
	else
	//document.write('<a href="'+slideshow_url+'"><img name="defaultslide" id="fading-slideshow" border="0" src="'+fadeimages[0]+'" /></a>')
	document.write('<img name="defaultslide" id="fading-slideshow" border="0" src="'+fadeimages[0]+'" />')
	
	
	var curpos=10
	var degree=10
	var curcanvas="canvas0"
	var curimageindex=0
	var nextimageindex=1
	var nexttextindex=1
	
	

	
	

	function fadepic(){
	if (curpos<100){
	curpos+=10
	if (tempobj.filters)
	tempobj.filters.alpha.opacity=curpos
	else if (tempobj.style.MozOpacity)
	tempobj.style.MozOpacity=curpos/101
	}
	else{
	clearInterval(dropslide)
	nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
	tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
	//tempobj.innerHTML='<a href="'+slideshow_url+'"><img src="'+fadeimages[nextimageindex]+'" border="0" id="fading-slideshow" alt="" /></a>'
	tempobj.innerHTML='<img src="'+fadeimages[nextimageindex]+'" alt="" border="0" id="fading-slideshow" style="z-index: 0;" />'
	nextimageindex=(nextimageindex<fadeimages.length-1)? nextimageindex+1 : 0
	setTimeout("rotateimage()",pause)
	}
	}
	
	
	
	
	
	function rotateimage(){
	if (ie4||dom){
	resetit(curcanvas)
	var crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
	crossobj.style.zIndex++
	var temp='setInterval("fadepic()",50)'
	dropslide=eval(temp)
	curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
	}
	else
	document.images.defaultslide.src=fadeimages[curimageindex]
	curimageindex=(curimageindex<fadeimages.length-1)? curimageindex+1 : 0
	}
	
	function resetit(what){
	curpos=10
	var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
	if (crossobj.filters)
	crossobj.filters.alpha.opacity=curpos
	else if (crossobj.style.MozOpacity)
	crossobj.style.MozOpacity=curpos/101
	}
	
	function startit(){
	var crossobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
	//crossobj.innerHTML='<a href="'+slideshow_url+'"><img src="'+fadeimages[curimageindex]+'" alt="" border="0" id="fading-slideshow" /></a>'
	crossobj.innerHTML='<img src="'+fadeimages[curimageindex]+'" alt="" border="0" id="fading-slideshow" />'
	rotateimage()
	}
	
	if (ie4||dom)
	window.onload = function() {
						startit();
						startList(); /* So we don't overwrite the function that makes the menu work in MSIE. A hack, but it works. */
					}
	else
	setInterval("rotateimage()",pause)
