// PHOTO GALLERY

var GalleryThumbs = function(xcat){
	$('#thumbsbox').html("");
	seePhoto(xcat,0);
	if(xcat == 0){catname = 'Canyon Views';}
	if(xcat == 1){catname = 'More Canyon Views';}
	if(xcat == 2){catname = 'Activities & History';}
	if(xcat == 3){catname = 'Other Area Views';}
	$('#thumbsbox').append('<div style="color:#fff;text-align:left;padding:0 0 10px 0;"><b>'+catname+'</b></div>');
	var xcategory = piclist[xcat];
	for (var ximage_index in xcategory) {
		var ximagepair = xcategory[ximage_index];
		var xthumbnail = ximagepair[0];
		var xcaption = ximagepair[1];
		$('#thumbsbox').append('<div id="thumbs"><img src="'+xthumbnail+'" alt="'+xcaption+'" onclick="seePhoto('+xcat+','+ximage_index+')"></div>');
	}		
};
var seePhoto = function(c,p){
	$("#wphoto").html('');
	$('#wphoto').hide();
	var ximagepair2 = piclist[c][p];
	var xlrgimg = ximagepair2[0];
	var xcaption2 = ximagepair2[1];
	$("#wphoto").append('<div id="wpic">'+xcaption2+'<br /><img id="wbimgb" src="'+xlrgimg+'" alt="'+xcaption2+'" width="660"></div>');
	$("#wphoto").fadeIn(200);	
};


// FRONT SHOW
var time;
var fShow = function(fS){
	if(fS==1){sFrame1();}
	if(fS==2){sFrame2();}
	if(fS==3){sFrame3();}
	if(fS==4){sFrame4();}
	if(fS==5){sFrame5();}
	fS++
	if(fS==6){fS=1;}
	time = setTimeout('fShow('+fS+')',5000);
};
var sFrame1 = function(){
	$('#tx5').animate({opacity:0}, 1000);
	$('#fs5').animate({opacity:0}, 1000);
	$('#fs1').animate({opacity:1}, 1000);
	$('#tx1').animate({opacity:0, marginLeft: "-30px"}, 1000) //delays next animation
		.animate({opacity:1, marginLeft: "0px"}, 1000); //animate text
};
var sFrame2 = function(){
	$('#tx1').animate({opacity:0}, 1000);
	$('#fs2').animate({opacity:1}, 1000);
	$('#tx2').animate({opacity:0, marginLeft: "30px"}, 1000) //delays next animation
		.animate({opacity:1, marginLeft: "0px"}, 1000); //animate text
};
var sFrame3 = function(){
	$('#tx2').animate({opacity:0}, 1000);
	$('#fs3').animate({opacity:1}, 1000);
	$('#fs2').animate({opacity:0}, 1000);
	$('#tx3').animate({opacity:0, marginLeft: "-30px"}, 1000) // delays next animation
		.animate({opacity:1, marginLeft: "0px"}, 1000); //animate text
};
var sFrame4 = function(){
	$('#tx3').animate({opacity:0}, 1000);
	$('#fs4').animate({opacity:1}, 1000);
	$('#fs3').animate({opacity:0}, 1000);
	$('#tx4').animate({opacity:0, marginLeft: "-30px"}, 1000) // delays next animation
		.animate({opacity:1, marginLeft: "0px"}, 1000); //animate text
};
var sFrame5 = function(){
	$('#tx4').animate({opacity:0}, 1000);
	$('#fs5').animate({opacity:1}, 1000);
	$('#fs4').animate({opacity:0}, 1000);
	$('#tx5').animate({opacity:0, marginLeft: "30px"}, 1000) // delays next animation
		.animate({opacity:1, marginLeft: "0px"}, 1000); //animate text
};


// 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);
}

// Flash
var Flash = function(x){
	$('#flashDiv'+x+'').animate({opacity:.6}, 50);
	$('#flashDiv'+x+'').animate({opacity:0}, 200);
};

$(document).ready(function(){					
	mainmenu();
	
	$('#fs1').css({opacity:1});
	$('#tx1').css({opacity:0});
	$('#fs2').css({opacity:0});
	$('#tx2').css({opacity:0});
	$('#fs3').css({opacity:0});
	$('#tx3').css({opacity:0});
	$('#fs4').css({opacity:0});
	$('#tx4').css({opacity:0});
	$('#fs5').css({opacity:0});
	$('#tx5').css({opacity:0});
	$('#flashDiv1').css({opacity:0});
	$('#flashDiv2').css({opacity:0});
	$('#flashDiv3').css({opacity:0});
	$('#flashDiv4').css({opacity:0});
	$('#flashDiv5').css({opacity:0});

	fShow(1);
	theGoogMap();
});

// Google Map
var theGoogMap = function(){	
	var map = new GMap2(document.getElementById('cmap'));	
	var mapControl = new GHierarchicalMapTypeControl();
	mapControl.clearRelationships();
	mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Labels", false);
	map.addMapType(G_PHYSICAL_MAP);
	map.addControl(mapControl);
	map.addControl(new GSmallMapControl());
//	map.addControl(new GMapTypeControl());
	var cavelakes = new GLatLng(37.1249848,-112.5704836);
//	var cavelakes = new GLatLng(lx,ly);
	map.setCenter(cavelakes, 11);	
	marker = new GMarker(cavelakes); 
	map.addOverlay(marker);
};

// FORM CHECK
function checkform()
{
	if (document.feedback.FirstName.value == '')
	{
		alert('Your name is required');
		return false;
	}
	else if (document.feedback.LastName.value == '')
	{
		alert('Your name is required');
		return false;
	}
	else if (document.feedback.Address.value == '')
	{
		alert('Your Address is required');
		return false;
	}
	else if (document.feedback.City.value == '')
	{
		alert('Your City is required');
		return false;
	}
	else if (document.feedback.ZipCode.value == '')
	{
		alert('Your Zipcode is required');
		return false;
	}
	else if (document.feedback.Country.value == '')
	{
		alert('Your Country is required');
		return false;
	}
	else if (document.feedback.phone.value == '')
	{
		alert('Your Phone is required');
		return false;
	}
	else if (document.feedback.captcha.value == '')
	{
		alert('Type the characters you see in the image');
		return false;
	}
	else if (document.feedback.captcha.value != 'enjoy')
	{
		alert('Type the characters you see in the image');
		return false;
	}
	return true;
}
