function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function clearHideNavMenu() {
  if (window.delay)
    clearTimeout(delay);
}

function delayHideNavMenu(sMenu) {
  delay = setTimeout("hideNavMenu('" + sMenu + "')", 500);
}

function hideNavMenu(sMenu) {
  if (sMenu)
    document.getElementById(sMenu).style.visibility = "hidden";
  else {
    document.getElementById('nav_3_1').style.visibility = "hidden";
  }
}

function showNavMenu(sMenu) {
  clearShowMenu();
  document.getElementById('nav_3_1').style.visibility = "hidden";
  clearHideNavMenu();
  document.getElementById(sMenu).style.visibility = "visible";
}

function clearShowMenu(){
	for(i=1;i<=5;i++){
		eval('sMenu = \'nav_3_'+i+'\'');
		if(document.getElementById(sMenu)){
			document.getElementById(sMenu).style.visibility = "hidden";
		}
	}
}

function printFunction(){
	URL = "print_friendly.php?page=" + document.location.toString().substring( document.location.toString().lastIndexOf("/")+1, document.location.toString().lastIndexOf(".") );
	window.open (URL, 'newwindow', 'height=600, width=750, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no')
}

function printFunction_special(){
	URL = "print_friendly_special.php?page=" + document.location.toString().substring( document.location.toString().lastIndexOf("/")+1, document.location.toString().lastIndexOf(".") );
	window.open (URL, 'newwindow', 'height=600, width=750, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no')
}

function setImageList(ImgNum){
	resetImgBorder();
	if(document.getElementById("list_1")){
		document.getElementById("list_1").border = 2;
	}else{
		document.list_1.border = 2;
	}

	Photo_Description.innerText = imageFile[ImgNum][1];
	document.showImg.src = imageFile[ImgNum][2];

	for(i=1;i<=5;i++){
		num = ImgNum+(i-1);
		if(imageFile.length > num){
			eval('document.list_'+i+'.src = imageFile['+num+'][2];');
		}else{
			eval('document.list_'+i+'.src = "../images/blank_photo.gif"');
			eval('document.list_'+i+'.width = 100');
		}
	}
	
	tmp = imageFile.length%5;
	PageNum = parseInt(imageFile.length/5);
	if(tmp!=0){
		PageNum++;
	}

	for(i=1;i<=PageNum;i++){
		if(document.getElementById('ImgList'+i)){
			changeClass('ImgList'+i, '');
		}
	}

	changeClass('ImgList'+(parseInt(ImgNum/5)+1), 'link_highlight');
}

function changeClass(Elem, myClass) {
	var elem;
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	elem.className = myClass;
}

function simg(obj,list,num){
	if( list.src.toString().substring(list.src.toString().lastIndexOf("/")+1, list.src.length) != 'blank_photo.gif' ){
		var ImageFile = list.src.toString().substring(list.src.toString().indexOf("images/"), list.src.length);
		
		for(i=1;i<=imageFile.length-1;i++){
			if(imageFile[i][2]=="../"+ImageFile){
				Photo_Description.innerText = imageFile[i][1];
				newImage = imageFile[i][2];
			}
		}
		
		resetImgBorder();
		if( document.getElementById("list_"+num) ){
			document.getElementById("list_"+num).border = 2;
		}else{
			eval("document.list_"+num+".border = 2;");
		}
	
		obj.src = newImage; 
	}
}

function checkCurrentImg(){
	var ImageFile = showImg.src.toString().substring(showImg.src.toString().indexOf("images/"), showImg.src.length);
	
	for(i=1;i<=imageFile.length-1;i++){
		if(imageFile[i][2]=="../"+ImageFile){
			return i;
		}
	}
}

function showNext(){
	var ImageNum = checkCurrentImg();
	if(imageFile.length-1 > ImageNum){
		if(ImageNum%5==0){
			setImageList(parseInt(ImageNum)+1);
		}else{
			resetImgBorder();
			Photo_Description.innerText = imageFile[ImageNum+1][1];
			document.showImg.src = imageFile[ImageNum+1][2];
			if( document.getElementById("list_"+(parseInt(ImageNum%5)+1)) ){
				document.getElementById("list_"+(parseInt(ImageNum%5)+1)).border = 2;
			}else{
				eval("document.list_"+(parseInt(ImageNum%5)+1)+".border = 2;");
			}
		}
	}
}

function showPrev(){
	var ImageNum = checkCurrentImg();
	if(ImageNum != 1){
		if((parseInt(ImageNum)-1)%5==0){
			setImageList(parseInt(ImageNum)-5);
		}else{
			resetImgBorder();
			if(ImageNum%5!=0){
				if( document.getElementById("list_"+(parseInt(ImageNum%5)-1)) ){
					document.getElementById("list_"+(parseInt(ImageNum%5)-1)).border = 2;
				}else{
					eval("document.list_"+(parseInt(ImageNum%5)-1)+".border = 2;");
				}
			}else{
				if( document.getElementById("list_4") ){
					document.getElementById("list_4").border = 2;
				}else{
					document.list_4.border = 2;
				}
			}
			Photo_Description.innerText = imageFile[ImageNum-1][1];
			document.showImg.src = imageFile[ImageNum-1][2];
		}
	}
}

function loadorder() {
	window.scrollTo(0,0);
}

function resetImgBorder(){
	for(i=1;i<=5;i++){
		if( document.getElementById("list_"+i) ){
			document.getElementById("list_"+i).border = 0;
		}else{
			eval("document.list_"+i+".border = 0;");
		}
	}
}

function changeLang(lang){
	Location = location.href.toString();
	Location = Location.replace('/en/', '/'+lang+'/');
	Location = Location.replace('/tc/', '/'+lang+'/');
	Location = Location.replace('/sc/', '/'+lang+'/');
	
	document.location = Location;
//	alert(Location);
}