function initTaf() {
	var objBody = document.getElementsByTagName("body").item(0);
		
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','tafOverlay');
	objOverlay.style.display = 'none';
	objOverlay.onclick = function() { closeTAF(1); closeTAF(); }
	objBody.appendChild(objOverlay);
}

function openTAF(panel){
	hideSelectBoxes();
	hideFlash();
	
	var arrayPageSize = getPageSize();
	Element.setWidth('tafOverlay', arrayPageSize[0]);
	Element.setHeight('tafOverlay', arrayPageSize[1]);
	new Effect.Appear('tafOverlay', { duration: overlayDuration, from: 0.0, to: 0.5 });
	
	if(panel == 1) {
		new Effect.Opacity('taf', {duration:0.0, from:0.0, to:0.0});
		$('taf').style.display = "block";
		
		var tafHeight = $('taf').offsetHeight;
		var tafWidth = $('taf').offsetWidth;
		
		$('taf').style.display = "none";
		
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 2) - (tafHeight / 2);
		var lightboxLeft = arrayPageScroll[0] + (arrayPageSize[0] / 2) - (tafWidth / 2);
		Element.setTop('taf', lightboxTop);
		Element.setLeft('taf', lightboxLeft);
		
		new Effect.Appear('taf', {duration:overlayDuration, from:0.0, to:1});
	}else{
		new Effect.Opacity('inclusive', {duration:0.0, from:0.0, to:0.0});
		$('inclusive').style.display = "block";
		
		var tafHeight = $('inclusive').offsetHeight;
		var tafWidth = $('inclusive').offsetWidth;
		
		$('inclusive').style.display = "none";
		
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 2) - (tafHeight / 2);
		var lightboxLeft = arrayPageScroll[0] + (arrayPageSize[0] / 2) - (tafWidth / 2);
		Element.setTop('inclusive', lightboxTop);
		Element.setLeft('inclusive', lightboxLeft);
		
		new Effect.Appear('inclusive', {duration:overlayDuration, from:0.0, to:1});
	}
}

function closeTAF(panel){
	new Effect.Fade('tafOverlay', { duration: overlayDuration});
	showSelectBoxes();
	showFlash();
	if(panel == 1) {
		new Effect.Fade('taf', { duration: overlayDuration});
	}else{
		new Effect.Fade('inclusive', { duration: overlayDuration});
	}
}

function toggleTAF(){
	if(document.getElementById('taf').style.display == "none"){
		openTAF(1);	
	}else{
		closeTAF(1);
	}
}

function toggleInclusive(){
	if(document.getElementById('inclusive').style.display == "none"){
		openTAF(2);	
	}else{
		closeTAF(2);
	}
}

//gallery window
function openGallery(gallery) {
	viewGallery = '';
	if(gallery) {
		viewGallery = '/'+gallery;
	}
	width = 1100;
	height = 700;
	
	if(screen.width < width) {
		width = screen.width;
	}
	
	if(screen.height < height) {
		height = screen.height;
	}
	
	params  = 'width='+width;
	params += ', height='+height;
	params += ', top=0, left=0';
	params += ', fullscreen=yes';
	window.open('/en/modules/gallery/black'+viewGallery, 'PhotoGallery', params);
}

Event.observe(window, 'load', initTaf, false);
