// functions to show/hide modal windows //

//array of modal windows
mw = new Array('donate_modal','vol_modal','meetbobby_modal','endorse_modal');

function closeModal(elem){
	$("#"+elem).hide();
	hideBox();
}
function showModal(elem){
	//hide other modal windows
	for(i=0;i<mw.length;i++){
		$("#"+mw[i]).hide;
	}
	showBox();
	$("#"+elem).show();
}


//function for gallery navigation

function galleryNav(dir,gal){
	var curr = $("#gallery_current").text();
	var total = $("#gallery_total").text();
	
	//determine image num. to retrieve
	if(dir == 'prev'){
		if(curr == 1){
			var photo = parseInt(total);
		}else{
			var photo = parseInt(curr) -1;
		}
	}else{
		if(curr == total){
			var photo = parseInt(1);
		}else{
			var photo = parseInt(curr)+1;
		}
	}
	
	var pars = 'photo='+photo+'&gallery='+gal;

		$.ajax({
		   type: "POST",
		   url: "ajax.gallery.php",
		   data: pars,
			success: function(msg){
				
				var myJson = eval('(' + msg + ')');			
				var html ='';

				for(i=0;i<myJson.photo.length;i++){
					html += '<img src="im/galleries/'+myJson.photo[i].image+'" alt="" id="image" />';
					html += '<div id="caption"><div id="nav">';
					html += '<a href="javascript:galleryNav(\'prev\','+gal+')" id="gallery_prev"><img src="im/gallery_prev.gif" alt="prev" /></a>';
					html += '<span><span id="gallery_current">'+photo+'</span>/<span id="gallery_total">'+total+'</span></span>';
					html += '<a href="javascript:galleryNav(\'next\','+gal+')" id="gallery_next"><img src="im/gallery_next.gif" alt="next" /></a>';
					html += '</div>'+myJson.photo[i].capt+'</div>';

				}

					$("#gallery").html(html);
			}
		 });
}