// JavaScript Document
function getXmlData(strfile,objOnloadFunction,strFuncVars){
		
	var xmlObj = null;
	if(window.ActiveXObject){
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");		
	} else if(window.XMLHttpRequest){
		xmlObj = new XMLHttpRequest();
		xmlObj.overrideMimeType('text/xml');
	} else {
		return;
	}
	xmlObj.onreadystatechange = function(){		
		if(xmlObj.readyState == 4){			
			objOnloadFunction(xmlObj,strFuncVars)
		}
	}
	xmlObj.open ('GET', strfile, true);
	xmlObj.send ('');
}

function sendXmlData(strFile,objOnloadFunction,strVars,strFuncVars) {	
	var xmlObj = null;
	strVars = encodeURI(strVars)
	
	
	if(window.ActiveXObject){
		xmlObj = new ActiveXObject("MSXML2.XMLHTTP.3.0");		
	} else if(window.XMLHttpRequest){
		xmlObj = new XMLHttpRequest();
		xmlObj.overrideMimeType('text/xml');
	} else {
		return;
	}
	xmlObj.open ('POST', strFile, true);


	xmlObj.onreadystatechange = function(){
		if(xmlObj.readyState == 4){
			objOnloadFunction(xmlObj,strFuncVars)
			
		}
	}
	
	xmlObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');	
	xmlObj.send (strVars);
}
function element(name,content,attributes){
    var att_str = ''
    if (attributes) { // tests false if this arg is missing!
        att_str = formatAttributes(attributes)
    }
    var xml
    if (!content){
        xml='<' + name + att_str + '/>'
    }
    else {
        xml='<' + name + att_str + '>' + content + '</'+name+'>'
    }
    return xml
}
var APOS = "'";
var QUOTE = '"'
var ESCAPED_QUOTE = {  }
ESCAPED_QUOTE[QUOTE] = '&quot;'
ESCAPED_QUOTE[APOS] = '&apos;'
   
/*
   Format a dictionary of attributes into a string suitable
   for inserting into the start tag of an element.  Be smart
   about escaping embedded quotes in the attribute values.
*/
function formatAttributes(attributes) {
    var att_value
    var apos_pos, quot_pos
    var use_quote, strescape, quote_to_escape
    var att_str
    var re
    var result = ''
   
    for (var att in attributes) {
        att_value = attributes[att]
        
        // Find first quote marks if any
        apos_pos = att_value.indexOf(APOS)
        quot_pos = att_value.indexOf(QUOTE)
       
        // Determine which quote type to use around 
        // the attribute value
        if (apos_pos == -1 && quot_pos == -1) {
            att_str = ' ' + att + "='" + att_value +  "'"
            result += att_str
            continue
        }
        
        // Prefer the single quote unless forced to use double
        if (quot_pos != -1 && quot_pos < apos_pos) {
            use_quote = APOS
        }
        else {
            use_quote = QUOTE
        }
   
        // Figure out which kind of quote to escape
        // Use nice dictionary instead of yucky if-else nests
        strescape = ESCAPED_QUOTE[use_quote]
        
        // Escape only the right kind of quote
        re = new RegExp(use_quote,'g')
        att_str = ' ' + att + '=' + use_quote + 
            att_value.replace(re, strescape) + use_quote
        result += att_str
    }
    return result
}
