function ro()
{
	$('.ro').mouseover( function()
	{
		rep = ".";
		ext = $(this).attr('src').substr(-4, 4);
		src = $(this).attr('src').replace(rep, "-on.");
		$(this).attr('src', src);
		
	});
	$('.ro').mouseout( function()
	{
		rep = "-on.";
		ext = $(this).attr('src').substr(-4, 4);
		src = $(this).attr('src').replace(rep, ".");
		$(this).attr('src', src);
		
	});
}

function toggleInvite()
{
	$('.invite a').click( function(mouse)
	{
		$('.inviteForm').fadeOut('1000');
		eventID = $(this).attr("id").replace(/ID-/,"");
		type = $(this).parent().parent().parent().attr("class").replace(/each /,"");
		x = mouse.pageX - 356;
		y = mouse.pageY - 17;
		action = "toggle_on";
		
		
		$.ajax({
			type: "POST",
			url: "/action/send-invite.php",
			dataType: "html",
			data: { eventID:eventID, x:x, y:y, action:action, type:type },
			success: function(html){
				$('body').append(html);
				sendInvite();
			}
		});
		
		return false;
	});
	
	
}

function sendInvite()
{
	
	$(".inviteForm form").submit( function()
	{
		
		yName = $('.inviteForm #yName').val();
		yAddress = $('.inviteForm #yAddress').val();
		fAddress = $('.inviteForm #fAddress').val();
		eventID = $('.inviteForm #eventID').val();
		type = $('.inviteForm #type').val();
		action = "sending";
		
		$.ajax({
			type: "POST",
			url: "/action/send-invite.php",
			dataType: "html",
			data: { yName:yName, yAddress:yAddress, fAddress:fAddress, eventID: eventID, action:action, type:type },
			success: function(html){
				$('.inviteForm').fadeOut('1000');
				return false;
			}
		});
		
		return false;
	});
	
	$('.close a').click( function()
	{
		$('.inviteForm').fadeOut('1000');
		return false;
	});
}

function mainNav()
{
	$('#nav ul li').mouseover( function()
	{
		$("ul", this).css("display", "block");
	});
	$('#nav ul li').mouseout( function()
	{
		$("ul", this).css("display", "none");
	});
}

$(document).ready(function(){
	/*
	$('#kenburns').crossSlide({
	  fade: 1
	}, [
	  {
	    src:  '/media/img/kenburns/img1.jpg',  //sand castle
	    from: '100% 80% 1x',
	    to:   '100% 0% 1.7x',
	    time: 8
	  }, {
	    src:  '/media/img/kenburns/img1.jpg',  //sand castle
	    from: 'top left',
	    to:   'bottom right 1.5x',
	    time: 8
	  }, {
	    src:  '/media/img/kenburns/img1.jpg',  //sand castle
	    from: '100% 80% 1.5x',
	    to:   '80% 0% 1.1x',
	    time: 8
	  }, {
	    src:  '/media/img/kenburns/img1.jpg',  //sand castle
	    from: '100% 50%',
	    to:   '30% 50% 1.5x',
	    time: 8
	  }
	]);
	*/
	$(window).resize( function()
	{
		if( $(window).height() < 640 )
		{
			$("#nav").css("position", "absolute");
		}
		else
		{
			if( $.browser.msie )
			{
				// IF IE
				if( $.browser.version.substr(0,1) == "6")
				{
					// IF IE 6
					$("#nav").css("position", "absolute");
				}
				else
				{
					// IF OTHER THAN IE 6
					$("#nav").css("position", "fixed");
				}
			}
			else
			{
				// IF NOT IE
				$("#nav").css("position", "fixed");
			}
		}
	});


	$('#thumbnail-list a').lightBox({
		imageLoading: 'http://fall.tnvacation.com/media/img/lb/loading.gif',
		imageBtnClose: 'http://fall.tnvacation.com/media/img/lb/close.gif',
		imageBtnPrev: 'http://fall.tnvacation.com/media/img/lb/prev.gif',
		imageBtnNext: 'http://fall.tnvacation.com/media/img/lb/next.gif'

	});
	
	toggleInvite();
	mainNav();
	ro();


});