var _thumbnails = null;
var _currentIndex = null;

function ShowInGallery(imageUrl, title)
{
	var gallery = document.getElementById("gallery");

	if (gallery)
	{
		var galleryImage = document.getElementById("galleryImg");

		if (galleryImage)
		{
			galleryImage.src = imageUrl;
			galleryImage.alt = title;
			
			gallery.style.display="block";
			gallery.style.visibility="visible";
		}
	}

	return false;
}

function GalleryPic(imageUrl, title)
{
    this.src = imageUrl.replace("\/Thumbnails\/", "\/img\/");
    this.src = this.src.replace("\/s_large\/", "\/");
    this.title = title;
}

function ShowInGallery2(containerId, anchor)
{
	var gallery = document.getElementById("gallery");

	if (gallery)
	{
		var galleryImage = document.getElementById("galleryImg");

	    if (galleryImage)
	    {
	        var sourceImage = GetImageFromAnchor(anchor);
	        
	        if (sourceImage)
	        {	    
	            var pic = new GalleryPic(sourceImage.src, sourceImage.alt);
	            
		        galleryImage.src = pic.src;
		        galleryImage.alt = pic.title;

                if (_thumbnails == null)
                {	
		            LoadThumbnailInfo(containerId);
		        }
    		
		        ConfigureNextButton(pic.src);
    		
		        gallery.style.display="block";
		        gallery.style.visibility="visible";
		    }
	    }
    }

	return false;
}

function CloseGallery()
{
	var gallery = document.getElementById("gallery");	

	if (gallery)
	{
		gallery.style.display="none";
		gallery.style.visibility="hidden";
	}

	return false;
}

function GetImageFromAnchor(anchor)
{
    var images = anchor.getElementsByTagName("img");
    
    if (images != null && images.length > 0)
    {
        return images[0];
    }
    
    return null;
}

function LoadThumbnailInfo(containerId)
{
	var container = document.getElementById(containerId);

	if (container != null)
	{
		var candidates = container.getElementsByTagName("img");
		
		if (candidates != null)
		{
		    var ti = 0;
		
            for(ci=0; ci < candidates.length; ci++)
            {
                if (_thumbnails == null)
                {
                    _thumbnails = new Array();
                }  
                
                _thumbnails[ti] = new GalleryPic( candidates[ci].src, candidates[ci].alt );                
                                   
                ti++;   
            }
		}	
	}	
}

function ConfigureNextButton(imageUrl)
{       
    var nextButton = document.getElementById("galleryNext");
        
    if (nextButton)
    {
        if (_thumbnails != null && _thumbnails.length > 1)
        {        
            _currentIndex = 0;
        
            for(ti = 0; ti < _thumbnails.length; ti++)
            {            
                if (_thumbnails[ti].src.search(imageUrl) >= 0)
                {
                    _currentIndex = ti;
                    break;
                }
            }
            
            nextButton.style.visibility = "visible";
        }   
        else
        {
            nextButton.style.visibility = "hidden";
        }        
    }    
}

function ShowNext()
{
    if (_thumbnails != null && _thumbnails.length > 0)
    {
        if (_currentIndex == null)
        {
            _currentIndex = 0;
        }
    
        _currentIndex++;
        
        if (_currentIndex >= _thumbnails.length)
        {
            _currentIndex = 0;
        }
        
		var galleryImage = document.getElementById("galleryImg");

	    if (galleryImage)
	    {
		    galleryImage.src = _thumbnails[_currentIndex].src;
		    galleryImage.alt = _thumbnails[_currentIndex].title;
        }
    }
    
    return false;
}



function showTab (numb,tot) {



document.getElementById("tab_"+numb).className = "active";
document.getElementById("tabcnt_"+numb).className = "shown";

for(var b=1;b<tot+1;b++){ 

			if(b!=numb){
					document.getElementById("tab_"+b).className = "passive";
					document.getElementById("tabcnt_"+b).className = "behind";				

				}

			}


return false;


}
