﻿var current_image=0;
function Show_thumbs(abc,max){
	for (x=0; x<max; x++){
		for (y=0; y<max; y++){
			document.getElementById('gallery_thumb-'+abc+'-'+x+'-'+y).style.display='none';
		}
	}
	i=0;
	for (x=(current_image-3); x<(current_image+4); x++){
		if (x<0)
			document.getElementById('gallery_thumb-'+abc+'-'+i+'-'+(max+x)).style.display='block';
		else if ((x+1)>max)
			document.getElementById('gallery_thumb-'+abc+'-'+i+'-'+(x-max)).style.display='block';
		else
			document.getElementById('gallery_thumb-'+abc+'-'+i+'-'+x).style.display='block';
		i++;
	}
}

function Go_left(abc,max){
	for (x=0; x<max; x++){
		if (document.getElementById('latest-image-'+abc+'-'+x).style.display=='block'){
			if (x==0){
				document.getElementById('latest-image-'+abc+'-'+(max-1)).style.display='block';
				//document.getElementById('latest-current').innerHTML=max;
			}
			else {
				document.getElementById('latest-image-'+abc+'-'+(x-1)).style.display='block';
				//document.getElementById('latest-current').innerHTML=x;
			}
			document.getElementById('latest-image-'+abc+'-'+x).style.display='none';
			current_image=x-1;
			if (max>7)
				Show_thumbs(abc,max);
			break
		}
	}
}

function Go_right(abc,max){	
	for (x=0; x<max; x++){
		if (document.getElementById('latest-image-'+abc+'-'+x).style.display=='block'){
			if (x==(max-1)){
				document.getElementById('latest-image-'+abc+'-0').style.display='block';
				document.getElementById('latest-image-'+abc+'-'+x).style.display='none';
			}
			else {
				document.getElementById('latest-image-'+abc+'-'+(x+1)).style.display='block';
				document.getElementById('latest-image-'+abc+'-'+x).style.display='none';
			}
			current_image=x+1;
			if (max>7)
				Show_thumbs(abc,max);						
			break
		}
	}
}
function Show_gallery (abc,max){
	for (x=0; x<max; x++)
		if (abc==x)
			$('#gallerytitle-'+x).css('fontWeight','bold');
		else
			$('#gallerytitle-'+x).css('fontWeight','normal');
	$("#galleryholder").html(Gallery[abc])	
}
function Load_Image (abc,a,max){
	for (x=0; x<max; x++){
		if (x==a){
			document.getElementById('latest-image-'+abc+'-'+x).style.display='block'
			current_image=a;			
		}
		else {
			document.getElementById('latest-image-'+abc+'-'+x).style.display='none';			
		}
	}
	if (max>7)
		Show_thumbs(abc,max);	
}
function Swap(obj){
	obj.src=obj.id;
}
function SwapBack(obj){
	obj.src=obj.alt;
}
