// define reel player SWF parameters
var o;
o = {
	url: 'reel-player.swf',
	id: 'video-obj',
	size: { w:484, h:345 },
	version: '9.0.28',
	xi: false,
	fvars: { nocache:new Date().getTime() },
	params: { menu:false, bgcolor:'#000000', allowFullScreen:true },
	attrs: { id:'video-swf', name:'video-swf' }
};

// embed the reel player SWF
swfobject.embedSWF(o.url, o.id, o.size.w, o.size.h, o.version, o.xi, o.fvars, o.params, o.attrs);

// define the animation SWF parameters
/*
o = {
	url: 'swf/animation.swf',
	id: 'anim-obj',
	size: { w:230, h:65 },
	version: '9.0.28',
	xi: false,
	fvars: { nocache:new Date().getTime() },
	params: { menu:false, bgcolor: '#000000', allowFullScreen:false },
	attrs: { id:'anim-swf', name:'anim-swf' }
};

// embed the animation SWF
swfobject.embedSWF(o.url, o.id, o.size.w, o.size.h, o.version, o.xi, o.fvars, o.params, o.attrs);
*/

// create callbacks to configure the ULs
function setupWhereToList (event) {
	// loop over all the footer list items
	$$('#header #menu li').each(function (element, index) {
		// get the HREF of the contained link
		var href = element.getElement('a').get('href');
		// duplicate the link as an onclick event of the list item
		element.addEvent('click', function () { location.href = href; });
	});
	// setup the slide transition
	var menuSlide = new Fx.Slide($('menu-list'), { duration:'short', transition:Fx.Transitions.Expo.easeOut }).hide();
	// set the triggers
	$('menu').addEvent('mouseenter', function (event) {
		$('menu-label').addClass('menu-label-open');
		menuSlide.cancel();
		menuSlide.slideIn();

	});
	$('menu').addEvent('mouseleave', function (event) {
		$('menu-label').removeClass('menu-label-open');
		menuSlide.cancel();
		menuSlide.slideOut();
	});
}

function setupContactList (event) {
	// loop over all the footer list items
	$$('#footer ul li').each(function (element, index) {
		// get the HREF of the contained link
		var href = element.getElement('a').get('href');
		// duplicate the link as an onclick event of the list item
		element.addEvent('click', function () { location.href = href; });
	});
}

function setupReelSeeMore (event) {
	var rsm = $('reel-see-more');
	// get the HREF of the contained link
	var href = rsm.getElement('a').get('href');
	// duplicate the link as an onclick event of the list item
	rsm.addEvent('click', function () { location.href = href; });
}

function setupLangSelector (event) {
	var ls = $('lang-selector');
	// get the HREF of the contained link
	var href = ls.getElement('a').get('href');
	// duplicate the link as an onclick event of the list item
	ls.addEvent('click', function () { location.href = href; });
}

function setupNyLinks (event) {
	if (/taxi\-nyc\.com/i.test(location.hostname)) {
		$$('#menu li a').each(function (element, index) {
			var href = element.get('href');
			element.set('href', href.split('?').join('?ny=true&'));
		});
	}
}
				
// modify the list items when ready
window.addEvent('domready', setupNyLinks);
window.addEvent('domready', setupWhereToList);
window.addEvent('domready', setupContactList);
window.addEvent('domready', setupReelSeeMore);
window.addEvent('domready', setupLangSelector);
