function disappear(obj) {
	if (document.layers){
		d1=document.layers[obj];
		if (d1.visibility=="hide"){
			d1.visibility="show";
		}else{
			d1.visibility="hide";
		}
	}else{
		if (document.getElementById){
			d1=document.getElementById(obj);
		}else if (document.all){
			d1=document.all[obj];
		}else{
			return;
		}
		if (d1.style.display=="none"){
			d1.style.display="block";
		//updateArea(area,'COLLAPSE DATA');
		}else{
			d1.style.display="none";
		//updateArea(area,'EXPAND DATA');
		}
	}
}

function forwardPanel(){
	if(currentPanelID<maxPanels){
		for(c=1;c<=maxPanels;c++){
			if(c==currentPanelID && c<maxPanels){
				newPanelID = currentPanelID+1;
			}
		}
		disappear('collection'+currentPanelID+'panel');
		disappear('collection'+newPanelID+'panel');
		currentPanelID = newPanelID;
		document.getElementById('pagination').innerHTML = pageTxt + '&nbsp;' + currentPanelID + "&nbsp;/&nbsp;" + maxPanels;	
	}
}
function backPanel(){
	if(currentPanelID>1){
		for(c=1;c<=maxPanels;c++){
			if(c==currentPanelID && c>0){
				newPanelID = currentPanelID-1;
			}
		}
		disappear('collection'+currentPanelID+'panel');
		disappear('collection'+newPanelID+'panel');
		currentPanelID = newPanelID;
		document.getElementById('pagination').innerHTML = pageTxt + '&nbsp;' + currentPanelID + "&nbsp;/&nbsp;" + maxPanels;	
	}
}

function forwardImagePanel(){
	if(currentPanelID<maxPanels){
		for(c=1;c<=maxPanels;c++){
			if(c==currentPanelID && c<maxPanels){
				newPanelID = currentPanelID+1;
			}
		}
		disappear('collection'+currentPanelID+'panel');
		disappear('collection'+newPanelID+'panel');
		currentPanelID = newPanelID;
		document.getElementById('pagination').innerHTML = pageTxt + '&nbsp;' + currentPanelID + "&nbsp;/&nbsp;" + maxPanels;	
		processImages(currentPanelID);
	}
}
function backImagePanel(){
	if(currentPanelID>1){
		for(c=1;c<=maxPanels;c++){
			if(c==currentPanelID && c>0){
				newPanelID = currentPanelID-1;
			}
		}
		disappear('collection'+currentPanelID+'panel');
		disappear('collection'+newPanelID+'panel');
		currentPanelID = newPanelID;
		document.getElementById('pagination').innerHTML = pageTxt + '&nbsp;' + currentPanelID + "&nbsp;/&nbsp;" + maxPanels;	
		processImages(currentPanelID);
	}
}
function processImages(idnum){
	var panelImageArray = eval('image'+idnum+'array');
	for(c=0;c<panelImageArray.length;c++){
		var imageTarget = eval('document.panel'+idnum+'img'+c+'holder');
		//imageTarget.src = 'http://<?php echo IMAGE_SERVER;?>'+panelImageArray[c];
		//if(c==0){alert(panelImageArray[c]);}
		imageTarget.src = panelImageArray[c];
	}
}

// setup common definitions for show / hide
if (document.layers) {
	visible = 'show'; hidden = 'hide';
}else if (document.all) { 
	visible = 'visible'; hidden = 'hidden';
}else if (!document.all && document.getElementById){ 
	visible = 'visible'; hidden = 'hidden';
}


function nextPage(){
	if(currentPage != maxPages){
		page2show = 'thumbPageID' + (currentPage+1);
		page2hide = 'thumbPageID' + (currentPage);
		showLayer(page2show);
		hideLayer(page2hide);
		currentPage = (currentPage+1);
		if(language == "en"){
			pageTxt = "Page ";
		}
		if(language == "it"){
			pageTxt = "Pagina ";
		}
		if(language == "ru"){
			pageTxt = "Страница ";
		}
		document.getElementById('paginationDisplay').innerHTML = pageTxt + currentPage + "/" + maxPages;
	}
	if(currentPage == maxPages){
		hideLayer('paginationNext');
		showLayer('paginationPrevious');
	}else{
		showLayer('paginationNext');
	}
	if(currentPage != maxPages && currentPage != 1){
		showLayer('paginationNext');
		showLayer('paginationPrevious');
	}
}
function prevPage(){
	if(currentPage != 1){
		page2show = 'thumbPageID' + (currentPage-1);
		page2hide = 'thumbPageID' + (currentPage);
		showLayer(page2show);
		hideLayer(page2hide);
		currentPage = (currentPage-1);
		if(language == "en"){
			pageTxt = "Page ";
		}
		if(language == "it"){
			pageTxt = "Pagina ";
		}
		if(language == "ru"){
			pageTxt = "Страница ";
		}
		document.getElementById('paginationDisplay').innerHTML = pageTxt + currentPage + "/" + maxPages;
	}
	if(currentPage == 1){
		hideLayer('paginationPrevious');
		showLayer('paginationNext');
	}else{
		showLayer('paginationPrevious');
	}
	if(currentPage != maxPages && currentPage != 1){
		showLayer('paginationNext');
		showLayer('paginationPrevious');
	}
}
pageInfoArray = Array();
function nextPiecePage(section){
	//alert(pageInfoArray[section][0] + ', ' + pageInfoArray[section][1]);
	if(pageInfoArray[section][0] != pageInfoArray[section][1]){
		page2show = 'thumbPage' + section + 'ID' + (pageInfoArray[section][0]+1);
		page2hide = 'thumbPage' + section + 'ID' + (pageInfoArray[section][0]);
		showLayer(page2show);
		hideLayer(page2hide);
		pageInfoArray[section][0] = (pageInfoArray[section][0]+1);
		if(language == "en"){
			pageTxt = "Page ";
		}
		if(language == "it"){
			pageTxt = "Pagina ";
		}
		if(language == "ru"){
			pageTxt = "Страница ";
		}
		document.getElementById('pagination' + section + 'Display').innerHTML = pageTxt + pageInfoArray[section][0] + "/" + pageInfoArray[section][1];	
		if(pageInfoArray[section][0] == pageInfoArray[section][1]){
			hideLayer('pagination' + section + 'Next');
			showLayer('pagination' + section + 'Previous');
		}else{
			showLayer('pagination' + section + 'Next');
		}
		if(pageInfoArray[section][0] != pageInfoArray[section][1] && pageInfoArray[section][0] != 1){
			showLayer('pagination' + section + 'Next');
			showLayer('pagination' + section + 'Previous');
		}
	}
}
function prevPiecePage(section){
	if(pageInfoArray[section][0] != 1){
		page2show = 'thumbPage' + section + 'ID' + (pageInfoArray[section][0]-1);
		page2hide = 'thumbPage' + section + 'ID' + (pageInfoArray[section][0]);
		showLayer(page2show);
		hideLayer(page2hide);
		pageInfoArray[section][0] = (pageInfoArray[section][0]-1);
		if(language == "en"){
			pageTxt = "Page ";
		}
		if(language == "it"){
			pageTxt = "Pagina ";
		}
		if(language == "ru"){
			pageTxt = "Страница ";
		}
		document.getElementById('pagination' + section + 'Display').innerHTML = pageTxt + pageInfoArray[section][0] + "/" + pageInfoArray[section][1];	
		if(pageInfoArray[section][0] == 1){
			hideLayer('pagination' + section + 'Previous');
			showLayer('pagination' + section + 'Next');
		}else{
			showLayer('pagination' + section + 'Previous');
		}
		if(pageInfoArray[section][0] != pageInfoArray[section][1] && pageInfoArray[section][0] != 1){
			showLayer('pagination' + section + 'Next');
			showLayer('pagination' + section + 'Previous');
		}
	}
}


var lastMenu = "";
var timerID = "";
var dispTime = 5000;
function getDOM(menu){
          if (document.layers) { thisMenu = document.layers[menu];} 
          else if (document.all) { thisMenu = document.all(menu).style;}
          else if (!document.all && document.getElementById) { thisMenu = document.getElementById(menu).style;}
          return thisMenu;
}
function hideLayer(layer){
          getDOM(layer);
          thisMenu.visibility = hidden;
}
function showLayer(layer){
          getDOM(layer);
          thisMenu.visibility = visible;
}

function moveLayerLeft(layer,pos){
          getDOM(layer);
          thisMenu.left = pos;
}
function moveLayerTop(layer,pos){
          getDOM(layer);
          thisMenu.top = pos;
}
function showMenu(menu){
	if(lastMenu != "" && lastMenu != menu){
		showLayer(menu);
		hideLayer(lastMenu);
		lastMenu = menu;
		menuShowing = true;
		clearTimeout(timerID);
		timerID = setTimeout("outsideArea()",dispTime);
	}else if(lastMenu == menu){
		hideLayer(lastMenu);
		menuShowing = false;
		lastMenu = "";
		clearTimeout(timerID);
	}else{
		showLayer(menu);
		lastMenu = menu; 
		menuShowing = true;
		clearTimeout(timerID);
		timerID = setTimeout("outsideArea()",dispTime);
	}
}
function flipMenu(menu){
	if(menuShowing == true && lastMenu != menu){
		showMenu(menu);
	}
}
function outsideArea(){
	hideLayer(lastMenu);
	lastMenu = "";
	menuShowing = false;
}

function changeSubStyle(subitem,substyle){
	getDOM(subitem);
	if(substyle == 'over'){
		thisMenu.className=substyle;
	}
	if(substyle == 'out'){
		thisMenu.className=substyle;
	}
}



// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
function correctPNG(){
   for(var i=0; i<document.images.length; i++){
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	  }
   }
}
if(document.all){  // make sure IE only sees this, otherwise firefox thinks its a js error
	window.attachEvent("onload", correctPNG);
}
// EOF transparency code



//fixes winie css select text bug ... sometimes!
if (window.createPopup && document.compatMode && document.compatMode=="CSS1Compat")
{
  document.onreadystatechange = onresize = function fixIE6AbsPos()
  {
    if (!document.body) return;
    if (document.body.style.margin != "0px") document.body.style.margin = 0;
    onresize = null;
    document.body.style.height = 0;
    setTimeout(function(){ document.body.style.height = document.documentElement.scrollHeight+'px'; }, 1);
    setTimeout(function(){ onresize = fixIE6AbsPos; }, 100);
  }
}

