
//var projection = 'nomap';
var projectionlist = new Array(2);
projectionlist[0] = 'Equirectangular' ;
projectionlist[1] = 'Mercator' ;
//var projection = 'nomap';

var gridlist = new Array(2);
gridlist[0] = 'off' ;
gridlist[1] = 'on' 

// #######################################################
// Kartenprojektion

function setProjection(){
        
  projection = document.carto_form.mapprojection.value ;
  document.carto_form.jsMapProjection.value = projection;      
 }


//------------------------------------------------------- 
function initProjection(){
        
  projection = document.carto_form.jsMapProjection.value ;
  var len = document.carto_form.mapprojection.length ;
  var ii=0;
  
  for (i = 1; i < len; i++){
   	
    	ix  = projection.search(projectionlist[i]);
    	    	
    	if (ix>=0) { var ii=i ;} 
        
       
    }
    document.carto_form.mapprojection.selectedIndex = ii ;
      
    //-------------
    counter();
    //-------------  
 }
//----------------------------------------------------
// EventManager lädt zu Beginn setupFolders
EventManager.Add(window, 'load', initProjection, false);


//-------------------------------------------------
// Setzen des Kartennetzes
function setMapGrid(){
        
    var ix  = document.carto_form.mapgrid.value ;    
    var val = document.carto_form.jsMapGrid.value = ix ;    
 }
function initGrid(){
        
  var grid = document.carto_form.jsMapGrid.value ;
  var len = document.carto_form.mapgrid.length ;
  var ii=0;
  
  for (i = 1; i < len; i++){
   	
    	ix  = grid.search(gridlist[i]);
    	    	
    	if (ix>=0) { var ii=i ;}    
    }
    document.carto_form.mapgrid.selectedIndex = ii ;
      
 }
//------------------------------------------------------
// EventManager lädt zu Beginn setupFolders
EventManager.Add(window, 'load', initGrid, false);

//-------------------------------------------------------
// PAN-Funktion

function panCoord(dir){
    
    var MminX = xGetElementById('Mminx');
    var MmaxX = xGetElementById('Mmaxx');
    var MminY = xGetElementById('Mminy');
    var MmaxY = xGetElementById('Mmaxy');


    if (MminX != null) {
        
        var minx = 1.0*MminX.value ;
        var maxx = 1.0*MmaxX.value ;
        var miny = 1.0*MminY.value ;
        var maxy = 1.0*MmaxY.value ;
        
        var dx = (MmaxX.value - MminX.value)*1.0 ;
        var dy = (MmaxY.value - MminY.value)*1.0 ;
    }
   
  // document.carto_form.testout.value = dx ;
  // document.carto_form.testout2.value = dy ;
    
    var MINX = -180 ;
    var MAXX =  180 ;
    var MINY =  -89.9 ;
    var MAXY =   89.9 ;
    
    //var dx = (maxx - minx) ;
    //var dy = (maxy - miny) ;    
        
    switch (dir) {
        
        case 'NW':
           minx = Math.max(minx - dx, MINX) ;
           maxx = minx + dx ;
           maxy = Math.min(maxy + dy, MAXY) ;
           miny = maxy - dy ;
        break;        
        case 'N':           
           maxy = Math.min(maxy + dy, MAXY) ;
           miny = maxy - dy ;
   
        break;
        case 'NE':
           maxx = Math.min(maxx + dx, MAXX) ;
           minx = maxx - dx ;
           maxy = Math.min(maxy + dy, MAXY) ;
           miny = maxy - dy ;
        break;         
        case 'W':
           minx = Math.max(minx - dx, MINX) ;
           maxx = minx + dx ;
        break;
        case 'E':
           maxx = Math.min(maxx + dx, MAXX) ;
           minx = maxx - dx ;
        break; 
        case 'SW':
           minx = Math.max(minx - dx, MINX) ;
           maxx = minx + dx ;
           miny = Math.max(miny - dy, MINY) ;
           maxy = miny + dy ;
        break;  
        case 'S':
           miny = Math.max(miny - dy, MINY) ;
           maxy = miny + dy ;
        break;
        case 'SE':
           maxx = Math.min(maxx + dx, MAXX) ;
           minx = maxx - dx ;
           miny = Math.max(miny - dy, MINY) ;
           maxy = miny + dy ;
        break;
   }
    var box_xmin = xGetElementById('box_xmin');
    var box_xmax = xGetElementById('box_xmax');
    var box_ymin = xGetElementById('box_ymin');
    var box_ymax = xGetElementById('box_ymax');
        
    if (box_xmin != null) {  
      /*   
       box_xmin.value = Math.min(minx,-180) ; 
       box_xmax.value = Math.min(maxx, 180) ;    
       box_ymin.value = Math.max(miny, -90) ; 
       box_ymax.value = Math.max(maxy,  90) ;       
     */  
       box_xmin.value = minx ; 
       box_xmax.value = maxx ;    
       box_ymin.value = miny ; 
       box_ymax.value = maxy ;       
        
    }
    
    doSubmit();
   
}



// #######################################################
// Reset-Funktion
// #######################################################
function FormItemSelected() {
  
  var gravtool = document.carto_form.js_folder_grav.value ;
   
  if (gravtool == 9){
      
      CitySearch(); 
   }
  
  
  
   
  doSubmit();
}

 


//--------------------------------------------------
//
//   Aktivierung eines 'Tools' mit der Maus, 
//   der entsprechenden Registerkarte und der Kartenfunktion

function setActiveToolButton(toolid) {
	

  document.carto_form.tools_id.value = toolid ;
    
  //---------------------------------------------	
	
  var elt = setActiveTool(toolid); 
  //-------------------------------------------
  setActiveRegisterMap(toolid) ;
}
//------------------------------------------------
// Aktivierung des zuletzt gebrauchten ToolButton
//
// Funktion wird in setupFolder aufgerufen

function setInitialToolButton() {

   var toolid = document.carto_form.tools_id.value ;   
   var zoneid = document.carto_form.zone_id.value ;
   
   if (zoneid > 0) {      
      toolid = 'GravityZone' ;   
   }
   
   setActiveTool(toolid); 
   
   //--------------------------------------
   // Setze Map function
   if (toolid.indexOf('LocalGravity') != -1) {
        mainmap.LocalGravity('map'); 
   }
   else if (toolid.indexOf('LocalGravity') != -1) {
        mainmap.LocalGravity('map'); 
   }
   else if (toolid.indexOf('CitySearch') != -1) {
       mainmap.LocalGravity('map');  
   }
   else if (toolid.indexOf('zoomin')     != -1) {
        mainmap.zoomin('map');   
   }
   else if (toolid.indexOf('zoomout')     != -1) {
        mainmap.zoomout('map');   
   }    
   else if (toolid.indexOf('Move')     != -1) {
        //mainmap.Move('map');  
   }
   else if (toolid.indexOf('Maplayer') != -1) {
        //mainmap.zoomin('map');  
   }
   else if (toolid.indexOf('surface') != -1){           
         mainmap.surface('map'); 
   }
   else if (toolid.indexOf('distance') != -1 ) {  
         mainmap.distance('map'); 
   }  
   
   
   
   
      
}

//---------------------------------------------------
// Hilfsfunktion in setActiveToolButton und setInitialToolButton

function setActiveTool(toolid){
        
  for (var i = 0; i < cw3_tools.length; i++) {
    var elt = xGetElementById(cw3_tools[i] + "_icon");

    if(elt == null) return;
    
    if ( toolbar_rendering == 'swap') {
   	
      if (cw3_tools[i] == toolid) {
      	

      	
        var from = cw3_tools[i] + '.gif';
        var to = cw3_tools[i] + '_active.jpg';
      } else {
        var from = cw3_tools[i] + '_active.jpg';
        var to = cw3_tools[i] + '.gif';
      }

      var pic = elt.getAttribute('src');
      var re = new RegExp(from);
      var newpic = pic.replace(re, to);
       
      if (newpic != pic) {
        elt.setAttribute('src', newpic);
      }
    
    } else {
      // default case: toolbar_rendering = outline
      if (cw3_tools[i] == toolid) {
        elt.className = "toolbar_on";
      } else {
        elt.className = "toolbar_off";
      }
    }
  }
  return elt;
}
//----------------------------------------------------
// Hilfsfunktion in setActiveToolButton
//
// Aktivierung einer Registerkarte

function setActiveRegisterMap(toolid){

  
  var zonetool  = document.carto_form.js_folder_zone.value ;
  
  //var gravtool  = document.carto_form.js_folder_grav.value ;
  //var layertool = document.carto_form.js_folder_layer.value ;
  //var helptool  = document.carto_form.js_folder_help.value ;
  // var id2  = document.carto_form.js_folder_id2.value ;
  
  
  
   var elt = xGetElementById("tool");
   elt.value = toolid;
  
//  if (typeof myfolders != "undefined") { // not on page load
    if (toolid.indexOf('notoolbar') != -1) {
      ontop(1);
      
     // Bild_active(register,'reg_','start');
     RegisterActive('start') ; 
    }
    else if (toolid.indexOf('LocalGravity') != -1) {
      ontop(4);
      
      //if (gravtool != 10)  // 8 oder 10
      //     gravtool = 8;  
      ontop(8); //ontop2(gravtool); // 8    
      RegisterActive('gravity') ; 
      mainmap.LocalGravity('map'); 
    }
    
    else if (toolid.indexOf('CitySearch') != -1) {
      ontop(4);
      //if (gravtool != 10)  // 8 oder 10
      //     gravtool = 9;  
      ontop(9); //ontop2(gravtool); // 8
      //Bild_active(register,'reg_','gravity');
      RegisterActive('gravity') ; 
      mainmap.LocalGravity('map');  
    }
     else if (toolid.indexOf('GravityZone') != -1) {
      ontop(5);
      if (zonetool != 13)  // 11 oder 13
           gravtool = 11;  
      ontop(zonetool); //ontop2(gravtool); // 8
      //Bild_active(register,'reg_','gravityzones') ;
      RegisterActive('gravityzones') ; 
      
    }
    else if (toolid.indexOf('Help') != -1) {
      ontop(7);
      ontop(17); //ontop(gravtool); 
      RegisterActive('help') ;
    }
    else if (toolid.indexOf('zoomin')     != -1) {
        ontop(2);
        RegisterActive('navigation') ;
        mainmap.zoomin('map');   
    }
    else if (toolid.indexOf('zoomout')     != -1) {
        ontop(2);      
        RegisterActive('navigation') ;
        mainmap.zoomout('map');   
    }    
    else if (toolid.indexOf('Move')     != -1) {
        mainmap.Move('map');   
        ontop(2);                  
        RegisterActive('navigation') ;
    }
    else if (toolid.indexOf('Maplayer') != -1) {
      ontop(3);
      ontop(14);  //ontop4(layertool);     
      RegisterActive('maplayer') ;
      mainmap.zoomin('map');  
      
    }
    else if (toolid.indexOf('surface') != -1){           
      ontop(6);
      RegisterActive('additionals');
      setActiveStatictool('surface') ;
      mainmap.surface('map'); 
    }
    else if (toolid.indexOf('distance') != -1 ) {  
      ontop(6);
      RegisterActive('additionals');
      setActiveStatictool('distance') ;
      mainmap.distance('map'); 
    }                
}
// #########################################################
// 
// Wechsel zwischen dem aktiven und passiven Registerkartenbild

function RegisterActive(folder2){
 //---------------------------------------------	
  //document.carto_form.js_folder_name.value = arr.length ;
  //---------------------------------------------	
    
  var folder1 = document.carto_form.register_1.value ;
  
  //--------------------------------------
  // altes aktives Bild
  var bildId1 = 'reg_' + folder1 ;
  var from = bildId1 + '2.gif';
  var to   = bildId1 + '1.gif';
  
  var elt = xGetElementById( bildId1 );
  if (elt != null){
     pic = elt.getAttribute('src');
     re = new RegExp(from);
     newpic = pic.replace(re, to);
  
     if (newpic != pic) {
          elt.setAttribute('src', newpic);
     }
  }
  //--------------------------------------
  // neues aktives Bild
  var bildId2 = 'reg_' + folder2 ;
  from =  bildId2 + '1.gif';
  to   =  bildId2 + '2.gif';
  
  elt = xGetElementById( bildId2 );


  if (elt != null){
     pic = elt.getAttribute('src');
     re = new RegExp(from) ;
     newpic = pic.replace(re, to);
 
     if (newpic != pic) {
          elt.setAttribute('src', newpic);
     }
   }

   document.carto_form.register_1.value  = folder2 ;     
 }       
//----------------------------------------------------
// EventManager lädt zu Beginn setupFolders
//EventManager.Add(window, 'load', setInitialToolButton, false);


//----------------------------------------------------
//
// Größenänderung des Fensters

function WindowResize() {
        
        //var stat = window.status ;
        //var navType = navigator.appName ;
        //document.carto_form.testout.value = stat ; 
        var listId = document.carto_form.mapsize.value ;
                
        
        switch(listId){
        case "0":
           window.resizeTo(790,660) ;
           
           break;      
        case "1": 
           window.resizeTo(950,740);
           
           break;
        case "2":
           window.resizeTo(1200,920) ;
           
           break;           
        }
        
}        
//----------------------------------------------------
// EventManager lädt zu Beginn setupFolders
EventManager.Add(window, 'load', WindowResize, false);


//------------------------------------------------
function checkRadio(id) {
  xGetElementById(id).checked = 'checked';
}
//-------------------------------------------------------------
function setSearchFrame(project, type) {
  var ifr = document.getElementById('search');
  ifr.style.height = '350px';
  ifr.src = project + '/search/index.php?project=' + project + '&searchname=' + type;
}
//----------------------------------------------------
function resetSession() {
    elm = xGetElementById('fake_reset');
    elm.name = 'reset_session';
    elm.value = 'reset_session';
    document.carto_form.posted.value=0;
    doSubmit();
}
//----------------------------------------------------
function clearQuery() {
    elm = xGetElementById('fake_query');
    elm.name = 'query_clear';
    elm.value = 'query_clear';
    doSubmit();
}
//----------------------------------------------------
function submitGravityOK() {
    document.carto_form.gravity_ok.value = 1;
    doSubmit();	
}

//----------------------------------------------------
function submitZoneOK() {
 
//alert(' submitZoneOK' );        
    document.carto_form.Raster.value = 'zone' ;
    document.carto_form.zone_ok.value = 1;
    
    var minx = document.carto_form.Mminx.value ;
    var maxx = document.carto_form.Mmaxx.value ;
    var miny = document.carto_form.Mminy.value ;
    var maxy = document.carto_form.Mmaxy.value ;
    
    var dx = maxx - minx ;
    var dy = maxy - miny ;
    
    var dd = Math.max(dx,dy);
    // Ausschnitt begrenzen
    if (dd > 50) {
        document.carto_form.Raster.value = 'topo' ;
        document.carto_form.zone_ok.value = 0;                    
        alert('The area is too big for the computation of gravity zones. Please select a smaller area!');
        //window.open("./SISproject/ErrAusschnitt.htm", "Zweitfenster", 
        //            "scrollbars=no,resizable=no,status=no,width=300,height=200,screenX="+x1+",screenY="+y1);  
    }else{
      
      doSubmit();	
    }
}
//----------------------------------------------------
function MapSectionSelected() {
    
    document.carto_form.mapsection_ok.value = 1 ;   
    
    document.carto_form.box_xmin.value = document.carto_form.pminx.value ;
    document.carto_form.box_xmax.value = document.carto_form.pmaxx.value ;
    document.carto_form.box_ymin.value = document.carto_form.pminy.value ;
    document.carto_form.box_ymax.value = document.carto_form.pmaxy.value ;
    
    
    doSubmit();
}
//----------------------------------------------------
function SelectContinent() {
  
  document.carto_form.Raster.value = 'topo' ;
  document.carto_form.Contour.value = '' ;
  
  ix = document.carto_form.continents.value ;
  document.carto_form.cont_ok.value =  ix;
  
  doSubmit();
}
//----------------------------------------------------
function SetContinent(ix) {
  
  document.carto_form.Raster.value = 'topo' ;
  document.carto_form.Contour.value = '' ;
  document.carto_form.continents.value = ix ;
  document.carto_form.cont_ok.value = ix ;
  
  doSubmit();
}
//----------------------------------------------------
function CitySearch() {
    
    document.carto_form.gravp_x.value = '';
    document.carto_form.gravp_y.value = '';
    document.carto_form.gravp_h.value = '';
    
    document.carto_form.citysearch_ok.value = 1 ;   
        
    doSubmit();
}
//----------------------------------------------------
function NewCitySearch() {
    
    document.carto_form.gravp_x.value = '';
    document.carto_form.gravp_y.value = '';
    document.carto_form.gravp_h.value = '';
    
    document.carto_form.newcitysearch.value = 1 ;   
        
    doSubmit();
}
//-----------------------------------------------------
function CityListSelected() {
        
    document.carto_form.citylist_ok.value = 1 ;   
        
    doSubmit();	 	
}

//---------------------------------------------------------
// Kreis zeichnen
function dPoint(aDisplay,xp,yp) {
	
var feature = new Point();
    
  if (aDisplay._map.onNewFeature)
    aDisplay._map.onNewFeature(feature);

  // aDisplay._map.currentLayer.features.push(feature);
  aDisplay.currentLayer = xGetElementById(aDisplay.id + "_" + aDisplay._map.currentLayer.id);
 
 
      
  var dShape = aDisplay.addDiv(aDisplay.currentLayer, 0, 0, null, null);
  dShape.id = dShape.title = aDisplay.id + "_" + feature.id;
  dShape.X = new Array();
  dShape.Y = new Array();
  aDisplay.feature = feature;
  aDisplay.dShape = dShape;
  
  aDisplay._map.updateFeaturesCount();
  
  
  //------------------------------------------------------
  projection = document.carto_form.jsMapProjection.value ;
  
  // Koordinatentransformation
  //ex = geo2Pix(xp, aDisplay._map.extent.xmin, aDisplay._map.extent.xmax, 0, aDisplay._width) ;
  //ey = geo2Pix(yp, aDisplay._map.extent.ymax, aDisplay._map.extent.ymin, 0, aDisplay._height) ;
   var coo = Proj2Pix(projection, xp, aDisplay._map.extent.xmin, aDisplay._map.extent.xmax, 0, aDisplay._width,
                                  yp, aDisplay._map.extent.ymax, aDisplay._map.extent.ymin, 0, aDisplay._height);  
  
   ex = coo[0] ;
   ey = coo[1] ;
   
  // document.carto_form.testout.value  = ex ;
  // document.carto_form.testout2.value = ey
   //------------------------------------------------
  
  var vertex = new Vertex(ex, ey) ;
  vertex.index = aDisplay.feature.vertices.length;
  
  pts = 40 ;
  wi = 2*Math.PI/pts ; 
  r = 15 ;
  xx = r*Math.cos(wi) + ex ;
  yy = r*Math.sin(wi) + ey ;
  	
  aDisplay.dShape.X.push(xx);
  aDisplay.dShape.Y.push(yy);
       
  for (i=1; i<=pts; i++){
    	
  	xx = r*Math.cos(i*wi) + ex ;
  	yy = r*Math.sin(i*wi) + ey ;
  	
  	aDisplay.dShape.X.push(xx);
        aDisplay.dShape.Y.push(yy);
                 
       dp = aDisplay.drawLine(aDisplay.dShape, xx, yy,
      aDisplay.dShape.X[i - 1], aDisplay.dShape.Y[i - 1],
      _OFF);
      
  }
    
 } 
//-----------------------------------------------------
function GravMarker(map){

   
   map.setCurrentLayer('gravpoint');
      
   var xp = xGetElementById('gravp_x');
   var yp = xGetElementById('gravp_y');
   
   var ok = xGetElementById('gravity_ok');
   
   var aDisplay = map.getDisplay('map'); 
   
   
   if (ok.value > 0){
       dPoint(aDisplay,xp.value,yp.value) ;
       document.carto_form.gravity_ok.value = 0 ; 
    }
}
//----------------------------------------------------
// EventManager lädt zu Beginn setupFolders
//EventManager.Add(window, 'load', setupGravMarker, false);

function HelpHref(url)
{
 ontop(17);
 document.carto_form.target = 'helpFenster';
 window.location.href = url;
}
//-------------------------------------------------
// (1)     ontop
//---------------

  
function helpix(id) {
	
   ontop(18);
//var myform = document.forms['carto_form'] ; 
currentFolder = myhelp[12];
// document.carto_form.grav_out.value = currentFolder.id.substring(4,6);
 
 var act = 0 ;
 
  for (i = 0; i < myhelp.length; i++) {
    currentFolder = myhelp[i];
    current = currentFolder.id.substring(4,6);
    //currentLabel = xGetElementById('helpid' + current);
    
        
    
    if (current == id) {
      currentFolder.style.display = "inline";
    //  currentLabel.className = 'active';
    act = current;
    } else {
      currentFolder.style.display = "none";
    //  currentLabel.className = '';
    }
//    document.carto_form.grav_out.value = act ;
//    document.carto_form.grav_out2.value = id ;
  }
}



//--------------------------------------------------
function setActiveStatictool(toolid) {
	
   
  //---------------------------------------------	
	
  for (var i = 0; i < cw3_tools.length; i++) {
  
    
    
    var elt = xGetElementById(cw3_tools[i] + "_stat");
   	
    if(elt != null) {
      if (cw3_tools[i] == toolid) {
      	      	
        var from = cw3_tools[i] + '.gif';
        var to = cw3_tools[i] + '_active.jpg';
      } else {
        var from = cw3_tools[i] + '_active.jpg';
        var to = cw3_tools[i] + '.gif';
      }
     
      var pic = elt.getAttribute('src');
      var re = new RegExp(from);
      var newpic = pic.replace(re, to);
       
      if (newpic != pic) {
        elt.setAttribute('src', newpic);
      }
     }
  }
}


//-------------------------------------------------
// (1)     How to Start
//---------------

  
function howto() {
	
   ontop(7);	
   ontop(18);

   currentFolder = myhelp[1];
   
   currentFolder.style.display = "inline";
}
//-------------------------------------------------
// Setzen der Eichwerteliste(VSI) aufgrund der Instrumentenklasse
function setClassList(){
        
    var class2 = new Array(3) ;
    class2[0] = '10000';
    class2[1] = '20000';
    class2[2] = '50000';
    
    var class3 = new Array(9) ;
    class3[0] = '500';
    class3[1] = '1000';
    class3[2] = '2000';
    class3[3] = '3000';
    class3[4] = '4000';
    class3[5] = '5000';
    class3[6] = '6000';
    class3[7] = '8000';
    class3[8] = '10000';
    
    var class4 = new Array(4) ;
    class4[0] = '100';
    class4[1] = '300';
    class4[2] = '500';
    class4[3] = '1000';
    
    //---------------------------------    
    var classitem = document.carto_form.classlist.value ;
       
   
    var len = document.carto_form.vsilist.length;
    
    var newlen = len ;
    //-------------------------------
    // Einträge löschen
    for (j=0 ; j<len; j++){
        newlen = newlen - 1 ;
        document.carto_form.vsilist.remove(newlen);
    }
    
    
    //-------------------------------
    
    switch (classitem) {
    case '0':
    
   
    for (i=0;i<3;i++){
        NeuerEintrag = new Option(class2[i], class2[i], false);
       document.carto_form.vsilist.options[i] = NeuerEintrag ;
    }
    document.carto_form.vsilist.selectedIndex = 0 ;
    
    break;
    
    case '1':
    
    for (i=0;i<9;i++){
        NeuerEintrag = new Option(class3[i], class3[i], false);
       document.carto_form.vsilist.options[i] = NeuerEintrag ;
    }
    document.carto_form.vsilist.selectedIndex = 3 ;
    
    break;
    case '2':
    for (i=0;i<4;i++){
        NeuerEintrag = new Option(class4[i], class4[i], false);
       document.carto_form.vsilist.options[i] = NeuerEintrag ;
    }
    document.carto_form.vsilist.selectedIndex = 0 ;
    break;
    }
    
}
//----------------------------------------------------
// EventManager lädt zu Beginn setupFolders
//EventManager.Add(window, 'load', setClassList, false);

//-----------------------------------------------------
// Besucherzähler

function counter(){
        
    var cnt = document.carto_form.sessnum.value ;
    var oldcnt = cnt - 1 ;
    
    oc = oldcnt + '';
    nc = cnt + '';
    
    var olen = oc.length;
    var nlen = nc.length;
    if (olen < nlen){
        oc = '0' + oldcnt;
    } 
    
    for (i=1;i<=nlen;i++){
      bildId = 'count_' + i ;  
      var elt = xGetElementById( bildId);
 
      if(elt != null) {
          
          var from =  '0.gif'; //
          var to   = nc[nlen - i] + '.gif';
       
//document.carto_form.testout.value = from;
//document.carto_form.testout2.value = to;      
         
        var pic = elt.getAttribute('src');
        var re = new RegExp(from);
        var newpic = pic.replace(re, to);
       
        //if (newpic != pic) {
  
          elt.setAttribute('src', newpic);
        //}
     }
   }
}

//EventManager.Add(window, 'load', counter, false);

