function confirmation(whichMessage)
{
    if (whichMessage == 1)
    {
	    return confirm('Are you sure you want to delete this gallery? All associated images will also be deleted.');    
    }
    
    if (whichMessage == 2)
    {
	    return confirm('Are you sure you want to delete this exhibitor? All associated galleries and clients will also be deleted.');    
    }
    
    if (whichMessage == 3)
    {
	    return confirm('Are you sure you want to delete this client?');    
    }
    
    if (whichMessage == 4)
    {
	    return confirm('Are you sure you want to update this gallery?');    
    }
}

function changeImg(whichImg, whichExhibitor, whichGallery, whichThumb)
	    {                
	        
            document.getElementById('mainImgFrame').style.visibility = "hidden"; 
                    
	        strImg = MyImages[whichImg];
            whichImgIsCurrent = document.getElementById('mainImgFrame').className
	        
	        document.getElementById('mainImgFrame').src = "gallery/" + whichExhibitor + "/" + whichGallery + "/main/" + strImg;       
            
            strNewImgName = "gallery/" + whichExhibitor + "/" + whichGallery + "/main/" + strImg;
            
            document.getElementById('mainImgFrame').className = whichImg;  
            
            
            if (whichThumb == 1)
            {
                document.getElementById('thumb' + whichImgIsCurrent).className = "galleryThumb";
                document.getElementById('thumb' + whichImg).className = "galleryThumbSelected";          
            }    
            
            if (whichThumb == 2)
            {
                document.getElementById('thumbVA' + whichImgIsCurrent).className = "galleryThumb";
                document.getElementById('thumbVA' + whichImg).className = "galleryThumbSelected";        
            }
            
            document.getElementById('getNext').style.display = "none";  
            document.getElementById('getPrev').style.display = "none"; 
            //document.getElementById('mainImgFrame').style.visibility = "visible";                                  var mainImgWidth, mainImgHeight
            mainImgWidth = document.getElementById('mainImgFrame').offsetWidth
            mainImgHeight = document.getElementById('mainImgFrame').offsetHeight
            
            //diffA = (685 - mainImgWidth)
            
            //var middleOfImgWidth = (mainImgWidth/2) + diffA
            //var middleOfImgHeight = ((mainImgHeight/2) + 20)
            
            //document.getElementById('mainImgLoading').style.left = middleOfImgWidth + "px";
           // document.getElementById('mainImgLoading').style.top = middleOfImgHeight + "px";
            //document.getElementById('mainImgLoading').style.display = "block";
	    }
	    
	    function showImageOnLoad()
	    {
	        //alert('showImageOnLoad');
            document.getElementById('mainImgFrame').style.visibility = "visible";
            imageId = 'mainImgFrame';
            image = document.getElementById(imageId);
            setOpacity(image,0,1);
            image.style.visibility = 'visible';
            fadeIn(imageId,0,1);
	    }
	    
	    function changeMainImg(intTotalCount, nextOrPrev, whichExhibitor, whichGallery)
	    {            
	        whichIsLastImage = intTotalCount - 1;
	        
	        var whichImgIsCurrent        
            whichImgIsCurrent = document.getElementById('mainImgFrame').className;
	        //alert(whichImgIsCurrent);
	        
	        if (nextOrPrev == 1)
	        {
	            newImg = parseInt(whichImgIsCurrent) + parseInt(1)
	        }
	        
	        if (nextOrPrev == 2)
	        {
	            newImg = parseInt(whichImgIsCurrent) - parseInt(1)
	        }
	        
	        //alert(newImg);
	        changeImg(newImg, whichExhibitor, whichGallery); 
    	    
    	    document.getElementById('thumb' + whichImgIsCurrent).className = "galleryThumb";
            document.getElementById('thumb' + newImg).className = "galleryThumbSelected";
    	    document.getElementById('thumbVA' + whichImgIsCurrent).className = "galleryThumb";
            document.getElementById('thumbVA' + newImg).className = "galleryThumbSelected";
            
	    }
	    
	    function showPrevNext(intTotalCount)
	    {
	        whichIsLastImage = intTotalCount - 1;
	        
	        mainImgWidth = document.getElementById('mainImgFrame').offsetWidth;
    
    prevNextTop = 685 - mainImgWidth;
    document.getElementById('getPrev').style.left = prevNextTop + "px"; 
	        
	        var whichImgIsCurrent        
            whichImgIsCurrent = document.getElementById('mainImgFrame').className;
              
            imgNext = parseInt(whichImgIsCurrent) + parseInt(1)
            imgPrev = whichImgIsCurrent - 1            
            
            document.getElementById('getNext').style.display = "none";  
            document.getElementById('getPrev').style.display = "none"; 
            
            if (whichImgIsCurrent == 0)
            {
                //alert('show only next'); 
                document.getElementById('getNext').style.display = "block";  
            }            
            else if (whichImgIsCurrent == whichIsLastImage)
            {
                //alert('show only prev');
                document.getElementById('getPrev').style.display = "block"; 
            }            
            else
            {
                //alert('show next AND prev');       
                document.getElementById('getNext').style.display = "block";  
                document.getElementById('getPrev').style.display = "block"; 
            } 
	    }
	    
	    function hidePrevNext(intTotalCount)
	    {
	        whichIsLastImage = intTotalCount - 1;
	        
	        var whichImgIsCurrent        
            whichImgIsCurrent = document.getElementById('mainImgFrame').className;
              
            imgNext = parseInt(whichImgIsCurrent) + parseInt(1)
            imgPrev = whichImgIsCurrent - 1
            
            if (whichImgIsCurrent == 0)
            {
                //alert('show only next'); 
                document.getElementById('getNext').style.display = "none";  
            }            
            else if (whichImgIsCurrent == whichIsLastImage)
            {
                //alert('show only prev');
                document.getElementById('getPrev').style.display = "none"; 
            }            
            else
            {
                //alert('show next AND prev');       
                document.getElementById('getNext').style.display = "none";  
                document.getElementById('getPrev').style.display = "none"; 
            }
	    }

function onloadStuff()
{   
    imageId = 'mainImgFrame';
    image = document.getElementById(imageId);
    setOpacity(image,0,1);
    image.style.visibility = 'visible';
    fadeIn(imageId,0,1);  
}

function setOpacity(obj, opacity, fadeStarted) {

       // alert(fadeStarted);
    if (fadeStarted == 1)
    {
        //alert('startFade');
        opacity = 0;
        //clearTimeout(t);
    }
    else
    {
        opacity = (opacity == 100)?99.999:opacity;
    }
    
        //alert(opacity);
    // IE/Win
    obj.style.filter = "alpha(opacity:"+opacity+")";

    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity/100;

    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity/100;

    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity,fadeStarted) {
    //alert(fadeStarted);
    
    if (fadeStarted == 1)
    {
        //alert('startFade');
        opacity = 0;
        fadeStarted = 0;
        if (window.t != null)
        {
            //alert('no timeout');
            clearTimeout(t);
        }
    }
    
    if (opacity == 0)
    {
        var mainImgWidth, mainImgHeight
        mainImgWidth = document.getElementById('mainImgFrame').offsetWidth
        mainImgHeight = document.getElementById('mainImgFrame').offsetHeight
        
        diffA = (685 - mainImgWidth)
        
        var middleOfImgWidth = (mainImgWidth/2) + diffA
        var middleOfImgHeight = ((mainImgHeight/2))
        
        document.getElementById('mainImgLoading').style.left = middleOfImgWidth + "px";
        document.getElementById('mainImgLoading').style.top = middleOfImgHeight + "px";
        document.getElementById('mainImgLoading').style.display = "block";
    }

  if (document.getElementById) {
    obj = document.getElementById(objId);
        
    if (opacity <= 100) {
      setOpacity(obj, opacity, fadeStarted);
      opacity += 50;
      
      if (fadeStarted == 1)
      {
        opacity = 0;
      }
      
      t=window.setTimeout("fadeIn('"+objId+"',"+opacity+","+fadeStarted+")", 5);
    }
  }
}


function sliderArrowOver(whichSliderArrow)
{
    document.getElementById(whichSliderArrow).src = "images/" + whichSliderArrow + "Over.gif"
}

function sliderArrowOut(whichSliderArrow)
{
    document.getElementById(whichSliderArrow).src = "images/" + whichSliderArrow + ".gif"
}

function showNext()
{
    document.getElementById('galleryNext').style.display = "block";
}

function hideNext()
{
    document.getElementById('galleryNext').style.display = "none";

}

function viewAll()
{   
    
    var whichImgIsCurrent
    whichImgIsCurrent = document.getElementById('mainImgFrame').className
    document.getElementById('thumbVA0').className = "galleryThumb";
    document.getElementById('thumb' + whichImgIsCurrent).className = "galleryThumb";
    document.getElementById('thumbVA' + whichImgIsCurrent).className = "galleryThumbSelected";
        
    document.getElementById('controlsPrev').style.visibility = "hidden";
    document.getElementById('controlsNext').style.visibility = "hidden";
    
    document.getElementById('imageBox').style.display = "none";
    document.getElementById('viewAllBox').className = "viewAllBoxVisible";
    document.getElementById('controlsViewAll').innerHTML = "<a href='javascript:hideAll();'>HIDE ALL</a>";
}

function hideAll()
{  
    
    var whichImgIsCurrent
    whichImgIsCurrent = document.getElementById('mainImgFrame').className
    document.getElementById('thumbVA' + whichImgIsCurrent).className = "galleryThumb";
    document.getElementById('thumb' + whichImgIsCurrent).className = "galleryThumbSelected";
    
    whichImgIsCurrent = whichImgIsCurrent.replace("va","");
    
    document.getElementById('controlsPrev').style.visibility = "visible";
    document.getElementById('controlsNext').style.visibility = "visible";
       
       
    document.getElementById('imageBox').style.display = "block";
    document.getElementById('viewAllBox').className = "viewAllBoxHidden";
    document.getElementById('controlsViewAll').innerHTML = "<a href='javascript:viewAll();'>VIEW ALL</a>";
}

function submitForm(whichForm)
{
	document.getElementById(whichForm).submit();
}

function checkEnquiryForm()
{
    valid = true;

    if ( document.sendEnquiry.enquiryName.value == "" )
    {
        document.sendEnquiry.enquiryName.className = "inputMedError";
        valid = false;
    }
    else
    {
        document.sendEnquiry.enquiryName.className = "inputMed";
    }

    if ( document.sendEnquiry.enquiryEmail.value == "" )
    {
        document.sendEnquiry.enquiryEmail.className = "inputMedError";
        valid = false;
    }
    else
    {
        document.sendEnquiry.enquiryEmail.className = "inputMed";
    }

    if ( document.sendEnquiry.enquiryText.value == "" )
    {
        document.sendEnquiry.enquiryText.className = "inputTextError";
        valid = false;
    }
    else
    {
        document.sendEnquiry.enquiryText.className = "inputText";
    }
    
    if ( valid == false )
    {        
        alert ( "Please complete all fields in red." );
    }
    
    if ( valid == true )
    {        
        submitForm('sendEnquiry');
    }
}