function WhichPlugin() {
	window.open('WhichPlugin.htm', 'whichplugin', 'dependent,scrollbars,WIDTH=400,HEIGHT=400');
}

//
// Opens up the Usage page in a new window
//
function SampleUsage(sSample) {
	if (sSample == null || sSample == "") {
		sSample = "Simple";
	}
	window.open('Usage.htm#' + sSample, 'Usage', 'dependent,scrollbars,WIDTH=400,HEIGHT=400,resizable=yes');
}

//
// Opens up the Notes page in a new window
//
function SampleNotes(sSample) {
	if (sSample == null || sSample == "") {
		sSample = "Simple";
	}
	window.open('Notes.htm#' + sSample, 'Notes', 'dependent,scrollbars,WIDTH=500,HEIGHT=500,resizable=yes');
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------
// Function roundOff() --  Round off floating point numbers
//                         to set level of precision
// ----------------------------------------------------------

function roundOff(value, precision) {

     precision = parseInt(precision, 10);
     precision = (!precision ? 2 : precision);
     return Math.round(value*Math.pow(10,precision))/Math.pow(10,precision);
}

//  ---------------------------------------------------------------------------
//  getLatString() -- Get the LL text for a given coords Latitude
//  ---------------------------------------------------------------------------

function getLatString(latView) {

    northSouth = "N";
    if (latView < 0) {
        northSouth = "S";
        latView = Math.abs(latView);
    }

    latDegree = Math.floor(latView);
    latFraction = latView - latDegree;
    latMinute = latFraction * 60;
    latSeconds = Math.abs((latMinute - Math.floor(latMinute)) * 60);
    latMinute = Math.floor(latMinute);
    latSeconds = roundOff(latSeconds, 1);

    return(latDegree + ":" + latMinute + ":" + latSeconds + northSouth);
}

//  ---------------------------------------------------------------------------
//  getLonString() -- Get the LL text for a given coords Latitude
//  ---------------------------------------------------------------------------

function getLonString(longView) {

    eastWest = "E";
    if (longView < 0) {
        eastWest = "W";
        longView = Math.abs(longView);
    }

    longDegree = Math.floor(longView);
    longFraction = longView - longDegree;
    longMinute = longFraction * 60;
    longSeconds = Math.abs((longMinute - Math.floor(longMinute)) * 60);
    longMinute = Math.floor(longMinute);
    longSeconds = roundOff(longSeconds, 1);

    return(longDegree + ":" + longMinute + ":" + longSeconds + eastWest);
}
var wmImg=null;
function setWatermarke(lyrName, position, aImg) {
  if (!position || position=="" || position.length<2) position="lb";
  var hrz=position.substr(0,1);
  var ver=position.substr(1, 1);
  if (aImg) {
    var w=getObjWidth("mapview");//document.ECWView1.GetViewWidth();
    var h=getObjHeight("mapview");//document.ECWView1.GetViewHeight();
    sParams = "";
    sParams += "mode=WINABSOLUTE;";
    sParams += "body=;";
    sParams += "action=GET;";
    sParams += "worldTLX=-1;";
    sParams += "worldTLY=-1;";
    switch (hrz.toUpperCase()) {    
      case "L":
        sParams += "worldBRX=-"+w+";";
      break;
      case "R":
        sParams += "worldBRX=-"+aImg.width+";";
      break;
      case "C":
        sParams += "worldBRX=-"+((w+aImg.width)/2)+";";
      break;
      default :
        sParams += "worldBRX=-"+w+";";
      break;
    }
    switch (ver.toUpperCase()) {    
      case "T":
        sParams += "worldBRY=-"+h+";";
      break;
      case "B":
        sParams += "worldBRY=-"+aImg.height+";";
      break;
      case "C":
        sParams += "worldBRY=-"+((h+aImg.height)/2)+";";
      break;
      default :
        sParams += "worldBRY=-"+aImg.height+";";
      break;
    }
    /*
    var theImg=aImg.src;
    if (theImg.indexOf("?")>0) {
      var theImgP=theImg.split("?");
      alert(theImgP[0]);
      sParams += "url=" + theImgP[0]+";"; 
    }
    else
    */ 
    sParams += "url=" + aImg.src+";";
    document.ECWView1.AddLayer( "GISOverlay", "", lyrName, sParams);
    //document.ECWView1.SetLayerTransparency(lyrName,"#ffffff",0);
  }
}
function ECWToggleLogo(value, position) {
  document.ECWView1.DeleteLayer( "LogoLayer" );
  if (value) {
    if (!position || position=="" || position.length<2) position="rb";
    setWatermarke("LogoLayer", position, imgLogo);
    /*
    var w=document.ECWView1.GetViewWidth();
    var h=document.ECWView1.GetViewHeight();
    sParams = "";
    sParams = "mode=WINABSOLUTE;";
    sParams = sParams + "body=;";
    sParams = sParams + "action=GET;";
    sParams = sParams + "worldTLX=-1;";
    sParams = sParams + "worldTLY=-1;";
    sParams = sParams + "worldBRX=-"+imgLogo.width+";";
    sParams = sParams + "worldBRY=-"+imgLogo.height+";";
    sParams = sParams + "url=" + imgLogo.src+";";
    document.ECWView1.AddLayer( "GISOverlay", "", "LogoLayer", sParams);
    document.ECWView1.SetLayerTransparency("LogoLayer","#ffffff",0);
    */
  }  
}
function setViewExtentsAll(NCSView) {
  if (typeof(NCSView)=="string")
    NCSView=eval(NCSView);  
  var sLayer=getFirstActiveLayerName(NCSView);
  if (sLayer!=null) { 
    var xmin=NCSView.GetLayerImageTopLeftWorldCoordinateX(sLayer);
    var ymin=NCSView.GetLayerImageBottomRightWorldCoordinateY(sLayer);
    var xmax=NCSView.GetLayerImageBottomRightWorldCoordinateX(sLayer);
    var ymax=NCSView.GetLayerImageTopLeftWorldCoordinateY(sLayer);
    setViewExtent(NCSView, xmin,ymin,xmax,ymax);
  }
}
function setViewExtent(NCSView,xmin,ymin,xmax,ymax) {
  NCSView.SetExtents(xmin,ymax,xmax,ymin);

  var wExt=xmax-xmin;
  var hExt=ymax-ymin;    
  var mX=xmin+wExt/2;
  var mY=ymin+hExt/2;      
    
  var vXmin=NCSView.GetTopLeftWorldCoordinateX();
  var vYmin=NCSView.GetBottomRightWorldCoordinateY();
  var vXmax=NCSView.GetBottomRightWorldCoordinateX();
  var vYmax=NCSView.GetTopLeftWorldCoordinateY();
  var mVX=vXmin+(vXmax-vXmin)/2;
  var mVY=vYmin+(vYmax-vYmin)/2;
  var difXs=mVX-mX;
  var difYs=mVY-mY;
  if (difXs!=0) {
    xmin=vXmin-difXs;
    xmax=vXmax-difXs;          
  }
  if (difYs!=0) {
    ymin=vYmin-difYs;
    ymax=vYmax-difYs;    
  }
  NCSView.SetExtents(xmin,ymax,xmax,ymin);  
}
function moveMap(NCSView,difX, difY) {
  var xa=2;
  var ya=2;
  var xe=xa+Math.abs(difX);
  var ye=ya+Math.abs(difY);
  var wc0=ECWVectorLayer.Pixel2Word(xa,ya);
  var wc1=ECWVectorLayer.Pixel2Word(xe,ye);
  var difXW=(wc1[0]-wc0[0])/10;
  var difYW=(wc0[1]-wc1[1])/10;
  var xmin=NCSView.GetTopLeftWorldCoordinateX();
  var ymin=NCSView.GetBottomRightWorldCoordinateY();
  var xmax=NCSView.GetBottomRightWorldCoordinateX();
  var ymax=NCSView.GetTopLeftWorldCoordinateY();
  if (difX>0) {
    xmin+=difXW;
    xmax+=difXW;
  }
  else {
    xmin-=difXW;
    xmax-=difXW;      
  }
  if (difY>0) {
    ymin-=difYW;
    ymax-=difYW; 
  }
  else {
    ymin+=difYW;
    ymax+=difYW;  
  }
  setViewExtent(NCSView,xmin,ymin,xmax,ymax);    
}
function setExtent(aValue, distance) {
  var aExtent=aValue.split(",");
  if (aExtent.length==4) {
    var  NCSView = (document.ECWView1 == null ? document.ToolPanelForm.ECWView1 : document.ECWView1);
    if (aExtent[0]==aExtent[2] || aExtent[1]==aExtent[3]) {
      if (distance)
        var zoomDist=distance;
      else var zoomDist=zoomDefDist;
      if (aExtent[0]==aExtent[2]) {
        aExtent[0]=parseFloat(aExtent[0])-zoomDist*1.5;
        aExtent[2]=parseFloat(aExtent[2])+zoomDist*1.5;
      }
      if (aExtent[1]==aExtent[3]) {
        aExtent[1]=parseFloat(aExtent[1])-zoomDist;
        aExtent[3]=parseFloat(aExtent[3])+zoomDist;
      }
    }
    var xmin=parseFloat(aExtent[0]);
    var ymin=parseFloat(aExtent[1]);
    var xmax=parseFloat(aExtent[2]);
    var ymax=parseFloat(aExtent[3]);
    setViewExtent(NCSView,xmin,ymin,xmax,ymax);    
    /*
    NCSView.SetExtents(_left,_top,_right,_bottom);
    var wExt=parseFloat(aExtent[2])-parseFloat(aExtent[0]);
    var hExt=parseFloat(aExtent[3])-parseFloat(aExtent[1]);    
    var mX=parseFloat(aExtent[0])+wExt/2;
    var mY=parseFloat(aExtent[1])+hExt/2;      
    
    var xmin=NCSView.GetTopLeftWorldCoordinateX();
    var ymin=NCSView.GetBottomRightWorldCoordinateY();
    var xmax=NCSView.GetBottomRightWorldCoordinateX();
    var ymax=NCSView.GetTopLeftWorldCoordinateY();
    var mVX=xmin+(xmax-xmin)/2;
    var mVY=ymin+(ymax-ymin)/2;
    var difXs=mVX-mX;
    var difYs=mVY-mY;
    if (difXs!=0) {
      _left=xmin-difXs;
      _right=xmax-difXs;          
    }
    if (difYs!=0) {
      _bottom=ymin-difYs;
      _top=ymax-difYs;    
    }
    NCSView.SetExtents(_left,_top,_right,_bottom);
    */  
  }
}
var refreshAktive=null;
function resizeRefresh() {
  if (refreshAktive!=null) clearTimeout(refreshAktive);
  refreshAktive=setTimeout("refreshMap()",300);
}
function setClass(name,className) {
  var aObj=getObject(name);
  if (aObj) 
    aObj.className=className;
}
var mainDefault=null;
var dum=2;
function refreshMapExtent() {
  var xmin=document.ECWView1.GetTopLeftWorldCoordinateX();
  var ymin=document.ECWView1.GetBottomRightWorldCoordinateY();
  var xmax=document.ECWView1.GetBottomRightWorldCoordinateX();
  var ymax=document.ECWView1.GetTopLeftWorldCoordinateY();
  setViewExtent(document.ECWView1,xmin,ymin,xmax,ymax);
}
function fullDefault() {
  var aSize=getObjectSize("maptable");
  mainDefault=new Array();
  mainDefault["maptable"]=new Array(getPosition("maptable"),getObjectSize("maptable"));
  mainDefault["mapview"]=new Array(getPosition("mapview"),getObjectSize("mapview"));
  mainDefault["toolbar"]=new Array(getPosition("toolbar"),getObjectSize("toolbar"));
  mainDefault["ort"]=new Array(getPosition("ort"),getObjectSize("ort"));
  mainDefault["product"]=new Array(getPosition("product"),getObjectSize("product"));
  mainDefault["status"]=new Array(getPosition("status"),getObjectSize("status"));
  mainDefault["layers"]=new Array(getPosition("layers"),getObjectSize("layers"));
  mainDefault["xy"]=new Array(getPosition("xy"),getObjectSize("xy")); 
}
var stHeight=0;
function controlsPosition(aList) {
  var result=0;
  for (var i=0;i<aList.length;i++) {
    if (getObjWidth("product")>0) {
      result=getObjWidth("product");
      break;
    }
  }
  return result;
}
function resizeClient(w, isComentar) {
  resizeOrder();
  if (stHeight===0)
    stHeight=getObjHeight("status");
  if (stHeight==getObjHeight("status") && isComentar) return false;  
  var h=Math.round(2100*w/2970);
  var h2=getPosition("mapview").y+getObjHeight("status");
  if ((h+h2)>=size.height) {
    h=size.height-h2;
    w=Math.round(2970*h/2100);
  }
  resizeLayer("mapview", w, h);
  resizeLayer("status", w, getObjHeight("status"));
  if (isChrome || isOpera) {
    rand=getPosition("status").y - (getPosition("mapview").y+h);
    resizeLayer("layers", getObjWidth("layers"), h-getPosition("layers").y+getObjHeight("status")+rand);
    resizeLayer("xy", getObjWidth("layers"), h-getPosition("layers").y+getObjHeight("status")+rand);
    resizeLayer("product", getObjWidth("product"), h-getPosition("product").y+getObjHeight("status")+rand);
  }
  /*
  var randH=Math.round((size.height-(h+getObjHeight("status")+2))/2);
  var leftObjWidth=controlsPosition(new Array("overview","login","product"));
  var randV=Math.round((size.width-(w+leftObjWidth+getObjWidth("toolbar")+getObjWidth("layers")+3*2))/2);
  if (leftObjWidth>0) {
    moveLayer("overview",randV,randH);
    moveLayer("login",randV,getPosition("overview").y+getObjHeight("overview")+((isIE && !isOpera)?4:2));
    moveLayer("product",randV,getPosition("login").y+getObjHeight("login")+2);
  }
  else {
    moveLayer("overview",0,0);
    moveLayer("login",0,0);
    moveLayer("product",0,0);
  }
  moveLayer("mapview",Math.max(getPosition("product").x+getObjWidth("product")+2,randV),randH);
  moveLayer("status",getPosition("mapview").x,getPosition("mapview").y+h+2);
  moveLayer("toolbar",getPosition("mapview").x+w+2,randH);
  moveLayer("ort",getPosition("toolbar").x+getObjWidth("toolbar")+2,randH);
  moveLayer("layers",getPosition("toolbar").x+getObjWidth("toolbar")+2,getPosition("ort").y+getObjHeight("ort")+2);
  moveLayer("xy",getPosition("toolbar").x+getObjWidth("toolbar")+2,getPosition("ort").y+getObjHeight("ort")+2);

  rand=getPosition("status").y - (getPosition("mapview").y+h);
  if (!isIE || isOpera) resizeLayer("overview", getObjWidth("product"), getObjHeight("overview"));
  resizeLayer("product", getObjWidth("product"), h+getObjHeight("status")-getObjHeight("overview")-getObjHeight("login")-((isIE&&!isOpera)?4:2));  
  resizeLayer("toolbar", getObjWidth("toolbar"),h+getObjHeight("status")+rand);    
  resizeLayer("layers", getObjWidth("layers"), h+getObjHeight("status")-getObjHeight("ort"));//+getObjHeight("status")+rand);
  resizeLayer("xy", getObjWidth("layers"), h+getObjHeight("status")-getObjHeight("ort"));  
  */
  if (isPlugIn==-1 || isPlugIn==6) setTimeout("refreshMapExtent()",300);
}
function ECWToggleWatermarke() {
  var orthoCheck=getObject("orthoCheck");
  var dgmCheck=getObject("dgmCheck");
  document.ECWView1.DeleteLayer( "WaterLayer" );
  if (dgmCheck && dgmCheck.checked) {
    var wmImg=new Image();
    wmImg.src=dgmArray[lastDgm][1];
    setWatermarke("WaterLayer",dgmArray[lastDgm][2],wmImg);
  }
  else if (orthoCheck && orthoCheck.checked) {
    var wmImg=new Image();
    wmImg.src=orthoArray[lastOrtho][1];  
    setWatermarke('WaterLayer',orthoArray[lastOrtho][2],wmImg);
  }
}
function refreshMap(isComentar) {
  if (!mainDefault) fullDefault();
  if (client!="LBS") {  
    size=getWindowSize();
    //alert("W "+mainDefault["mapview"][1].width);
    //if (size.width>1000) {
    if (size.width>mainDefault["mapview"][1].width) {      
      var width=getObjWidth("overview")+2*dum+getObjWidth("toolbar")+dum+getObjWidth("ort");
      var dif=size.width-width;
      //alert("H "+mainDefault["mapview"][1].height)
      //if (dif>600) {
      if (dif>mainDefault["mapview"][1].height) {
        resizeClient(dif,isComentar);
      }
      else  {
        resizeClient(mainDefault["mapview"][1].width,isComentar);
      }
    }
    else {
      resizeClient(mainDefault["mapview"][1].width,isComentar);
    }
  }
  ECWToggleLogo(false);
  ECWToggleLogo(true,logoPos);
  ECWToggleWatermarke();  
}
var cntOrtho=0;
var cntDGM=0;
var orthoArray=null;
var dgmArray=null;
var tbl="";
function getOrthoComment(NCSView) {
  var cnt=NCSView.GetNumberLayers();
  var result="";
  for (var i=0;i<cnt;i++) {
    var sLayer=NCSView.GetLayerName(i);
    if (NCSView.GetLayerType(sLayer).toUpperCase()=="ECW") {
      var isshow=NCSView.GetLayerParameter(sLayer,"visibility").toUpperCase();
      if (isshow=="TRUE") {
        result=orthoArray[i][0];
      }
    }
  }  
  return result;
}
var lastOrtho=0;
var lastDgm=0;
function ECWToggleLayer(layerName,lyrType) {
  var orthoCheck=getObject("orthoCheck");
  var dgmCheck=getObject("dgmCheck");
  if (lyrType=="ORTHOPHOTO") {
    var ak="ortho";
    var theCount=cntOrtho;
    var theArray=orthoArray;
    var aCheckCtr=orthoCheck;
  }
  else {
    var ak="dgm";
    var theCount=cntDGM;
    var theArray=dgmArray;
    var aCheckCtr=dgmCheck;
  }
  for (var i=0;i<theCount;i++) {
    var lyrName=ak+i;
    if (aCheckCtr && aCheckCtr.checked) {
      var aCtr=getObject(ak+"Radio"+i);
      document.ECWView1.SetLayerVisible(lyrName, aCtr.checked);
      if (aCtr.checked && theArray) {
        if (aCheckCtr==dgmCheck || (aCheckCtr==orthoCheck && !(dgmCheck && dgmCheck.checked)))
          theStatus.showComment(theArray[i][0]);
        refreshMap(true);
        wmImg=null;
        if (lyrType=="ORTHOPHOTO") lastOrtho=i;
        else lastDgm=i;
        if (theArray[i][1]) {
          wmImg=new Image();
          wmImg.src=theArray[i][1];
          document.ECWView1.DeleteLayer( "WaterLayer" );        
          setTimeout("setWatermarke('WaterLayer','"+theArray[i][2]+"',wmImg)",200);
        }
      }
    }
    else {
      document.ECWView1.SetLayerVisible(lyrName, false);
      theStatus.showComment(null);
    }
  }
  if (!aCheckCtr.checked) {
    if (dgmCheck && dgmCheck.checked) theStatus.showComment(dgmArray[lastDgm][0]);
    else if (orthoCheck && orthoCheck.checked) theStatus.showComment(orthoArray[lastOrtho][0]);
    ECWToggleWatermarke();
  }
}
function ECWToggleSubLayer(layerName,lyrType) {
  /*
  if (lyrType=="ORTHOPHOTO")
    var aCtr=getObject("orthoCheck");
  else var aCtr=getObject("dgmCheck");
  */
  ECWToggleLayer(layerName,lyrType);
}
function loadHelpLayers() {
  if (document.ECWView1.AddLayer("simplevector", "", "VectorOverlay", "visibility=TRUE;") < 0) {
    alert(document.ECWView1.GetLastErrorText());
  }
  else {
    ECWVectorLayer = new NCSVectorLayer(document.ECWView1, "mapview","VectorOverlay",theStatus);
    ECWVectorSetPenColor(linecolor);
    ECWVectorSetLineWidth(linewidth);
    //ECWVectorSetFillColor(polycolor);
    //ECWVectorSetTransparency(transparency);    
    ECWVectorLayer.setCaptureCoord(ECWCaptureCoord);
  }
  ECWToggleLogo(true,logoPos);
}
function getColor(i) {
  switch (i) {
    case 0:
      return "ff";
    break;
    case 1:
      return "fe";
    break;
    case 2:
      return "fd";
    break;
    case 3:
      return "fc";
    break;    
    case 4:
      return "fb";
    break;
    case 5:
      return "fa";
    break;    
  }
}
function setlayerTransparency(lyrname) {
  var tiefe=4;
  for (var i=0;i<tiefe;i++) {
    var a="#"+getColor(i);
    for (var j=0;j<tiefe;j++) {
      var b=getColor(j);
      for (var k=0;k<tiefe;k++) {
        var c=getColor(k);
        var color=a+b+c;
        document.ECWView1.setLayerTransparency(lyrname,color,0.0);
        ECWCaptureCoord.AddText(color);
      }
    }
  }
}
function ECWLoadMapview(type,ecw,name,parameter) {
  document.ECWView1.AddLayer(type,ecw,name, parameter);
}
function loadTableValues(fldName) {
  switch (fldName) {
    case "land":
      var param="&client="+client;
      var landSL=getObject("land");      
      if (landSL.selectedIndex>0) param+="&land="+landSL.options[landSL.selectedIndex].value;
      param+="&CONTROL=bundesland";
      loadNaviOptions("bundesland",param,"SELECT");          
      //setTimeout("loadTableValues(\"bundesland\")",1000);
    break;
    case "bundesland":
      var param="&client="+client;
      var landSL=getObject("land");      
      if (landSL.selectedIndex>0) param+="&land="+landSL.options[landSL.selectedIndex].value;    
      var bLandSL=getObject("bundesland");
      if (bLandSL.selectedIndex>0) param+="&bland="+bLandSL.options[bLandSL.selectedIndex].value;
      param+="&CONTROL=kreis";
      loadNaviOptions("kreis",param,"SELECT");          
      //setTimeout("loadTableValues(\"kreis\")",1000);
    break;
    case "kreis":
      var param="&client="+client;
      var landSL=getObject("land");      
      if (landSL.selectedIndex>0) param+="&land="+landSL.options[landSL.selectedIndex].value;    
      var bLandSL=getObject("bundesland");
      if (bLandSL.selectedIndex>0) param+="&bland="+bLandSL.options[bLandSL.selectedIndex].value;    
      var kreisSL=getObject("kreis");
      if (kreisSL.selectedIndex>0) param+="&kreis="+kreisSL.options[kreisSL.selectedIndex].value;
      param+="&CONTROL=orte";
      loadNaviOptions("orte",param,"SELECT");          
    break;
  }
}
function loadNewMap(cbCtrPLZ, cbCtrStr,txtCtr,hnrCtr) {
  window.focus();
  var orteSL=getObject("orte");
  clearCtr(document.getElementById(cbCtrStr),"SELECT");
  clearCtr(document.getElementById(hnrCtr),"DIV");
  document.getElementById(txtCtr).value="";
  var newExtent=null;
  if (orteSL.selectedIndex>0) {
    document.ECWView1.DeleteAllLayers();
    var aOrt=orteSL.options[orteSL.selectedIndex].value;
    var aText="";
    loadLayers(aOrt,"document.ECWView1","layers");
    //setTimeout("loadNewOptions(\"PLZ\",\""+cbCtrPLZ+"\",\"SELECT\")",500);
  }  
}
function onIWSError ( layerName, num, code, desc ) {
  if (layerName.indexOf("ortho")===0) {
    var ak="ortho";
    var idx=parseInt(layerName.substr(ak.length));
    var theArray=orthoArray;
  }
  else {
    var ak="dgm";
    var idx=parseInt(layerName.substr(ak.length));
    var theArray=dgmArray;
  }
  if( num == ERROR_CONNECTION_LOST ) { // Connection lost
    alert("Layer '" + theArray[idx][3] + "' has lost connection to Image Web Server.\n" + "Only locally cached data will be viewable.");
  }
  else {
    alert(theArray[idx][3] + " - " + code + "(" + num + "), " + desc);
  }
}
function showSite(url,w,h) {
  if (w && h)
    window.open(url,"","width="+w+",height="+h+",status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,hotkeys=yes,dependent=yes");
  else window.open(url,"","status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes,hotkeys=yes,dependent=yes");
}
function getSelectValue(slName,idxS, _default) {
  if (slName=="plz") return _default;
  var aSelect=getObject(slName);
  if (aSelect && aSelect.selectedIndex>=idxS) {
    return aSelect.options[aSelect.selectedIndex].text;
  }
  else return _default;
}
function getLocalHost(aHost) {
  var port="";
  if (aHost.indexOf(":")) {
    var params=aHost.split(":");
    if (params.length>1 && params[1] && params[1]!="")  
      port=":"+params[1];
  }
  return "localhost"+port;
}
function resizeOrder() {
  var size=getWindowSize();
  var aLyr=getLayer("htmlDisabled");
  if (size && aLyr) {
    aLyr.width=size.width+document.body.scrollLeft;
    aLyr.height=size.height+document.body.scrollTop;
  }  
  /*
  var frmOSize=getObjectSize("ifrmOrder");
  if (frmOSize) {
    resizeLayer("ifrmOrder",size.width-100,size.height-100);
  }
  */
  centerLayer("ifrmOrder");
  //relativeTo("divCloseOrder","ifrmOrder","r","t",getObjWidth("divCloseOrder")+5, 5);
  relativeTo("divCloseOrder","ifrmOrder","r","t",0,0);
  relativeTo("divBtnOrder","ifrmOrder","l","t",0,0);
}
function closeOrder() {
  hideLayer("ifrmOrder");
  hideLayer("htmlDisabled");
  hideLayer("divCloseOrder");
  hideLayer("divBtnOrder");
  var afrm=window.frames[0];
  afrm.location="about:blank";  
}
function f_order(NCSView) {
  var sLayerFileName = getLayersFileName(NCSView,true);
  //var comment=getOrthoComment(NCSView);
  var orthoCheck=getObject("orthoCheck");
  var dgmCheck=getObject("dgmCheck");
  //if (!dgmCheck && !orthoCheck) return false; 
  if (dgmCheck && dgmCheck.checked) {
    var comment=dgmArray[lastDgm][0];
    var title=dgmArray[lastDgm][3];
  }
  else if (orthoCheck && orthoCheck.checked) {
    var comment=orthoArray[lastOrtho][0];
    var title=orthoArray[lastOrtho][3];
  }   
  // When using the java plugin, we need to convert the returned JavaScript wrapper to a JavaScript string by appending
  // an empty string to it.  
  if(bUseJavaPlugin) {
    sLayerFileName += "";
  }
  var w=NCSView.GetViewWidth();
  var h=NCSView.GetViewHeight();    
  var pgWidth=300;//150;//198;
  var pgHeight=h*pgWidth/w;
  var xmin = NCSView.GetTopLeftWorldCoordinateX();
  var ymin = NCSView.GetBottomRightWorldCoordinateY();
  var xmax = NCSView.GetBottomRightWorldCoordinateX();
  var ymax = NCSView.GetTopLeftWorldCoordinateY();  
  var thePoints="";
  var thePointsPX="";
  if (ECWVectorLayer) {
    if (ECWVectorLayer.AreaPointsX.length>2) {
      thePoints=ECWVectorLayer.PointsAsString(";");
      for (var i=0; i<ECWVectorLayer.AreaPointsX.length;i++) {
        //thePoints+=(thePoints==""?"":";")+ECWVectorLayer.AreaPointsX[i]+";"+ECWVectorLayer.AreaPointsY[i];
        var pxP=ECWVectorLayer.WordCoord2Pixel(ECWVectorLayer.AreaPointsX[i],ECWVectorLayer.AreaPointsY[i],pgWidth,pgHeight,xmin,ymin,xmax,ymax);
        thePointsPX+=(thePointsPX==""?"":";")+pxP[0]+";"+pxP[1];
      }
    }
    else {
      alert("Zeichnen Sie ein Polygon");
      return;
    }
  }
  var ort=getSelectValue("orte",1,"");
  var plz=getSelectValue("plz",1,"");
  var str=getSelectValue("str",0,"");
  var extentPX= ECWVectorLayer.getPixelExtent(pgWidth,pgHeight,xmin,ymin,xmax,ymax);
  var jetzt = new Date();
  var monat=jetzt.getMonth()+1;
  monat=(monat<10?"0":"")+monat;  
  var tag=jetzt.getDate();
  tag=(tag<10?"0":"")+tag;
  var stunden=jetzt.getHours();
  stunden=(stunden<10?"0":"")+stunden;
  var minuten=jetzt.getMinutes();
  minuten=(minuten<10?"0":"")+minuten;
  var segunden=jetzt.getSeconds();
  segunden=(segunden<10?"0":"")+segunden;
  //var orderNr=jetzt.getFullYear()+monat+tag+stunden+minuten+segunden; 
  var orderNr=stunden+minuten+segunden;
  var datum=tag+"."+monat+"."+jetzt.getFullYear();
  /*
  var awin=window.open();
  awin.document.write("<html>");
  awin.document.write("<head>");
  awin.document.write("<title>Karte drucken...</title>");
  awin.document.write("<script>");
  awin.document.write("function showOrder(){");
  awin.document.write("  window.document.order.submit();");
  awin.document.write("}");
  awin.document.write("</script>");
  awin.document.write("</head>");
  awin.document.write("<body>");
  awin.document.write("<form name='order' action='order.php' method='POST'>");
  awin.document.write("<input type='hidden' name='execute' value='http://" + getLocalHost(document.location.host) + "/ecwp/ImageX.dll?image?'>");
  awin.document.write("<input type='hidden' name='layers' value='"+MakeRelativePath(sLayerFileName)+"'>");
  awin.document.write("<input type='hidden' name='worldtlx' value='"+NCSView.GetTopLeftWorldCoordinateX()+"'>");
  awin.document.write("<input type='hidden' name='worldtly' value='"+NCSView.GetTopLeftWorldCoordinateY()+"'>");
  awin.document.write("<input type='hidden' name='worldbrx' value='"+NCSView.GetBottomRightWorldCoordinateX()+"'>");
  awin.document.write("<input type='hidden' name='worldbry' value='"+NCSView.GetBottomRightWorldCoordinateY()+"'>");
  awin.document.write("<input type='hidden' name='client' value='"+client+"'>");
  awin.document.write("<input type='hidden' name='sizex' value='"+pgWidth+"'>");
  awin.document.write("<input type='hidden' name='sizey' value='"+pgHeight+"'>");
  awin.document.write("<input type='hidden' name='fillcolor' value='0x00FFFFFF'>");
  awin.document.write("<input type='hidden' name='quality' value='100'>");  
  awin.document.write("<input type='hidden' name='type' value='png'>");  
  awin.document.write("<input type='hidden' name='points' value='"+thePoints+"'>");
  awin.document.write("<input type='hidden' name='bb' value='"+ECWVectorLayer.getExtent()+"'>");
  awin.document.write("<input type='hidden' name='pointsPX' value='"+thePointsPX+"'>");
  awin.document.write("<input type='hidden' name='extentPX' value='"+extentPX+"'>");    
  awin.document.write("<input type='hidden' name='polyArea' value='"+ECWVectorLayer.getAbsArea()+"'>");
  awin.document.write("<input type='hidden' name='rectArea' value='"+ECWVectorLayer.getPolyExtentArea()+"'>");
  awin.document.write("<input type='hidden' name='orderNr' value='"+orderNr+"'>");
  awin.document.write("<input type='hidden' name='datum' value='"+datum+"'>");
  awin.document.write("<input type='hidden' name='frmtyp' value='ORDER'>");
  awin.document.write("<input type='hidden' name='aNr' value='"+aNr+"'>");  
  awin.document.write("<input type='hidden' name='ort' value='"+escape(ort)+"'>");
  awin.document.write("<input type='hidden' name='plz' value='"+plz+"'>");
  awin.document.write("<input type='hidden' name='str' value='"+escape(str)+"'>");
  awin.document.write("<input type='hidden' name='kommentar' value='"+escape(comment)+"'>");  
  awin.document.write("<input type='hidden' name='title' value='"+title+"'>");
  awin.document.write("<input type='hidden' name='hnr' value='"+globalHNR+"'>");
  awin.document.write("</form>");
  awin.document.write("</body>");
  awin.document.write("</html>");
  awin.showOrder();
  */
  document.order.execute.value="http://" + document.location.host + "/ecwp/ImageX.dll?image?";
  document.order.LAYERS.value=MakeRelativePath(sLayerFileName);
  document.order.worldtlx.value=NCSView.GetTopLeftWorldCoordinateX();
  document.order.worldtly.value=NCSView.GetTopLeftWorldCoordinateY();
  document.order.worldbrx.value=NCSView.GetBottomRightWorldCoordinateX();
  document.order.worldbry.value=NCSView.GetBottomRightWorldCoordinateY();
  document.order.client.value=client;
  document.order.sizex.value=pgWidth;
  document.order.sizey.value=pgHeight;
  document.order.fillcolor.value="0x00FFFFFF";
  document.order.quality.value=100;
  document.order.type.value="png";
  document.order.points.value=thePoints;
  document.order.bb.value=ECWVectorLayer.getExtent();
  document.order.pointsPX.value=thePointsPX;
  document.order.extentPX.value=extentPX;
  document.order.polyArea.value=ECWVectorLayer.getAbsArea();
  document.order.rectArea.value=ECWVectorLayer.getPolyExtentArea();
  document.order.orderNr.value=orderNr;
  document.order.datum.value=datum;
  document.order.frmtyp.value="ORDER";
  document.order.aNr.value=aNr;
  document.order.ORT.value=escape(ort);
  document.order.PLZ.value=plz;
  document.order.STR.value=escape(str);
  document.order.kommentar.value=escape(comment);  
  document.order.title.value=title;
  document.order.HNR.value=globalHNR;
  document.order.submit();
  //document.body.style.overflow="hidden";
  showLayer("htmlDisabled");
  showLayer("ifrmOrder");
  showLayer("divCloseOrder");  
  resizeOrder();
}
function sendClick(aHnr){
  globalHNR=aHnr;
  makePOSTRequest("countClick.php","CLIENT="+client);
}
/*
function openRegistry() {
  window.showModalDialog("dlglogin.htm",null, "dialogWidth:6.5cm; dialogHeight:7.5cm;resizable:no;status:no;help:no;" );  
}
*/
function showConfirm(aURL) {
  var aLink=getObject("orderPDF");
  if (aLink)
    aLink.href=aURL;  
  showLayer("divBtnOrder");
  relativeTo("divBtnOrder","ifrmOrder","l","t",0,0);
}
