function GmxWOParams() { // constructor
/*
	this.param = {
		id:null, name:null, enable:null, uri:null,
		size:null, height:null, callback_name:null, 
		font_id:null, stock_type:null, line_width:null};
	this.altitude = {km:null};
	this.label_texture = {id:null};
	this.label_font = {id:null};
	this.orientation = {rotation:null, axis:null};
	this.reference = {x:null, y:null};
	this.color = {red:null, green:null, blue:null, alpha:null};
	this.distance_enable = {min_distance:null, max_distance:null};
	this.label_interval = {min_distance:null, max_distance:null};
	this.texture = {id:null};
	this.region = {x_offset:null, y_offset:null, x_size:null, y_size:null};
	this.highlight_texture = {id:null};
	this.highlight_region = {x_offset:null, y_offset:null, x_size:null, y_size:null};
*/
	this.param = new Object();
	this.altitude = new Object();
	this.label_texture = new Object();
	this.label_font = new Object();
	this.orientation = new Object();
	this.reference = new Object();
	this.color = new Object();
	this.distance_enable = new Object();
	this.label_interval = new Object();
	this.texture = new Object();
	this.region = new Object();
	this.highlight_texture = new Object();
	this.highlight_region = new Object();
	//this.label_frame = new Object(); // depricated
}


function GmxWOInstanceParams() { // constructor
	this.param = new Object();	// id, name, height, scale, label, 
															// label_string, string, callback_data
	this.position_2 = new Object();	// latitude, longitude
	this.position_3 = new Object(); // latitude, longitude, altitude
	this.attitude = new Object(); // yaw, pitch, roll
}

function GmxXML() { // constructor
  this.str = "";
}

GmxXML.prototype.begin = function() {
	this.str = 
		'<?xml version="1.0" encoding="UTF-8"?>\n' +
		'<gmx_document>\n' +
		'<gmx_session version="1.5.1">\n';
}

GmxXML.prototype.end = function() {
	this.str += 
		'</gmx_session>\n' +
		'</gmx_document>\n';
}

GmxXML.prototype.beginObject = function(type, id) {
	this.str += '<object type="'+ type +'" id="'+ id +'">\n';
}

GmxXML.prototype.endObject = function() {
	this.str += '</object>\n';
}

GmxXML.prototype.create = function(type, subtype, parms) {
	this.str += '<create type="'+ type +'" subtype="'+ subtype +'">\n';
	for(var prop in parms) {
		if(prop == 'param') {
		  for(var param in parms[prop]) {
				if(parms[prop] != null)
					this.str += '  <param '+ param +'="'+ parms[prop][param] +'"/>\n';
			}
		} else {
			var first_time = 1;
		  for(var param in parms[prop]) {
		  	if(first_time && parms[prop] != null) {	// only create this if the property has values defined
					this.str += '  <'+ prop +' ';
					first_time = 0;
				}		  	
				this.str += param +'="'+ parms[prop][param] +'" ';
			}
			if(!first_time && parms[prop] != null)	// go ahead, finish it off, there were values for this property
				this.str += '/>\n';
		}
	}
	this.str += '</create>\n';
}

GmxXML.prototype.attach = function(type, id, parms) {
	this.str += '  <attach type="'+ type +'" id="'+ id +'">\n';
  for(var name in parms['param']) {
		this.str += '    <param '+ name +'="'+ parms['param'][name] +'"/>\n';
	}
	switch(type) {
	case 'gmxWORLD_OBJECT':
		if(parms['position_2'].latitude != null)
			this.str += '    <position_2' 
							 +' latitude="'+ parms['position_2'].latitude +'"' 
							 +' longitude="'+ parms['position_2'].longitude +'"/>\n' ;
		else if (parms['position_3'].latitude != null)
			this.str += '    <position_3'
							 +' latitude="'+ parms['position_3'].latitude +'"' 
							 +' longitude="'+ parms['position_3'].longitude +'"'
							 +' altitude="'+ parms['position_3'].altitude +'"/>\n' ;
		if(parms['attitude'].yaw != null)
			this.str += '    <attitude'
							 +' yaw="'+ parms['attitude'].yaw +'"' 
							 +' pitch="'+ parms['attitude'].patch +'"'
							 +' roll="'+ parms['attitude'].roll +'"/>\n' ;	
		break;
		
	default:
		break;
	}
/* old way - subject to wrong ordering of name/value pairs
	for(var prop in parms) {
		if(prop == 'param') {
		  for(var param in parms[prop]) {
				this.str += '    <param '+ param +'="'+ parms[prop][param] +'"/>\n';
			}
		} else {
			var first_time = 1;
		  for(var param in parms[prop]) {
		  	if(first_time) {	// only create this if the property has values defined
					this.str += '    <'+ prop +' ';
					first_time = 0;
				}		  	
				this.str += param +'="'+ parms[prop][param] +'" ';
			}
			if(!first_time)	// go ahead, finish it off, there were values for this property
				this.str += '/>\n';
		}
	}
*/
	this.str += '  </attach>\n';
}

GmxXML.prototype.get = function() {
	return(this.str);
}