$(document).bind('keydown', 'ctrl+c', 
		function(e) {
		checkEnter(e);
//		showBlurbs();
		}
		);



function checkEnter(e){ //e is event object passed from function invocation
var characterCode; // literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e;
characterCode = e.which; //character code is contained in NN4's which property
}
else{
e = event;
characterCode = e.keyCode; //character code is contained in IE's keyCode property
}

if(characterCode == 66){ //if generated character code is equal to ascii 13 (if enter key)

showBlurbs();

return false;
}
else{
return true;
}

}


//set up the boxes and positions...
		
		  var box1 =	$("<img />").attr({id: "box1"});
		  var box2 =	$("<img />").attr({id: "box2"});
		  var box3 =	$("<img />").attr({id: "box3"});
		  var box4 =	$("<img />").attr({id: "box4"});
		  var box5 =	$("<img />").attr({id: "box5"});
		  var box6 =	$("<img />").attr({id: "box6"});



function amenities() {
		
		$('#amenitiesPopUp').css("opacity","0");
		
		$('#live').css({position: "absolute", top: "200px", left: "40px", zIndex: "2000", opacity: "0"});
		$('#play').css({position: "absolute", top: "200px", left: "295px", zIndex: "2000", opacity: "0"});
		$('#relax').css({position: "absolute", top: "200px", left: "560px", zIndex: "2000", opacity: "0"});		

		// Have the words fade in in sequence

		$('#live').animate({opacity: "1"},  1800, function() {
		$('#play').animate({opacity: "1"},  1800, function() {
		$('#relax').animate({opacity: "1"}, 1800, function() {
		$('#live').animate({top: "-15px"}, 		 800, function() {
		$('#play').animate({top: "-15px"}, 		 800, function() {
		$('#relax').animate({top: "-15px"}, 	 800, function() {
		  return false;
		});						
		});		
		});
		});			
		});		
		});

		
		
		$('#textBody').hide().fadeIn(3100);
		
		$("#live").
			mouseover(function() {
				$(this).css("background-image","url(logos/LIVE_ON.gif)");
				$('#amenitiesPopUp').animate({opacity: "0"},"fast").animate({top:"600"},"fast");
				$('#textBody img').animate({opacity: "0"},"fast");
				goLive();
		}).mouseout(function() {
			$(this).css("background-image","url(logos/LIVE.gif)");
		});		

		
		$("#play").
		mouseover(function() {
			$(this).css("background-image","url(logos/PLAY_ON.gif)");
			$('#amenitiesPopUp').animate({opacity: "0"},"fast").animate({top:"600"},"fast");
			$('#textBody img').animate({opacity: "0"},"fast");			
			goPlay();
		}).mouseout(function() {
			$(this).css("background-image","url(logos/PLAY.gif)");
		});		

		
		$("#relax").
		mouseover(function() {
			$(this).css("background-image","url(logos/RELAX_ON.gif)");
			$('#amenitiesPopUp').animate({opacity: "0"},"fast").animate({top:"600"},"fast");
			$('#textBody img').animate({opacity: "0"},"fast");
			goRelax();
		}).
		mouseout(function() {
			$(this).css("background-image","url(logos/RELAX.gif)");
		});		
		
		$("#closeButton").
			mouseover(function() {
				$(this).css({"backgroundImage": "url(images/live/closeButtonHover.png)"})
				}).
			mouseout(function() {
				$(this).css({"backgroundImage": "url(images/live/closeButton.png)"})
				}).
			click(function(){
				$("#amenitiesPopUp").animate({opacity:"0", top: "200"},"slow").animate({top:"600"},"fast");			
				});
	}
	
function goLive() {
		
		$('#textBody').children().hide('slow').remove();
		$('#textBody').append(box1,box2,box3,box4,box5,box6);
	  
	  		box1	  		
	  		.css({opacity: "0"})
	  		.attr({src: "images/live/shopping.jpg", alt: "Shopping"})
	  		.data("title","Food Shopping")
		  	.data("body",
		  			"Within one block of the Markle Evangeline Residence " +
		  			"there is a modest-sized specialty foods grocery store " +
		  			"on the northwest corner of 14th Street and 7th Avenue. " +
		  			"Further afield, walking east on 14th Street to Union " +
		  			"Square, just after crossing University Place, you will " +
		  			"find Whole Foods Market, a large supermarket which " +
		  			"features many organic food choices."
		  	);

	  		box2
	  		.css({opacity: "0"})
	  		.attr({src: "images/live/busTrain.jpg", alt: "Trains and Buses"})
		  	.data("title","Trains & Buses")
		  	.data("body",
		  	"Whether you work or go to school, you will likely commute " +
		  	"via public train or bus, if not both. The Markle Evangeline " +
		  	"Residence is located within one block of the 2, 3, F, V, L and " +
		  	"PATH trains. Most other major train lines are within a ten minute" +
		  	" walk and several city bus lines run across 14th Street or up 6th" +
		  	" and 7th Avenues. Consult the MTA " +
		  	"<a target='_top' src='http://www.mta.info/nyct/maps/subwaymap.pdf'>" +
		  	"subway</a> or the MTA <a target='_top' " +
		  	"src='http://www.mta.info/nyct/maps/index.html> maps page</a> " +
		  	"for bus maps."
		  	);
		  
	  		
	  		box3
	  		.css({opacity: "0"})
	  		.attr({src: "images/live/live_05.jpg", alt: "Dining / Cafeteria"})
	  		.data("title","Dining / Cafeteria")
		  	.data("body",
		  	"The Markle Evangeline Residence has an on-site dining room with cafeteria-style service. " +
		  	"The dining room is located on the lower level of the building and is accessible via elevator. " +
		  	"Room and Board is the only plan available at Markle Evangeline Residence. Two meals per day " +
		  	"are included for each resident."		
		  	);

	  		box4
	  		.css({opacity: "0"})
	  		.attr({src: "images/live/live_03.jpg", alt: "Free Wireless / Wi-Fi"})
		  	.data("title","Free Wireless / Wi-Fi")
		  	.data("body",
		  	"The Markle Evangeline Residence features free wireless service through out the building. Use the Wi-Fi in your room, the lobby, or in several lounges. For students and working women alike, the lounges provide an alternative to your room for studying and socializing."
		  	);

		    box5.attr({src: "images/live/laundry.jpg", alt: "Laundry"})
	  		.css({opacity: "0"})
		    .data("title","Laundry")
		  	.data("body",
		  	"A clean, spacious laundry room is available for the convenience of all residents. No hauling clothes outside to the laundromat as so many New Yorkers do, just purchase a laundry card, then grab soap and bag of clothes, and hop on the elevator."		
		  	);

		    box6.attr({src: "images/live/frontDesk.jpg", alt: "Front Desk"})
   	  		.css({opacity: "0"})
		  	.data("title","Front Desk Services")
		  	.data("body","Our friendly and accommodating front desk staff forms the 'heart-beat' of " +
		  			"the Residence and is available 24 hours a day to help residents with questions or " +
		  			"needs ranging from local restaurants and subway directions to room repairs or " +
		  			"personal emergencies.");
		  
		  //run the picture box animation
		  showBoxes();
		  //add the pop-up box functionality
		  affixPopup();

		  return false;
	}

	function goPlay() {
		
		$('#textBody').children().hide('slow').remove();
		$('#textBody').append(box1,box2,box3,box4,box5,box6);

		  box1.attr({src: "images/live/play_01.jpg", alt: "Union Square"})
		  .data("title", "Union Square")
		  .data("body", 
		  "The Union Square area located at 14th Street and Broadway is a great place to shop, sight-see and people watch. Union Square Park is well maintained and draws people from all walks of life, with street vendors selling artwork, and a Farmer's Market on most days. Performers and musicians often entertain crowds on the south side of the park."
		  );
		  
		  box2.attr({src: "images/live/play_02.jpg", alt: "The Meat Packing District"})
		  .data("title", "The Meat Packing District")
		  .data("body", "" +
		  		"If you walk West on 14th Street you will arrive at the Meat Packing District. As the name implies, this area was formerly used strictly for warehousing meat and other produce. Although the Meat Packing District retains some of the grit of an earlier time, the area has become trendy in the past several years with an active nightlife and fine dining. If you plan to socialize, the Meat Packing District is the place to head when the sun sets.");
		  
		  box3.attr({src: "images/live/play_03.jpg", alt: "Chelsea"})
		  .data("title", "Chelsea")
		  .data("body", 
		  "The area in Manhattan called Chelsea is a fun and vibrant neighborhood known for being popular with artists, many of whom stayed or lived at the famous Chelsea Hotel in the 50s, 60s and 70s. The area contains many very interesting art galleries which may provide for many an illuminating cultural experience. As Chelsea starts to the south at 14th Street to the west of Sixth Avenue, continuing up to 23rd Street, all of these galleries are but an easy stroll away."
		  );

		  box4.attr({src: "images/live/play_04.jpg", alt: "West Village/Washington Sq."})
		  .data("title", "The West Village/Washington Square")
		  .data("body", 
				  "World famous for having been the mecca of the beat generation of the 50s and the folk-rock scene of the 60s, the West Village is the area most people think of when they use the term 'Greenwich Village', or simply 'The Village'. This area, steeped in history, is the epitome of downtown Manhattan. Many of the famous folk cafes still exist on Bleecker and on West 4th  Streets. From the Markle Evangeline Residence, a 15-minute stroll straight down 6th Avenue will take you to Washington Square Park, the iconic epicenter of the Village. Find the famous Cafe Wha? where Dylan and Hendrix once played before fame found them, and listen to some live music. Grab a tasty and inexpensive falafel sandwich from Mamouns on MacDougal and West 3rd Street and you will realize that the bohemian spirit of that bygone era lives on."
		  );

		  
		  box5.attr({src: "images/live/play_05.jpg", alt: "The East Village"})
		  .data("title", "The East Village")
		  .data("body", 
		"Despite its rough reputation, the East Village is fast becoming a more 'respectable' place with trendy cafes, restaurants and clubs to rival it's counterpart to the West, much to the chagrin of the old, and new, punk crowd who once seemingly had the place to themselves. Although CBGBs is now tragically gone and most of the old flop-houses on the Bowery have been shut down, if you continue East to Alphabet City you may still find the hard-edge of the neighborhood which gave rise to the Ramones, Lou Reed, Blondie and countless other acts which shaped popular and independent music through the 70s and 80s. Not quite as far to the East is Second Avenue which is just jammed with restaurants of an unimaginable variety. Try the area around Sixth Street for an inexpensive Indian meal.<br/> <br/> If these places seem a bit far from the Markle Evangeline Residence you don't have to go all that way to experience the East Village mystique. Six blocks south of the Markle Evangeline Residence, you will find St. Marks Place (this is 8th Street to the east of 3rd Avenue) which has many fun record and clothing stores with plenty of attitude and some great inexpensive sidewalk eateries sprinkled in between."
		);

		  box6.attr({src: "images/live/play_06.jpg", alt: "The Flat Iron District"})
		  .data("title", "The Flat Iron District")
		  .data("body", 
		"The Flat Iron District is about a 15 minute walk north on 5th Avenue to 23rd Street, where Broadway intersects 5th Avenue and forms a sharp angle. At this intersection the famous and iconic Flat Iron building, one of the first skyscrapers, can be found. This area is where the famous Madison Avenue begins and there is also a small park there at Madison Square. This area is a mixed residential and business district with several historic buildings such as the Met Life building built in 1909, which was the tallest building in the world until 1913."
		);

		  var contents =  $("#textBody").children();
		  contents.css({opacity: "0"});
		  //run the picture box animation
		  showBoxes();
		  //add the pop-up box functionality
		  affixPopup();

		  return false;
	}
	
function goRelax() {
	$('#textBody').children().hide('fast').remove();
	$('#textBody').append(box1,box2,box3,box4,box5,box6);
  
  		box1.attr({src: "images/live/relax_02.jpg", alt: "bookstores"})
  		.data("title","Bookstores")
	  	.data("body",
	  	"If you want to browse for magazines and take some time to yourself, there are several " +
	  	"<a href='http://maps.google.com/maps?rls=com.microsoft:en-us&oe=UTF-8&um=1&ie=UTF-8&q=bookstores+manhattan&fb=1&gl=us&hq=bookstores&hnear=manhattan&view=text&ei=2RgYS-z6G9PIlAe43bnvAg&sa=X&oi=local_group&ct=more-results&resnum=1&ved=0CCIQtQMwAA'>bookstores" +
	  	"</a> in the vicinity of the Markle. Bookstores present an ideal place to relax, find some great reading material" +
	  	"whether it be the latest bestselling novel or non-fiction. The world famous <a href='http://www.strandbooks.com/'>Strand bookstore</a>, a major purveyor of" +
	  	"discount and used books is at Broadway "
	  	);

  		box2.attr({src: "images/live/relax_01.jpg", alt: "coffee shops"})
	  	.data("title","Coffee Shops/Cafes")
	  	.data("body",
	  	"There are plenty of coffees shops, cafes, and small eateries along six avenue, 14th Street and the " +
	  	"many blocks that are within walking distance of the Markle Residence. Several Starbucks are close " +
	  	"by as well as many independent establishments that serve coffee, tea, bagels, pastries etc. These " +
	  	"places are often excellent places to meet with friends, meet new friends, people watch, study or read " +
	  	"while enjoying the daily 'cup of joe'. Many places now provide wireless internet access as well. " +
	  	"We would tell you where to find these places, but that would ruin the adventure of making your own " +
	  	"discoveries, and besides, places change too frequently for us to keep up with on this site. So just " +
	  	"ask a fellow resident where their neighborhood spot is -everyone has their favorites - or take a " +
	  	"stroll, get to know the neighborhood, sample what's brewing, and find your own special hang-out.... " +
	  	"and soon you'll be known as the local authority on where to go when staying at the Markle."
	  	);
	  
  		
  		box3.attr({src: "images/live/roofDeck.jpg", alt: "roof deck"})
  		.data("title","The Roof Deck")
	  	.data("body",
	  	"The roof of the Markle features a very private and roomy deck where, in the summer time " +
	  	"residents can relax and enjoy the warm weather. High above the streets you can escape the " +
	  	"the busy flow and get a great view of the city and the sky any time of the year."
	  	);

  		box4.attr({src: "images/live/gym.jpg", alt: "Exercise Room"})
	  	.data("title","Exercise Room")
	  	.data("body",
	  	"Staying or getting in shape is not always easy to do in an urban environment. Relieve some " +
	  	"stress by taking advantage of the exercise machines on the 17th floor of the Markle Evangeline " +
	  	"Residence where you will find treadmills, step machines and plenty of floor space for stretching " +
	  	"and exercise. Great city views help pass the time, making your work-out that much more pleasant."
	  	);

	    box5.attr({src: "images/live/pianoLounge.jpg", alt: "TV Lounge"})
	    .data("title","TV Lounge")
	  	.data("body",
	  	"If you want to entertain yourself and your friends at the Markle Evangeline " +
	  	"Residence you can make use of the TV Lounge located on the 4th floor. Here you " +
	  	"will find comfortable couches and a large screen television for showing movies. " +
	  	"For those who are gifted in dance or musically inclined, right off the TV Lounge " +
	  	"there is a small mirrored practice room which holds an upright piano. There is " +
	  	"also another small study room if you want to study in private."
	  	);

	    box6.attr({src: "images/live/cinema.jpg", alt: "Local Cinemas"})
	  	.data("title","Local Cinemas")
	  	.data("body",
	  	"For relaxation and fun, nothing beats a good film. There are several good" +
	  	"cinemas within short walking distance: The Regal Union Square Stadium 14 at " +
	  	"13th and Broadway, Cinema Village at East 12th and University Place and the " +
	  	"IFC Center on 6th Avenue and West 3rd Street are conveniently located.");
	  
	  //run the picture box animation
	  showBoxes();
	  //add the pop-up box functionality
	  affixPopup();

	  return false;
	}

/*
 * showBoxes animates each of the six picture boxes on the page in sequence so that
 * when one box is done appearing the next one is set to small and at the center 
 * with zero opacity and then rises to it's position in the grid
*/



function showBoxes() {
	 

	//hide and show all the new boxes 
	
	  var contents =  $("#textBody").children();
	  
	  //make boxes invisible
	  
	  contents.css({opacity: "0"});	  
	  
	  //enable links
	  
//	  links.css({fontSize: "24px"});

  	  $('#textBody img').css({width: "24px", height: "18px", position: "absolute",
			top: "180px", left: "300px"}			);

	  $("#box1").animate({opacity: "1", top: "16", 
		  left: "20", height: "180", 
		  width: "240"}, "slow", "swing", function(){

	  $("#box2").animate({opacity: "1", top: "16", 
	      left: "280", height: "180", 
		  width: "240"}, "slow", "linear", function(){
	  
	  $("#box3").animate({opacity: "1", top: "16", 
	      left: "540", height: "180", 
		  width: "240"}, "slow", "linear", function(){
			  
	  $("#box4").animate({opacity: "1", top: "230", 
		  left: "20", height: "180", 
		  width: "240"}, "slow", "linear", function(){
			  
	  $("#box5").animate({opacity: "1", top: "230", 
	      left: "280", height: "180", 
		  width: "240"}, "slow", "linear", function(){

	  $("#box6").animate({opacity: "1", top: "230", 
	      left: "540", height: "180", 
		  width: "240"}, "slow", "linear", function(){

		  });
		  });
		  });
		  });
		  });
		  });
	  
//	  showBlurbs();

}

/*
 * affixPopup() binds the popup animation to the click event of all the picture boxes on the screen. 
 * upon click the titles and body text are put in place first then the text box will arise.
*/


function affixPopup() {
	
	  var contents =  $("#textBody").children();

	  contents.css({cursor:'pointer'}).click(function(){
		  $("#popUpTitle").text($(this).data("title"));
		  $("#popUpBody").html($(this).data("body"));
		  $("#amenitiesPopUp").animate({opacity:"1", top: "130"},"slow");
		  $("#popUpBody a")
		  	.css({textDecoration: "underline", color: "#4444CC"})
		  	.click(function(){
		  		var thisUrl = $(this).attr("href");
		  		window.open(thisUrl);
		  		return false;
		  	})
		  	.mouseover(
		  			function(){
		  			$(this).css({textDecoration: "none", cursor: "pointer"})	
		  			})
		  	.mouseout(
		  			function(){
			  			$(this).css({textDecoration: "underline"})		
		  			});
	  });
}

 
// showBlurbs shows all the text under the current category
 
function showBlurbs() {
	var blurb =  
		box1.data("title")+"\n\r"+box1.data("body")+"\n\r\n\r" +
		box2.data("title")+"\n\r"+box2.data("body")+"\n\r\n\r" +
		box3.data("title")+"\n\r"+box3.data("body")+"\n\r\n\r" +
		box4.data("title")+"\n\r"+box4.data("body")+"\n\r\n\r" +
		box5.data("title")+"\n\r"+box5.data("body")+"\n\r\n\r" +
		box6.data("title")+"\n\r"+box6.data("body")+"\n\r"

	alert(blurb);
}

