/***********************************************
* 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='259px' //SET IMAGE WIDTH
var slideshow_height='194px' //SET IMAGE HEIGHT
var tour_speed=8000 //SET PAUSE BETWEEN SLIDE (3000=3 seconds)

var fadeimages=new Array()
//SET 1) IMAGE PATHS, 2) optional link, 3), optional link target, 4), title text, 5), text for a text display::
fadeimages[0]=["images/tour2/pic0.jpg", "", "", "<b>Swimming Pool &amp; Hot Tub</b>", "Our pool is the perfect place to soak up the sun.  Take a refreshing dip, or just relax!  The pool is always clean and the hot tub is open all-year round."] 
fadeimages[1]=["images/tour2/pic8b.jpg", "", "", "<b>Dining Area</b>", "Dine in style!  Along with the rest of the apartment, each dining room is fully furnished with quality furniture."]
fadeimages[2]=["images/tour2/pic5.jpg", "", "", "<b>Living Room</b>", "Each living room has two comfy couches.  Plus, you get lots of space to hang out with your friends."] 
fadeimages[3]=["images/tour2/pic7.jpg", "", "", "<b>Bedroom</b>", "Every bedroom is private and large.  High-speed internet, cable TV, and phone jacks are available in every bedroom, plus locks on all bedroom doors."] 
fadeimages[4]=["images/tour2/pic9.jpg", "", "", "<b>Kitchen</b>", "Cook like a gourmet!  Each kitchen is well-layed out, and features a dishwasher, microwave, and lots of pantry and cupboard space."] 
fadeimages[5]=["images/tour2/pic3.jpg", "", "", "<b>Sand Volleyball</b>", "Volleyball is a great way to unwind from your studies.  Our sand volleyball court is one of the most popular in town, making it the perfect place to meet people!"] 
fadeimages[6]=["images/tour2/pic11.jpg", "", "", "<b>Bus Stop</b>", "The UTA bus stop is right outside."] 
fadeimages[7]=["images/tour2/pic12.jpg", "", "", "<b>Laundry Room</b>", "The laundry room is located in the basement of the clubhouse.  It has plenty of well-maintained washers and dryers."] 
fadeimages[8]=["images/tour2/pic15.jpg", "", "", "<b>Public Computer Room</b>", "How about computer access? The clubhouse has a computer room with public computers, which are free for tenants to use!"] 
fadeimages[9]=["images/tour2/pic13.jpg", "", "", "<b>Beautiful Sunset</b>", "Nestled against the Wasatch Mountains, Carriage Cove is a great place to watch the sunset!"] 
fadeimages[10]=["images/tour2/pic14.jpg", "", "", "<b>Friendly Staff</b>", "Our office staff and maintenance crew are very friendly!  Maintenance requests are always handled promptly."] 

////NO need to edit beyond here/////////////

var preloadedimages=new Array()
for (p=0;p<fadeimages.length;p++){
	preloadedimages[p]=new Image()
	preloadedimages[p].src=fadeimages[p][0]
}

var ie4=document.all
var dom=document.getElementById

if (ie4||dom)
	document.write('<div style="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"></div><div id="canvas1" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10;visibility: hidden"></div></div>')
else
	document.write('<img name="defaultslide" src="'+fadeimages[0][0]+'">')

var curr_alpha=10
var fade_in_canvas="canvas0"
var curr_index=0
var next_index=0
var slide_timeout=0
var slide_interval=0
var paused = false
var doing_fade = false
var queue_prev = false
var queue_next = false

var slide_title_obj=ie4? eval("document.all.slide_title") : document.getElementById("slide_title") 
var slide_text_obj=ie4? eval("document.all.slide_text") : document.getElementById("slide_text") 


function fadepic(){
	if (curr_alpha<100){
		curr_alpha+=10
		if (new_img_obj.filters)
			new_img_obj.filters.alpha.opacity=curr_alpha
		else if (new_img_obj.style.MozOpacity)
			new_img_obj.style.MozOpacity=curr_alpha/101
	} else{
		//Done doing the picture fade, set up for next image fade

		//Clear the alpha interval timer
		clearInterval(alpha_interval)
		doing_fade = false
		curr_index = next_index;

		if (queue_prev) {
			queue_prev = false
			prev_slide()
		} else if (queue_next) {
			queue_next = false
			next_slide()
		}

		if (!paused) slide_timeout = setTimeout("next_slide()",tour_speed)
	}
}

function insertcontent(i){
	var result = fadeimages[i][1]!=""? '<a href="'+fadeimages[i][1]+'" target="'+fadeimages[i][2]+'">' : ''
	result += '<img src="'+fadeimages[i][0]+'" border="0">'
	result += fadeimages[i][1]!=""? '</a>' : ''
	return result
}

function change_slide() {
	if (ie4||dom){


		new_img_obj=ie4? eval("document.all."+fade_in_canvas) : document.getElementById(fade_in_canvas)
		new_img_obj.innerHTML=insertcontent(next_index)
//		var tempobj2=ie4? eval("document.all."+fade_in_canvas) : document.getElementById(fade_in_canvas)
//		tempobj2.style.visibility="hidden"

		reset_alpha(fade_in_canvas)
//		var curr_img_obj=new_img_obj=ie4? eval("document.all."+fade_in_canvas) : document.getElementById(fade_in_canvas)
		new_img_obj.style.zIndex++
		new_img_obj.style.visibility="visible"



		doing_fade = true
		var temp='setInterval("fadepic()",50)'
		alpha_interval=eval(temp)
		fade_in_canvas=(fade_in_canvas=="canvas0")? "canvas1" : "canvas0"




	}
	else 
		document.images.defaultslide.src=fadeimages[curr_index][0]
	

	slide_title_obj.innerHTML = fadeimages[next_index][3];
	slide_text_obj.innerHTML = fadeimages[next_index][4];
}

function next_slide() {
	next_index = (curr_index<fadeimages.length-1)? curr_index+1 : 0;
	change_slide()
}

function prev_slide() {
	next_index = (curr_index>0)? curr_index-1 : fadeimages.length-1;
	change_slide()
}





function reset_alpha(obj){
//	if (window.alpha_interval) clearInterval(alpha_interval)
	curr_alpha=10
	var curr_img_obj=ie4? eval("document.all."+obj) : document.getElementById(obj)
	if (curr_img_obj.filters)
		curr_img_obj.filters.alpha.opacity=curr_alpha
	else if (curr_img_obj.style.MozOpacity)
		curr_img_obj.style.MozOpacity=curr_alpha/101
}

function startit(){
//	var obj=ie4? eval("document.all."+fade_in_canvas) : document.getElementById(fade_in_canvas)
//	obj.innerHTML=insertcontent(curr_index)
//	rotateimage()
	change_slide()
}

if (ie4||dom) 
	window.onload=startit
else 
	slide_interval = setInterval("next_slide()",tour_speed)










//Global controls for the slideshow
function show_pause() {
	if (!paused) {
		if (ie4||dom) clearTimeout(slide_timeout)
		else clearInterval(slide_interval)
		paused = true
	}
}

function show_play() {
	if (paused) {
		if (ie4||dom){
			next_slide()
		} else slide_interval = setInterval("next_slide()",tour_speed)
		paused = false
	}
}

function show_next() {
	show_pause()
	if (doing_fade) queue_next = true
	else next_slide()
}

function show_prev() {
	show_pause()
	if (doing_fade) queue_prev = true
	else prev_slide()
}
