$(document).ready(function(){

		var x = 0;	// counter variable for the films arrays
		var k = 0;	// counter variable for the films arrays
		var loopCounter = 0;
		var currFilmIndex;	// stores the index of the current film
		var filmsArray = new Array();
		var filmTitlesArray = new Array();	
		var currFilmIndex = location.hash.substring(1);	

		var tweeterMessageArray = new Array();
		var tweeterMessageDateArray = new Array();

		// if no currFilmIndex selected set it as 0
		if(!currFilmIndex){  currFilmIndex = 0;	}
			
		loadFashionFilm();	
		
		$('#s1').cycle({ 
		    fx:    'fade', 
		    speed:  1500,
			timeout:  0 ,
			next: '.nextBtn',
			prev: '.prevBtn'
		 });				
			
		// initialize Google Analytics
		$.gaTracker('UA-7210865-1');		
		$.gaTracker('UA-7210865-1');		

		// when clicking the individual films load the corresponding player
		$('.fashionFilm .viewFashionFilm').click( function() {
				removeSelectedNav();
				// scroll to the page top
				$('html,body').animate({scrollTop: 200}, 500);
				loadFashionFilm();
		});


		// when clicking the individual films load the corresponding player
		$('.videoThumb a').each( function() {
			
			$(this).attr('video', $(this).attr('href'));
			$(this).attr('href', '#' + $(this).parent('.videoThumb').attr('id').replace(/^video/,'') );		
			
			$(this).click(function() {
				removeSelectedNav();
				// set the video title
				$("#filmTitle h4").html($(this).attr('title'));

				// display the video			
				$('.VideoPlayer').attr('href', $(this).attr('video'));	
				$('.VideoPlayer').media( {   width: 630, height: 377, params:{allowFullScreen:true}, bgColor:'#e5e0d0', flashVersion:'9'  });		
		
				// scroll to the page top
				$('html,body').animate({scrollTop: 200}, 500);
				$(this).addClass("selectedVideoThumb");
			});
			
		});

		function loadFashionFilm(){
				$('.VideoPlayer').attr('href', '/swf/mediaplayer_white.swf?file=/projects/softfurnishings/mp4/sf_makingof.mp4&image=/projects/softfurnishings/img/sf_making_of_still.jpg&autostart=true&screencolor=0xe5e0d0');	
				$('.VideoPlayer').media( {   width: 630, height: 377, params:{allowFullScreen:true}, bgColor:'#e5e0d0', flashVersion:'9'  });	
				$('.videoThumbs .videoThumb:first a').addClass("selectedVideoThumb");					
		}	
		
		function removeSelectedNav(){
				$(".selectedVideoThumb").removeClass("selectedVideoThumb");	
		}

});


