
$(document).ready(function() {
	var content = $('#seo_buddy1').html();
	if(content != null) {
		$('#seo_buddy2').css('borderTopWidth', '1px').html(content);
		$('#seo_buddy1').remove();
	}
});


/*************** Image Rollovers **************/
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		mainNav_antarctica_over = newImage("images/mainNav_antarctica_over.gif");
		mainNav_arctic_over = newImage("images/mainNav_arctic_over.gif");
		mainNav_tripSearch_over = newImage("images/mainNav_tripSearch_over.gif");
		
		// Preaload the blip images
		blipPart_1 = newImage("images/info_top.png");
		blipPart_2 = newImage("images/info_blip_bottomLeft.png");
		blipPart_3 = newImage("images/info_blip_bottomRight.png");
		blipPart_4 = newImage("images/info_blip_left.png");
		blipPart_5 = newImage("images/info_blip_right.png");
		blipPart_6 = newImage("images/info_blip_topLeft.png");
		blipPart_7 = newImage("images/info_blip_topRight.png");
		blipPart_8 = newImage("images/info_bottom.png");
		blipPart_9 = newImage("images/info_middle.png");

		preloadFlag = true;
	}
}




/****************** Banner Images *************************/
function initBanner(bannerSrc) {
	var bannerVars = new Object();
	bannerVars["pageTitle"] = $("#bannerTitle").text();


	// get the source images
	var i=0;
	$("#bannerImages img").each(function() {
		bannerVars["image"+(i++)] = $(this).attr("src")
	});
	
	bannerVars["numberOfImages"] = String(i);

		
	// load up the flash
	var banner = $("#banner");
	swfobject.embedSWF("images/"+bannerSrc, "banner", "796", "325", "9.0.0", "expressInstall.swf", bannerVars, { menu: "false", wmode: "transparent" }, {id: "banner", name: "banner"});
}



function initTopRight() {
	var flashVars = new Object();

	// get the source images
	var i=0;
	$("#topRight img").each(function() {
		flashVars["image"+(i++)] = $(this).attr("src")
	});
	
	flashVars["numberOfImages"] = String(i);

		
	// load up the flash
	var topRight = $("#topRight");
	swfobject.embedSWF("images/topRight.swf", "topRight", "154", "220", "9.0.0", "", flashVars, { menu: "false", wmode: "transparent" }, {id: "topRight", name: "topRight"});
}


	

function printPage() {
	window.print();
}

function viewThisYearsRates(id) {
	window.location.href = "itinerary.cfm?jump=thisYear&ship=" + id;
}

function viewNextYearsRates(id) {
	window.location.href = "itinerary.cfm?jump=nextYear&ship=" + id;
}

function viewDeckPlans(id) {
	window.location.href = "itinerary.cfm?jump=deckPlans&ship=" + id;
}


function getBlipBody(id) {
	// get the blip info from blip.cfm
	$.get("inc/blips.cfm", {id: id}, function(data) {
		return $("#tooltip .body").html(data);
	});
	
	// send a loading signal till it's loaded
	return '<span class="t2">Loading...</span>';
}



function increaseSize() {
	$(".t3").each(function() {
		var currentSize = parseInt($(this).css("fontSize"));
		$(this).css("fontSize", (currentSize+1) + "px");
	});
}

function decreaseSize() {
	$(".t3").each(function() {
		var currentSize = parseInt($(this).css("fontSize"));
		$(this).css("fontSize", (currentSize-1) + "px");
	});
}


function closeCurrentTooltip() {
	$.tooltip.hide();
}



var lastPoleSearch = 'Antarctica';
function reload_forms(pole, dev) {
	var vars = {};
	var targetURL = '/tripSearch_ajaxfields.cfm';
	if(dev == true) {
		targetURL = '/tripSearch_ajaxfields.cfm?dev=true';
	}
	if(pole != undefined) {
		var form = eval('document.' + pole);
		lastPoleSearch = pole;
		vars.pole = pole;
		vars[pole + '_int_destination'] = form.int_destination[form.int_destination.selectedIndex].value;
		vars[pole + '_str_date'] = form.str_date[form.str_date.selectedIndex].value;
		vars[pole + '_int_ship'] = form.int_ship[form.int_ship.selectedIndex].value;
		vars[pole + '_int_activity'] = form.int_activity[form.int_activity.selectedIndex].value;
	
		// Set them all to say "Updating..."
		form.int_destination[form.int_destination.selectedIndex].innerHTML = 'Updating Destinations...';
		form.str_date[form.str_date.selectedIndex].innerHTML = 'Updating Dates...';
		form.int_ship[form.int_ship.selectedIndex].innerHTML = 'Updating Ships...';
		form.int_activity[form.int_activity.selectedIndex].innerHTML = 'Updating Adventure Options...';
	}
	
	$("#pole_forms")
		.fadeTo('normal', .5)
		.load(targetURL, vars, function() {
			// Change all of them to say "Reset" instead of "Select"
			var form = eval('document.' + lastPoleSearch);
			if(form.int_destination.selectedIndex != 0) form.int_destination[0].innerHTML = 'Reset Destinations';
			if(form.str_date.selectedIndex != 0) form.str_date[0].innerHTML = 'Reset Dates';
			if(form.int_ship.selectedIndex != 0) form.int_ship[0].innerHTML = 'Reset Ships';
			if(form.int_activity.selectedIndex != 0) form.int_activity[0].innerHTML = 'Reset Adventure Options';

			$("#pole_forms").stop().fadeTo('normal', 1, function() {
				this.style.removeAttribute('filter');
			});
		});
	
}

function reload_forms2(pole) {
	var vars = {};
	if(pole != undefined) {
		var form = eval('document.' + pole);
		lastPoleSearch = pole;
		vars.pole = pole;
		vars[pole + '_int_destination'] = form.int_destination[form.int_destination.selectedIndex].value;
		vars[pole + '_str_date'] = form.str_date[form.str_date.selectedIndex].value;
		vars[pole + '_int_ship'] = form.int_ship[form.int_ship.selectedIndex].value;
		vars[pole + '_int_activity'] = form.int_activity[form.int_activity.selectedIndex].value;
	
		// Set them all to say "Updating..."
		form.int_destination[form.int_destination.selectedIndex].innerHTML = 'Updating Destinations...';
		form.str_date[form.str_date.selectedIndex].innerHTML = 'Updating Dates...';
		form.int_ship[form.int_ship.selectedIndex].innerHTML = 'Updating Ships...';
		form.int_activity[form.int_activity.selectedIndex].innerHTML = 'Updating Adventure Options...';
	}
	
	$("#pole_forms")
		.fadeTo('normal', .5)
		.load('/tripSearch_ajaxfields2.cfm', vars, function() {
			// Change all of them to say "Reset" instead of "Select"
			var form = eval('document.' + lastPoleSearch);
			if(form.int_destination.selectedIndex != 0) form.int_destination[0].innerHTML = 'Reset Destinations';
			if(form.str_date.selectedIndex != 0) form.str_date[0].innerHTML = 'Reset Dates';
			if(form.int_ship.selectedIndex != 0) form.int_ship[0].innerHTML = 'Reset Ships';
			if(form.int_activity.selectedIndex != 0) form.int_activity[0].innerHTML = 'Reset Adventure Options';

			$("#pole_forms").stop().fadeTo('normal', 1, function() {
				this.style.removeAttribute('filter');
			});
		});
	
}


function resetForms() {
	$('#pole_forms select').each(function() {
		this.selectedIndex = 0;
	});
}
