/**
*	Despliegue de imágenes para sitio temporal
*	@author Daniel Pliscoff <dpliscoff@workspace.cl>
*/

$(document).ready(function(){
	mode = 2;
	lista = [];
	posturl = 'http://www.brainworks.cl/php/getimagelist.php';
	container = $('#mainimage');

	switch(mode) {
		case (1):	// Alt 1: One image with fadein
			$.post(posturl, {one:"1"}, randomImage, 'text');
		break;

		case (2):	// Alt 2: Shuffled image list
			$.post(posturl, '', imageList, 'text');
		break;
		
		default:
		break;
	}

	function imageList(data) {
		imgs = data.split(';');
		container.html('<img src="http://www.brainworks.cl/img/fotos/'+ imgs[0] +'"/>');
		for(var i in imgs) {
			slide = '<img src="http://www.brainworks.cl/img/fotos/'+ imgs[i] +'"/>';
			if (i > 0) {
				container.append(slide);
			}
		}

		container.cycle({
			delay:1500,
			speed:1500,
			pause:false
		});
	}

	function randomImage(data) {
		img = '<img src="http://www.brainworks.cl/img/fotos/'+ data +'"/>';
		container.html(img);
		container.fadeIn(500, function(){return 0;});
	}
});
 