var activeNav = 0;
//Controls left nav sifr links on the Building Restoration Projects page
function showProjects(lang,typeId,txtMoreInfo,numb) {
	$('#projectsList .info').css('background','#ffffff').fadeOut(400);
	
	$('#projectsList').pause(400).hide(200, function(){
		$.get('../pages/functions/getadditionalprojects.php', {'lang':lang,'type':typeId,'txtMoreInfo':txtMoreInfo}, function(data){
		
		sIFR.callbacks['#sifrNav .leftLink'][activeNav].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#545454','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
		});
		sIFR.callbacks['#sifrNav .leftLink'][numb].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#000000','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
		});
		activeNav = numb;
		
		$('#projectsList').html(data).animate({opacity: 'show'},"fast",function(){

			$('#projectsList .info:hidden').css('background','#ffffff').fadeIn(300,function(){});
			$("#contentBucket3 .info .title a").bind("click",function(event){
					$('#contentBucket3 .info .details:visible').slideUp(380, function() {
					$("#contentBucket3 .info .title a").css({ color:"#898989" });
				});
				$(this).parent().parent().children('.details:hidden').slideDown(420, function(){
					$(this).parent().children().children().css({ color:"#000" });
				});
			});
		});
	  });
	});
}

var instId;
//Used on Grants page, displays description info about institution
function getInstitutionInfo(id,lang,appNow) {
	$('.readyToHide').css('background','#ffffff');
	$(".descr:hidden",".contentBucket2").remove();
	
	if(instId == id){
		$('.readyToHide').fadeOut(300, function(){
			$('.homeCopy').fadeIn(400,function(){
				$('.homeCopy').addClass('readyToHide');
			});
		});
		instId = "";
	} else {
		$.get('../pages/functions/getinstitutiondescription.php', {'lang':lang,'id':id,'appNow':appNow}, function(data){
			//
			$('.readyToHide').css('background','#ffffff').fadeOut(300, function(){
				$('.readyToHide').removeClass('readyToHide');
				//$('.killMe').remove();
				$('.contentBucket2').append(data).css('background','#ffffff').fadeIn(400,function(){
					
					$('.descr').addClass('readyToHide');
			});
			});
		});
		instId = id;
	}
}

//used on special project page
function getSpecialProjectInfo(id,lang) { 
	$(".descr:hidden",".contentBucket2").remove();
	if(instId == id){
		$("#contentBucket3 .info .title a").unbind();
		$("#contentBucket3 .info .title a").click(function(event){
			$('#contentBucket3 .info .details:visible').slideUp(380, function() {
				$("#contentBucket3 .info .title a").css({ color:"#898989" });
			});
			//$(this).css({ color:"#000" });
			$(this).parent().parent().children('.details:hidden').slideDown(420, function(){
				$(this).parent().children().children().css({ color:"#000" });
			});
		});
		$('.readyToHide').css('background','#ffffff').fadeOut(300, function(){
			$('.backMoreInfo').fadeOut(100,function() {
				$('.justMoreInfo').fadeIn(10);
			});
			$('.homeCopy').fadeIn(400,function(){
				$('.homeCopy').addClass('readyToHide');
			});
		});
		instId = "";
	} else {
		//set it up to close
		$("#contentBucket3 .info .title a").bind("click", function(){
			getSpecialProjectInfo(id,lang);
		});
		$.get('../pages/functions/getspecialprojectdescription.php', {'lang':lang,'id':id}, function(data){
			$('.justMoreInfo').fadeOut(100,function() {
				$('.backMoreInfo').fadeIn(10);
			});
			$('.readyToHide').css('background','#ffffff').fadeOut(300, function(){
				$('.readyToHide').removeClass('readyToHide');
				//$('.killMe').remove();
				$('.contentBucket2').append(data).css('background','#ffffff').fadeIn(400,function(){
					
					$('.descr').addClass('readyToHide');
			});
			});
		});
		instId = id;
	}
}

//Controls left nav sifr links on the Building Restoration Projects page
function getExhibitionsByYear(lang,year,numb) {
	
	$('#exhibitionsList .info').css('background','#ffffff').fadeOut(400);
	$('#exhibitionsList').pause(400).hide(200, function(){
		
		$.get('../pages/functions/getpastexhibitions.php', {'lang':lang,'year':year}, function(data){
		sIFR.callbacks['#sifrNav .leftLink'][activeNav].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#545454','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
		});
		sIFR.callbacks['#sifrNav .leftLink'][numb].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#000000','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
		});
		activeNav = numb;
		
		$('#exhibitionsList').html(data).animate({opacity: 'show'},"fast",function(){
			$('#exhibitionsList .info:hidden').css('background','#ffffff').fadeIn(300,function(){
				
			});
			$("#contentBucket3 .info .title a").bind("click",function(event){
					$('#contentBucket3 .info .details:visible').slideUp(380, function() {
					$("#contentBucket3 .info .title a").css({ color:"#898989" });
				});
				$(this).parent().parent().children('.details:hidden').slideDown(420, function(){
					$(this).parent().children().children().css({ color:"#000" });
				});
			});
		});
	  });
	});
}

//Controls left nav sifr links on the Building Restoration Projects page
function getSpecialProjectsByYear(lang,year,numb) {
	$('#exhibitionsList .info').css('background','#ffffff').fadeOut(400);
	
	$('#exhibitionsList').pause(400).hide(200, function(){
		$.get('../pages/functions/getspecialprojects.php', {'lang':lang,'year':year}, function(data){
		
		sIFR.callbacks['#sifrNav .leftLink'][activeNav].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#545454','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
		});
		sIFR.callbacks['#sifrNav .leftLink'][numb].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#000000','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
		});
		activeNav = numb;
		
		$('#exhibitionsList').html(data).animate({opacity: 'show'},"fast",function(){
			$('#exhibitionsList .info:hidden').css('background','#ffffff').fadeIn(300,function(){
				
			});
			$("#contentBucket3 .info .title a").bind("click",function(event){
					$('#contentBucket3 .info .details:visible').slideUp(380, function() {
					$("#contentBucket3 .info .title a").css({ color:"#898989" });
				});
				$(this).parent().parent().children('.details:hidden').slideDown(420, function(){
					$(this).parent().children().children().css({ color:"#000" });
				});
			});
		});
	  });
	});
}

var vidobj = true;
var imgobj = null;

function showVideoGallery() {
	
	if(imgobj) {
		$('#imgGalleryContainer').fadeOut(500, function() {
			$('#videoPlayerContainer').show();
			sIFR.callbacks['#sifrNav .leftLink'][1].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#545454','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
			});
			
			sIFR.callbacks['#sifrNav .leftLink'][0].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#000000','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
		});
		});
		
		
		imgobj = null;
		vidobj = true;
	}
	
}

function showPhotoGallery() {
	if(vidobj) {
		$('#videoPlayerContainer').animate({opacity:'hide'},"slow", function() {
			$('#imgGalleryContainer').animate({opacity:'show'},"slow");
			sIFR.callbacks['#sifrNav .leftLink'][0].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#545454','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
			});
			
			sIFR.callbacks['#sifrNav .leftLink'][1].changeCSS({
			'.sIFR-root': {'font-weight': 'bold'},
			'a': {'color': '#000000','text-decoration': 'none'},
			'a:hover': {'color': '#000000'}
		});
		});
		
		
		vidobj = null;
		imgobj = true;
	}
}
