var captions = []
captions[0] = "Our View";
captions[1] = "Cranes";
captions[2] = "Beach Rugby";
captions[3] = "Cranes at Sunset";
captions[4] = "Sunday Morning in the Square";
captions[5] = "Masts";
captions[6] = "Darsena 2";
captions[7] = "Beach Life";
captions[8] = "The Tower";
captions[9] = "Golf Course";
captions[10] = "Our View";
captions[11] = "Night View";
captions[12] = "View From Golf Course";
captions[13] = "Golf Course";
captions[14] = "Golf Course";
captions[15] = "Boats at Play";
captions[16] = "The Beach";
captions[17] = "Sunset";
captions[18] = "Jamons";
captions[19] = "Sunset";
captions[20] = "View From the Sea";
captions[21] = "Beach Life";
captions[22] = "Beach Football";
captions[23] = "Virgen del Carmen";
captions[24] = "Night Life";
captions[25] = "The Square at Night";
captions[26] = "The Square";
captions[27] = "Yacht";
captions[28] = "May Cross";
captions[29] = "Our View";
captions[30] = "Golf Course";
captions[31] = "Our View";
captions[32] = "Our View";
captions[33] = "Almerimar Marina";

// just name the images /slideshow/imageX.jpg (where X is the corresponding caption + 1)
// eg captions[33] points to /slideshow/image34.jpg

var index = 0;

window.setInterval(function() {
	if (index >= captions.length) index=0; else index++;
	$('#thecaption').text(captions[index]);
	$('#slide').attr('src', '/slideshow/image' + (index+1) + '.jpg');
}, 4000);


$(function() { // other on-load behaviours
			
	var webcam = $('#today .webcam .pic');
	var webcam2 = $('#prefoot .webcam');
	
	var webcamURL = "url(http://almerimarlife.com/webcam.jpg?";
	var refreshWebcam = setInterval(function() {
		newURL = webcamURL + new Date().getTime() + ')';
		webcam.css('background-image', newURL);
		webcam2.css('background-image', newURL);
	}, 30000);


	$('#searchbox').click(function() {
		if ($(this).val() == 'Search')
			$(this).val('');
	});

	$('#searchbox').blur(function() {
		if ($(this).val() == '')
			$(this).val('Search');
	});

	$('.vid').click(function(){
		id = $(this).attr('id');
		vid = $(this).attr('rel');
	
		vidbox = new SWFObject('/wp-content/themes/almerimarlife/media/player.swf', 'player' , '320', '180', 9);
		vidbox.addParam('flashvars','file='+ vid +'&stretching=fill&controlbar=over&autostart=true');
		vidbox.addParam('wmode', 'transparent');
		vidbox.write(id);
	
		$(this).unbind('click');
	});

});
