﻿var search_clear=0
var index
var items
var descriptions
var cart
var slide_number=1
var started=false
var loaded=false


function $(div){return document.getElementById(div)}

function init()
{
	$('search-box').onfocus=function(){search_clear++;search_clear==1?this.value='':''}

	if(cart_count!=0)
	{
		$("cart").onmouseover=function(){$("cart-popup").style.top="60px"}
		$("cart").onmouseout=function(){$("cart-popup").style.top="-5000px"}
	}
}

function initIndex()
{
	init()
	
	loadNext()
	navigator.userAgent.indexOf("MSIE")!=-1?ie=true:ie=false
	play_button=$('play-button')
	play_button.style.top='172px'
	play_button.onclick=function()
	{
		play_button.style.display='none'
		started=true
		if (loaded) slideShow()
	}
}

function loadNext()
{
	slide_number++
	slide_number>slide_count?slide_number=1:''
	$('next').innerHTML='<img id="next-slide" width="100%" height="100%" alt="" src="../graphics/slides/novembre/slide-'+slide_number+'.jpg" onload="loaded=true;slideShow()" />'
}


function slideShow()
{
	if (started)
	{
		if (ie)
		{
			actual_slide=$('slide')
			actual_slide.filters[0].apply()
			actual_slide.src=$('next-slide').src
			actual_slide.filters[0].play(5)
			setTimeout("loadNext()",5550)
		}
		else
		{
			actual_slide=$('next').style
			actual_slide.opacity=0
			actual_slide.top='1px'
				
			count=0
			timer=setInterval(fade, 20)
		}
	}
}

function fade() 
{
	actual_slide.opacity=count/100
	count++

	if (count>100) 
	{
		$('slide').src=$('next-slide').src
		clearInterval(timer)
		actual_slide.top='-5000px'
		setTimeout("loadNext()",1000)
	}
}

function zoom(id)
{
	var height=$('container').offsetHeight
	var window_height=windowHeight()
									
	bg_mask=$('mask').style
	window_height>height?bg_mask.height=window_height+'px':bg_mask.height=height+'px'
	bg_mask.display='block'
			
	bg_zoom=$('zoom')
	bg_zoom.style.display='block'
	bg_zoom.innerHTML='<img width="550" height="550" alt="" src="graphics/photos-big/'+photo_directory+id+'.jpg" />'
			
	close_button=$('close')
	close_button.style.top='63px'
	close_button.onclick=function()
	{
		bg_mask.display='none'
		bg_zoom.innerHTML=''
		bg_zoom.style.display='none'
		close_button.style.top='-1000px'
	}
}

function windowHeight()
{
	var height=0
	if (typeof window.innerHeight!='undefined') {height=window.innerHeight}
	else if (typeof document.documentElement!='undefined' && typeof document.documentElement.clientHeight!='undefined' && document.documentElement.clientHeight!= 0) {height=document.documentElement.clientHeight}
	else {height=document.getElementsByTagName('body')[0].clientHeight}
	return height
}



