function SmallImageOnClick(gal,src,lbl,dsc,txt,cu0,cu1,cu2,cu3,cu4,cu5,cu6,cu7,cu8,cu9,h,w,scaled,code,stop,imgnum) {
	try{
		if(scaled=="True")
			document.getElementById('htmgal_med_img'+gal).src = "ViewImage.aspx?height="+h+"&width="+w+"&image="+src;
		else
			document.getElementById('htmgal_med_img'+gal).src = src;
	}catch(e){
		try{document.getElementById('htmgal_med_img'+gal).src = 'images/1x1.gif';}catch(e){}
	}
	try{
		
		var obj = htmgal_rotate_find(gal);
		if(imgnum) obj.image_idx = parseInt(imgnum);
		if(stop)
		{
			if(obj.rotate_status) {
				obj.stop();
			}
		}
	}catch(e){}
	try{
	  if(!lbl)lbl="";	  if(!dsc)dsc="";	  if(!txt)txt="";	  if(!cu0)cu0="";
	  if(!cu1)cu1="";	  if(!cu2)cu2="";	  if(!cu3)cu3="";	  if(!cu4)cu4="";
	  if(!cu5)cu5="";	  if(!cu6)cu6="";	  if(!cu7)cu7="";	  if(!cu8)cu8="";
	  if(!cu9)cu9="";
	}catch(e){}
	try{document.getElementById('htmgal_med_lbl'+gal).innerHTML = unescape(lbl);}catch(e){}
	try{document.getElementById('htmgal_med_dsc'+gal).innerHTML = unescape(dsc);}catch(e){}
	try{document.getElementById('htmgal_med_txt'+gal).innerHTML = unescape(txt);}catch(e){}
	try{document.getElementById('htmgal_med_cu0'+gal).innerHTML = unescape(cu0);}catch(e){}
	try{document.getElementById('htmgal_med_cu1'+gal).innerHTML = unescape(cu1);}catch(e){}
	try{document.getElementById('htmgal_med_cu2'+gal).innerHTML = unescape(cu2);}catch(e){}
	try{document.getElementById('htmgal_med_cu3'+gal).innerHTML = unescape(cu3);}catch(e){}
	try{document.getElementById('htmgal_med_cu4'+gal).innerHTML = unescape(cu4);}catch(e){}
	try{document.getElementById('htmgal_med_cu5'+gal).innerHTML = unescape(cu5);}catch(e){}
	try{document.getElementById('htmgal_med_cu6'+gal).innerHTML = unescape(cu6);}catch(e){}
	try{document.getElementById('htmgal_med_cu7'+gal).innerHTML = unescape(cu7);}catch(e){}
	try{document.getElementById('htmgal_med_cu8'+gal).innerHTML = unescape(cu8);}catch(e){}
	try{document.getElementById('htmgal_med_cu9'+gal).innerHTML = unescape(cu9);}catch(e){}
	try{document.getElementById('htmgalmedimgnum'+gal).value = code;}catch(e){}
}

var htmgal_array = new Array();
function gallery_elem(g,t,s,m)
{
	this.gal = g;
	this.delay_time = t;
	this.rotate_status = s;
	this.image_idx = 1;
	this.images_max = m;
	this.timerID = null;
	this.start = function (){this.rotate_status = true;this.timerID = setTimeout("htmgal_rotate_next("+this.gal+")", this.delay_time);};
	this.stop = function (){this.rotate_status = false;this.image_idx = 1;clearTimeout(this.timerID);};
	this.switchstate = function (){if(this.rotate_status) {this.stop();} else {this.start();}this.rotate_status = !this.rotate_status};
}
function htmgal_rotate_setup(g,t,s,m){
	var obj = new gallery_elem(g,t,s,m);
	htmgal_array[htmgal_array.length] = obj;
	if(obj.rotate_status)
		obj.start();
}
function htmgal_rotate_find(gal)
{
	var obj = null;
	if(htmgal_array.length != 0)
	{
		for(var i = 0; i < htmgal_array.length; i++)
		{
			if(htmgal_array[i].gal == gal)
				obj = htmgal_array[i];
		}
	}
	return obj;
}

function htmgal_rotate_next(gal){
	var obj = htmgal_rotate_find(gal);
	var code = obj.image_idx + "_" + obj.gal;
	if(obj.rotate_status)
	{
		htmgalleryautoscript(code);
		obj.image_idx++;
		if(obj.image_idx > obj.images_max - 1)
			obj.image_idx = 0;	
		obj.start();
	}
}

function htmgal_rotate_prev(gal){
	var obj = htmgal_rotate_find(gal);
	var code = obj.image_idx + "_" + obj.gal;
	if(obj.rotate_status)
	{
		htmgalleryautoscript(code);
		obj.image_idx--;
		if(obj.image_idx < 0)
			obj.image_idx = obj.images_max - 1;	
		obj.start();
	}
}

function htmgal_next(gal){
	var obj = htmgal_rotate_find(gal);
	obj.image_idx++;
	if(obj.image_idx > obj.images_max - 1)
		obj.image_idx = 0;	
	var code = obj.image_idx + "_" + obj.gal;
	htmgalleryautoscript(code);
}

function htmgal_prev(gal){
	var obj = htmgal_rotate_find(gal);
	obj.image_idx--;
	if(obj.image_idx < 0)
		obj.image_idx = obj.images_max - 1;	
	var code = obj.image_idx + "_" + obj.gal;
	htmgalleryautoscript(code);
}

function htmgal_rotate_switch(gal){
	var obj = htmgal_rotate_find(gal);
	if(obj.rotate_status)
		obj.stop();
	else
		obj.start();
}
