var imOK = false;
var im = new Image();
var fs;

function formOnChange() {
  im.onload = checkSize

  if (!chkFormat(document.upload.file.value)) {
	return false;
	}

  im.src = "file://"+decodeURI(document.upload.file.value);
//  im.src = "http://forum.angeklickt.net/angeklicktmenu/angeklickt_header_1x1.gif";
  imOK = true;
  return true;
}

function checkSize() {
  
  if (navigator.userAgent.indexOf("Explorer")) 
	fs = im.fileSize; 
  else
	fs = 0; 

       if((im.width<3200 & im.height<2400) | (im.width<2400 & im.height<3200)) 
             	imOK = true;
	else if (im.width>0 < im.height>0)
		imOK = false;
          
  
  display(im);
  if(!imOK || fs>3500000)
    alert("ACHTUNG: Das Bild scheint etwas zu groß zu sein!\n");
}

function display(im) {
if (fs) 
  document.getElementById("display_size").firstChild.nodeValue = "Dateigröße: "+Math.round(fs/1024)+" KByte";
	

if (im.width) 
  document.getElementById("display_form").firstChild.nodeValue = "Bildformat: "+im.width+" x "+im.height+" Pixel";
	
}

function chkFormat(v) {

ok  = v.match(/jpg/i);

if (!ok)
	alert("Bitte nur JPG-Dateien hochladen!!");

return ok;
}

function visible() {
document.getElementById("loadbox").style.visibility = "visible";
}

function skal(ox, oy, w){

document.format.format.value="Format";

if (w!="y") {
	document.format.y_skal.value = Math.round(document.format.x_skal.value / (ox/oy));
	return;
	}

document.format.x_skal.value = Math.round(document.format.y_skal.value / (oy/ox));
}

function skal_korrekt() {
koord=document.format.format.value.split("x");
document.format.x_skal.value = koord[0];
document.format.y_skal.value = koord[1];
}

function popup(paras) {
window.open("popup.php?"+paras, "popup", "dependent=yes,height=320,width=460,menubar=no,resizable=no,scrollbars=no");
}
