// This javascript controls the display and hiding of the left navigation

//Handle hiding or showing the current id
function ShowOrHideTable(sTheID,iStep) {
	
	if ( sTheID == "subcata" )
	{
		return;
	}

	if ( document.getElementById(sTheID).style.display == "" )  {
		document.getElementById(sTheID).style.display = "none";
	}
	else {
		HideAll("subcat");
		document.getElementById(sTheID).style.display = "";
	}
}

function HideAll(sPrefix) {

	var oTags = document.getElementsByTagName("*");
	var iPrefixLength = sPrefix.length;

	//Loop through the entire document looking at each tag
	for (var i = 0; i < oTags.length; i++) {
		//If the current tag supports having an ID, continue
		if ( oTags[i].id ) {
			//If the current tag has an ID, continue
			if ( oTags[i].id.length > iPrefixLength ) {
				//Check to see if the current ID is prefixed with what we are trying to hide
				if ( oTags[i].id.substring(0,iPrefixLength) == sPrefix ) {
					document.getElementById(oTags[i].id).style.display = "none";
				}
			}
		}
	}
}

function popUp( id )
{
	theWindow = window.open("", "_blank", "width=1000,height=700,scrollbars=yes,resizable=yes");
	theWindow.document.write("<img src=\"admin/pages/image.php?field=full_res&id=" + id + "\" alt=\"\" />");
	theWindow.document.write("<p><a href=\"javascript:window.close()\">Close Window</a></p>");
	theWindow.document.close( );
}

$('document').ready( function() {
	// Initalise the Facebook JavaScript SDK
	(function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) return;
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=100001182306034";
	  fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));

	// Initialise Google+1 SDK
	(function() {
	var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
	po.src = 'https://apis.google.com/js/plusone.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
	})();
});
