<?php
// rangegeo.php
// countries.geojson
//  data-iso2="XX"
//  <area 
//   are 
//   ]
//   [
//   '></area>

  ini_set('max_execution_time', 6000);
  
  $minlat=0;
  $minlong=0;
  $maxlat=0;
  $maxlong=0;
  $cstuff='';
  $delim='';
  $valafters='';
  $evn=1;
  $opcss='';
  $tenthousand=10000;
  
  if (isset($_GET['geojson']) && isset($_GET['ccode'])) {
  if (isset($_GET['justthat'])) {   $opcss="opacity:0.3;"; $tenthousand=120000; }
  $extras='';
  $extra='';
  $bigxy=file_get_contents('../../HTMLCSS/countries.html');
  //$smallxy=file_get_contents('./image_chart.php');
  $thelist=explode(',', str_replace('CN','CH',str_replace('+',' ',urldecode($_GET['ccode']))));
  if (1 == 1) {
  for ($iii=0; $iii<sizeof($thelist); $iii++) {
  $thislen=-1;
  $prevlen=-1;
  $exts='';
  $preexts='';
   $recs=explode(' data-iso2="' . $thelist[$iii] . '"', $bigxy);
   //$records=explode(',' . $thelist[$iii] . ',', $smallxy);
   if (sizeof($recs) > 1) { // && sizeof($records) > 1) {
     for ($ii=1; $ii<sizeof($recs); $ii++) {
      $thislen=strlen(str_replace('[','',str_replace(']','',explode("'", explode("ates are", $recs[$ii])[1])[0])));
      $cclls=explode(',', str_replace('[','',str_replace(']','',explode("'", explode("ates are", $recs[$ii])[1])[0])));
  if (1 == 1) {
      //for ($jj=0; $jj<sizeof($cclls); $jj++) {
      //$records=explode('context.moveTo(' . $cclls[0] . ',' . $cclls[1] . ');', $bigxy);
      //if (sizeof($records) == 2) {
      //  $downto=explode('.stroke();', $records[1])[0] . '.stroke();';
      //  $rest=substr($records[1], strlen($downto));
      //}
      if (1 == 1) {
      if ($thislen <= $prevlen) {
      $preve=$extra;
      $extra=" jaconto.addEventListener('click', () => console.log('clicked')); 
 evt" . $evn . " = new MouseEvent('click', {
  clientX: " . (180 + $cclls[0]) . ",
  clientY: " . (90 - $cclls[1]) . "
 });
 setTimeout(function() { iaconto.canvasclick(evt" . $evn . "); }, " . ($evn * $tenthousand) . ");  " . $preve;
      $preexts.="  for (xij=0; xij<xars.length; xij++) { if (xars[xij].outerHTML.indexOf(' title=\"" . explode('.',('' . (180 + $cclls[0])))[0] . ".') != -1) { if (xars[xij].innerHTML.indexOf('<div ') == -1) { if (Math.abs(" . (180 + $cclls[0]) . " - eval(xars[xij].outerHTML.split(' title=\"')[1].split(',')[0])) < 0.00001) {    xars[xij].innerHTML=xars[xij].innerHTML.replace(/lime/g, 'orange').replace(/rgb\(50\,\ 205\,\ 50\)/g, 'orange').replace(/rgb\(50\,205\,50\)/g, 'orange'); if (justthat) {  justthatbih+=xars[xij].outerHTML; }   } } } } ";
      } else {
      $exts=" jaconto.addEventListener('click', () => console.log('clicked')); 
 evta.push(new MouseEvent('click', {
  clientX: " . (180 + $cclls[0]) . ",
  clientY: " . (90 - $cclls[1]) . "
 }));
 setTimeout(function() { iaconto.canvasclick(evta[" . (-1 + $evn) . "]); }, " . ($evn * $tenthousand) . "); ";
      $extra.=" jaconto.addEventListener('click', () => console.log('clicked')); 
 evt" . $evn . " = new MouseEvent('click', {
  clientX: " . (180 + $cclls[0]) . ",
  clientY: " . (90 - $cclls[1]) . "
 });
 setTimeout(function() { iaconto.canvasclick(evt" . $evn . "); }, " . ($evn * $tenthousand) . ");  
";
      $preexts.="  for (xij=0; xij<xars.length; xij++) { if (xars[xij].outerHTML.indexOf(' title=\"" . explode('.',('' . (180 + $cclls[0])))[0] . ".') != -1) {  if (xars[xij].innerHTML.indexOf('<div ') == -1) { if (Math.abs(" . (180 + $cclls[0]) . " - eval(xars[xij].outerHTML.split(' title=\"')[1].split(',')[0])) < 0.00001) {   xars[xij].innerHTML=xars[xij].innerHTML.replace(/lime/g, 'orange').replace(/rgb\(50\,\ 205\,\ 50\)/g, 'orange').replace(/rgb\(50\,205\,50\)/g, 'orange'); if (justthat) {  justthatbih+=xars[xij].outerHTML; }  } } } } ";
      $prevlen=$thislen; 
      }
      //$evn++;
      } else {
      $bigxy=str_replace('context.moveTo(' . $cclls[0] . ',' . $cclls[1] . ');' . $downto . $rest, " context.strokeStyle = '#0000ff'; " . 'context.moveTo(' . $cclls[0] . ',' . $cclls[1] . ');' . $downto . " context.strokeStyle = '#000000'; " . $rest, $bigxy);
      }
      }
  //}
     }
   }
  $extras.=$preexts . $exts;
  $evn++;
  }
  }
  echo "<html><head><title>GeoJson World Countries via Google Chart Image Chart Map Chart - RJM Programming - November, 2023</title>
  <!--style>
    body { 
      cursor: progress; 
    }
  </style-->
  <script type=text/javascript> 
    var evt1, evt2, evt3, evt4, evt5, evt6, evt7, evt8, evt9;
    var evta=[];
    
    var startw=eval((window.orientation == 0 ? window.innerHeight: window.innerWidth));
    var starth=eval((window.orientation == 0 ? window.innerWidth: window.innerHeight));
    var wasw=startw;
    var wash=starth;
    
    var documentURL=document.URL; //.replace(/\%\,/g,'%25,').replace(/\%\&/g,'%25&').replace(/\%$/g,'%25');
    var justrectimg=null;
    var justinfill=false, justincover=false, justincontain=false, justid='', justido=null, prejust='', justrect=null, justimgo=null;
    
    if (document.URL.indexOf('justthat=+') != -1 || document.URL.indexOf('justthat=%20') != -1) {
       justinfill=true;
       documentURL=documentURL.replace('justthat=+', 'justthat=').replace('justthat=%20', 'justthat='); 
    }
    var justthatzoom='1.0', justzoomcss='';
    var justthat=(document.URL.indexOf('justthat=') == -1 ? false : true);
    var justthatoverlay=(document.URL.indexOf('justthat=overlay') == -1 ? false : true);
    var justthatbih='';
            
    var xars=[];
    var xij;

    if (documentURL.indexOf('justthat=cover') != -1) {
       justincover=true;
       documentURL=documentURL.replace('justthat=cover', 'justthat='); 
       //justimgo=document.getElementsByTagName('img')[0];
    } else if (documentURL.indexOf('justthat=contain') != -1) {
       justincontain=true;
       documentURL=documentURL.replace('justthat=contain', 'justthat='); 
       //justimgo=document.getElementsByTagName('img')[0];
       //alert(justimgo);
    }

    if (documentURL.indexOf('justthat=idis') != -1) {
       prejust=documentURL.split('justthat=idis')[1].split('&')[0].split('#')[0];
       justid=decodeURIComponent(prejust).trim();
       if (document.getElementById(justid)) {
          justido=document.getElementById(justid);
          startw=eval('' + justido.getBoundingClientRect().width);
          starth=eval('' + justido.getBoundingClientRect().height);
          justimgo=document.getElementsByTagName('img')[0];
       documentURL=documentURL.replace('justthat=idis' + prejust, 'justthat='); 
       } else if (window.parent) {
          if (parent.document.getElementById(justid)) {
           justido=parent.document.getElementById(justid);
          startw=eval('' + justido.getBoundingClientRect().width);
          starth=eval('' + justido.getBoundingClientRect().height);
           justimgo=parent.document.getElementsByTagName('img')[0];
       documentURL=documentURL.replace('justthat=idis' + prejust, 'justthat='); 
          } else if (window.top) {
           if (top.document.getElementById(justid)) {
            justido=top.document.getElementById(justid);
          startw=eval('' + justido.getBoundingClientRect().width);
          starth=eval('' + justido.getBoundingClientRect().height);
            justimgo=top.document.getElementsByTagName('img')[0];
       documentURL=documentURL.replace('justthat=idis' + prejust, 'justthat='); 
           }
          }
       }
    }

    if (1 == 2) {
    //if (documentURL.indexOf('justthat=cover') != -1) {
    //   justincover=true;
    //   documentURL=documentURL.replace('justthat=cover', 'justthat='); 
    //   justimgo=document.getElementsByTagName('img')[0];
    //} else if (documentURL.indexOf('justthat=contain') != -1) {
    //   justincontain=true;
    //   documentURL=documentURL.replace('justthat=contain', 'justthat='); 
    //   justimgo=document.getElementsByTagName('img')[0];
    //   //alert(justimgo);
    //}
    if (justincover) {
       if (justido != null && justimgo != null) {
         justrect=justido.getBoundingClientRect();
         justrectimg=justimgo.getBoundingClientRect();
         documentURL=documentURL.replace('justthat=', 'justthat=' + encodeURIComponent(both('' + eval(startw / justrectimg.width) + ';' + eval(starth / justrectimg.height))) + '&xjunkx=');
       } else if (justimgo != null) {
         justrectimg=justimgo.getBoundingClientRect();
         documentURL=documentURL.replace('justthat=', 'justthat=' + encodeURIComponent(both('' + eval((window.orientation == 0 ? window.innerHeight: window.innerWidth) / justrectimg.width) + ';' + eval((window.orientation == 0 ? window.innerWidth: window.innerHeight) / justrectimg.height))) + '&xjunkx=');
       }
    }
    if (justincontain) {
       if (justido != null && justrectimgo != null) {
         justrect=justido.getBoundingClientRect();
         justrectimg=justimgo.getBoundingClientRect();
         documentURL=documentURL.replace('justthat=', 'justthat=' + Math.min(eval(startw / justrectimg.width),eval(starth / justrectimg.height)) + '&xjunkx=');
       } else if (justimgo != null) {
         justrectimg=justimgo.getBoundingClientRect();
         documentURL=documentURL.replace('justthat=', 'justthat=' + Math.min(eval((window.orientation == 0 ? window.innerHeight: window.innerWidth) / justrectimg.width),eval((window.orientation == 0 ? window.innerWidth: window.innerHeight) / justrectimg.height)) + '&xjunkx=');
         //alert(documentURL);
       }
    }
    }
    
    if ((!justincover && !justincontain) || 7 == 7) {
    justthatzoom=(documentURL.indexOf('justthat=0') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=1') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=2') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=3') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=4') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=5') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=6') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=7') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=8') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=9') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    //alert(justthatzoom);
    justthatzoom=both(justthatzoom);
    if (justthatzoom != '1.0') { justzoomcss=('transform:scale(' + justthatzoom + ')').replace(/\ /g,'');  }
    }
    
  function ourdecodeURIComponent(inid) {
    if (inid.indexOf('%,') != -1 || inid.indexOf('%&') != -1 || (' ' + inid).slice(-1) == '%') {
       return inid;
    }
    return decodeURIComponent(inid);
  }
    
  function both(inwh) { 
    var bparts=[];
    //alert(inwh);
    if (inwh.indexOf(';') != -1) {
      if (inwh.indexOf('%') != -1) {
      bparts=inwh.split(';');
      if (bparts[0].indexOf('%') != -1) {
      bparts[0]='' + (eval(eval('' + bparts[0].split('%')[0]) / 100.0));
      }
      if (bparts[1].indexOf('%') != -1) {
      bparts[1]='' + (eval(eval('' + bparts[1].split('%')[0]) / 100.0));
      }
      return '' + bparts[0] + ';' + bparts[1];
      }
    } else if (inwh.indexOf(',') != -1) {
      if (inwh.indexOf('%') != -1) {
      bparts=inwh.split(',');
      //alert(inwh + ' ... ' + bparts[1]);
      if (bparts[0].indexOf('%') != -1) {
      bparts[0]=('' + wprop(bparts[0] + 'px')).replace(/px$/g,''); //'' + (eval(eval('' + bparts[0].split('%')[0]) / 100.0));
      }
      if (bparts[1].indexOf('%') != -1) {
      bparts[1]=('' + hprop(bparts[1] + 'px')).replace(/px$/g,''); //'' + (eval(eval('' + bparts[1].split('%')[0]) / 100.0));
      }
      startw=eval('' + bparts[0]);
      starth=eval('' + bparts[1]);
      if (!justincontain && !justincover) { justincover=true; }
      return '' + bparts[0] + ',' + bparts[1];
      }
    } else if (inwh.indexOf('%') != -1) {
     return '' + (eval(eval('' + inwh.split('%')[0]) / 100.0));
    } 
    return inwh;
  }
  
 function wprop(inw) {
   var outw=inw;
   //var startw=eval((window.orientation == 0 ? window.innerHeight: window.innerWidth));
   if (prejust == '') {
    startw=eval((window.orientation == 0 ? window.innerHeight: window.innerWidth));
    starth=eval((window.orientation == 0 ? window.innerWidth: window.innerHeight));
   }
   if (inw.indexOf('%px') != -1) {
     return ''+ Math.round(eval(eval('' + inw.split('%')[0]) * startw / 100.0)) + 'px';
   } else if (inw.toLowerCase().indexOf('vwpx') != -1) {
     return ''+ Math.round(eval(eval('' + inw.toLowerCase().split('vw')[0]) * startw / 100.0)) + 'px';
   } else if (inw.toLowerCase().indexOf('pxpx') != -1) {
     return outw.substring(0, eval(-2 + outw.length));
   } else if (inw.indexOf('0px') == -1 && inw.indexOf('1px') == -1 && inw.indexOf('2px') == -1 && inw.indexOf('3px') == -1 && inw.indexOf('4px') == -1 && inw.indexOf('5px') == -1 && inw.indexOf('6px') == -1 && inw.indexOf('7px') == -1 && inw.indexOf('8px') == -1 && inw.indexOf('9px') == -1) {
     return outw.substring(0, eval(-2 + outw.length));
   }
   return outw;
 } 
  
 function hprop(inh) {
   var outh=inh;
   if (prejust == '') {
    startw=eval((window.orientation == 0 ? window.innerHeight: window.innerWidth));
    starth=eval((window.orientation == 0 ? window.innerWidth: window.innerHeight));
   }
   //alert(inh);
   if (inh.indexOf('%px') != -1) {
     return ''+ Math.round(eval(eval('' + inh.split('%')[0]) * starth / 100.0)) + 'px';
   } else if (inh.toLowerCase().indexOf('vhpx') != -1) {
     return ''+ Math.round(eval(eval('' + inh.toLowerCase().split('vw')[0]) * starth / 100.0)) + 'px';
   } else if (inh.toLowerCase().indexOf('pxpx') != -1) {
     return outh.substring(0, eval(-2 + outh.length));
   } else if (inh.indexOf('0px') == -1 && inh.indexOf('1px') == -1 && inh.indexOf('2px') == -1 && inh.indexOf('3px') == -1 && inh.indexOf('4px') == -1 && inh.indexOf('5px') == -1 && inh.indexOf('6px') == -1 && inh.indexOf('7px') == -1 && inh.indexOf('8px') == -1 && inh.indexOf('9px') == -1) {
     return outh.substring(0, eval(-2 + outh.length));
   }
   return outh;
 } 
      
 function jfonl() {
  //if (justthat) { document.body.style.cursor='progress'; }
  if (justthatzoom.indexOf(',') != -1) {  document.body.style.width='' + wprop(justthatzoom.split(',')[0] + 'px');   document.body.style.height='' + hprop(justthatzoom.split(',')[1] + 'px'); } else if (justzoomcss.indexOf(';') != -1) {  if (1 == 2) { document.body.style.transform='scale(' + justthatzoom.replace(';',',') + ')';  document.body.style.transformOrigin='left'; }   } else if (justzoomcss != '') { if (prejust == '' && (wash != starth || wasw != startw)) { justthatzoom='' + Math.min(eval(startw / justrectimg.width),eval(starth / justrectimg.height));  }  document.body.style.zoom='' + justthatzoom + '';  }
  if (('' + location.hash).indexOf(',') != -1 || ('" . str_replace('+',' ',urldecode($_GET['ccode'])) . "').indexOf(',') != -1) {
  var inidea='" . str_replace('+',' ',urldecode($_GET['ccode'])) . "';
  location.hash='#' + inidea;
  //alert(inidea + ' vs ' + location.hash);
  ifonl(inidea.replace('#','').split(',')[0]);
  }
}
    
   
function ifonl(inidea) {
  var outidea=inidea;
  var gcsuff='%20[~' + inidea + '~,2]';
  if (decodeURIComponent('' + location.hash).indexOf(',') != -1) {
  var prefix=null;
  var jprefix=null;
  if (window.top !== window) {
  prefix=top.document.getElementById('kfrepos').src.split('&iso=')[0] + '&iso=';
  jprefix=(top.document.getElementById('jfrepos').src.split('&data=')[0]).replace('Greenwich%20London%20Places', 'My%20World%20Countries') + '&data=';
  } else if (!document.getElementById('kfrepos')) {
  return outidea;
  } else {
  prefix=document.getElementById('kfrepos').src.split('&iso=')[0] + '&iso=';
  jprefix=(document.getElementById('jfrepos').src.split('&data=')[0]).replace('Greenwich%20London%20Places', 'My%20World%20Countries') + '&data=';
  }
  if (jprefix.indexOf(';My') != -1) {
     jprefix=jprefix.replace(jprefix.split('title=')[1].split(';')[0] + ';', '').replace(/\&are/g,'&arJUNKe').replace('peninfo=','penJUNKinfo=');
  }
  var moref=decodeURIComponent('' + location.hash).split(',');
  for (var im=1; im<moref.length; im++) {
    outidea+='&iso' + eval(1 + im) + '=' + moref[im];
    gcsuff+='%20,%20[~' + moref[im] + '~,2]';
  } 
  //alert(jprefix);
  //alert(gcsuff);
  if (window.top != window) {
    if (top.document.getElementById('kfrepos').src.indexOf(outidea) == -1) {
    top.document.getElementById('kfrepos').src=prefix + outidea;
    top.document.getElementById('jfrepos').src=jprefix + '&data=' + gcsuff;
    }
  } else {
    if (document.getElementById('kfrepos').src.indexOf(outidea) == -1) {
    document.getElementById('kfrepos').src=prefix + outidea;
    document.getElementById('jfrepos').src=jprefix + '&data=' + gcsuff;
    }
  }
  }
  return outidea;
}

  function coordscale(affecting, jtz) {
   var idv=0, jdv=0, pdelim='';
   var factorx=eval('' + jtz.split(',')[0]);
   var factory=eval('' + jtz.split(',')[1]);
   var topis='', leftis='', widthis='', heightis='', pstris='', pco=[], newpstris='';
   var newsc=affecting;
   // left: top: width: height: points=
   
   var divsare=affecting.split('<div ');
   newsc=affecting[0].replace(/^\<$/g,''); // + '<div ';
   //alert(divsare.length);
   
   for (idv=1; idv<divsare.length; idv++) {
     pdelim='';
     newpstris='';
     pstris=divsare[idv].split(' points=\"')[1].split('\"')[0];
     pco=pstris.replace(/\ /g,',').split(',');
     for (jdv=0; jdv<pco.length; jdv+=2) {
       newpstris+=pdelim + eval(factorx * pco[jdv]) + ',' + eval(factory * pco[eval(1 + jdv)]);
       pdelim=' ';
     }
     topis=divsare[idv].split('top:')[1].split('px')[0].split(';')[0].split('\"')[0];      
     leftis=divsare[idv].split('left:')[1].split('px')[0].split(';')[0].split('\"')[0];      
     widthis=divsare[idv].split('width:')[1].split('px')[0].split(';')[0].split('\"')[0];      
     heightis=divsare[idv].split('height:')[1].split('px')[0].split(';')[0].split('\"')[0]; 
     //console.log('topis=' + topis + ' and heightis=' + heightis);
     newsc+='<div ' + divsare[idv].replace(pstris,newpstris).replace('top:' + topis, 'top:' + eval(eval('' + topis.trim()) * factory)).replace('left:' + leftis, 'left:' + eval(eval('' + leftis.trim()) * factorx)).replace('height:' + heightis, 'height:' + eval(eval('' + heightis.trim()) * factory)).replace('width:' + widthis, 'width:' + eval(eval('' + widthis.trim()) * factorx));    
   }
   
   return newsc;
  }


  function whatwas(newih) { //}, oldih) {
    var interim='';
    if (justinfill) {
       for (var ij=0; ij<xars.length; ij++) {
          if (('' + xars[ij].title).indexOf(',') != -1) {
            if (newih.indexOf('' + xars[ij].title) == -1) {
              newih+=xars[ij].outerHTML.replace(/lime/g, 'yellow');
            }
          }
       }
    }
    
    //if (prejust == '') { alert('startw=' + startw + ' and wasw=' + wasw + ' and justthatzoom=' + justthatzoom + ' and justzoomcss=' + justzoomcss); }
    if (justzoomcss.indexOf(';') != -1) { 
      //interim='<div style=' + justzoomcss.replace(';',',').replace(/\ /g,'') + ';>' + newih + '</div>';
      if (prejust == '' && (wash != starth || wasw != startw)) { justthatzoom='' + eval(startw / justrectimg.width) + ',' + eval(starth / justrectimg.height);  }  
      newih=coordscale(newih, justthatzoom.replace(';',',')); 
    } else if (justthatzoom.indexOf(',') != -1 && !justincontain && !justincover) { 
      if (prejust == '' && (wash != starth || wasw != startw)) { justthatzoom='' + eval(startw / justrectimg.width) + ',' + eval(starth / justrectimg.height);  }  
      //newih=coordscale(newih, '' + eval(eval('' + justthatzoom.split(',')[0]) / eval('' + justimgo.getBoundingClientRect().width)) + ';' + eval(eval('' + justthatzoom.split(',')[1]) / eval('' + justimgo.getBoundingClientRect().height))   ); 
      newih=coordscale(newih, justthatzoom.replace(';',',')); 
    }
    
    setTimeout(function(){
      //alert(justthatzoom);

    if (justthatzoom.indexOf(',') != -1) {  document.body.style.width='' + justthatzoom.split(',')[0] + 'px';   document.body.style.height='' + justthatzoom.split(',')[1] + 'px'; } else if (justzoomcss.indexOf(';') != -1) { if (1 == 2) { document.body.style.transform='scale(' + justthatzoom.replace(';',',') + ')'; }  } else if (justzoomcss != '') { document.body.style.zoom='' + justthatzoom + ''; }
    }, 2000);
    return newih;
  }    
       
    function dolater(iois) {   if (iois != null) {
    var jaconto=(iois.contentWindow || iois.contentDocument);
    var iaconto=jaconto;
    if (jaconto != null) {
       if (jaconto.document) { jaconto = jaconto.document; }
       if (jaconto.body != null) {

    if (justincover) { //if (documentURL.indexOf('justthat=cover') != -1) {
       justincover=true;
       documentURL=documentURL.replace('justthat=cover', 'justthat='); 
       justimgo=jaconto.getElementsByTagName('img')[0];
    } else if (justincontain) { //documentURL.indexOf('justthat=contain') != -1) {
       justincontain=true;
       documentURL=documentURL.replace('justthat=contain', 'justthat='); 
       justimgo=jaconto.getElementsByTagName('img')[0];
       //alert(justimgo);
    }
    if (documentURL.indexOf('justthat=idis') != -1) {
       prejust=documentURL.split('justthat=idis')[1].split('&')[0].split('#')[0];
       justid=decodeURIComponent(prejust).trim();
       documentURL=documentURL.replace('justthat=idis' + prejust, 'justthat='); 
       if (jaconto.getElementById(justid)) {
          justido=jaconto.getElementById(justid);
          startw=eval('' + justido.getBoundingClientRect().width);
          starth=eval('' + justido.getBoundingClientRect().height);
          justimgo=jaconto.getElementsByTagName('img')[0];
       } else if (document.getElementById(justid)) {
          justido=document.getElementById(justid);
          startw=eval('' + justido.getBoundingClientRect().width);
          starth=eval('' + justido.getBoundingClientRect().height);
          justimgo=document.getElementsByTagName('img')[0];
       } else if (window.parent) {
          if (parent.document.getElementById(justid)) {
           justido=parent.document.getElementById(justid);
          startw=eval('' + justido.getBoundingClientRect().width);
          starth=eval('' + justido.getBoundingClientRect().height);
           justimgo=parent.document.getElementsByTagName('img')[0];
          } else if (window.top) {
           if (top.document.getElementById(justid)) {
            justido=top.document.getElementById(justid);
          startw=eval('' + justido.getBoundingClientRect().width);
          starth=eval('' + justido.getBoundingClientRect().height);
            justimgo=top.document.getElementsByTagName('img')[0];
           }
          }
       }
    }
    if (justincover) {
       if (justido != null && justimgo != null) {
         justrect=justido.getBoundingClientRect();
         justrectimg=justimgo.getBoundingClientRect();
         documentURL=documentURL.replace('justthat=', 'justthat=' + encodeURIComponent(both('' + eval(startw / justrectimg.width) + ';' + eval(starth / justrectimg.height))) + '&xjunkx=');
       } else if (justimgo != null) {
         justrectimg=justimgo.getBoundingClientRect();
         documentURL=documentURL.replace('justthat=', 'justthat=' + encodeURIComponent(both('' + eval((window.orientation == 0 ? window.innerHeight: window.innerWidth) / justrectimg.width) + ';' + eval((window.orientation == 0 ? window.innerWidth: window.innerHeight) / justrectimg.height))) + '&xjunkx=');
       }
    }
    if (justincontain) {
       if (justido != null && justrectimgo != null) {
         justrect=justido.getBoundingClientRect();
         justrectimg=justimgo.getBoundingClientRect();
         documentURL=documentURL.replace('justthat=', 'justthat=' + Math.min(eval(startw / justrectimg.width),eval(starth / justrectimg.height)) + '&xjunkx=');
       } else if (justimgo != null) {
         justrectimg=justimgo.getBoundingClientRect();
         documentURL=documentURL.replace('justthat=', 'justthat=' + Math.min(eval((window.orientation == 0 ? window.innerHeight: window.innerWidth) / justrectimg.width),eval((window.orientation == 0 ? window.innerWidth: window.innerHeight) / justrectimg.height)) + '&xjunkx=');
         //alert(documentURL);
       }
    }
    justthatzoom=(documentURL.indexOf('justthat=0') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=1') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=2') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=3') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=4') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=5') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=6') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=7') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=8') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=(documentURL.indexOf('justthat=9') != -1 ? (ourdecodeURIComponent(documentURL.split('justthat=')[1].split('&')[0].split('#')[0])) : justthatzoom);
    justthatzoom=both(justthatzoom);
    if (justthatzoom != '1.0') { justzoomcss=('transform:scale(' + justthatzoom + ')').replace(/\ /g,'');  }

//  if (justthatzoom.indexOf(',') != -1) {  document.body.style.width='' + justthatzoom.split(',')[0] + 'px';   document.body.style.height='' + justthatzoom.split(',')[1] + 'px'; } else if (justzoomcss.indexOf(';') != -1) {  document.body.style.transform='scale(' + justthatzoom.replace(';',',') + ')';   } else if (justzoomcss != '') { document.body.style.zoom='' + justthatzoom + ''; }

       xars=jaconto.getElementsByTagName('div');
 " . $extras . ' } justthatbih=("" + justthatbih).replace(/undefined/g,""); if (justthatbih.length > 0 && !justthatoverlay) { document.body.innerHTML=whatwas(justthatbih.replace(/orange/g, "brown"));  } else if (justthatbih.length > 0 && justthatoverlay) { document.getElementById("doverlay").innerHTML="<iframe style=position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:899;background-color:transparent; id=ifdiv srcdoc= src=></iframe>"; document.getElementById("ifdiv").srcdoc="<html><body style=background-color:transparent;>" + justthatbih.replace(/orange/g,"brown") + "</body></html>"; document.body.style.cursor="pointer";   } } } }  setTimeout(function(){ if (document.getElementById("boff")) {  document.getElementById("boff").style.opacity="1.0";  } }, 60000);   </script></head><body onload=jfonl();><iframe id=boff onload=dolater(this); src="../../HTMLCSS/countries.html" style=width:100%;height:900px;' . $opcss . '></iframe><input typ=hidden id=data value=""></input><div id=overlay></div></body></html>';
  
  } else if (isset($_GET['ccode'])) {
  $bigxy=file_get_contents('./countries.html');
  $smallxy=file_get_contents('./image_chart.php');
  $recs=explode(' data-iso2="' . $_GET['ccode'] . '"', $bigxy);
  $records=explode(',' . $_GET['ccode'] . ',', $smallxy);
  if (sizeof($recs) > 1 && sizeof($records) > 1) {
    $valafters=explode(' value=', $records[0])[-1 + sizeof(explode(' value=', $records[0]))];
    for ($ii=1; $ii<sizeof($recs); $ii++) {
      $cstuff.=$delim . str_replace('[','',str_replace(']','',explode("'", explode("ates are", $recs[$ii])[1])[0]));
      $delim=',';
    }
    $ccs=explode(',', $cstuff);
    if (sizeof($ccs) > 1) {
  $minlat=$ccs[1];
  $minlong=$ccs[0];
  $maxlat=$ccs[1];
  $maxlong=$ccs[0];
      for ($ij=2; $ij<sizeof($ccs); $ij+=2) {
        if ($minlat > $ccs[1 + $ij]) {  $minlat=$ccs[1 + $ij];  }
        if ($maxlat < $ccs[1 + $ij]) {  $maxlat=$ccs[1 + $ij];  }
        if ($minlong > $ccs[0 + $ij]) {  $minlong=$ccs[0 + $ij];  }
        if ($maxlong < $ccs[0 + $ij]) {  $maxlong=$ccs[0 + $ij];  }
      }
      $from=$valafters . ',' . $_GET['ccode'] . ',';
      if (strpos($from, ' title=') === false && strpos($from, ' data-geo=') !== false) {
      $to=str_replace(' data-geo=', ' title=' . "\\\"" . str_replace(' ','',('' . $minlat . ',' . $minlong . ',' . $maxlat . ',' . $maxlong)) . "\\\" data-geo=", $from); // ... ' . $valafters;
      file_put_contents('./image_chart.php', str_replace($from, $to, $smallxy));
      echo $to;
      }
    }
  }    
  }
  exit;
?>
