var curIndex=0;
var arr=new Array();
var imgTexts=new Array();


 function showImage()
 {     
        if(arr[curIndex].indexOf("<object")==-1)
        {       document.getElementById("popImage").innerHTML='<table width=764 height=714 border=0 cellpadding=10><tr><td valign=middle align=center width="100%" ><img src="'+arr[curIndex]+'" alt="'+imgTexts[curIndex]+'"  class="" /></td></tr><tr><td>'+imgTexts[curIndex]+'</td></tr></table>';
//                if(isIE){addRoundedIECorners(); }else {addRoundedCorners();}
        }
        else
        {
                document.getElementById("popImage").innerHTML=arr[curIndex];
        }       
        positionPicFrame();      
         $("#grey_transp").fadeIn(200);
		 $('#grey_transp').css("height",document.body.offsetHeight+"px");
 }
 
 function showNext()
 {
        if(curIndex<arr.length-1){curIndex++;}
        else{curIndex=0};
        showImage();
 }
 
 function initImage(imgArray, imgIndex, texts)
 {      arr=imgArray;
		imgTexts=texts;
        curIndex=imgIndex;
        showImage();
 }
 
 function showPrevious()
 {
        if(curIndex>0){curIndex--;}
        else{curIndex=arr.length-1};
        showImage();
 }
 
  $(document).ready(function(){
    $("div.gal_img").click(function () {

    });
        
        $("a.close_link").click(function () {
      $("#grey_transp").fadeOut(200);
    });

        $("a.gal_prev").click(function () {
    showPrevious()
    });
                
        $("a.gal_next").click(function () {
     showNext()
    });
  });
  
  function positionPicFrame() {
        picContainer = document.getElementById('popCont');
        windowSize = getWindowSize();
        scrollOffset = getScrollOffset();
        if (windowSize[1] > 720) {
                picContainerTopOffset = ((windowSize[1] - 650) / 2 )- 53;
        } else {
                picContainerTopOffset = 0;
        }
        picContainer.style.top = (scrollOffset[1]+picContainerTopOffset)+'px';
}

function getWindowSize() {
        var myWidth = 0, myHeight = 0;
        if( typeof( window.innerWidth ) == 'number' ) {
                //Non-IE
                myWidth = window.innerWidth;
                myHeight = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
                //IE 6+ in 'standards compliant mode'
                myWidth = document.documentElement.clientWidth;
                myHeight = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                //IE 4 compatible
                myWidth = document.body.clientWidth;
                myHeight = document.body.clientHeight;
        }
        return [ myWidth, myHeight ];
}

function getScrollOffset() {
        var scrOfX = 0, scrOfY = 0;
        if( typeof( window.pageYOffset ) == 'number' ) {
                //Netscape compliant
                scrOfY = window.pageYOffset;
                scrOfX = window.pageXOffset;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
                //DOM compliant
                scrOfY = document.body.scrollTop;
                scrOfX = document.body.scrollLeft;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
                //IE6 standards compliant mode
                scrOfY = document.documentElement.scrollTop;
                scrOfX = document.documentElement.scrollLeft;
        }
        return [scrOfX,scrOfY ];
}