function readlne_img(filename){

	property=getImageSize(filename);
	if (property.width ==0){onClick="window.close(self)";}
	else{
		win=eval('window.open(\'\',\'\',\'left=0,top=0,screenx=0,screeny=0,Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbar=0, Resizable=1, Copyhistory=1,Width='+property.width+',Height='+property.height+'\');');
		win.document.write('<html><title></title><body topmargin="0" leftmargin="0">'+
 		'<a href=""><img src="'+filename+'" onClick="window.close(self)" border="0"></a></body></html>');
	}

//	win.document.write('<html><title>'+alt+' ['+property.width+'x'+property.height+']</title><body style="margin:0 0 0 0;"><img src="'+filename+'" alt="'+alt+'" border=0 onClick=\"window.close(self)\" style=\"cursor:hand\"></body></html>');
//	alert(property.width+'x'+property.height);

}


function preload()
{
	/*	
	alert(1);
	var img_frame=window.parent.foto_frame.document;
	var reg=/([^\/]+)$/;
	for (i=0;i<img_frame.images.length;i++)
	{
		var img_medium[i]=new Image();
		file_frame=reg.exec(img_frame.images[i].src);
		img_medium[i].src='/site_upload/gallery/medium/'+file_frame[0];

	}
	*/
}

function getImageSize(oPic)
{
	var oHlpr = document.createElement('IMG');
	oHlpr.style.visibility = 'hidden';
	oHlpr.style.position = 'absolute';
	oHlpr.top = 0; oHlpr.left = 0;
	oHlpr.src = oPic;
	document.body.appendChild( oHlpr);
	var imSize = { 'width':oHlpr.offsetWidth,'height':oHlpr.offsetHeight }
	document.body.removeChild( oHlpr);
	return imSize;
}

function open_pic(img,alt)
{
	var reg=/([^\/]+)$/;
	var file_main=reg.exec(img.src);
	var src='/site_upload/gallery/'+file_main[0];

		property=getImageSize(src);
	//win=eval('window.open(\'\',\'\',\'left=0,top=0,screenx=0,screeny=0,Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbar=0, Resizable=0, Copyhistory=1,Width='+property.width+',Height='+property.height+'\');');
		win=eval('window.open(\'\',\'\',\'left=0,top=0,screenx=0,screeny=0,Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbar=0, Resizable=1, Copyhistory=1,Width='+property.width+',Height='+property.height+'\');');
	//win.document.write('<html><title>'+alt+' ['+property.width+'x'+property.height+']</title><body style="margin:0 0 0 0;"><img src="'+src+'" alt="'+alt+'" border=0 onClick=\"window.close(self)\" style=\"cursor:hand\"></body></html>');
		win.document.write('<html><title>'+alt+' ['+property.width+'x'+property.height+']</title><body style="margin:0 0 0 0;"><img src="'+src+'" alt="'+alt+'" border=0 onClick=\"window.close(self)\" style=\"cursor:hand\"></body></html>');
	//alert(property.width+'x'+property.height);
}

function img_frame_num()
{
	var img_main=document.getElementById('img_main');
	var img_frame=window.parent.foto_frame.document;
	var reg=/([^\/]+)$/;
	var file_main=reg.exec(img_main.src);

	for(var k=0;k<img_frame.images.length;k++)
	{
		file_frame=reg.exec(img_frame.images[k].src);
		if (file_main[0]==file_frame[0])
		{
			return k;
		}
	}
	return -1;
}

function img_frame_show(i)
{
	var img_main=document.getElementById('img_main');
	var img_frame=window.parent.foto_frame.document;

	reg=/([^\/]+)$/;
	if (i<=img_frame.images.length)
	{
		file=reg.exec(img_frame.images[i].src);
		img_main.src='/site_upload/gallery/medium/'+file[0];
		window.parent.foto_frame.scroll(95*(i-2),0);
		return true;
	}
	return false;
}

function slide_show(i)
{
	var img_start_stop=document.getElementById('img_start_stop');
	if (img_start_stop.src.indexOf('go.gif')>0) return;

	var img_main=document.getElementById('img_main');
	var img_frame=window.parent.foto_frame.document;

	var timeout=3000;
	k=img_frame_num();
	if (k>0) i=k+1;
	if (img_frame.images.length==i) i=0;

	if (i<img_frame.images.length)
	{
		img_frame_show(i);
		setTimeout('slide_show('+(i+1)+');',timeout);
	}
	else setTimeout('slide_show(0);',timeout);

}

function prev_img()
{
	var img_frame=window.parent.foto_frame.document;
	k=img_frame_num();
	if (k==0) img_frame_show(img_frame.images.length-1);
	else img_frame_show(k-1);
}

function next_img()
{
	var img_frame=window.parent.foto_frame.document;
	k=img_frame_num();
	if (k>=(img_frame.images.length-1)) img_frame_show(0);
	else img_frame_show(k+1);
}

function start_stop()
{
	obj=document.getElementById('img_start_stop');
	if (obj.src.indexOf('go.gif')>0) obj.src='/img/24/stop.gif';
	else obj.src='/img/24/go.gif';
	slide_show(0);
}

