// parses a xml-file
// http://www.w3schools.com/Dom/dom_parser.asp (for initial idea)

function fct_ParseXml(datei)
{
	try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    xmlDoc=document.implementation.createDocument("","",null);
    }
  catch(e)
    {
    alert(e.message);
    return;
    }
  }
  		xmlDoc.async=false;
		xmlDoc.load(datei);
  		var pts = [];
  		var scenes = xmlDoc.getElementsByTagName("scene");
  		for (var s = 1; s<scenes.length+1; s++) {
            // get any state attributes
            // scene[s]['Name'] ; scene[s]['Lat1'] ; scene[s]['Lng1'] ; scene[s]['Lat2'] ; scene[s]['Lng2'] ; scene[s]['Lat3'] ; scene[s]['Lng3'] ; scene[s]['Lat4'] ; scene[s]['Lng4'] ; scene[s]['FotoFormat'] ; scene[s]['FotoName'] ; scene[s]['FotoLoc'] ; scene[s]['DownloadName'] ; scene[s]['DownloadLoc'] ;  scene[s]['InfoImagingMode'] ; scene[s]['InfoAcquisitionTime'] ; scene[s]['InfoPolarizationMode'] ; scene[s]['InfoPolarizationChannel'] ; scene[s]['InfoOrbit'] ; scene[s]['InfoIncidence'] ; scene[s]['InfoProductType'] ; scene[s]['InfoResolutionVariant'] ; scene[s]['InfoCopyrights']
			scene[s]['Name'] = scenes[s-1].getAttribute('Name');
            scene[s]['Lat1'] = parseFloat(scenes[s-1].getAttribute('Lat1'));
            scene[s]['Lng1'] = parseFloat(scenes[s-1].getAttribute('Lng1'));
 			scene[s]['Lat2'] = parseFloat(scenes[s-1].getAttribute('Lat2'));
			scene[s]['Lng2'] = parseFloat(scenes[s-1].getAttribute('Lng2'));
			scene[s]['Lat3'] = parseFloat(scenes[s-1].getAttribute('Lat3'));
			scene[s]['Lng3'] = parseFloat(scenes[s-1].getAttribute('Lng3'));
			scene[s]['Lat4'] = parseFloat(scenes[s-1].getAttribute('Lat4'));
			scene[s]['Lng4'] = parseFloat(scenes[s-1].getAttribute('Lng4'));
			scene[s]['FotoFormat'] = scenes[s-1].getAttribute('FotoFormat');
			scene[s]['FotoName'] = scenes[s-1].getAttribute('FotoName');
			scene[s]['FotoLoc'] = scenes[s-1].getAttribute('FotoLoc');
			scene[s]['DownloadName'] = scenes[s-1].getAttribute('DownloadName');
			scene[s]['DownloadLoc'] = scenes[s-1].getAttribute('DownloadLoc');
			scene[s]['DownloadSize'] = scenes[s-1].getAttribute('DownloadSize');
			scene[s]['Imaging Mode'] = scenes[s-1].getAttribute('InfoImagingMode');
			scene[s]['Acquisition Time'] = scenes[s-1].getAttribute('InfoAcquisitionTime');
			scene[s]['Polarization Mode'] = scenes[s-1].getAttribute('InfoPolarizationMode');
			scene[s]['Polarization Channel'] = scenes[s-1].getAttribute('InfoPolarizationChannel');
			scene[s]['Orbit'] = scenes[s-1].getAttribute('InfoOrbit');
			scene[s]['Incidence Angle'] = scenes[s-1].getAttribute('InfoIncidence');
			scene[s]['Product Type'] = scenes[s-1].getAttribute('InfoProductType');
			scene[s]['Resolution Variant'] = scenes[s-1].getAttribute('InfoResolutionVariant');
			scene[s]['Projection'] = scenes[s-1].getAttribute('Projection');
			scene[s]['Format'] = scenes[s-1].getAttribute('Format');
			scene[s]['Copyrights'] = scenes[s-1].getAttribute('InfoCopyrights');
			
			scene[s]['CenterLat'] = (scene[s]['Lat1'] + scene[s]['Lat2'] + scene[s]['Lat3'] + scene[s]['Lat4'])/4;
			scene[s]['CenterLng'] = (scene[s]['Lng1'] + scene[s]['Lng2'] + scene[s]['Lng3'] + scene[s]['Lng4'])/4;
			
			pts[1] = new GLatLng(scene[s]['Lat1'],scene[s]['Lng1']);
			pts[2] = new GLatLng(scene[s]['Lat2'],scene[s]['Lng2']);
			pts[3] = new GLatLng(scene[s]['Lat3'],scene[s]['Lng3']);
			pts[4] = new GLatLng(scene[s]['Lat4'],scene[s]['Lng4']);
			pts[5] = new GLatLng(scene[s]['Lat1'],scene[s]['Lng1']);
		
            var poly = new GPolygon(pts,"#000000",1,1,"#ff0000",0.5);
            polys.push(poly);
  		}
}