/*
	NYLIne - Global JavaScript Functions
	Author: Michael "Spell" Spellacy, Senior UI Developer <contact@nyline.org>
	Company: NYLine, LLC
*/

/* ====== Global Navigation ====== */

// $("#nav").clone().appendTo("#wrapper").attr("id", "nav-clone").end();

// $("#nav-clone li a").removeAttr("href");

/* ====== Apple Safari, iPhone specific meta tags ====== */
	
$("title").after("<meta name=\"viewport\" content=\"width=694\"/>");

/* ====== Rotating background images ====== 

$("#nav li").each(function() {

	// Get number of list items (and add 1)
	
	var nodeselect = $(this).index() + 1;

	// set list id's
	
	$(this).attr("id", "nav-" + nodeselect);

	// Set mouseover (and keyup) and add class to wrapper based on id
	
	$(this).mouseover(function() {

		$("#wrapper").removeClass();
		$("#wrapper").addClass("hover-" + nodeselect);

	});
	
	$(this).keyup(function() {

		$("#wrapper").removeClass();
		$("#wrapper").addClass("hover-" + nodeselect);

	});

	// Set mouseout and remove class to wrapper based on id
	
	$("#article").mouseout(function() {

		$("#wrapper").removeClass();

	});

}); */

/* ====== Unobtrusive JavaScript ====== */

$(".js").remove();

/* ====== Sitewide Accordions ====== */

// First Child Disabled: Contact Us, Video Pages

if ( $("#contact-us").length || $("#nyline-3-congratulations-to-the-nyline").length )

	$("#group-list").accordion({ autoHeight: false, active: false});

// First Child Shown: FAQ, Press Coverage, Video and Gallery

if ( $("#faq").length || $("#press-coverage").length || $("#video-index").length || $("#gallery-index").length)

	$("#group-list").accordion({ autoHeight: false});	

/* ====== Remove Link Lists on FAQ and Press Coverage ====== */

if ( $("#faq").length || $("#press-coverage").length)

	$("ol").remove();

/* ====== Lightbox ====== */

// All Gallery Pages

if ( !$("#gallery-index").length && $(".gallery").length)

	$("#article a[href^=_source]").lightBox();

/* ====== Facebook Connect ======*/

if ( $("#fb-root").length)

	$("#fb-root").prepend('<h2 id="share-memories"><a href="mailto:contact@nyline.org">Share Your Memories</a></h2>');
	$("#fb-root").append('<fb:comments width="478" reverse="true"> </fb:comments>');

	window.fbAsyncInit = function() {

		// NYLine

		FB.init({appId: "375542421281", xfbml: true});

	};

	(

		function() {

			var e = document.createElement("script"); 
			e.async = true;
  			e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js";
  			document.getElementById("fb-root").appendChild(e);
		}()

	);
