// PHOTO GALLERY
var GalleryThumbs = function(cat){
	$('#thethumbs').html("");
	if(cat == 0){catname = 'Do St. George';}
//	$('#thethumbs').append('<div style="color:#fff;text-align:left;padding:0 0 10px 0;"><b>'+catname+'</b></div>');
	var category = piclist[cat];
	for (var image_index in category) {
		var imagepair = category[image_index];
		var thumbnail = imagepair[0];
		var caption = imagepair[2];
		$('#thethumbs').append('<div id="thumb"><img src="'+thumbnail+'" alt="'+caption+'" onclick="seePhoto('+cat+','+image_index+')"></div>');
	}		
};

var seePhoto = function(c,p){
	$("#thephoto").html('');
	$('#thephoto').hide();
	var imagepair2 = piclist[c][p];
	var lrgimg = imagepair2[1];
	var caption2 = imagepair2[2];
	$("#thephoto").append('<div id="tpic">'+caption2+'<br /><img id="timg" src="'+lrgimg+'" alt="'+caption2+'" width="400"></div>');
	$("#thephoto").fadeIn(200);	
};

//GOOGLE MAP

var seeGoogMap = function(lx,ly){	
	$("#gmaptitle").html('');
	$("#gmaptitle").append('> <a onclick="hideGoogMap();">Hide Google Map</a>');
	$("#googmap").show();
	initialize(lx,ly);	
};
var hideGoogMap = function(){
	$("#gmaptitle").html('');
	$("#gmaptitle").append('> <a onclick="seeGoogMap(<? echo"$row[recordLon],$row[recordLat]";?>);">View Google Map</a>');
	clearCmap();
	$("#googmap").hide();
};

function clearCmap() {
	var clear = document.getElementById('cmap').innerHTML = "";
}

function initialize(lx,ly) {
    var latlng = new google.maps.LatLng(lx,ly);
    var myOptions = {
      zoom: 11,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("cmap"),
        myOptions);
}

$(document).ready(function(){				   
	GalleryThumbs(0);
	seePhoto(0,0);
//	initialize();
	mainmenu();

});

// TOGGLE SERVICES DROPDOWN
function toggle_visibility(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
	  e.style.display = 'none';
   else
	  e.style.display = 'block';
}

// MENU
function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


