//----------- values required for gallery box content
// images location Z:\_EM_WAD\_Projects\ENTAGROUP\WWW\Gallery
var gallery = new Array(8);
gallery[0] = new Array(2);
gallery[0]['text'] = "China and Angels was painted by Jia Ke in 1999. The painting comprises of 4 individual canvases which together depict four antiques being guarded by four flying angels, all upon a vivid blue background.";
gallery[0]['image'] = "_layout/0708_main/maincont_M/1_JiaKe.jpg";
gallery[1] = new Array(2);
gallery[1]['text'] = "Sakyamuni, meaning ‘Sage of the Sakyas’ is the Buddha of compassion. This piece was carved from Taiwanese Hinoki wood by Min Chun Tseng in 2004 and stands pride of place in the centre of the Tsai gallery.";
gallery[1]['image'] = "_layout/0708_main/maincont_M/2_Sakyamuni.jpg";
gallery[2] = new Array(2);
gallery[2]['text'] = "Sieur Tzen painted the faces of 150 fellow artists in 1996. Each artist’s face is a separate canvas and together they produce an impressive wall of famous faces including Andy Warhol, Jackson Pollock, Pablo Picasso and Georges Braque.";
gallery[2]['image'] = "_layout/0708_main/maincont_M/3_SieurTzen.jpg";
gallery[3] = new Array(2);
gallery[3]['text'] = "A piece of string which runs the length of three large canvases, linking them together, represents the linking together of objects through time and space in this painting by Jia Ke.";
gallery[3]['image'] = "_layout/0708_main/maincont_M/4_JiaKe.jpg";
gallery[4] = new Array(2);
gallery[4]['text'] = "An unusual piece, this series of three pictures depicts traditional Eastern subject matter whilst using a traditional western media. A pond containing Koi Carp, a symbol of luck and success is painted using oils on canvas by the artist Yong-chen Liu.";
gallery[4]['image'] = "_layout/0708_main/maincont_M/5_YCLiu.jpg";
gallery[5] = new Array(2);
gallery[5]['text'] = "A traditional depiction by Ming Nan Tseng of a lost industry. This painting shows the traditional Taiwanese salt farming industry which has now been eradicated by new technology and cheaper alternatives.";
gallery[5]['image'] = "_layout/0708_main/maincont_M/";
gallery[6] = new Array(2);
gallery[6]['text'] = "Produced in 1995 from Nantou clay, this piece depicts love, showing a strong, protective mother dog with her small puppies. The artist Tseng Ming Nan brought this and several other pieces to the Tsai gallery for a special exhibition at the opening ceremony of Enta’s pagoda offices in 1995.";
gallery[6]['image'] = "_layout/0708_main/maincont_M/";
gallery[7] = new Array(2);
gallery[7]['text'] = "This painting of the Enta pagoda was painted in 1996 by Yong-Fun Kao and was presented to Jason Tsai to exhibit at the opening ceremony of the pagoda.";
gallery[7]['image'] = "_layout/0708_main/maincont_M/";

gallery[8] = new Array(2);
gallery[8]['text'] = "";
gallery[8]['image'] = "2008/EGNO/EGNO-1.JPG";

//----------- function to get the scrolling on the page
function getPageScroll(){// Returns array with x,y page scroll values.
	var yScroll;
	if(self.pageYOffset){
		yScroll = self.pageYOffset;
	}else if(document.documentElement && document.documentElement.scrollTop){// Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	}else if(document.body){// all other Explorers
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll);
	return arrayPageScroll;
}
// function to get the dimensions of the page and screen
function getPageSize(){// get the page size, returns an array with width, height, window width and window height
	var xScroll, yScroll;
	if(window.innerHeight && window.scrollMaxY){	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}else if(document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}else{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if(self.innerHeight){	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight){ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}else if(document.body){// other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	}else{ 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	}else{
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}
//----------- function to display gallery box
// parameter 1 - the id for the image to display
function showGalleryBox(id){
	// prep objects
	var objOverlay = document.getElementById('Overlay');
	var objGalleryBox = document.getElementById('GalleryBox');
	var objImage = document.getElementById('GalleryBoxImage');
	var objText = document.getElementById('GalleryBoxText');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var posLeft = (arrayPageSize[0]/2) - 320;
	var posTop = arrayPageScroll[1] + 100;
	// position the error message box
	objGalleryBox.style.position = 'absolute';
	objGalleryBox.style.top = posTop+"px";
	objGalleryBox.style.left = posLeft+"px";
	// set the image class to display
	objImage.innerHTML = '<img src="'+gallery[id-1]['image']+'" width="580" border="0" />';
	// set the text to be displayed
	objText.innerHTML = gallery[id-1]['text'];
	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.width = (arrayPageSize[2] + 'px');
	objOverlay.style.display = 'block';
}
//---------- function to hide the overlay box
function hideBox(){
	// get objects
	var objOverlay = document.getElementById('Overlay');
	// hide error box and overlay
	objOverlay.style.display = 'none';
	// make select boxes visible
	selects = document.getElementsByTagName("select");
    for(i = 0; i != selects.length; i++){
		selects[i].style.visibility = "visible";
	}
}
//---------- fucntion to initialise gallery box html
function initGalleryBox(){
	var objBody = document.getElementsByTagName("body").item(0);
	// create ErrorBox div
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','Overlay');
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	// create gallery box div
	var objGalleryBox = document.createElement("div");
	objGalleryBox.setAttribute('id', 'GalleryBox');
	objOverlay.appendChild(objGalleryBox);// add div to overlay
	// create gallery box header div
	var objGalleryBoxHeader = document.createElement("div");
	objGalleryBoxHeader.setAttribute('id', 'GalleryBoxHeader');
	objGalleryBoxHeader.setAttribute('title', 'Tsai gallery');
	objGalleryBox.appendChild(objGalleryBoxHeader);// add div to gallery box
	// create close box div
	var objGalleryBoxClose = document.createElement("div");
	objGalleryBoxClose.setAttribute('id', 'GalleryBoxClose');
	objGalleryBoxClose.setAttribute('title', 'Close gallery image');
	objGalleryBoxClose.innerHTML = "&nbsp;";
	objGalleryBoxClose.onclick = function (){hideBox(); return false;}// add onlcick close fucntion	
	objGalleryBoxHeader.appendChild(objGalleryBoxClose);// add div to gallery header
	// create gallery image div
	var objGalleryImg = document.createElement("div");
	objGalleryImg.setAttribute('id', 'GalleryBoxImage');
	objGalleryBox.appendChild(objGalleryImg);// add div to gallery box
	// create gallery text div
	var objGalleryText = document.createElement("div");
	objGalleryText.setAttribute('id', 'GalleryBoxText');
	objGalleryBox.appendChild(objGalleryText);// add div to gallery box
}
//----------- function to display map box
function showMapBox(){
	// prep objects
	var objOverlay = document.getElementById('Overlay');
	var objMapBox = document.getElementById('MapBox');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var posLeft = (arrayPageSize[0]/2) - 320;
	var posTop = arrayPageScroll[1] + 50;
	// position the error message box
	objMapBox.style.position = 'absolute';
	objMapBox.style.top = posTop+"px";
	objMapBox.style.left = posLeft+"px";
	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.width = (arrayPageSize[2] + 'px');
	objOverlay.style.display = 'block';
}
//---------- fucntion to initialise map box html
function initMapBox(){
	var objBody = document.getElementsByTagName("body").item(0);
	// create ErrorBox div
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','Overlay');
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	// create gallery box div
	var objMapBox = document.createElement("div");
	objMapBox.setAttribute('id', 'MapBox');
	objOverlay.appendChild(objMapBox);// add div to overlay
	// create gallery box header div
	var objMapBoxHeader = document.createElement("div");
	objMapBoxHeader.setAttribute('id', 'MapBoxHeader');
	objMapBoxHeader.setAttribute('title', 'How to find Entagroup');
	objMapBox.appendChild(objMapBoxHeader);// add div to gallery box
	// create close box div
	var objMapBoxClose = document.createElement("div");
	objMapBoxClose.setAttribute('id', 'MapBoxClose');
	objMapBoxClose.setAttribute('title', 'Close Map');
	objMapBoxClose.innerHTML = "&nbsp;";
	objMapBoxClose.onclick = function (){hideBox(); return false;}// add onlcick close fucntion	
	objMapBoxHeader.appendChild(objMapBoxClose);// add div to gallery header
	// create gallery image div
	var objMapImg = document.createElement("div");
	objMapImg.setAttribute('id', 'MapBoxImage');
	objMapImg.innerHTML = "<img src='_layout/0708_main/maincont_M/map_580x550.jpg' width='580' height='550' border='0' />";
	objMapBox.appendChild(objMapImg);// add div to gallery box
}