//JQUERY
$(document).ready(function(){
	$('a.playVid').click(function(e) { 
		e.preventDefault;
		return false;
	});

	$('a.playVid').click(function() {
		var vidID = $(this).attr('title');
		var vidFile = $(this).attr('rel');

		$('.hideAllVids').hide();

		$.ajax({
			type: 'GET',
			url: '/tourXX/includes/get_video.php',
			data: 'id=' + vidID + '&file=' + vidFile,
			dataType: 'html',
			beforeSend: function() {
				$('#updateFade' + vidID).hide();
				$('#updateFade' + vidID).addClass("updateFade");
				$('#updateFade' + vidID).fadeIn('slow');

				$('#updateClose' + vidID).hide();
				$('#updateClose' + vidID).removeClass("boxInv");
				$('#updateClose' + vidID).addClass("boxVis");
				$('#updateClose' + vidID).fadeIn('slow');

				$('#updateVid' + vidID).html('<b>Loading...</b>');
				if(!vidID) {
					//$('#updateVid' + vidID).html('<p>No VID!.</p>');   	
					//return false;
				}	
			},
			success: function(response) {
				$('#updateVid' + vidID).hide();
				$('#updateVid' + vidID).html(response);
				$('#updateVid' + vidID).fadeIn('slow');
			}
		});
	});

	$('.updateClose').click(function() {
		var vidID = $(this).attr('rel');

			$('#updateFade' + vidID).hide();
			$('#updateFade' + vidID).removeClass("updateFade");
			$('#updateFade' + vidID).fadeIn('slow');
			$('#updateClose' + vidID).hide();
			$('#updateVid' + vidID).html('');
	});

	$('a.updateRating').click(function(e) { 
		e.preventDefault;
		return false;
	});

	$('a.updateRating').click(function() {
		var vidID = $(this).attr('rel');
		var vidRa = $(this).attr('title');
		$.ajax({
			type: 'GET',
			url: '/tourXX/includes/insert_rating.php',
			data: 'id=' + vidID + '&ra=' + vidRa,
			dataType: 'html',
			beforeSend: function() {
				$('#rateBox' + vidID).hide();
				$('#rateBox' + vidID).html('<b>Loading...</b>');
				$('#rateBox' + vidID).fadeIn('slow');
				if(!vidID) {
					//$('#updateVid' + vidID).html('<p>No VID!.</p>');   	
					//return false;
				}	
			},
			success: function(response) {
				$('#rateBox' + vidID).hide();
				$('#rateBox' + vidID).html(response);
				$('#rateBox' + vidID).fadeIn('slow');
			}
		});
	});
});
