old_id=0;

function SetPreview(src,cond){

        if(!cond){
                img=new Image()
                img.src=src
                form.image.src='../img/empty.gif'
                form.image.width=1
                form.image.height=1
        }
        if(!img.complete){
                setTimeout("SetPreview('"+src+"',true)",200)
                return
        }
        var W=img.width
        var H=img.height
        
        if(W>100){
                H=H*((100.0)/W)
                W=100
        }
        if(H>100){
                W=W*((100.0)/H)
                H=100
        }
        if(W>100)
                W=100
        form.image.src=img.src
        form.image.width=W
        form.image.height=H  
        if ((img.width>100) || (img.height>100))
        {
        var on_clk = "window.open(img.src,'news_img','width="+(img.width+40)+",height="+(img.height+40)+",menu=1,scrollbars=1,resizable=1,top=10,left=10')";
        document.all.image_info.innerHTML='(' +img.width+ 'x' +img.height+ ')<br/><a href="javascript:void(0)" onclick="'+on_clk+'">preview</a>';
        }
        else
        document.all.image_info.innerHTML='(' +img.width+ 'x' +img.height+ ')<br/>';
        
}

function set_img(id,url,path){
        if(old_id>0)
                document.getElementById(old_id).style.background='#F7F7F7'
       
		document.getElementById(id).style.background='#C8FF99'
        old_id=id
		document.getElementById('fsrc').value = url;
        
		//image.src = url
		//image.width = 100;
		//image.height = 100;
		SetPreview(path+url);
}

function out_img(url,width,height,caption){
        document.getElementById('cur_img').src = url;
		document.getElementById('cur_img').width = width;
		document.getElementById('cur_img').height = height;
		document.getElementById('cur_img').alt = caption;
        document.all.cur_caption.innerHTML = caption;
}