// Home page JavaScript Documents and CSS Files 
$(document).ready(function() {
	$("a#tour").colorbox({width:"750px", height:"600px", iframe:true});
	
	var pictures = new Array();
	pictures[0] = new Array('TPR-Meeting-1.jpg', 'Main Meeting House', '/page/facilities/main-meeting-house/');
	pictures[1] = new Array('TPR-George-Fox-1.jpg', 'George Fox Room', '/page/facilities/george-fox-room/');
	pictures[2] = new Array('TPR-Southall-3.jpg', 'Southall Room', '/page/facilities/southall-room/');
	pictures[3] = new Array('TPR-Will-Penn-2.jpg', 'William Penn Room', '/page/facilities/william-penn-room/');
	pictures[4] = new Array('TPR-Eliz-Fry-1.jpg', 'Elizabeth Fry Room', '/page/facilities/elizabeth-fry-room/');
	pictures[5] = new Array('TPR-Lloyd-1.jpg', 'Lloyd Room', '/page/facilities/lloyd-room/');
	pictures[6] = new Array('TPR-Reading-3.jpg', 'Reading Room', '/page/facilities/reading-room/');
	pictures[7] = new Array('TPR-Sturge-1.jpg', 'Sturge Room', '/page/facilities/sturge-room/');
	pictures[8] = new Array('TPR-Marg-Fell-3.jpg', 'Margaret Fell Room', '/page/facilities/margaret-fell-room');


	var timer = setInterval( showSample, 5000);
	var counter = 0;
	var countMe = (pictures.length-1);

	// hide the original image
	$('#home-showreel .hide').hide();
	$.each(pictures, function(index)
	{
		link = pictures[index][2];	
		title = pictures[index][1];	
		image = pictures[index][0];
		$('#home-showreel').append('<div id="id_'+index+'" class="sample hide" ><a href="'+link+'" title="visit the '+title+'" ><img src="/themes/default/assets/images/room-sample/'+image+'" alt="'+title+'" /></a><h5>'+title+'</h5><p><a href="'+link+'" title="visit the '+title+'" >view this rooms options</a></p></div>');
	});

	$('#id_0').removeClass('hide');
	function showSample() {
		$('#home-showreel .sample').addClass('hide');
		$('#id_'+counter).removeClass('hide');
		counter == countMe? counter = 0 : counter++; 
	}
	
	
	var testTimer = setInterval( testimonal, 8000);
	
	function testimonal() {
		$.get('/testimonial/random', function(data) {
	  		$('.testimonial').not('#testimonial').replaceWith(data).fadeIn('slow');
	  		//alert('Load was performed.');
		});
	}
	
	
	
	
	
});

