var galleryArray = [
	['../images/youth.ch1.main', ''],
	['../images/youth.ch1.text', ''],
	['../images/youth.ch2.main', ''],
	['../images/youth.ch2.text', ''],
	['../images/youth.ch3.main', ''],
	['../images/youth.ch3.text', ''],
	['../images/youth.ch4.main', ''],
	['../images/youth.ch4.text', ''],
	['../images/youth.ch5.main', ''],
	['../images/youth.ch5.text', ''],
	['../images/youth.ch6.main', ''],
	['../images/youth.ch7.main', ''],
	['../images/youth.ch7.text', '']
];

var galleryIdx = 0;
var numLinksShown = 5;
 
function GalleryView()
{
		$("#new").attr("src", galleryArray[galleryIdx][0] + ".gallery.jpg");
		var fade = $("div.fade div");
		if (fade.is(":animated"))
			fade.stop().fadeTo(250, 1);
		else
			fade.fadeIn(250, PutInFront);
			
		$('a[rel=galleryViewerLink]').attr("title", galleryArray[galleryIdx][1]).attr("href", galleryArray[galleryIdx][0] + ".big.jpg");
		
		$('a.numLink').css("background", "none").css("color", "#f89831");
		$($('a.numLink')[galleryIdx]).css("background", "#f89831").css("color", "#fff");
}

function PutInFront()
{
	$("#current").attr("src", $("#new").attr("src"));
	$("div.fade div").fadeOut("fast");
}

function NextPhoto()
{
	if (galleryIdx < galleryArray.length - 1)
	{
		galleryIdx++;
		GalleryView();
		if ($($("a.numLink")[galleryIdx]).css("display") == "none")
		{
			$($("a.numLink")[galleryIdx]).css("display", "block");
			if (galleryIdx >= numLinksShown && $($("a.numLink")[galleryIdx-numLinksShown]).css("display") == "block")
				$($("a.numLink")[galleryIdx-numLinksShown]).css("display", "none");
		}
	}
}
function PrevPhoto()
{
	if (galleryIdx > 0)
	{
		galleryIdx--;
		GalleryView();
		if ($($("a.numLink")[galleryIdx]).css("display") == "none")
		{
			$($("a.numLink")[galleryIdx]).css("display", "block");
			if (galleryIdx <= galleryArray.length - numLinksShown && $($("a.numLink")[galleryIdx+numLinksShown]).css("display") == "block")
				$($("a.numLink")[galleryIdx+numLinksShown]).css("display", "none");
		}
	}
}
function ViewPhoto(picIdx)
{
	if (picIdx >= 0 && picIdx < galleryArray.length)
	{
		galleryIdx = picIdx;
		GalleryView();
	}
}

function HideArticle()
{
	if (document.getElementById)
	{
		document.getElementById('theRest').style.display = 'none';
		document.getElementById('readLink').style.display = 'block';
		document.getElementById('topLink').style.display = 'none';
	}
}
function ContinueReading()
{
	if (document.getElementById)
	{
		document.getElementById('theRest').style.display = 'block';
		document.getElementById('readLink').style.display = 'none';
		document.getElementById('topLink').style.display = 'block';
	}
	return false;					
}
$(document).ready(function() {

	$('a[rel=gallery]').lightBox({

		imageLoading: '../images/lightbox-ico-loading.gif',
		imageBtnClose: '../images/lightbox-btn-close.gif',
		imageBtnPrev: '../images/lightbox-btn-prev.gif',
		imageBtnNext: '../images/lightbox-btn-next.gif',
		containerResizeSpeed: 350,
		txtImage: 'Image',
		txtOf: '/'
	});
	$('a[rel=galleryViewerLink]').lightBox({

		imageLoading: '../images/lightbox-ico-loading.gif',
		imageBtnClose: '../images/lightbox-btn-close.gif',
		imageBtnPrev: '../images/lightbox-btn-prev.gif',
		imageBtnNext: '../images/lightbox-btn-next.gif',
		containerResizeSpeed: 350,
		txtImage: 'Image',
		txtOf: '/'
	});
	  
	$("a.numLink").click(function() {
		var i = $("a.numLink").index(this);
		$($("a.numLink")[i]).attr("href", galleryArray[i][0] + ".big.jpg");
		ViewPhoto(i);
		return false;
	});
	$($('a.numLink')[0]).css("background", "#f89831").css("color", "#fff");
	
	if ($.browser.safari)
		$("ul.pag").css("width", 210);
});

