var thumbActive = 0;
var total = 0;
$(document).ready(
	function() {
		init();
	}
);

function init(){
	var parametrosFlash = new Array();
	getFlash('ants', 'hormigas.swf', 'hormigas','174', '340',parametrosFlash);
	pintarSpots();
}


function pintarSpots(){
	getSpots(function(json){
		var htmlImg='';
		var htmlDesc='';
		var htmlTit='';
		//var htmlControl='';
		
		for(var i=0; i<json.list.length; i++){
			htmlImg +='<img src="'+path+'images/spots/'+json.list[i].id+'.jpg" class="spot-img-img" id="spot_img_'+i+'" style="display:none;"/>';
			htmlTit +='<div id="spot_tit_'+i+'" class="spot-tit-tit" style="display:none;">'+unescape(json.list[i].titulo)+'</div>';
			htmlDesc +='<div id="spot_desc_'+i+'" class="spot-desc-desc" style="display:none;">'+unescape(json.list[i].descripcion);
			if(json.list[i].url!=null){
				if(json.list[i].url!=''){
					htmlDesc +='<br style="clear:both;"/><br/><a href="'+unescape(json.list[i].url)+'" target="_blank" style="color:#666; font-weight:bold;">'+unescape(json.list[i].url)+'</a>';
				}
			}
			htmlDesc +='</div>';
			//htmlControl+='<div class="spot-thumb" id="spot_bt_'+(i)+'" onClick="thumbActive='+i+'; nextSpot('+json.list.length+');"></div>';
		}
		total = json.list.length;
		escribir($('#spot_img'), htmlImg);
		escribir($('#spot_titulo'), htmlTit);
		escribir($('#spot_info'), htmlDesc);
		//escribir($('#spot_controls'), htmlControl);
		$('#spot_img_0').fadeIn();
		$('#spot_desc_0').show();
		$('#spot_tit_0').show();
		//$('#spot_bt_0').addClass('spotSelected');
	});
}


function nextSpot(){
	//alert(total)
	thumbActive ++;
	var nextThumb = thumbActive;	
	if(nextThumb>=total){
		nextThumb=0; 
		thumbActive=0;
	}	

	$(".spot-img-img").hide();
	$(".spot-desc-desc").hide();
	$(".spot-tit-tit").hide();
	
	$("#spot_img_"+nextThumb).fadeIn('slow');
	$("#spot_desc_"+nextThumb).show();
	$("#spot_tit_"+nextThumb).show();
	
}

function prevSpot(){
	//alert(total)
	thumbActive --;
	var nextThumb = thumbActive;
	if(nextThumb<0){
		nextThumb=total-1;
		thumbActive = total-1;
	}

	$(".spot-img-img").hide();
	$(".spot-desc-desc").hide();
	$(".spot-tit-tit").hide();

	$("#spot_img_"+nextThumb).fadeIn('slow');
	$("#spot_desc_"+nextThumb).show();
	$("#spot_tit_"+nextThumb).show();
	
}

function presupuesto(){
	var html = '<div class="form">';
		html += '	<label for="nomyap">Nombre y Apellido</label><br/><input type="text" name="nomyap" id="nomyap" /><br/><br/>';
		html += '	<label for="empresa">Empresa / Emprendimiento</label><br/><input type="text" name="empresa" id="empresa" /><br/><br/>';
		html += '	<label for="mail2">eMail</label><br/><input type="text" name="mail2" id="mail2" /><br/><br/>';
		html += '	<label for="telefono">Tel&eacute;fono</label><br/><input type="text" name="telefono" id="telefono" /><br/><br/>';
		html += '	<label for="detalle_empresa">Detalles de la empresa o emprendimiento</label><br/><textarea name="detalle_empresa" id="detalle_empresa" cols="30" rows="10"></textarea><br/><br/>';
		html += '	<label for="secciones_sitio">Secciones del sitio web</label><br/><textarea name="secciones_sitio" id="secciones_sitio" cols="30" rows="10"></textarea><br/><br/>';
		html += '	<label for="sitios_referncias">Sitios de referencia</label><br/><input type="text" name="sitios_referencias" id="sitios_referencias" /><br/><br/>';
		html += '	<div class="radiobutton">';
		html += '	<span>¿El sitio debe ser autoadministrable desde un administrador de contenidos?</span>';

		html += '	<input type="radio" name="autoadministrable" id="autoadministrable_si" value="1" /><label for="">Si</label>';
		html += '	<input type="radio" name="autoadministrable" id="autoadministrable_no" value="0" checked /><label for="">No</label><br/>';
				
		html += '	<span>¿El sitio tendrá galerías de fotos y videos?</span>';
		html += '	<input type="radio" name="galerias" id="galerias_si" value="1" /><label for="">Si</label>';
		html += '	<input type="radio" name="galerias" id="galerias_no" value="0" checked /><label for="">No</label><br/>';
				
		html += '	<span>¿El sitio tendrá vinculación a redes sociales?</span>';
		html += '	<input type="radio" name="redes_sociales" id="redes_sociales_si" value="1" /><label for="">Si</label>';
		html += '	<input type="radio" name="redes_sociales" id="redes_sociales_no" value="0" checked /><label for="">No</label><br/>';
		html += '	<span>¿El sitio tendrá más de 1 idioma?</span>';
		html += '	<input type="radio" name="idiomas" id="idiomas_si" value="1" /><label for="">Si</label>';
		html += '	<input type="radio" name="idiomas" id="idiomas_no" value="0" checked /><label for="">No</label>';
		html += '	<label for="" class="labelcuantos">¿Cuantos?</label>';
		html += '	<input type="text" name="cant_idiomas" id="cant_idiomas" class="radiocuantos"/><br/>';
		
		html += '	<span>¿El sitio incluirá carrito de compras?</span>';
		html += '	<input type="radio" name="carrito_compras" id="carrito_compras_si" value="1" /><label for="">Si</label>';
		html += '	<input type="radio" name="carrito_compras" id="carrito_compras_no" value="0" checked /><label for="">No</label><br/>';
		html += '	</div>';

		html += '	<label for="">Más comentarios</label><br/><textarea name="mas_comentarios" id="mas_comentarios" cols="30" rows="10"></textarea><br/><br/>';
		html += '	</div>';
	getModalContent('Solicitud de presupuesto:', 800, 500, html);	
}
