var origimg;
function loadimgs()
{
 if (!document.images) return;
 origimg=new Image(); origimg.src = "http://"+document.form1.img1.value;
  waitforcomplete();
}
function waitforcomplete()
{
 if (origimg.complete)
 {
    document.form1.imgwidth.value = origimg.width;
  document.form1.imgheight.value = origimg.height;
 }
 else setTimeout ("waitforcomplete();", 500);
}
function makecode()
{
 var imgname = document.form1.img1.value.substr (document.form1.img1.value.lastIndexOf('/')+1, document.form1.img1.value.lastIndexOf('.')-document.form1.img1.value.lastIndexOf('/')-1);
 document.form1.imagecode.value = '<a href="'+(document.form1.click[0].checked?(document.form1.linktype[0].checked?("http://"+document.form1.wwwdest.value):("mailto:"+document.form1.emaildest.value)):"javascript:void(0);")+'" onMouseOver="if (document.images) document.'+imgname+'.src=\'http://'+document.form1.img2.value+'\';" onMouseOut="if (document.images) document.'+imgname+'.src=\'http://'+document.form1.img1.value+'\';"><img src="http://'+document.form1.img1.value+'"'+(document.form1.imgwidth.value.length<1?"":" width="+document.form1.imgwidth.value)+''+(document.form1.imgheight.value.length<1?"":" height="+document.form1.imgheight.value)+''+(document.form1.alttext.value.length<1?"":' alt="'+document.form1.alttext.value+'"')+' name="'+imgname+'" border='+document.form1.borderwidth.value+'></a>';
 document.form1.preloadcode.value = '<script language="javascript" type="text/javascript">\n<'+'!--\nif (document.images) {var '+imgname+'=new Image(); '+imgname+'.src="http://'+document.form1.img2.value+'";}'+'\n//--'+'>\n</script>';
}
function preview()
{
 var imgwidth = (document.form1.imgwidth.value.length<1 ? 400 : parseInt(document.form1.imgwidth.value)+50);
 var imgheight = (document.form1.imgheight.value.length<1 ? 200 : parseInt(document.form1.imgheight.value)+50);
 prev = window.open('', '', 'width='+imgwidth+',height='+imgheight+',menubar=yes,resizable=yes,top=0,left=0');
 prev.focus();
 prev.document.open ("text/html");
 prev.document.writeln ("<html><body bgcolor=\"white\" text=\"black\"><center><table width=100% height=100% border=0><tr><td align=center valign=middle>"+document.form1.imagecode.value+"</td></tr></table><br>"+document.form1.preloadcode.value+"</body></html>");
 prev.document.close();
}