peeps = Array('Bert Crabbe', 'Phil McCardle', 'Paul Taylor','Joe Walser','Stan Buck');

$(document).ready(function(){	
	$('#peepthumb a').bind('click', switchPeeps);		
	$('#testimonial .watch a').live('click', playTestimonial);
	
	$('#designthumb a').bind('click', switchDesign);
});

function switchPeeps(){
	var $ul = $(this).parent().parent();
	$ul.find('li').removeClass('current');
	$(this).parent().addClass('current');
	
	// get the index of the clicked link
	var index = $('#peepthumb a').index(this);
	$.get('/ajax/peeps.php', { name:peeps[index] }, function(o){
		$('#testimonial').html(o);
	});
	
	return false;
}

function playTestimonial(){
	var url = $(this).attr('href');		
	var flashvars = { 
		file: url,
		autostart:'true',
		frontcolor: 'ffffff',
		lightcolor: 'cc9900',
		//skin: 'http://www.longtailvideo.com/jw/upload/overlay.swf',
		controlbar: 'over'
	};
		
	var params = { wmode:'transparent' };
	var attributes = {  };
		
	if($(this).find('img').attr('src')){
		flashvars.image = $(this).find('img').attr('src');
	}
	$('#testimonial p:first').attr('id', 'test-vid').css('margin-bottom', '25px');
	swfobject.embedSWF("/file/media/player.swf", "test-vid", "440", "248", "9.0.0", "/file/media/expressInstall.swf", flashvars, params, attributes);			
	$(this).hide();
	$(this).parent().hide();
	return false;
}

function switchDesign(){
	var $ul = $(this).parent().parent();
	$ul.find('li').removeClass('current');
	$(this).parent().addClass('current');
	
	// get the index of the clicked link
	var index = $('#designthumb a').index(this);	
	var img = $(this).next('div').html();
	$('#rdesigns .mediabox').html(img);
	return false;
}
