
function GET (url)
{
	var objHTTP = new XMLHttpRequest();
	objHTTP.open( "GET", url, false, cfg.XmlProUserID, cfg.XmlProPassword );
	objHTTP.send();
	return ""+ objHTTP.responseText;	
}

function _( id ){ return document.getElementById( id ) }


function findOption( e, value )
{
	for (var i=0; i<e.length; i++)
	{
		if (value == e.options[i].value)
			return i;
 	}
	return -1; 	
}


function forConfig( f )
{
	for (var name in cfg)
	{
		var item = cfg[ name ];
		var e = document.getElementsByName( name );
		if (e && e[0]) f( e[0], item, name );
	}		
}


function init()
{
	function setHtml( e, item )
	{
		switch (e.tagName)
		{
			case "INPUT": e.value = item; break;
			case "SELECT":e.selectedIndex = findOption( e, item )
		}
	}
	
	forConfig( setHtml );
}                                        

function send()
{
	var s = "";

	function changeNote( e, item, name)
	{	
		var v;
		switch (e.tagName)
		{
			case "INPUT": v = e.value; break;
			case "SELECT":v = e.selectedIndex;
				if (v<0) return;
				v = e.options[ v].value;
		};
		switch (typeof item )
		{
			case "number":	s += name +'='+ (v-0) +";\n"; break;
			case "string":	s += name +'="'+ v.replace(/"/g,"\\\"") +'";\n';  break;
			case "boolean":	s += name + (v ? '=true;\n' : '=false;\n'); break;
		}
	}

	forConfig( changeNote );

	document.xfer.change.value = s;
	document.xfer.submit();	
}

