// JavaScript Document

function ucwords(str) {
	return str.substring(0,1).toUpperCase() + str.substring(1,str.length);
}

jQuery(document).ready(function($) {
	$('a.pop').fancybox({
		'hideOnContentClick'    : false
    })
	
	$('a.popform').fancybox({
		'hideOnContentClick'    : false, 
		'frameHeight' 			: 450
    })
	
	$(document).pngFix(); 
	
	$('div[rel*=roll]').hover( 
		function() {
			var name = $(this).attr("id");
			$(this).attr("style","background: url(images/features/" + name + "_over.jpg) no-repeat; color: #902222;");
		},
		function() {
			var name = $(this).attr("id");
			$(this).attr("style","background: url(images/features/" + name + ".jpg) no-repeat; color: #333333;");
		}
	);
	
	$('div.tab').hover(
		function() {
			$(this).animate( {top:"0"},"fast" );	
		},
		function() {
			$(this).animate( {top:"-15"},"fast" );
		}
	);
	
	$('input').focus( function() {
		var val = $(this).attr('value');
		var oldval = ucwords($(this).attr('name'));
		if(val == oldval) $(this).attr('value','');
	});
	
	$('input').blur( function() {
		var val = $(this).attr('value');
		var newval = ucwords($(this).attr('name'));
		if(!val) $(this).attr('value',newval);
	});
	
	$('textarea#privatebox').focus( function() {
		var val = $(this).attr('value');
		var oldval = "Tell us about your event.";
		if(val == oldval) $(this).attr('value','');
	});
	
	$('textarea#reservebox').focus( function() {
		var val = $(this).attr('value');
		var oldval = "Any special requests?";
		if(val == oldval) $(this).attr('value','');
	});
	
	$('textarea#privatebox').blur( function() {
		var val = $(this).attr('value');
		var newval = "Tell us about your event.";
		if(!val) $(this).attr('value',newval);
	});
	
	$('textarea#reservebox').blur( function() {
		var val = $(this).attr('value');
		var newval = "Any special requests?";
		if(!val) $(this).attr('value',newval);
	});
	
	$('#next').click( function() {
		var title = $('#caltitle').html();
		var nextlink;
		var nextval;
		if(title.search('This') != -1) {
			title = 'Next Week at Mannys';
			nextlink = 'Back to This Week';
			$('#tablebody1').fadeOut('normal',function(){$('#tablebody2').fadeIn();});
		} else {
			title = 'This Week at Mannys';
			nextlink = 'Go to Next Week';
			$('#tablebody2').fadeOut('normal',function(){$('#tablebody1').fadeIn();});
		}
		
		//$('#tablebody').load('script/getweek.php',{next: nextval});
		//$('#caltitle').fadeOut('normal',function() {$('#caltitle').html(title);});
		//$('#next').fadeOut('normal',function() {$('#next').html(next);});
		$('#caltitle').html(title);
		$('#next').html(nextlink);
		//$('#tablebody').fadeIn();
		//$('#legend').fadeOut();
		//$('#caltitle').fadeIn();
		//$('#next').fadeIn();
		//$('#legend').fadeIn();
				
	});
	
	$("#datepicker1").datepicker({showAnim:'fadeIn'});
	
	$("#datepicker2").datepicker({showAnim:'fadeIn'});
	
	$(".ui-icon-close").click(function() {
		$('#message').fadeOut();
	});
	
})

if (document.images) {
	pic1= new Image(); 
	pic1.src="images/features/delivery_over.jpg"; 
	
	pic2= new Image(); 
	pic2.src="images/features/email_over.jpg"; 
	
	pic3= new Image(); 
	pic3.src="images/features/facebook_over.jpg"; 
	
	pic4= new Image(); 
	pic4.src="images/features/floors_over.jpg"; 
	
	pic5= new Image(); 
	pic5.src="images/features/private_over.jpg"; 
	
	pic6= new Image(); 
	pic6.src="images/features/taps_over.jpg"; 
	
	pic7= new Image(); 
	pic7.src="images/features/tvs_over.jpg"; 
	
	pic8= new Image(); 
	pic8.src="images/features/wifi_over.jpg"; 
}

function popup() {
	window.open ("http://tours.vrnational.com/?vSiteId=100301178-14945",
"Tour","menubar=0,resizable=1,width=350,height=575"); 
}
