spafinder.classes.giftcertificates = Class.create({
	initialize: function() {
		this.observers();
		this.setCondeNastTravelerTip('condenast-traveler-opener', $('condenast-traveler-details').innerHTML);
	},
	observers: function() {
		try {
			$('SF_shipto').observe('change', function(event) {
				return this.getOtherAddress(event);
			}.bind(this));
		} catch(e) {}
	},
	getOtherAddress: function(event) {
		if (!(element = $(event.element()))) return false;
		if ( element.options ) {
			if ( element.options[element.options.selectedIndex].value == 'Other' ) {
				$('SF_other_address').setStyle({
					position: 'static',
					left: (element.cumulativeOffset().left - 10),
					top: (element.cumulativeOffset().top + 25),
					display: 'block'
				});
			} else {
				$('SF_other_address').setStyle({display: 'none'});
			}
		}
	},
	setCondeNastTravelerTip: function(element, content){
		if (!(element = $(element))) return;
		new Tip(element, content, {
			title: 'Conde Nast Traveler magazine offer & refund details',
			effect: 'appear',
			showOn: 'click',
			hideOn: {element: 'closeButton', event: 'click'},
			hideOthers: true,
			hook: {target: 'topRight', tip: 'leftMiddle'},
			stem: {position: 'leftMiddle', height: 12, width: 15},
			offset: {x: 0, y: -25},
			border: 0,
			radius: 5,
			width: 350,
			viewport: true
		});
	}
});
document.observe("dom:loaded", function() {
	new spafinder.classes.giftcertificates();
});