//var me = 0;





/************tooltip************************/
ShowTooltip = function(e)
{
	var text = $(this).next('.show-tooltip-text');
	if (text.attr('class') != 'show-tooltip-text')
		return false;

	text.fadeIn('fast')
		.css('top', e.pageY)
		.css('left', e.pageX+10);

	return false;
}
HideTooltip = function(e)
{
	var text = $(this).next('.show-tooltip-text');
	if (text.attr('class') != 'show-tooltip-text')
		return false;

	text.fadeOut('slow');
}

SetupTooltips = function()
{
	$('.mairtooltip')
		.each(function(){
			$(this)
				.after($('<span/>')
					.attr('class', 'show-tooltip-text')
					.html($(this).attr('title')))
				.attr('title', '');
		})
		.hover(ShowTooltip, HideTooltip);
}

$(document).ready(function() {
	SetupTooltips();
});
/******************/


$( function() {

	$('.mainmenu').hover( function() {
		$('#overlay').show();
		$(this).addClass('menuhover').find('.submenu').slideDown('fast');
		$('.mainmenu').not('.menuhover').find('.submenu').each(function(){ $(this).slideUp();});
		
	}, function() {
		$('#overlay').hide();
		$(this).removeClass('menuhover').find('.submenu').hide();
	});
	

	$(".fancy").fancybox({'padding' :10});
	$('#watchMovie').fancybox({'frameWidth': 320,'frameHeight': 280});
	$('.model').fancybox({'frameWidth': 625,'frameHeight': 480,'hideOnContentClick': false });
	
	$('#accordian h3').click( function() {
		_parent = $(this).parent();
		if (_parent.find('div:visible').length == 0) {
			$(this).parent().find('div').addClass('toShow');
			$('#accordian div div:visible').hide('blind', function() {
				$('.toShow').show('blind').removeClass('toShow');
			});
		}
	});

	
	$('#taf').hover(function(){
		hoverMe('taf');
		$('#tafImage').click(function(){
			document.location = './tell-a-friend';
		});
	});
	
	$('#dv').hover(function(){
		hoverMe('dv');
		$('#dvImage').click(function(){
			document.location = './pages/e-voucher.pdf';
		});
	});
	
	
	// loopAnimation();
	$("#cs").easySlider( {
		controlsBefore :'<span>',
		controlsAfter :'</span>',
		controlsShow :true,
		prevText :'<img src="./css/images/prev.png" alt="" />',
		nextText :'<img src="./css/images/next.png" alt="" />',
		prevId :'prevslide',
		nextId :'nextslide'
	});

});

var left = Array();
left['taf'] = true;
left['dv'] = true;
function hoverMe(id) {
	$('#'+id+'Image').show('slide', {direction :'down'}, function() {
		$('#'+id+'').unbind();
		$(this).mouseout(function() {
			if(left[id]){
				left[id] = false;
				$('#'+id+'Image').hide('slide', {direction :'down'}, function(){ $('#'+id+'').hover(function(){hoverMe(id)}); left[id] = true });
			}
		});

		
	});
}



/*
 * function loopAnimation() { if ($('.panal:eq(' + me + ')').text() != '') {
 * $('.panal:eq(' + me + ')').show('slide', { direction :"down" }, 1000); me++;
 * setTimeout(loopAnimation, 100); } }
 */
