﻿/// <reference path="libs/jquery-1.3.2-vsdoc.js" />

/**
*	Javascript Tools based on jquery
*
*	@date		2009-02-12
*	@author		Michal Gondar
*	@copyright	Live Nation (Music) UK
*   @require    jquery
*   @jquery     jquery-1.3.1.min.js
*
*   This is main file with javascript outside class.
*/


/*
 *  check all input[type=text] elements,
 *  remember default value
 *  make onFocus, onBlur functions
 *  // make focus on first found input
 */



function slideSwitchStart() {
	$('#slideshow').append('<div id="loading"></div>');
	preloadImages();
	slideSwitchStartTiming();
}

function preloadImages()
{
	var parent = $('#slideshow');
	for(i=0;i<images.length;i++)
	{
		if( typeof texts != "undefined")
			parent.append('<div class="slideshow-image"><img src="' + images[i] + '" width="635" height="340" /><div class="title">' + texts[i] + '</div></div>');
		else
			parent.append('<div class="slideshow-image"><img src="' + images[i] + '" width="635" height="340" /></div>');
	}

	$('#slideshow .slideshow-image img').load(function() {
		$(this).addClass('loaded');
	});
}

function slideSwitchStartTiming() {
	// if images are not loaded than dont start slideshow	
	if(($('#slideshow .loaded').size() < images.length ) && (typeof window.opera == "undefined"))
	{
		setTimeout("slideSwitchStartTiming()", 100);
		return false;
	}

	setInterval( "slideSwitch()", 3000 );
}

function slideSwitch() {


    var active = $('#slideshow .active');

    if ( active.length == 0 ) active = $('#slideshow .slideshow-image:last');

	next = activeImage + 1;
	
	if( next > images.length )
		next = 0;
	
	activeImage = next;
	
	next = $('#slideshow .slideshow-image:eq(' + next + ')');

	$(active).fadeOut(1000, function() {
		$(this).removeClass('active');
	});
	$(next).fadeIn(1000, function() {
		$(this).addClass('active');
	});

}


var talentGallery = {

	start:function() {
		
		$('.opacity, .description').css({display: 'none'});

		$('#images a').hover(function() {
			$('.opacity, .description', this).css({display: 'none'}).stop(true,true).fadeIn(200);
		}, function() {
			$('.opacity, .description', this).css({display: 'none'});
		});
	}
}
