var a_images_slideshow = new Array()
var a_images = new Array()
var a_links = new Array()
var image_opacity = 1
var last_call
var slideshow_continue = true
var last_cycle_call
var global_image_index = 0
var global_bg_target
var global_image_target
var fadeIn = 1
var fadeOut = 0

if (navigator.appName.indexOf("Microsoft")!=-1) 
{ 
	var browser = 'IE'
}
else 
{ 
	var browser = 'MZ' 
}

a_images_slideshow[0] = '/car_images/hg997/moppar.jpg';
a_images[0] = new Image(634, 258 )
a_images[0].src = '/car_images/hg997/moppar.jpg'
a_images[0].alt = ''
a_images[0].title = ''

a_links[0] = new Array();
a_links[0]['path'] = ''
a_links[0]['target'] = ''
a_images_slideshow[1] = '/car_images/hg998/31marchpeugeotservice.jpg';
a_images[1] = new Image(634, 258 )
a_images[1].src = '/car_images/hg998/31marchpeugeotservice.jpg'
a_images[1].alt = ''
a_images[1].title = ''

a_links[1] = new Array();
a_links[1]['path'] = '/uploads/peugeot/service plan copy.pdf'
a_links[1]['target'] = '_blank'
a_images_slideshow[2] = '/car_images/hg861/jeep adventure offer.jpg';
a_images[2] = new Image(634, 258 )
a_images[2].src = '/car_images/hg861/jeep adventure offer.jpg'
a_images[2].alt = ''
a_images[2].title = ''

a_links[2] = new Array();
a_links[2]['path'] = '/uploads/wrangler adventure.pdf'
a_links[2]['target'] = '_blank'
a_images_slideshow[3] = '/car_images/hg971/pt cruiser.jpg';
a_images[3] = new Image(634, 258 )
a_images[3].src = '/car_images/hg971/pt cruiser.jpg'
a_images[3].alt = ''
a_images[3].title = ''

a_links[3] = new Array();
a_links[3]['path'] = '/banners/pt cruiser special.pdf'
a_links[3]['target'] = '_blank'
a_images_slideshow[4] = '/car_images/hg963/porsche gt3 rs.jpg';
a_images[4] = new Image(634, 258 )
a_images[4].src = '/car_images/hg963/porsche gt3 rs.jpg'
a_images[4].alt = ''
a_images[4].title = ''

a_links[4] = new Array();
a_links[4]['path'] = ''
a_links[4]['target'] = ''
a_images_slideshow[5] = '/car_images/hg1004/mc sport line.jpg';
a_images[5] = new Image(634, 258 )
a_images[5].src = '/car_images/hg1004/mc sport line.jpg'
a_images[5].alt = ''
a_images[5].title = ''

a_links[5] = new Array();
a_links[5]['path'] = ''
a_links[5]['target'] = ''
a_images_slideshow[6] = '/car_images/hg1006/boxster new 2.jpg';
a_images[6] = new Image(634, 258 )
a_images[6].src = '/car_images/hg1006/boxster new 2.jpg'
a_images[6].alt = ''
a_images[6].title = ''

a_links[6] = new Array();
a_links[6]['path'] = ''
a_links[6]['target'] = ''
a_images_slideshow[7] = '/car_images/hg964/grancambrio.jpg';
a_images[7] = new Image(634, 258 )
a_images[7].src = '/car_images/hg964/grancambrio.jpg'
a_images[7].alt = ''
a_images[7].title = ''

a_links[7] = new Array();
a_links[7]['path'] = ''
a_links[7]['target'] = ''


function set_opacity(object,opacity)
{
	if (object.filters)
	{
		object.filters.alpha.opacity = opacity
	}
	else if (object.style.MozOpacity)
	{
		object.style.MozOpacity = opacity/100
	}
	else if (object.style.opacity)
	{
		object.style.opacity = opacity/100
	}
	else if (object.style.Opacity)
	{
		object.style.Opacity = opacity/100
	}
	else if (object.style.KhtmlOpacity)
	{
		object.style.KhtmlOpacity = opacity/100
	
	}
	
}

function fade_in()
{
	
	set_opacity(global_image_target,image_opacity)
	
	if (fadeIn != 1)
	{
		setTimeout( "fade_in()", 70 )
	}
	else if ( image_opacity < 100 )
	{
		
		image_opacity = image_opacity + 3
		last_call = setTimeout( "fade_in()", 70 )
	}
	else
	{
		setTimeout( "global_bg_target.src = global_image_target.src", 100 )

		image_opacity =  100
		fadeIn = 0;
		fadeOut = 1
		
	}
	
}

function fade_out()
{
	set_opacity(global_image_target,image_opacity)
	
	if (fadeOut != 1)
	{
		setTimeout( "fade_out()", 50 )
	
	}
	else if ( image_opacity > 25 )
	{
		
		image_opacity = image_opacity - 3
		
		last_call = setTimeout( "fade_out()", 50 )
	}
	else
	{
		image_opacity = 25	
		fadeIn = 1
		fadeOut = 0
		global_image_target.src = a_images_slideshow[global_image_index]
		fade_in()
	}
	
}

function extinguish()
{
	image_opacity = 1
	fadeIn = 1

	if ( last_call != '' )
	{
		clearTimeout( last_call )
	}

	if ( browser == 'IE' )
	{
		global_image_target.filters.alpha.opacity = 1
	}
	else
	{
		global_image_target.style.MozOpacity= 1/100
	}

}

function clear_last_call()
{
	if ( last_call != '' )
	{
		clearTimeout( last_call )
	}
}

function image_next()
{
	if( !bool_pause_slideshow )
	{
	
		if ( image_opacity > 0 && image_opacity < 100 )
		{
		
			setTimeout( "image_next()", 500 )
		}
		else 
		{
			global_image_index++


			if ( global_image_index >= a_images_slideshow.length )
			{
				global_image_index = 0	
			}
		
			clear_last_call()
			//fade_out()
			extinguish()
			setTimeout( "global_image_target.src = a_images_slideshow[global_image_index];global_image_target.alt = a_images[global_image_index].alt;global_image_target.title = a_images[global_image_index].title", 50 )
			setTimeout( "fade_in()", 100 )

			if ( a_links[global_image_index]['path'] != '' )
			{
				o = new getObj('image_fg')
				o.style.cursor = 'pointer'

			}
			else
			{
				o = new getObj('image_fg')
				o.style.cursor = 'default'

			}	
		}

	}
}

var bool_pause_slideshow = false

function pause_slideshow()
{

	bool_pause_slideshow = true
	slideshow_continue = false

	if ( last_cycle_call != '' )
		clearTimeout( last_cycle_call )

}

function restart_slideshow()
{

	bool_pause_slideshow = false
	slideshow_continue = true
	last_cycle_call = setTimeout( "cyle_thru_images()", 2.5*1000 ) 
}

function cyle_thru_images()
{
	
	image_next();

	if ( slideshow_continue )
	{
		last_cycle_call = setTimeout( "cyle_thru_images()", 5*1000 ) 
	}	
}

function start_slideshow()
{

	global_bg_target = document.image_bg

	global_image_target = document.image_fg
	extinguish()
	global_image_target.src = a_images_slideshow[global_image_index]
	fade_in()

	if ( a_images_slideshow.length > 1 )
	{
		setTimeout( "cyle_thru_images()", 4*1000 ) 
	}

}

function launch()
{
	if ( a_links[global_image_index]['path'] != '' )
	{
		if ( a_links[global_image_index]['target'] == '_blank' )
		{
			window.open( a_links[global_image_index]['path'], '_blank' )
		}
		else
		{
			window.location = a_links[global_image_index]['path']
		}
	}
}
