//Thmb image's width
var iThmbWidth=65; //65=63+2 (borders) //161;//94;

var iThmbWidthScroll2=148; //=142+3+3 (borders)
//var iThmbWidthScroll2=146; //=140+3+3 (borders)
//var iThmbWidthScroll2=144; //=138+3+3 (borders)
 
var iDivWidth = 15;
//var iDivWidth = 19;
//var iDivWidth = 21;


var swidthScroll2=iThmbWidthScroll2*4 + iDivWidth*3; 
//var swidthScroll2; 

//slider's width
var swidth=iThmbWidth*5; //swidth = 5 thmb images

//slider's height
//var sheight=64;          //sheight = thmb height 63=62+2 (borders)

//slider's 2 width

//slider's speed
var sspeed=2;
// timer frequency
var timerTimeout=50;

//images's width
var iwidth=650;//680;
iwidth = iwidth/2;
//images's height
var iheight=650;//510;
iheight = iheight/2;

var loop=2;
var theObj="";

var ScrolledDistance = 0;
var ScrolledDistanceScroll2 = 0;
var ScrolledDistanceRight = 0;
var ScrolledDistanceLeft = 0;

var screenX;
var screenY;

var imagef='';
var currentDescr='';
var currentImageID = 0;
var prevImageID = 0;

var idTimerRight = 0;
var idTimerLeft = 0;

var idTimerRight2 = 0;
var idTimerLeft2 = 0;

var imageCount = 0;
var imageCountScroll2 = 0;

//var DescrArray = new Array();
var DescrArray;

var fadein_img;

function start(tmpStr)
{
//alert(tmpStr);
	imagef = tmpStr;

    screenX = screen.availWidth/2;
    screenY = screen.availHeight/2;
    
    if(document.getElementById)
    {
        tdiv6=document.getElementById('slider');
        firstns6();
    }
   
    // show one big image by default
    //TEMPORARY - will be moved to scrollbar.aspx.cs   
    idImg = imageCount/2+3; // will show central image if scrollbar contains 5 thmb images (+3)
    //idImg = imageCount/2+1; // will show central image if scrollbar contains 3 thmb images (+1)???
    enlarge(idImg);
}

function startScrollbar2(tmpStr)
{	//init 2-d scrollbar

    if(document.getElementById)
    {
        tdiv6_Scroll2=document.getElementById('slider2');
		tdiv6_Scroll2.innerHTML=('<nobr>'+tmpStr+'</nobr>');
		
		thel=tdiv6_Scroll2.offsetWidth; //there is a problem in FireFox with offsetWidth, but scrollbar2 works in FF (coincidence), so let it works
	    //thel=iThmbWidthScroll2*imageCountScroll2 + iDivWidth*(imageCountScroll2-1); 

		
		//alert(thel);
		//alert(tmpStr);

		tdiv6_Scroll2.style.left=-thel/2; 
    }
}

function firstns6()
{
    tdiv6.innerHTML=('<nobr>'+imagef+'</nobr>');
    
    //tdiv6.style.width = '';
    //tdiv6.style.height = '';
    //tdiv6.currentStyle.width = '';
    //alert(tdiv6.style);
    //alert(tdiv6.currentStyle);
    
    //thel=tdiv6.offsetWidth;
    //thel=swidth*2;	//there is a problem in FireFox with offsetWidth, lets calculation position manually. 2 - it is cycle of images in scrollbar
    thel=iThmbWidth*imageCount;	//there is a problem in FireFox with offsetWidth, lets calculation position manually. 2 - it is cycle of images in scrollbar
    
    
    
  
    //alert("tdiv6.offsetWidth = " + thel);
    //alert("tdiv6.innerWidth = " + tdiv6.innerWidth);
    //alert("tdiv6.scrollWidth = " + tdiv6.scrollWidth);
    //alert("tdiv6.clientWidth = " + tdiv6.clientWidth);
    //alert("tdiv6.offsetLeft = " + tdiv6.offsetLeft);
    //alert(tdiv6.offsetWidth + parseInt(tdiv6.style.borderLeftWidth) + parseInt(tdiv6.style.borderRightWidth));
    
    
    
    
    
    
    tdiv6.style.left=-thel/2; 
}

function slidens6(direction, bFlag)
{
    if (direction == "right")
    {
        if (idTimerLeft)    // if we still process pressing of another button - do nothing 
            return;

        if(parseInt(tdiv6.style.left)>= 0)
        {
            //tdiv6.style.left=-(imageCount*iThmbWidth);
            tdiv6.style.left=-(imageCount/2*iThmbWidth);
            slidens6("right", 1);
        }
        else
        {
            if (ScrolledDistance+1  >= iThmbWidth)	//because ScrollWidth=325 (odd), but speed=2 -  and every time we'll go ahead for 1 px
            {
				//tdiv6.style.left=parseInt(tdiv6.style.left)+1;
            
                clearTimeout(idTimerRight);
                idTimerRight = 0;
                ScrolledDistance = 0;
				
				//prevImageID = currentImageID;
				var tmpNum;
				if (currentImageID == 1)
					tmpNum = imageCount;
				else
					tmpNum = currentImageID - 1;
				 
				//changeLargeImage(tmpNum);
				if (bFlag == 1)                
					enlarge(tmpNum+imageCount/2);
				else
					enlarge(tmpNum);
					
            }
            else
            {
                tdiv6.style.left=parseInt(tdiv6.style.left)+sspeed;
                ScrolledDistance += sspeed;
				if (ScrolledDistance+1  >= iThmbWidth)	//because ScrollWidth=325 (odd), but speed=2 -  and every time we'll go ahead for 1 px
					tdiv6.style.left=parseInt(tdiv6.style.left)+1;
                
                if (bFlag == 1)
					idTimerRight = setTimeout("slidens6('right', 1)",timerTimeout);
				else
					idTimerRight = setTimeout("slidens6('right', 0)",timerTimeout);
                
                //ScrolledDistance += sspeed;
            }
        }
    }
    if (direction == "left")
    {
        if (idTimerRight)    // if we still process pressing of another button - do nothing 
            return;

        //if(parseInt(tdiv6.style.left)<= -((imageCount*loop*iThmbWidth)-swidth))
        if(parseInt(tdiv6.style.left)<= -((imageCount*iThmbWidth)-swidth))
        {
            //tdiv6.style.left=-(tdiv6.offsetWidth-imageCount*iThmbWidth-swidth);
            tdiv6.style.left=-(tdiv6.offsetWidth-imageCount/2*iThmbWidth-swidth);
            slidens6("left", 1);
        }
        else
        {
            if (ScrolledDistance+1 >= iThmbWidth) //because ScrollWidth=325 (odd), but speed=2 -  and every time we'll go ahead for 1 px
            {
                clearTimeout(idTimerLeft);
                idTimerLeft = 0;
                ScrolledDistance = 0;

				//prevImageID = currentImageID;
				var tmpNum;
				if (currentImageID == imageCount)
					tmpNum = 1;
				else
					tmpNum = currentImageID + 1;
				
				//changeLargeImage(tmpNum);                
				if (bFlag == 1)                
					enlarge(tmpNum-imageCount/2);
				else
					enlarge(tmpNum);
            }
            else
            {
                if (ScrolledDistance == 0)
					tdiv6.style.left = parseInt(tdiv6.style.left)-1;//because Width=325 (odd)
            
                tdiv6.style.left=parseInt(tdiv6.style.left)-sspeed;
                if (bFlag == 1)
					idTimerLeft = setTimeout("slidens6('left', 1)",timerTimeout);
				else
					idTimerLeft = setTimeout("slidens6('left', 0)",timerTimeout);
				
                ScrolledDistance += sspeed;
            }
        }
    }
}

function slideScroll2(direction, bFlag)
{
    if (direction == "right")
    {
        if (idTimerLeft2)    // if we still process pressing of another button - do nothing 
            return;

        if(parseInt(tdiv6_Scroll2.style.left)>= 0)
        {
            tdiv6_Scroll2.style.left=-((imageCountScroll2/2*(iThmbWidthScroll2+iDivWidth)));
            slideScroll2("right", 1);
        }
        else
        {
            //if (ScrolledDistanceScroll2 >= iThmbWidthScroll2+iDivWidth)
            if (ScrolledDistanceScroll2+1 >= iThmbWidthScroll2+iDivWidth)//because iDivWidth=15 (odd) and every time we'll go ahead for 1 px
            {            
				tdiv6_Scroll2.style.left=parseInt(tdiv6_Scroll2.style.left)+1;
				
                clearTimeout(idTimerRight2);
                
                idTimerRight2 = 0;
                ScrolledDistanceScroll2 = 0;
				
            }
            else
            {
                tdiv6_Scroll2.style.left=parseInt(tdiv6_Scroll2.style.left)+sspeed;
                if (bFlag == 1)
					idTimerRight2 = setTimeout("slideScroll2('right', 1)",timerTimeout);
				else
					idTimerRight2 = setTimeout("slideScroll2('right', 0)",timerTimeout);
                
                ScrolledDistanceScroll2 += sspeed;
            }
        }
    }
    if (direction == "left")
    {
        if (idTimerRight2)    // if we still process pressing of another button - do nothing 
            return;

        if(parseInt(tdiv6_Scroll2.style.left)<= -((imageCountScroll2*(iThmbWidthScroll2+iDivWidth))-swidthScroll2))
        {
            tdiv6_Scroll2.style.left=-(tdiv6_Scroll2.offsetWidth-imageCountScroll2/2*(iThmbWidthScroll2+iDivWidth)-swidthScroll2);
            slideScroll2("left", 1);
        }
        else
        {
        
			if (ScrolledDistanceScroll2+1 >= iThmbWidthScroll2+iDivWidth)//because iDivWidth=15 (odd) and every time we'll go ahead for 1 px
            //if (ScrolledDistanceScroll2 >= iThmbWidthScroll2+iDivWidth)
            {
                clearTimeout(idTimerLeft2);

                idTimerLeft2 = 0;
                ScrolledDistanceScroll2 = 0;

            }
            else
            {
				if (ScrolledDistanceScroll2 == 0)
					tdiv6_Scroll2.style.left = parseInt(tdiv6_Scroll2.style.left)-1;//because iDivWidth=15 (odd)
				
            
                tdiv6_Scroll2.style.left=parseInt(tdiv6_Scroll2.style.left)-sspeed;
                if (bFlag == 1)
					idTimerLeft2 = setTimeout("slideScroll2('left', 1)",timerTimeout);
				else
					idTimerLeft2 = setTimeout("slideScroll2('left', 0)",timerTimeout);
				
                ScrolledDistanceScroll2 += sspeed;
            }
        }
    }
}



function enlarge(idThmb)
{
	if (idTimerLeft || idTimerRight)    // if we still process pressing of sliding button - do nothing 
            return;
    
    if (idThmb == currentImageID)		// if mouse over twice over the same element - do nothing
		return;
            
    // we should do the following:
    // 1. Set current thmb image into color state
    // 2. Set previous thmb image into black-and-white state
    // 3. Change large image

	//if (idThmb != currentImageID)
		prevImageID = currentImageID;
	currentImageID = idThmb;

	//set current thmb into color state
	imgObj = document.getElementById(currentImageID);
	strImgName = imgObj.src;
	
	// get name of previous image
	if (prevImageID != 0)
	{
		imgObj = document.getElementById(prevImageID);
		strPrevImgName = imgObj.src;		
	    ind = strPrevImgName.indexOf("_thmb");
	    strPrevImgName = strPrevImgName.substring(0, ind);
		strPrevImgName = strPrevImgName + ".jpg";
	}
	else
		strPrevImgName = "";
	
	
	var curPage = "";
	if (currentImageID > imageCount/2)
		curPage = ("PICTURE " + (currentImageID-imageCount/2)) + "/" + imageCount/2;
	else
		curPage = ("PICTURE " + (currentImageID)) + "/" + imageCount/2;
	
	txtCurPage = document.getElementById("txtSCrollPage");
	txtCurPage.innerHTML = curPage;
	
	// Change large image
    ind = strImgName.indexOf("_thmb");
    strImgName = strImgName.substring(0, ind);
    strImgName = strImgName + ".jpg";
	which = strImgName; 
	if (currentImageID > imageCount/2)
		ind = currentImageID-imageCount/2-1;
	else
		ind = currentImageID-1;
	
	currentDescr = DescrArray[ind];

    crossobj = document.getElementById? document.getElementById("showimage") : document.all.showimage
    
    big_rect = document.getElementById("for_scrollbar")
    scroll_rect = document.getElementById("scrollbar_rect")
    
    imageWidth = big_rect.offsetWidth;
    imageHeight = big_rect.offsetHeight - scroll_rect.offsetHeight;
    
    var horzpos = big_rect.offsetLeft;
    var vertpos = big_rect.offsetTop + 20; //+20 because I'd like to show big image UNDER "top_menu image" - not above
	
    crossobj.style.left=horzpos+"px"
    crossobj.style.top=vertpos+"px"

//    crossobj.innerHTML='<div align="right" id="dragbar"><span id="closetext" onClick="closepreview()">Close</span> </div><img src="'+which+'">'
    
//    crossobj.innerHTML='<div id="dragbar"><img src="'+which+'"><span class="CenterText_About" id="description"></br></br>'+currentDescr+'</span></div>';
//    crossobj.innerHTML='<div id="dragbar"><img width=' + imageWidth + ' src="'+which+'"></div>';
    
    //crossobj.innerHTML='<div id="dragbar"> <span id="toolTipBox" width=' + imageWidth + '></span><img width=' + imageWidth + ' onmouseover=toolTip("' + currentDescr + '") src="'+which+'"></div>';
    
    //crossobj.innerHTML='<div id="dragbar"> <span  class="toolTipBox" id="toolTipBox" width=' + imageWidth + '></span><img id=imgEnlarged width=' + imageWidth + ' onmouseover=toolTip("' + currentDescr +'") src="'+which+'"></div>';
    //crossobj.innerHTML='<table><tr><td><div id="dragbar"> <span class="toolTipBox" id="toolTipBox"></span><img id=imgEnlarged width=' + imageWidth + ' onmouseover=toolTip("' + currentDescr +'") src="'+which+'"></div></td></tr></table>';
    
    //crossobj.innerHTML='<div id="dragbar"> <span style="WIDTH: 200px" class="toolTipBox" id="toolTipBox"></span><img id=imgEnlarged width=' + imageWidth + ' onmouseover=toolTip("' + currentDescr +'") src="'+which+'"></div>';
    //crossobj.innerHTML='<div id="dragbar"> <span style="WIDTH: 200px" class="toolTipBox" id="toolTipBox"></span><img name="SLIDESIMG" id=SLIDESIMG width=' + imageWidth + ' onmouseover=toolTip("' + currentDescr +'") src="'+which+'" STYLE="filter:progid:DXImageTransform.Microsoft.Fade()" BORDER="0"></div>';
    
    if(strPrevImgName != "")
		crossobj.innerHTML='<div id="dragbar"> <span style="WIDTH: 200px" class="toolTipBox" id="toolTipBox"></span><img name="SLIDESIMG" id=SLIDESIMG width=' + imageWidth + ' onmouseover=toolTip("' + currentDescr +'") src="'+strPrevImgName+'" STYLE="filter:progid:DXImageTransform.Microsoft.Fade()" BORDER="0"></div>';
	else
		crossobj.innerHTML='<div id="dragbar"> <span style="WIDTH: 200px" class="toolTipBox" id="toolTipBox"></span><img name="SLIDESIMG" id=SLIDESIMG width=' + imageWidth + ' onmouseover=toolTip("' + currentDescr +'") src="'+which+'" STYLE="filter:progid:DXImageTransform.Microsoft.Fade()" BORDER="0"></div>';
	
	if (strPrevImgName != "")
	{
		SLIDES = new slideshow("SLIDES");
		s = new slide();
		s.src = strPrevImgName; 
		//s.src = which; 
		//s.text = "Open link in same window"; 
		SLIDES.add_slide(s); 

		s1 = new slide();
		s1.src = which; 
		//s1.src = strPrevImgName; 
		//s1.text = "Open link in same window"; 
		SLIDES.add_slide(s1); 

		//alert(strPrevImgName);
		SLIDES.play();
		

if (document.images) {


SLIDES.image = document.images.SLIDESIMG;
fadein_img = SLIDES.image;
// Tell the slideshow to call our function whenever the slide is changed
SLIDES.post_update_hook = function() { fadein(0.04); }

}

		
	}


/*
<IMG NAME="SLIDESIMG" SRC="pic1.jpg"
 WIDTH="150" HEIGHT="150" BORDER="0" ALT="slideshow image" STYLE="filter:progid:DXImageTransform.Microsoft.Fade()">


*/
        



    
    //ok
    //crossobj.innerHTML='<div align="right" id="dragbar"></div><img src="'+which+'">'
    crossobj.style.visibility="visible"
    return false;
}

function closepreview()
{
    crossobj.style.visibility="hidden";
}

function SlideRight_onclick()
{
    slidens6("right", 0);
}
function SlideLeft_onclick()
{
    slidens6("left", 0);
}

function Slide2Right_onclick()
{
    slideScroll2("right", 0);
}
function Slide2Left_onclick()
{
    slideScroll2("left", 0);
}


function initCount(count)
{
	imageCount = parseInt(count);
	DescrArray = new Array(imageCount/2);	
	//alert(imageCount/2);
}

function initCountScroll2(count)
{
	imageCountScroll2 = parseInt(count);
	//swidthScroll2=iThmbWidthScroll2*imageCountScroll2 + iDivWidth*(imageCountScroll2-1); 
	//alert(imageCountScroll2);
}

function convertDescr(descr)
{
	var re;
	re = new RegExp("%20","g");
	descr = descr.replace(re, " ");
	return descr;
}

function toolTip(text) 
{
	if(text == "undefined")
		return;

  //theObj=document.getElementById("imgEnlarged");
  theObj=document.getElementById("SLIDESIMG");
  theObj.onmousemove=updatePos;
  document.getElementById('toolTipBox').innerHTML = convertDescr(text);
  document.getElementById('toolTipBox').style.display="block";
  
  //window.onscroll=updatePos;
  updatePos();
}

function updatePos() {
  var ev=arguments[0]?arguments[0]:event;
  var x=ev.clientX;
  var y=ev.clientY;
  
  diffX=24;
  diffY=0;
  document.getElementById('toolTipBox').style.top  = y-2+diffY+document.body.scrollTop+ "px";
  document.getElementById('toolTipBox').style.left = x-2+diffX+document.body.scrollLeft+"px";
  
  theObj.onmouseout=hideMe;
}

function hideMe() {
  document.getElementById('toolTipBox').style.display="none";
}

function initDescr(sDescrAndID)
{
	var ind = sDescrAndID.lastIndexOf("&");
	var sDescr = sDescrAndID.substr(0, ind);
	var sId = sDescrAndID.substr(ind+1);
		
	if (sDescr != "")
	{
		DescrArray[parseInt(sId)-1] = sDescr;
	}
}

/*
function initDescriptionArray(sDescr1, sDescr2, sDescr3, sDescr4, sDescr5, sDescr6, sDescr7, sDescr8, sDescr9, sDescr10)
{ //temporary - can be extra strings in array (when count of images e.g. = 5)

	nCounter = 0;
	
	DescrArray[nCounter] = convertDescr(sDescr1);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr2);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr3);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr4);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr5);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr6);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr7);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr8);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr9);
	nCounter += 1;
	
	DescrArray[nCounter] = convertDescr(sDescr10);
	nCounter += 1;
}
*/


/*

function changeThmbColor(idThmb, imgFile)
{
    //thmb - set to color state

//    thmbObj = document.getElementById(parseInt(idThmb))
//    //alert(thmbObj.src);
//    thmbObj.src = imgFile;

    thmbObj = document.getElementsByName(parseInt(idThmb))
    //alert(thmbObj.src);
	for(i=0; i<loop; i++) //load twice
	    thmbObj[i].src = imgFile;
}

function changeLargeImage(idThmb)
{
    imgObj = document.getElementsByName(parseInt(idThmb));
    var strImgName = '';
    strImgName = imgObj[loop-1].src;
    ind = strImgName.indexOf("_thmb");
    strImgName = strImgName.substring(0, ind);
    strImgName = strImgName + ".jpg";
	enlarge(idThmb, strImgName); // loop-1 - last image

//    strImgName = imgObj[loop-1].src;
    ind = strImgName.indexOf(".jpg");
    strImgName = strImgName.substring(0, ind);
    strImgName = strImgName + "_thmb" + ".jpg";
	changeThmbColor(idThmb, strImgName);

}

function initCurrentDescr(descr)
{
	var re;
	re = new RegExp("%20","g");
	currentDescr = descr.replace(re, " ");
}*/



// Create a function to ramp up the image opacity in Mozilla
var fadein_opacity = 0.04;
function fadein(opacity) {
  if (typeof opacity != 'undefined') { fadein_opacity = opacity; }
  if (fadein_opacity < 0.99 && fadein_img && fadein_img.style &&
      typeof fadein_img.style.MozOpacity != 'undefined') {

    fadein_opacity += .05;
    fadein_img.style.MozOpacity = fadein_opacity;
    setTimeout("fadein()", 50);
  }
}

function enlarge_2(idThmb)
{
/*
	alert("enlarge_2");

	var nOrigWidth, nOrigHeight;
	var objArr = idThmb.split("<>");
	idThmb = objArr[0];
	nOrigWidth=objArr[1];
	nOrigHeight=objArr[2];
	alert(idThmb);
	alert(nOrigWidth);
	alert(nOrigHeight);
*/




	if (idTimerLeft || idTimerRight)    // if we still process pressing of sliding button - do nothing 
            return;
    
    if (idThmb == currentImageID)		// if mouse over twice over the same element - do nothing
		return;
            
    // we should do the following:
    // 1. Set current thmb image into color state
    // 2. Set previous thmb image into black-and-white state
    // 3. Change large image

	//if (idThmb != currentImageID)
		prevImageID = currentImageID;
	currentImageID = idThmb;

	//set current thmb into color state
	imgObj = document.getElementById(currentImageID);
	strImgName = imgObj.src;
	
	// get name of previous image
	if (prevImageID != 0)
	{
		imgObj = document.getElementById(prevImageID);
		strPrevImgName = imgObj.src;		
	    ind = strPrevImgName.indexOf("_thmb");
	    strPrevImgName = strPrevImgName.substring(0, ind);
		strPrevImgName = strPrevImgName + ".jpg";
	}
	else
		strPrevImgName = "";
	
	
	var curPage = "";
	if (currentImageID > imageCount/2)
		curPage = ("PICTURE " + (currentImageID-imageCount/2)) + "/" + imageCount/2;
	else
		curPage = ("PICTURE " + (currentImageID)) + "/" + imageCount/2;
	
	txtCurPage = document.getElementById("txtSCrollPage");
	txtCurPage.innerHTML = curPage;
	
	// Change large image
    ind = strImgName.indexOf("_thmb");
    strImgName = strImgName.substring(0, ind);
    strImgName = strImgName + ".jpg";
	which = strImgName; 
	if (currentImageID > imageCount/2)
		ind = currentImageID-imageCount/2-1;
	else
		ind = currentImageID-1;
	
	currentDescr = DescrArray[ind];

    crossobj = document.getElementById? document.getElementById("showimage") : document.all.showimage
    
    big_rect = document.getElementById("for_scrollbar")
    scroll_rect = document.getElementById("scrollbar_rect")
    
    imageWidth = big_rect.offsetWidth;
    imageHeight = big_rect.offsetHeight - scroll_rect.offsetHeight;
    
    var horzpos = big_rect.offsetLeft;
    var vertpos = big_rect.offsetTop + 20; //+20 because I'd like to show big image UNDER "top_menu image" - not above
	
    crossobj.style.left=horzpos+"px"
    crossobj.style.top=vertpos+"px"

    if(strPrevImgName != "")
		crossobj.innerHTML='<div id="dragbar"> <img align="center" name="SLIDESIMG" id=SLIDESIMG src="'+strPrevImgName+'" STYLE="filter:progid:DXImageTransform.Microsoft.Fade()" BORDER="0"></div>';
		//crossobj.innerHTML='<div id="dragbar"> <img width="'+nOrigWidth+'" height="'+nOrigHeight+'" align="center" name="SLIDESIMG" id=SLIDESIMG src="'+strPrevImgName+'" STYLE="filter:progid:DXImageTransform.Microsoft.Fade()" BORDER="0"></div>';
	else
		crossobj.innerHTML='<div id="dragbar"> </span><img align="center" name="SLIDESIMG" id=SLIDESIMG src="'+which+'" STYLE="filter:progid:DXImageTransform.Microsoft.Fade()" BORDER="0"></div>';
		//crossobj.innerHTML='<div id="dragbar"> </span><img width="'+nOrigWidth+'" height="'+nOrigHeight+'" align="center" name="SLIDESIMG" id=SLIDESIMG src="'+which+'" STYLE="filter:progid:DXImageTransform.Microsoft.Fade()" BORDER="0"></div>';
	
	if (strPrevImgName != "")
	{
		SLIDES = new slideshow("SLIDES");
		s = new slide();
		s.src = strPrevImgName; 
		SLIDES.add_slide(s); 

		s1 = new slide();
		s1.src = which; 
		SLIDES.add_slide(s1); 

		SLIDES.play();
		

		if (document.images) {
			SLIDES.image = document.images.SLIDESIMG;
			fadein_img = SLIDES.image;
			// Tell the slideshow to call our function whenever the slide is changed
			SLIDES.post_update_hook = function() { fadein(0.04); }
		}
	}

    crossobj.style.visibility="visible"
    return false;
}

