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

/* ====== 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();

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

// Write to all pages

$("body").prepend("<div id=\"fb-root\"></div>"); // Add necessary div for FB to sniff for

var likeButton = "<fb:like id=\"like-button-content\" send=\"true\" show_faces=\"false\" width=\"365\"></fb:like>";
var commentsBox = "<fb:comments width=\"450\" migrated=\"1\"></fb:comments>";
var plusOne = "<g:plusone id=\"g-plusone\" size=\"small\"></g:plusone>";

if($("body.fb-comment").length) {

	$("#article").append("<h2>Share Your Memories</h2>" + likeButton + plusOne + commentsBox);

} else {

	$("#article").append(likeButton + plusOne);

}

window.fbAsyncInit = function() {

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

};
(function() {

	// Facebook API
		
	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);
		
	// Google PlusOne

	var f = document.createElement("script"); 
	f.async = true;
	f.src = document.location.protocol + "//apis.google.com/js/plusone.js";
	document.getElementsByTagName("head")[0].appendChild(f);

}());

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

// All Gallery Pages

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

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

// All Article Pages

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

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

