/* RANDOM FUNCTIONS */
function popMap(url){ window.open(url,"vbMap","menubar=no,width=750,height=650,toolbar=no,scrollbars=yes"); }
function launchPostcard(){ window.open('http://www.vbfun.com/createPostcard/','reunionPostcard','width=810,height=678,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes'); }
function webcam_loaded(){ $("#shoutout").delay(1500).animate({opacity: 0}, 2000, function(){ /* alert("done"); */ }); }


/*
	VBFUN SEARCH SCRIPTS
*/
var numTabs = 10;
var currArea = 0;
	
function updateSelect(tabID){
	currArea = tabID;
	var zoneOptions = document.getElementById("zoneOptions");
	zoneOptions[currArea].selected = true;
	if(zoneOptions[0].selected){
		zoneOptions[0].selected = false;
	}
}
function rollOut(){
	updateSelect(currArea,false);
	document['search_map'].changeArea(currArea);
}
function updateFlash(theSelect,multiple){
	if(multiple){
		document['search_map'].changeArea(-1);
	} else {
		document['search_map'].changeArea(theSelect.selectedIndex);
	}
}
function multiSelect(obj){
	var x = 0;
	for (var i = 0; i < obj.length; i++) { if (obj[i].selected) { x++; } }
	if(x>1){ obj[0].selected = false; show=true; } else { show=false; }
	updateFlash(obj, show);
}
/* END SEARCH */




$(document).ready(function() {

	/* LIGHTBOX.  YOU'RE WELCOME! */
	// $("a.lightbox").lightbox();


	/* TABBED LEFT */
	if($(".tabbedleft").length > 0 && $(".tabbedleft .tabbedleft_content").length == 0){ 
		$(".tabbedleft li h4").eq(0).addClass("selected");
		$(".tabbedleft").append("<div class=\"tabbedleft_content\"></div><div class=\"breaker\"></div>");
		$(".tabbedleft_content").html($(".tabbedleft li:first").html());
		
		$(".tabbedleft li h4").click(function(){
			$(".tabbedleft li h4").removeClass("selected");
			$(this).addClass("selected");
			$(".tabbedleft_content").html($(this).parent().html());
		});
		
	}

	// Slinky...of DOOM
	$(".accordion li h4").click(function(){
		$(this).parent().addClass("selected");
		$(this).parent().siblings().removeClass("selected");
	});


	/* welcome to the wonderful world of live for video boxes */
	$("#more_videos_link, #video_list_close").click(function(){
		if($("#video_list").attr("class").indexOf("expand")==-1){
			$("#video_list").animate({height: 200});
			$("#video_list").addClass("expand"); 
		} else {
			$("#video_list").animate({height: 10});
			$("#video_list").removeClass("expand");
		}
		return false;
	});
	
	/*
		GET DIRECTIONS
		NOTE: THIS FUNCTION NEEDS TO BE LOWER IN THE STACK
		COMPARED TO THE TABBED INTERFACES.
		... YOU'RE WELCOME!
	*/
	$(".getDirectionsSubmit").live("click", function(){

		if( $(".tabbedleft_content").length > 0 ){
			str_tabs = ".tabbedleft_content ";
		} else {
			str_tabs = "";
		}
		
		var start_addr = $(str_tabs + "#getDirectionsStart").attr("value");
		var end_addr = $(str_tabs + "#getDirectionsEnd").attr("value");
		
		if((start_addr!="" && start_addr!=null) && (end_addr!="" && end_addr!=null)){
			url = "http://maps.google.com/maps?f=d&hl=en&ie=UTF8&daddr=" + end_addr + "&saddr=" + start_addr;
			window.open(url, "google_maps");
		} else {
			alert("Please enter a zip or postal code to receive directions");
		}
		
		return false;
	});
	


	
});

