﻿    var SelectedImageNum = 1;
    var TotalImages = 0;
    var SlideShow;
    var running = true;
    var fadebgcolor="transparent"
    var fadebgimage="assets/portfoliogradientbackground.jpg"
     
    ////NO need to edit beyond here/////////////
     
    var fadearray=new Array() //array to cache fadeshow instances
    var fadeclear=new Array() //array to cache corresponding clearinterval pointers
    var dom=(document.getElementById) //modern dom browsers
    var iebrowser=document.all
    function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder)
    {
        this.pausecheck=pause
        this.mouseovercheck=0
        this.delay=delay
        this.degree=10 //initial opacity degree (10%)
        this.curimageindex=0
        //this.nextimageindex=0
        fadearray[fadearray.length]=this
        this.slideshowid=fadearray.length-1
        this.canvasbase="canvas"+this.slideshowid
        this.curcanvas=this.canvasbase+"_0"
        
        if (typeof displayorder!="undefined")
        {
            theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
        }
           
        this.theimages=theimages
        this.imageborder=parseInt(borderwidth)
        this.postimages=new Array() //preload images
        
        for (p=0;p<theimages.length;p++)
        {
            this.postimages[p]=new Image()
            this.postimages[p].src=theimages[p][0]
        }
        this.nextimageindex = this.postimages.length;
        //alert(this.postimages.length);
        var fadewidth=fadewidth+this.imageborder*2
        var fadeheight=fadeheight+this.imageborder*2
     
        if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
        {
            document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div valign=\"middle\" id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;left:0;top:0;text-align:center;vertical-align:middle;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-image: url('+fadebgimage+');"></div><div id="'+this.canvasbase+'_1" valign=\"middle\" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;left:0;top:0;text-align:center;vertical-align:middle;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-image: url('+fadebgimage+');"></div></div>')
        }
        else
        {
            document.write('<div style="text-align:center;vertical-align:middle;"><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
        }
        if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
        {
            //alert('dom');
            this.startit()
        }
        else
        {
            this.curimageindex++
            setInterval("fadearray["+this.slideshowid+"].rotateimage('up', true, null)", this.delay)
            //alert('setInterval:' + this.delay + ' 65');
        }
    }
 
function fadepic(obj){
    if (obj.degree<100){
        obj.degree+=10
        if (obj.tempobj.filters&&obj.tempobj.filters[0])
        {
            if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
                obj.tempobj.filters[0].opacity=obj.degree
            else //else if IE5.5-
                obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
        }
        else if (obj.tempobj.style.MozOpacity)
            obj.tempobj.style.MozOpacity=obj.degree/101
        else if (obj.tempobj.style.opacity)
        {
            obj.tempobj.style.opacity=obj.degree/100
        }
        else if (obj.tempobj.style.KhtmlOpacity)
            obj.tempobj.style.KhtmlOpacity=obj.degree/100
    }
    else
    {
        //stop cycle
        clearInterval(fadeclear[obj.slideshowid])
    }
}
 
 
fadeshow.prototype.movenextslide=function(nextslide)
{
    if (this.pausecheck==1) //if pause onMouseover enabled, cache object
        var cacheobj=this
    if (this.mouseovercheck==1)
        setTimeout(function(){cacheobj.movenextslide(nextslide)}, 100)
    else if (iebrowser&&dom||dom)
    {
        this.resetit()
        var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
        crossobj.style.zIndex++

        //move nextimageindex to next slot
        this.nextimageindex=nextslide
        
        //load next canvasbase
        this.nextcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_0" : this.canvasbase+"_1"
        //losf tempobj
        this.tempobj=iebrowser? iebrowser[this.nextcanvas] : document.getElementById(this.nextcanvas)
        //add image to next canvas
        this.populateslide(this.tempobj, this.nextimageindex)
        //set rotateimage to run for next cycle
        
        fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
        this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
    }

}


//~~ rotateimage ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fadeshow.prototype.rotateimage=function()
    {

        //alert('pre rotateimage this.curimageindex= ' + this.curimageindex);
        if (this.pausecheck==1) //if pause onMouseover enabled, cache object
            var cacheobj=this
        if (this.mouseovercheck==1)
            setTimeout(function(){cacheobj.rotateimage()}, 100)
        else if (iebrowser&&dom||dom)
        {
            this.resetit()
            var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
            crossobj.style.zIndex++

            //move nextimageindex to next slot
            this.nextimageindex=(this.nextimageindex<this.postimages.length-1)? this.nextimageindex+1 : 0
            
            //load next canvasbase
            this.nextcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_0" : this.canvasbase+"_1"
            //losf tempobj
            this.tempobj=iebrowser? iebrowser[this.nextcanvas] : document.getElementById(this.nextcanvas)
            //add image to next canvas
            this.populateslide(this.tempobj, this.nextimageindex)
            //set rotateimage to run for next cycle

            var imagenum = this.nextimageindex + 1;
            //alert('nextimageindex ' + this.nextimageindex);
            //alert('imagenum ' + imagenum);
            try
            {
                ImgOff(SelectedImageNum)
                var oldicon = document.getElementById('icon_image_'+SelectedImageNum);
                var oldiconnum = document.getElementById('icon_num_'+SelectedImageNum);
                oldicon.src = 'assets/icon_off.gif';
                oldiconnum.className = 'SubNav';
            }
            catch(err)
            {}
            try
            {
                ImgOn(imagenum)
                var icon = document.getElementById('icon_image_'+imagenum);
                var iconnum = document.getElementById('icon_num_'+imagenum);
                icon.src = 'assets/icon_on.gif';
                iconnum.className = 'SubNavOn';
            }
            catch(err)
            {}
            SelectedImageNum = imagenum;
            
            fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
            this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
        }
    }


//~~ populateslide ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fadeshow.prototype.populateslide=function(picobj, picindex)
    {
        //alert('populateslide start');
        var slideHTML=""
        if (this.theimages[picindex][1]!="") //if associated link exists for image
        {
            slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
        }
        slideHTML+='<table border="0" cellpadding="0" cellspacing="0" width="495px" height="350px"><tr><td width="495px" height="350px" valign="middle" align="center"><img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px"></td></tr></table>'
        if (this.theimages[picindex][1]!="") //if associated link exists for image
        {
            slideHTML+='</a>'
        }
        picobj.innerHTML=slideHTML
        //alert('populateslide end');
    }


//~~ resetit ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fadeshow.prototype.resetit=function()
    {
        //alert('resetit');
        this.degree=10
        var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
        if (crossobj.filters&&crossobj.filters[0])
        {
            if (typeof crossobj.filters[0].opacity=="number") //if IE6+
            {
                crossobj.filters(0).opacity=this.degree
            }
            else //else if IE5.5-
            {
                crossobj.style.filter="alpha(opacity="+this.degree+")"
            }
        }
        else if (crossobj.style.MozOpacity)
        {
            crossobj.style.MozOpacity=this.degree/101
        }
        else if (crossobj.style.opacity)
        {
            crossobj.style.opacity=this.degree/100
        }
        else if (crossobj.style.KhtmlOpacity)
        {
            crossobj.style.KhtmlOpacity=obj.degree/100
        }    
        else
        {
            crossobj.style.opacity=this.degree/100
        }
    }


//~~ startit ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fadeshow.prototype.startit=function()
    {
        //alert('startit');
        var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
        this.populateslide(crossobj, this.curimageindex)
        //alert('this.curimageindex: ' + this.curimageindex);
        if (this.pausecheck==1)
        { //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
            var cacheobj=this
            var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
            crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
            crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
        }
        this.selectimage(SelectedImageNum);
        SlideShow = setInterval("fadearray[0].rotateimage()", this.delay);
    }


//~~ selectimage ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fadeshow.prototype.selectimage=function(imagenum)
    {
        try
        {
            var oldicon = document.getElementById('icon_image_'+SelectedImageNum);
            var oldiconnum = document.getElementById('icon_num_'+SelectedImageNum);
            oldicon.src = 'assets/icon_off.gif';
            oldiconnum.className = 'SubNav';
        }
        catch(err)
        {}
        try
        {
            var icon = document.getElementById('icon_image_'+imagenum);
            var iconnum = document.getElementById('icon_num_'+imagenum);
            icon.src = 'assets/icon_on.gif';
            iconnum.className = 'SubNavOn';
        }
        catch(err)
        {}
        SelectedImageNum = imagenum;
        clearInterval(SlideShow);
        imagenum=(imagenum>0)? imagenum-1 : TotalImages-1
        fadearray[0].movenextslide(imagenum);
        //nextImage();
        
        try
        {
           stopSlideShow();
        }
        catch(err)
        {}
    }
    
    
//~~ nextIcon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function initIcon()
    {
        var imagenum = SelectedImageNum;
        if(imagenum > TotalImages)
        {
            imagenum = 1;
        }
                //alert('initIcon');
            try
            {
                //alert('selectimage');
                ImgOn(imagenum);
            }
            catch(err)
            {}
        try
        {
            var icon = document.getElementById('icon_image_'+imagenum);
            var iconnum = document.getElementById('icon_num_'+imagenum);
            icon.src = 'assets/icon_on.gif';
            iconnum.className = 'SubNavOn';
            SelectedImageNum = imagenum
        }
        catch(err)
        {
            try
            {
                imagenum = 1
                var icon = document.getElementById('icon_image_'+imagenum);
                var iconnum = document.getElementById('icon_num_'+imagenum);
                icon.src = 'assets/icon_on.gif';
                iconnum.className = 'SubNavOn';
                SelectedImageNum = imagenum
            }
            catch(err)
            {}
        }
        //fadearray[0].rotateimage();
    }


//~~ prevImage ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function prevImage()
    {
        try
        {
            var oldicon = document.getElementById('icon_image_'+SelectedImageNum);
            var oldiconnum = document.getElementById('icon_num_'+SelectedImageNum);
            oldicon.src = 'assets/icon_off.gif';
            oldiconnum.className = 'SubNav';
        }
        catch(err)
        {}
        var imagenum = SelectedImageNum - 1;
        if(imagenum < 1)
        {
            imagenum = TotalImages;
        }
        try
        {
            var icon = document.getElementById('icon_image_'+imagenum);
            var iconnum = document.getElementById('icon_num_'+imagenum);
            icon.src = 'assets/icon_on.gif';
            iconnum.className = 'SubNavOn';
            SelectedImageNum = imagenum
        }
        catch(err)
        {
            imagenum = 1
            var icon = document.getElementById('icon_image_'+imagenum);
            var iconnum = document.getElementById('icon_num_'+imagenum);
            icon.src = 'assets/icon_on.gif';
            iconnum.className = 'SubNavOn';
            SelectedImageNum = imagenum
        }
    }


//~~ rollovericon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function rollovericon(imagenum)
    {
        if(SelectedImageNum!=imagenum)
        {
            var icon = document.getElementById('icon_image_'+imagenum);
            var iconnum = document.getElementById('icon_num_'+imagenum);
            icon.src = 'assets/icon_on.gif';
            iconnum.className = 'SubNavOn';
        }
    }


//~~ rollofficon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function rollofficon(imagenum)
    {
        if(SelectedImageNum!=imagenum)
        {
            var icon = document.getElementById('icon_image_'+imagenum);
            var iconnum = document.getElementById('icon_num_'+imagenum);
            icon.src = 'assets/icon_off.gif';
            iconnum.className = 'SubNav';
        }
    }


//~~ rollovericon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function rolloverresume()
    {
        var icon = document.getElementById('slideshowresumebutton');
        var icontext = document.getElementById('linkresume');
        icon.src = 'assets/resume_over.gif';
        icontext.className = 'SubNavOn';
    }


//~~ rollofficon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function rolloffresume()
    {
        var icon = document.getElementById('slideshowresumebutton');
        var icontext = document.getElementById('linkresume');
        icon.src = 'assets/resume.gif';
        icontext.className = 'SubNav';
    }


//~~ clickNext ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fadeshow.prototype.clickNext=function()
    {
        clearInterval(SlideShow);
        var newImageNum=(SelectedImageNum<TotalImages)? SelectedImageNum+1 : 1
        fadearray[0].selectimage(newImageNum);
        //nextImage();
        stopSlideShow();
    }


//~~ clickPrev ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fadeshow.prototype.clickPrev=function()
    {
        clearInterval(SlideShow);
        var newImageNum=(SelectedImageNum>1)? SelectedImageNum-1 : TotalImages
        fadearray[0].selectimage(newImageNum);
        //prevImage();
        stopSlideShow();
    }



//~~ stopSlideShow ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function stopSlideShow()
    {
        var slideshowControlcontainer = window.document.getElementById('slideshow_control_container');
        slideshowControlcontainer.style.visibility = "visible";
        clearInterval(SlideShow);
    }
    function hideSlideShowbutton()
    {
        var slideshowControlcontainer = window.document.getElementById('slideshow_control_container');
        slideshowControlcontainer.style.visibility = "hidden";
    }


//~~ resumeSlideShow ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    fadeshow.prototype.resumeSlideShow=function()
    {
        //alert('pauseplay');
        var pauseplay = window.document.getElementById('pauseplaytext');
        //alert(running);
        clearInterval(SlideShow);
        if(running)
        {
            pauseplay.innerHTML = "PLAY";
            running = false;
        }
        else
        {
            
            var nextimage=(SelectedImageNum<TotalImages)? SelectedImageNum+1 : 1
            clickThumbnail(nextimage);
            overimage = 0;
            SelectedImageNum = nextimage;
            fadearray[0].startit();
            pauseplay.innerHTML = "PAUSE";
            running = true;
        }
        //this.clickNext();
        
        //hideSlideShowbutton();
    }


//~~ Thumbnails ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var ivalup = new Array(15);
var ivaldwn = new Array(15);

var ImageArray = new Array(15);

var lastdwnlft, lastdwntop, lastdwnobj, imgname, imageid, nextid, totalthumbs, steps, maxx, maxy, currentx, currenty, dx, dy;
var baseopacity=0;
var fadein;
var fadeout;
var fadeinall;
var fadeoutall;
var thumbid = 0;
var ongoingcount=1;
var browserdetect;
var overimage = 0;

function ImgOver(num)
{
    var objnum = num;
    //alert(num);
    //alert(SelectedImageNum);
    if(num!=SelectedImageNum)
    {
	    var robjref = eval("document.getElementById('I" + objnum + "')");
        robjref.style.border='1px solid #ffffff';
	    robjref.style.height = 74;
	    robjref.style.width = 74;
	    
    }
    overimage=num;
}

function ImgOut(num)
{
    var objnum = num;
    if(num!=SelectedImageNum)
	{
	    var robjref = eval("document.getElementById('I" + objnum + "')");
        robjref.style.border='0px solid #ffffff';
	    robjref.style.height = 76;
	    robjref.style.width = 76;
	    overimage=0;
    }
}

function ImgOn(num)
{
    var objnum = num;
    //alert('ImgOver');
    var topnum = 1;
    var lftnum = parseInt(parseInt(objnum)%5);
    if (lftnum == 0)
        lftnum = 5;
	var robjref = eval("document.getElementById('I" + objnum + "')");
	var dobjref = eval("document.getElementById('D" + objnum + "')");
	var tobjref = document.getElementById('imagetitle');
    dobjref.style.zIndex = 100;
        
    browserdetect=robjref.filters? "ie" : typeof robjref.style.MozOpacity=="string"? "mozilla" : "";

    if (browserdetect=="mozilla"){
	    robjref.height = 76;
	    robjref.width = 76;
    }
    else if (browserdetect=="ie"){
	    robjref.style.height = 76;
	    robjref.style.width = 76;
    }
    robjref.style.border='1px solid #ffffff';
    dobjref.style.left = (((parseInt(lftnum)-1) * 112) + 13) + 'px';
    dobjref.style.top = '13px';
    
    if (ivalup[objnum] != null)
    {
        clearInterval(ivalup[objnum]);
    }
    if (ivaldwn[objnum] != null)
    {
		clearInterval(ivaldwn[objnum]);
    }
    var functionRef = "resizeImg('" + objnum + "', " + lftnum + ", " +  topnum + ", 'grow')";
    tobjref.innerHTML = ImageTitles[objnum-1];
    ivalup[objnum] = setInterval(functionRef, 30);

}


function ImgOff(num)
{

    var objnum = num;
    var lftnum = parseInt(parseInt(objnum)%5);
    if (lftnum ==0 )
        lftnum = 5;

    var topnum = 1;

    clearInterval(ivalup[objnum]);
    clearInterval(ivaldwn[objnum]);

	var functionRef = "resizeImg('" + objnum + "', " + lftnum + ", " +  topnum + ", 'shrink')";
    ivaldwn[objnum] = setInterval(functionRef, 30);
}


function resizeImg(objnum, lftnum, topnum, type) 
{
	var robjref = eval("document.getElementById('I" + objnum + "')");
	var dobjref = eval("document.getElementById('D" + objnum + "')");

	if (type == 'grow' && objnum != thumbid)
	{

	    if ((robjref.width<93) && (robjref.height<93)) {
	    //alert(browserdetect);
            if (browserdetect=="ie"){
		        robjref.style.height = robjref.height + 2;
		        robjref.style.width = robjref.width + 2;
		    }
            else{
		        robjref.height = robjref.height + 2;
		        robjref.width = robjref.width + 2;
		    }
            //alert("width - " + robjref.width + "; height - " + robjref.height);   	
		    //var lft = dobjref.left;
		    var lft = ((((parseInt(lftnum)-1) * 112) + 51) - ((parseInt(robjref.width))/2));
		    var tp = (51 - ((parseInt(robjref.width))/2));
            //alert("lft - " + lft + "; tp - " + tp + "; lftnum - " + lftnum + "; topnum - " + topnum);   	
		    dobjref.style.left = lft + 'px';
		    dobjref.style.top = tp + 'px';
	    }
	    else {
		    clearInterval(ivalup[objnum]);
            if (browserdetect=="ie"){
		        robjref.style.height = 96;
		        robjref.style.width = 96;
		    }
            else{
		        robjref.height = 96;
		        robjref.width = 96;
		    }
		    dobjref.style.left = (((parseInt(lftnum)-1) * 112)+3) + 'px';
		    dobjref.style.top = '3px';
            //alert("objnum - " + objnum + "; lftnum - " + dobjref.style.left + "; topnum - " + dobjref.style.top);   	
   	    }
   	}
   	else
   	{
	    if ((robjref.width>76) && (robjref.height>76)) {
            if (browserdetect=="ie"){
		        robjref.style.height = robjref.height - 2;
		        robjref.style.width = robjref.width - 2;
		    }
            else{
		        robjref.height = robjref.height - 2;
		        robjref.width = robjref.width - 2;
		    }
		    var lft = ((((parseInt(lftnum)-1) * 112) + 51) - (parseInt(robjref.width))/2);
		    var tp = (51 - (parseInt(robjref.width))/2);
		    dobjref.style.left = lft + 'px';
		    dobjref.style.top = tp + 'px';
	    }
	    else {
		    clearInterval(ivaldwn[objnum]);
		    //alert(objnum)
		    //alert(overimage)
		    if (objnum==overimage)
		    {
    		    robjref.style.border='1px solid #ffffff';
                if (browserdetect=="ie"){
		            robjref.style.height = 76;
		            robjref.style.width = 76;
		        }
                else{
		            robjref.height = 74;
		            robjref.width = 74;
		        }
		    }
		    else
		    {
    		    robjref.style.border='0px solid #ffffff';
                if (browserdetect=="ie"){
		            robjref.style.height = 76;
		            robjref.style.width = 76;
		        }
                else{
		            robjref.height = 76;
		            robjref.width = 76;
		        }
		    }
		    dobjref.style.left = (((parseInt(lftnum)-1) * 112) + 13) + 'px';
		    dobjref.style.top = '13px';
	        
   	    }
   	}	
}
function clickThumbnail(imagenum)
{
    if(SelectedImageNum!=imagenum)
    {
        ImgOff(SelectedImageNum);
        fadeshow.prototype.selectimage(imagenum);
        ImgOn(imagenum);
        SelectedImageNum = imagenum;
        var pauseplay = window.document.getElementById('pauseplaytext');
        clearInterval(SlideShow);
        pauseplay.innerHTML = "PLAY";
        running = false;
    }
}
/*
function clickImage(imagenum){
    var nextimage, oldclickedThumb, clickedThumb, imagepath;
    oldclickedThumb=document.getElementById('I'+thumbid);

    thumbid=imagenum;
    imagepath=ImageArray[parseInt(imagenum)].mainImage;
    clickedThumb=document.getElementById('I'+imagenum);

    if (fadeout != null)
    {
        clearInterval(fadeout);
    }
    if (fadein != null)
    {
        clearInterval(fadein);
    }
    
    if (imageid==1)
    {
        nextid = 2;
    }
    else if (imageid==2)
    {
        nextid = 1;
    }
    else
    {
        imageid = 1;
        nextid = 2;
    }
    
    nextimage=document.getElementById('image'+nextid);
    nextimage.src="Assets/spacer.gif";
    nextimage.src=imagepath;  
    
    
    
    browserdetect=nextimage.filters? "ie" : typeof nextimage.style.MozOpacity=="string"? "mozilla" : "";

    //set old thumb to off statef
    oldclickedThumb.style.border='0px solid #ffffff';
	//oldclickedThumb.style.height = 80;
	//oldclickedThumb.style.width = 80;
    if (browserdetect=="mozilla"){
	    oldclickedThumb.height = 80;
	    oldclickedThumb.width = 80;
        oldclickedThumb.style.MozOpacity=1.0;
    }
    else if (browserdetect=="ie"){
	    oldclickedThumb.style.height = 80;
	    oldclickedThumb.style.width = 80;
        oldclickedThumb.filters.alpha.opacity = 100;
    }
    //set new thumb to on state
    clickedThumb.style.border='4px solid #ffffff';
    if (browserdetect=="mozilla"){
	    clickedThumb.height = 100;
	    clickedThumb.width = 100;
        clickedThumb.style.MozOpacity=.5;
    }
    else if (browserdetect=="ie"){
	    clickedThumb.style.height = 100;
	    clickedThumb.style.width = 100;
        clickedThumb.filters.alpha.opacity = 50;
    }
    ImgOff(imagenum);


    fadeout=setInterval("gradualfadeout()",10);
    setCounter();
}


function gradualfadeout(){
    var cur2;
    cur2=document.getElementById("image" + imageid);
    
    if (browserdetect=="mozilla" && cur2.style.MozOpacity>0.0)
        cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity) - .1;
    else if (browserdetect=="ie" && cur2.filters.alpha.opacity>0)
        cur2.filters.alpha.opacity = parseInt(cur2.filters.alpha.opacity) -10;
    else {
        clearInterval(fadeout);
        cur2.src="Assets/spacer.gif";
    }
        
    if (browserdetect=="mozilla")
    {
        if (cur2.style.MozOpacity>0)
        {
            cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity) - .01;
        }
        else
        {
            clearInterval(fadeout);
            cur2.style.MozOpacity=0;
            cur2.src="Assets/spacer.gif";
            switchimages();
        }   
    }
    else if (browserdetect=="ie")
    {
        if (cur2.filters.alpha.opacity>0)
        {
            cur2.filters.alpha.opacity = parseInt(cur2.filters.alpha.opacity) + 1;
        }
        else
        {
            clearInterval(fadeout);
            cur2.filters.alpha.opacity = 0;
            cur2.src="Assets/spacer.gif";
            switchimages();
        }   
    }
        
}


function switchimages(){
    
    clearInterval(fadeout);
    var toplevel, nextimage;
    nextimage=document.getElementById('image'+nextid);

    if (imageid==1)
    {
        toplevel = "-300";
    }
    else if (imageid==2)
    {
        toplevel = "0";
    }
    else
    {
        toplevel = "-300";
    }
    thisdiv=document.getElementById('ImageContainer'+imageid);
    nextdiv=document.getElementById('ImageContainer'+nextid);
    
    imageid = nextid;
    thisdiv.style.top=-parseInt(toplevel) + "px";
    nextdiv.style.top=toplevel + "px";

    fadein=setInterval("gradualfadein()",10);

}


function gradualfadein(){
    var cur2;
    cur2=document.getElementById("image" + imageid);
    if (browserdetect=="mozilla")
    {
        if (cur2.style.MozOpacity<1)
        {
            cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity) + .05;
        }
        else
        {
            cur2.style.MozOpacity=1;;
            clearInterval(fadein);
        }   
    }
    else if (browserdetect=="ie")
    {
        if (cur2.filters.alpha.opacity<100)
        {
            cur2.filters.alpha.opacity = parseInt(cur2.filters.alpha.opacity) + 5;
        }
        else
        {
            cur2.filters.alpha.opacity = 100;
            clearInterval(fadein);
        }   
    }
}

function gradualfadeoutAll(){
    var cur2, cur1;
    //cur1=document.getElementById("thumbContainer");
    cur2=document.getElementById("image" + imageid);
    
    if (browserdetect=="mozilla" && cur2.style.MozOpacity>0.0){
        //cur1.style.MozOpacity=parseFloat(cur1.style.MozOpacity) - .1;
        cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity) - .1;
    }
    else if (browserdetect=="ie" && cur2.filters.alpha.opacity>0){
        //cur1.filters.alpha.opacity = parseInt(cur1.filters.alpha.opacity) -10;
        cur2.filters.alpha.opacity = parseInt(cur2.filters.alpha.opacity) -10;
    }
    else 
        clearInterval(fadeoutall);
        
        
    if (browserdetect=="mozilla")
    {
        if (cur2.style.MozOpacity>0)
        {
            //cur1.style.MozOpacity=parseFloat(cur1.style.MozOpacity) - .01;
            cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity) - .01;
        }
        else
        {
            clearInterval(fadeoutall);
            //cur1.style.MozOpacity=0;
            cur2.style.MozOpacity=0;
        }   
    }
    else if (browserdetect=="ie")
    {
        if (cur2.filters.alpha.opacity>0)
        {
            //cur1.filters.alpha.opacity = parseInt(cur1.filters.alpha.opacity) + 1;
            cur2.filters.alpha.opacity = parseInt(cur2.filters.alpha.opacity) + 1;
        }
        else
        {
            clearInterval(fadeoutall);
            //cur1.filters.alpha.opacity = 0;
            cur2.filters.alpha.opacity = 0;
        }   
    }
        
}

function gradualfadeinAll(){
    var cur2, cur1;
    cur1=document.getElementById("thumbContainer");
    cur2=document.getElementById("ContainerCanvas");
    if (browserdetect=="mozilla")
    {
        if (cur2.style.MozOpacity<1)
        {
            cur1.style.MozOpacity=parseFloat(cur1.style.MozOpacity) + .05;
            cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity) + .05;
        }
        else
        {
            cur1.style.MozOpacity=1;
            cur2.style.MozOpacity=1;
            clearInterval(fadeinall);
        }   
    }
    else if (browserdetect=="ie")
    {
        if (cur2.filters.alpha.opacity<100)
        {
            cur1.filters.alpha.opacity = parseInt(cur1.filters.alpha.opacity) + 5;
            cur2.filters.alpha.opacity = parseInt(cur2.filters.alpha.opacity) + 5;
        }
        else
        {
            cur1.filters.alpha.opacity = 100;
            cur2.filters.alpha.opacity = 100;
            clearInterval(fadeinall);
        }   
    }
}

function setthumbid(num){
    thumbid=num;
}

function settotalthumbs(num){
    totalthumbs=num;
}

function setCounter(){
    var leftarrow;
    var rightarrow;
    var counterdiv;
    leftarrow=document.getElementById("leftArrow");
    rightarrow=document.getElementById("rightArrow");
    counterdiv=document.getElementById("photocounter");
    counterdiv.innerHTML= thumbid + " of " + totalthumbs;
    setPhotoInfo();

}

function setPhotoInfo(){
    var MyPhotoInfo, imagename;
    MyPhotoInfo=document.getElementById("photoInfo");
    MyPhotoInfo.innerHTML=ImageArray[parseInt(thumbid)].DescText;
    
}

function goPrev(){
    var nextimage;
    if (thumbid==1)
    {
        nextimage = totalthumbs;
    }
    else
    {
        nextimage = thumbid-1;
    }
    clickImage(nextimage);
    
}

function goNext(){
    var nextimage;
    if (thumbid==totalthumbs)
    {
        nextimage = 1;
    }
    else
    {
        nextimage = thumbid+1;
    }
    clickImage(nextimage);
    
}

function FadeAllOut(){
    fadeoutall=setInterval("gradualfadeoutAll()",10);
}

function FadeAllIn(){
    fadeinall=setInterval("gradualfadeinAll()",10);
}
*/
