/*
 * Plasma AJAX - AJAX Engine for Plasma version 2007.01
 * Copyright (C) 1995-2006 IonicWeb, LLC.  All rights reserved.
 *
 * This library is only available for use as part of the Plasma 2007
 * Web Application Server by IonicWeb, LLC.  Any other use is currently
 * prohibited.  For more information and license options for this
 * work, please send requests to info@ionicweb.com. 
 *
 * The Plasma license is found at http://ionicweb.com/plasma/license
 */

/*
 * Java Script Execution method.  Pass a valid URI to a java script
 * file and it will be loaded and executed.
 *
 * Attributes:
 * script_path - a fully qualified URI to the java script file.  
 *               This can be a root relative uri for local Plasma 
 *               scripts.
 */
function executeScript( script_path )
{
    var head= document.getElementsByTagName('head').item(0);
    var scriptTag=document.getElementById('getchildren');
    if (scriptTag) head.removeChild(scriptTag);
    var script=document.createElement('script');
    script.src=script_path;
    script.type='text/javascript';
    script.id='getchildren';
    head.appendChild(script);
}

/*
 * Asynchronous AJAX Request.  Pass a valid URI to a Plasma AJAX
 * complient URI and a valid call back function to be executed when
 * the request completes.
 *
 * Attributes:
 * script_path - a fully qualified URI to the Plasma AJAX request.  
 *               This must be a root relative uri for local Plasma 
 *               requests for security reasons.
 *
 * callback    - Name of callback function to be executed when request
 *               completes.
 */
function ajaxAsynchRequest( script_path, callback)
{
    //return Ajax.get(script_path, callback);
    
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    req.open("GET", script_path, true);
    
    req.onreadystatechange = callback;
    req.send(null);
}

/*
 * Synchronous AJAX Request.  Pass a valid URI to a Plasma AJAX
 * complient URI.  All browser functionality stops until the request
 * is completed and control will then be passed to the line following
 * the synchronous request.
 *
 * Attributes:
 * script_path - a fully qualified URI to the Plasma AJAX request.  
 *               This must be a root relative uri for local Plasma 
 *               requests for security reasons.
 */
function ajaxSynchRequest(script_path)
{
    //return Ajax.get(script_path);

    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.open("GET", script_path, false);
    req.send(null);
}

/*
 * Parses a DOM Node.  Pass the DOM or a DOM node created by an AJAX
 * request.
 *
 * Attributes:
 * dom - A DOM object - either the entire DOM or a node from the DOM.
 */
function getXMLTree(dom)
{
    var xotree = new XML.ObjTree()
    if ( isNS )
        return xotree.parseDOM( dom );
    else
        return xotree.parseXML( dom.xml );
}

function postDeleteDataForm(delete_key, data_table, data_role, delete_val, form_action, tree_node, focus_field, scope_key, scope_val)
{
    var form_html = "<input type=\"hidden\" name=\"action\" value=\"" + form_action + "\">";
    form_html = form_html + setScopeKeys(scope_key, scope_val);
    form_html = form_html + "<input type=\"hidden\" name=\"raw\" value=\"on\">";
    form_html = form_html + "<input type=\"hidden\" name=\"" + delete_key + "\" value=\"" + delete_val + "\">";
    form_html = form_html + "<input type=\"hidden\" name=\"data_table\" value=\"" + data_table + "\">";
    form_html = form_html + "<input type=\"hidden\" name=\"data_role\" value=\"" + data_role + "\">";
    var error_message = "";

    turnAjaxMessageOn(false,"Update in progress....");
    var iFrameBody = document.getElementById("ajax_frame");
    window.frames[0].document.getElementById("ajax_form").innerHTML = form_html;
    window.frames[0].document.getElementById("ajax_form").submit();
    return true;
}

/*
 * Post Form.  Posts the form fields based on node information from
 * an XML Tree, populates an action form and calls the specified form_action.
 * The node name or a field attribute must contain the id of the form object 
 * to be retrieved and posted.
 *
 * Attributes:
 * delete_key - key for delete field (usually a unique id to the record to delete)
 * delete_val - value for the key to lookup the record to delete
 * form_action - Name of plasma action to call when sending the AJAX request
 * tree_node   - An XML Tree node to walk and rerieve data from.
 * focus_field - The ID of the field to get focus if there is an error posting.
 */
function postDeleteForm(delete_key, delete_val, form_action, tree_node, focus_field, scope_key, scope_val)
{
    var form_html = "<input type=\"hidden\" name=\"action\" value=\"" + form_action + "\">";
    form_html = form_html + setScopeKeys(scope_key, scope_val);
    form_html = form_html + "<input type=\"hidden\" name=\"raw\" value=\"on\">";
    form_html = form_html + "<input type=\"hidden\" name=\"" + delete_key + "\" value=\"" + delete_val + "\">";
    var error_message = "";

    turnAjaxMessageOn(false,"Update in progress....");
    var iFrameBody = document.getElementById("ajax_frame");
    window.frames[0].document.getElementById("ajax_form").innerHTML = form_html;
    window.frames[0].document.getElementById("ajax_form").submit();
    return true;
}
function callAction(action_key, action_val, form_action)
{
    var form_html = "<input type=\"hidden\" name=\"action\" value=\"" + form_action + "\">";
    form_html = form_html + "<input type=\"hidden\" name=\"raw\" value=\"on\">";
    form_html = form_html + "<input type=\"hidden\" name=\"" + action_key + "\" value=\"" + action_val + "\">";
    var error_message = "";
    
    var iFrameBody = document.getElementById("ajax_frame");
    
    window.frames[0].document.getElementById("ajax_form").innerHTML = form_html;
    window.frames[0].document.getElementById("ajax_form").submit();
    return true;
}

/*
 * Post Action.  Calls the action on the server.
 *
 * Attributes:
 * form_action - Name of plasma action to call when sending the AJAX request
 */
function postAction(form_action, fields, scope_key, scope_val)
{
    var form_html = "<input type=\"hidden\" name=\"action\" value=\"" + form_action + "\">";
    form_html = form_html + setScopeKeys(scope_key, scope_val);
    form_html = form_html + "<input type=\"hidden\" name=\"raw\" value=\"on\">";

    for ( var i=0; i < fields.length; i++ ) {
        form_html = form_html + "<input type=\"hidden\" name=\"" + fields[i].key + "\" value=\"" + fields[i].val + "\">";
    }

    var error_message = "";

    turnAjaxMessageOn(false,"Update in progress....");
    var iFrameBody = document.getElementById("ajax_frame");
    window.frames[0].document.getElementById("ajax_form").innerHTML = form_html;
    window.frames[0].document.getElementById("ajax_form").submit();

    return true;
}

function postDataForm(form_action, data_table, data_security, data_role, post_fields, scope_key, scope_val)
{
    //var form_html = "<form action='?action=" + form_action + "' method='POST'>";
    var form_html = "<input type=\"hidden\" name=\"action\" value=\"" + form_action + "\">";
    form_html = form_html + setScopeKeys(scope_key, scope_val);
    form_html = form_html + "<input type=\"hidden\" name=\"raw\" value=\"on\">";
    form_html = form_html + "<input type=\"hidden\" name=\"data_security\" value=\"" + data_security + "\">";
    form_html = form_html + "<input type=\"hidden\" name=\"data_role\" value=\"" + data_role + "\">";
    form_html = form_html + "<input type=\"hidden\" name=\"data_table\" value=\"" + data_table + "\">";
    var error_message = "";
    
    var next_field = 0;
    
    for ( var x=0; x < post_fields.length; x++ )
    {
	//name, type, required
	
        var field = post_fields[x].name;
        var required = post_fields[x].required;
        var data_type = post_fields[x].data_type;
        var external_format = post_fields[x].external_format;
        var number_of_decimals = post_fields[x].number_of_decimals;
	var field_data = "[" + field + "][" + data_type + "][" + external_format + "][" + number_of_decimals + "]";

	var field_line = "<input type=\"hidden\" name=\"field_" + next_field + "\" value=\"" + field_data + "\">";
	
        var value = "";

        var form_element = document.getElementById(field);
        var select_allowed = false;
	
        if ( form_element != null ) {
	    //alert(field + " = " + form_element.value);
            var type = "";
            for ( var i=0; i < form_element.attributes.length; i++ )
            {
                if ( form_element.attributes[i].name == "type" ) {
                    type = form_element.attributes[i].value;
                    break;
                }
            }
            if ( form_element.tagName == "TEXTAREA" || form_element.tagName == "textarea" ) {
		form_html = form_html + field_line;
		next_field++;
                form_html = form_html + "<textarea name=\"" + field + "\">" + form_element.value + "</textarea>";
                if ( required.toLowerCase() == "true" ) {
                    if ( form_element.value.trim == "" ) {
                        error_message = error_message + field + " is required.<BR>"
                        form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                    } else {
                        form_element.style.className="EDITOR_SECTION_FIELD";
                    }
                }

            } else if ( form_element.tagName == "INPUT" || form_element.tagName == "input" || form_element.tagName == "META" || form_element.tagName == "meta") {
                if ( type == "checkbox" || type == "CHECKBOX" ) {
                    
		    form_html = form_html + field_line;
		    next_field++;
                    form_html = form_html + "<input type=\"checkbox\" name=\"" + field + "\"";
                    if ( form_element.checked )
                        form_html = form_html + " checked>";
                    else
                        form_html = form_html + ">";
                } else if ( type == "password" || type == "PASSWORD" ) {
		    form_html = form_html + field_line;
		    next_field++;
                    form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
                    if ( required.toLowerCase() == "true" ) {
                        if ( form_element.value.trim == "" ) {
                            error_message = error_message + field + " is required.<BR>"
                            form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                        } else {
                            form_element.style.className="EDITOR_SECTION_FIELD";
                        }
                    }
                } else {
		    form_html = form_html + field_line;
		    next_field++;
                    form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
                    if ( required.toLowerCase() == "true" ) {
                        if ( form_element.value.trim == "" ) {
                            error_message = error_message + field + " is required.<BR>"
                            form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                        } else {
                            form_element.style.className="EDITOR_SECTION_FIELD";
                        }
                    }
                }
            } else if ( form_element.tagName == "SELECT" || form_element.tagName == "select" ) {
		form_html = form_html + field_line;
		next_field++;
                form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
                if ( required.toLowerCase() == "true" ) {
                    if ( form_element.value.trim == "" ) {
                        error_message = error_message + field + " is required.<BR>"
                        form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                    } else {
                        form_element.style.className="EDITOR_SECTION_FIELD";
                    }
                }
            }
        }
    }
    if ( error_message != "" )
        return false;
    
    turnAjaxMessageOn(false,"Update in progress....");
    var iFrameBody = document.getElementById("ajax_frame");
    try {
        window.frames[0].document.getElementById("ajax_form").innerHTML = form_html;
        window.frames[0].document.getElementById("ajax_form").submit();
    } catch ( e) {
        alert("An error occured while attempting to post the form.\n\n" + e.message);
        turnAjaxMessageOff();
    }

    return true;
}

/*
 * Post Form.  Posts the form fields based on node information from
 * an XML Tree, populates an action form and calls the specified form_action.
 * The node name or a field attribute must contain the id of the form object 
 * to be retrieved and posted.
 *
 * Attributes:
 * form_action - Name of plasma action to call when sending the AJAX request
 * tree_node   - An XML Tree node to walk and rerieve data from.
 * focus_field - The ID of the field to get focus if there is an error posting.
 */
function postForm(form_action, tree_node, focus_field, scope_key, scope_val)
{
    //var form_html = "<form action='?action=" + form_action + "' method='POST'>";
    var form_html = "<input type=\"hidden\" name=\"action\" value=\"" + form_action + "\">";
    form_html = form_html + setScopeKeys(scope_key, scope_val);
    form_html = form_html + "<input type=\"hidden\" name=\"raw\" value=\"on\">";
    var error_message = "";

    for ( var key in tree_node )
    {
        if ( key == "#text" ) continue;
        var val = tree_node[key];
        var field = key;
        var required = "false";
        var value = "";
        
        if ( typeof(val) == "object" ) {
            field = val["-field"];
            required = val["-required"];
            if ( !required )
                required = "false";
        }
        var form_element = document.getElementById(field);
        //alert(field + " - " + form_element);
        var select_allowed = false;

        if ( form_element != null ) {
            
            var type = "";
            for ( var i=0; i < form_element.attributes.length; i++ )
            {
                if ( form_element.attributes[i].name == "type" ) {
                    type = form_element.attributes[i].value;
                    break;
                }
            }
            
            if ( form_element.tagName == "TEXTAREA" || form_element.tagName == "textarea" ) {
                form_html = form_html + "<textarea name=\"" + field + "\">" + form_element.value + "</textarea>";
                if ( required.toLowerCase() == "true" ) {
                    if ( form_element.value.trim == "" ) {
                        error_message = error_message + field + " is required.<BR>"
                        form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                    } else {
                        form_element.style.className="EDITOR_SECTION_FIELD";
                    }
                }

            } else if ( form_element.tagName == "INPUT" || form_element.tagName == "input" || form_element.tagName == "META" || form_element.tagName == "meta") {
                if ( type == "checkbox" || type == "CHECKBOX" ) {
                    
                    form_html = form_html + "<input type=\"checkbox\" name=\"" + field + "\"";

                    if ( form_element.checked )
                        form_html = form_html + " checked>";
                    else
                        form_html = form_html + ">";
                    
                } else if ( type == "password" || type == "PASSWORD" ) {
                    form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
                    if ( required.toLowerCase() == "true" ) {
                        if ( form_element.value.trim == "" ) {
                            error_message = error_message + field + " is required.<BR>"
                            form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                        } else {
                            form_element.style.className="EDITOR_SECTION_FIELD";
                        }
                    }
                } else {
                    form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
                    if ( required.toLowerCase() == "true" ) {
                        if ( form_element.value.trim == "" ) {
                            error_message = error_message + field + " is required.<BR>"
                            form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                        } else {
                            form_element.style.className="EDITOR_SECTION_FIELD";
                        }
                    }
                }
            } else if ( form_element.tagName == "SELECT" || form_element.tagName == "select" ) {
                form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
                if ( required.toLowerCase() == "true" ) {
                    if ( form_element.value.trim == "" ) {
                        error_message = error_message + field + " is required.<BR>"
                        form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                    } else {
                        form_element.style.className="EDITOR_SECTION_FIELD";
                    }
                }
            }
        }
    }
    
    if ( error_message != "" ) {
        if ( focus_field == field ) {
            form_element.focus();
            if (select_allowed)
                form_element.select();
        }
        //turnAjaxMessageOff();
        return false;
    }
    
    turnAjaxMessageOn(false,"Update in progress....");
    var iFrameBody = document.getElementById("ajax_frame");
    try {
        window.frames[0].document.getElementById("ajax_form").innerHTML = form_html;
        window.frames[0].document.getElementById("ajax_form").submit();
    } catch ( e) {
        alert("An error occured while attempting to post the form.\n\n" + e.message);
        turnAjaxMessageOff();
    }

    return true;
}

/*
 * Populate Form.  Populates form fields based on node information from
 * an XML Tree.  The node name or a field attribute must contain the id
 * of the form object to be retrieved and populated.
 *
 * Attributes:
 * tree_node   - An XML Tree node to walk and rerieve data from.
 * focus_field - The ID of the field to get focus after the form is populated
 */
function populateForm(tree_node, focus_field)
{
    var data_section = "";
    var data_list = "";
    var data_prefix = "";
    var data_type = "";
    var data_desc = "";
    var data_section_tag = "";
    var data_list_tag = "";
    var data_section_found = false;
    var data_items_found = false;
    var innerHTML = "";
    var data_item_desc = "";
    var list_item = false;
    var section_item = false;

    for ( var key in tree_node )
    {
        if ( key == "#text" ) continue;
        var val = tree_node[key];
        var field = key;
        var value = "";
        if ( typeof(val) == "object" ) {
            if ( val["-field"] )
                field = val["-field"];
            
            value = val["#text"];
        
            if ( val["-type"] )
                data_type = val["-type"];
            else
                data_type = "";
            
            if ( val["-desc"] )
                data_desc = val["-desc"];
            else
                data_desc = "";

            section_item = false;
            if ( data_type == "checkbox_list" ) {
                if ( val["-section"] )
                    data_section = val["-section"];
                if ( val["-list"] )
                    data_list = val["-list"];
                if ( val["-prefix"] )
                    data_prefix = val["-prefix"];
                
                data_section_tag = document.getElementById(data_section);
                data_list_tag = document.getElementById(data_list);

                data_section_tag.style.display = "";
                data_list_tag.innerHTML = "";
                data_section_found = true;
                data_items_found = false;
                innerHTML = "";
                list_item = false;
                section_item = true;
            } else {

                if ( data_prefix.length > 0 && field.length > data_prefix.length && field.substring(0,data_prefix.length) == data_prefix ) {
                    if ( val["-desc"] )
                        data_item_desc = val["-desc"];
                    else
                        data_item_desc = "";
                    list_item = true;
                    data_items_found = true;
                } else {
                    list_item = false;
                }
            }

        } else {
            if ( data_prefix.length > 0 && field.length > data_prefix.length && field.substring(0,data_prefix.length) == data_prefix ) {
                if ( val["-desc"] )
                    data_item_desc = val["-desc"];
                else
                    data_item_desc = "";

                list_item = true;
                data_items_found = true;
            } else {
                list_item = false;
            }
            
            value = val;
        }
        if ( !value )
            value = "";
        
        if ( list_item ) {
            
            if ( value == "true" || value == "TRUE" ) {
                innerHTML = innerHTML + "<input type=\"checkbox\" id=\"" + field + "\" name=\"" + field + "\" checked>" + data_desc + "<BR>";
            } else {
                innerHTML = innerHTML + "<input type=\"checkbox\" id=\"" + field + "\" name=\"" + field + "\">" + data_desc + "<BR>";
            }
            data_list_tag.innerHTML = innerHTML;
            
        } else {

            if ( !section_item && data_section_found && !data_items_found ) {
                data_section_tag.style.display = "none";
                data_list_tag.innerHTML = "";
                data_section_found = false;
            }

            var form_element = document.getElementById(field);
            var select_allowed = false;
            if ( form_element != null ) {

                var type = "";
                for ( var i=0; i < form_element.attributes.length; i++ )
                {
                    if ( form_element.attributes[i].name == "type" ) {
                        type = form_element.attributes[i].value;
                        break;
                    }
                }
                if ( form_element.tagName == "INPUT" || form_element.tagName == "input" ) {
                    if ( type == "checkbox" || type == "CHECKBOX" ) {
                        if ( value == "true" || value == "TRUE" )
                            form_element.checked = true;
                        else
                            form_element.checked = false;

                        //Because there is no change event on checkboxes
                        form_element.fireEvent('onclick');


                    } else if ( type == "password" || type == "PASSWORD" ) {
                        //Do not populate password fields - these are only
                        //processed if entered from form on the update
                        form_element.fireEvent('onchange');
                        select_allowed = true;
                    } else {
                            form_element.value = value;
                            form_element.fireEvent('onchange');
                            select_allowed = true;
                    }
                } else if ( form_element.tagName == "SELECT" || form_element.tagName == "select" ) {
                    if ( value != "0" && value != "" ) {

                        for ( var i=0; i < form_element.options.length; i++ )
                        {
                            var option = form_element.options[i];
                            if ( option.value == value ) {
                                option.selected = true;
                            } else {
                                option.selected = false;
                            }
                        }

                    }
                    form_element.fireEvent('onchange');

                }

                if ( focus_field == field ) {
                    form_element.focus();
                    if (select_allowed)
                        form_element.select();
                }
            }
        }   
    }
    if ( data_section_found && !data_items_found ) {
        data_section_tag.style.display = "none";
        data_list_tag.innerHTML = "";
        data_section_found = false;
    }

}

/*
 * Turn Ajax Message On.  Pops up a message to display during an Ajax Process.
 *
 * Attributes:
 * ajax_msg   - Text of message to display
 */
    function turnAjaxMessageOn_Positioned(pos_y, pos_x, closer, ajax_msg)
    {
        var ajax_message = document.getElementById("ajax_message");
        var ajax_message_text = document.getElementById("ajax_message_text");
        
        ajax_message_text.innerHTML = ajax_msg;

        ajax_message.style.top = pos_y;
        ajax_message.style.left = pos_x;
        
        ajax_message.style.display = "";
    }
    
    
    function turnLoadMessageOn(the_message)
    {
	var pos_ = getCursorPosition();

        var pos_y = pos_.y;
        var pos_x = pos_.x;

        var load_message = document.getElementById("load_message");
        var load_message_text = document.getElementById("load_message_text");
        
        load_message_text.innerHTML = the_message;

        load_message.style.top = pos_y;
        load_message.style.left = pos_x;
        
        load_message.style.display = "";
    }
    
    function turnLoadMessageOff()
    {
        //var plasma_uploader = document.getElementById("plasma_uploader");
        //plasma_uploader.style.display = "none";
        
        var load_message = document.getElementById("load_message");
        var load_message_text = document.getElementById("load_message_text");
        load_message.style.display = "none";
        load_message_text.innerHTML = "";

    }
    
    function turnAjaxMessageOn(closer, ajax_msg)
    {
        var pos_y = findScreenPosY()+150;
        var pos_x = findScreenPosX()+250;

        var ajax_message = document.getElementById("ajax_message");
        var ajax_message_text = document.getElementById("ajax_message_text");
        
        ajax_message_text.innerHTML = ajax_msg;

        ajax_message.style.top = pos_y;
        ajax_message.style.left = pos_x;
        
        ajax_message.style.display = "";
    }

    /*
     * Turn Ajax Message Off.  Turns current Ajax Message off.
     *
     */
    function turnAjaxMessageOff()
    {
        var plasma_uploader = document.getElementById("plasma_uploader");
        plasma_uploader.style.display = "none";
        
        var ajax_message = document.getElementById("ajax_message");
        var ajax_message_text = document.getElementById("ajax_message_text");
        ajax_message.style.display = "none";
        ajax_message_text.innerHTML = "";

    }

    /*
     * Close popup message.
     */
    function closePlasmaPopup()
    {
        closePlasmaPopupMain("plasma_popup");
    }
    function closePlasmaPopupMain(popup_screen)
    {
        var plasma_popup = document.getElementById(popup_screen);

        if ( popup_screen == "plasma_popup" ) {
            var plasma_uploader = document.getElementById("plasma_uploader");
            plasma_uploader.style.display = "none";
        }
        
        if ( plasma_popup != null ) {
            plasma_popup.innerHTML = "";
            plasma_popup.style.display="none";
        }
    }

    /*
     * Open the Plasma Popup message/screen.
     * 
     * Attributes:
     * close_button- Dictates whether a close button is needed or not.
     * msg_color   - Color to use for this popup
     * msg_top     - Top location for absolute positioning of the message.
     * msg_left    - Left location for absolute positioning of the message.
     * msg_width   - Width of message to display.
     * msg_height  - Height of message to display.
     * msg_content - Message content (can be html, javascript, etc. as well as content);
     */
     function openPlasmaPopup(close_button, msg_color, msg_top, msg_left, msg_width, msg_height, msg_content, image_path, close_method)
     {
        openPlasmaPopupMain("plasma_popup",close_button, msg_color, msg_top, msg_left, msg_width, msg_height, msg_content, image_path, close_method);
     }
     function openPlasmaPopupMain(popup_screen,close_button, msg_color, msg_top, msg_left, msg_width, msg_height, msg_content, image_path, close_method)
     {
        var plasma_popup = document.getElementById(popup_screen);
        
        plasma_popup.style.top = msg_top;
        plasma_popup.style.left = msg_left;
        var popup_table = "";
        popup_table = "<table width=" + (msg_width+20) + " border-5 cellspacing=0 cellpadding=0>";
        popup_table = popup_table + "<tr onMouseMove=\"movePopup('" + popup_screen + "');\" onMouseDown=\"setPopupMoveable();\" onMouseUp=\"stopPopupMoveable();\" >";
        popup_table = popup_table + "<td width=10><img src=\"" + image_path + "cl_upper_left.gif\" border=0 width=10 height=10></td>";
        popup_table = popup_table + "<td width=" + msg_width + " style=\"background-color:" + msg_color + "; background-image: url(" + image_path + "cl_line_top.gif);\"><img src=\"" + image_path + "cl_line_top.gif\" border=0 width=" + msg_width + " height=10></td>";
        popup_table = popup_table + "<td width=10><img src=\"" + image_path + "cl_upper_right.gif\" border=0 width=10 height=10></td>";
        popup_table = popup_table + "</tr>";
        popup_table = popup_table + "<tr>";
        popup_table = popup_table + "<td onMouseMove=\"movePopup('" + popup_screen + "');\" onMouseDown=\"setPopupMoveable();\" onMouseUp=\"stopPopupMoveable();\" width=10 style=\"background-color:" + msg_color + "; background-image: url(" + image_path + "cl_line_left.gif);\" height=" + msg_height + "><img src=\"" + image_path + "cl_line_left.gif\" border=0 width=10 height=" + msg_height + "></td>";
        popup_table = popup_table + "<td valign=\"top\" width=" + msg_width + " height=" + msg_height + " style=\"background-color:" + msg_color + ";\">";
        
        popup_table = popup_table + "<table width=" + msg_width + " border=0 cellspacing=0 cellpadding=0>";
        if ( close_button ) {
            popup_table = popup_table + "<tr>";
            popup_table = popup_table + "<td onClick=\"" + close_method + ";\" valign=\"middle\" align=\"right\" width=" + msg_width + " height=16 style=\"background-color:" + msg_color + " ;cursor:pointer;\">";
            popup_table = popup_table + "<img src=\"" + image_path + "cl_close.gif\" border=0 width=15 height=15>";
            popup_table = popup_table + "</td>";
            popup_table = popup_table + "</tr>";
        }
        popup_table = popup_table + "<tr onMouseMove=\"movePopup('" + popup_screen + "');\" onMouseDown=\"setPopupMoveable();\" onMouseUp=\"stopPopupMoveable();\" >";
        popup_table = popup_table + "<td valign=\"top\" width=" + msg_width + " height=" + (msg_height-16) + " style=\"background-color:" + msg_color + ";\">";
        popup_table = popup_table + "<center>";
        
        popup_table = popup_table + msg_content;
        
        popup_table = popup_table + "</center>";
        popup_table = popup_table + "</td>";
        popup_table = popup_table + "</tr>";
        popup_table = popup_table + "</table>";
        
        popup_table = popup_table + "</td>";
        popup_table = popup_table + "<td width=10 style=\"background-color:" + msg_color + "; background-image: url(" + image_path + "cl_line_right.gif);\" height=" + msg_height + "><img src=\"" + image_path + "cl_line_right.gif\" border=0 width=10 height=" + msg_height + "></td>";
        popup_table = popup_table + "</tr>";
        popup_table = popup_table + "<tr>";
        popup_table = popup_table + "<td width=10><img src=\"" + image_path + "cl_lower_left.gif\" border=0 width=10 height=10></td>";
        popup_table = popup_table + "<td width=" + msg_width + "  style=\"background-color:" + msg_color + "; background-image: url(" + image_path + "cl_line_bottom.gif);\"><img src=\"" + image_path + "cl_line_bottom.gif\" border=0 width=" + msg_width + " height=10></td>";
        popup_table = popup_table + "<td width=10><img src=\"" + image_path + "cl_lower_right.gif\" border=0 width=10 height=10></td>";
        popup_table = popup_table + "</tr>";
        popup_table = popup_table + "</table>";

        plasma_popup.innerHTML = popup_table;

        plasma_popup.style.display="";
     }

     function getPlasmaPopupMain(msg_color, msg_top, msg_left, msg_width, msg_height, msg_content, image_path)
     {
        var popup_table = "";
        
        popup_table = "<div style=\"z-index:89; position:absolute; display:none; top:" + msg_top + ";left:" + msg_left + ";\">";

        popup_table = popup_table + "<table width=" + (msg_width+20) + " border-5 cellspacing=0 cellpadding=0>";
        popup_table = popup_table + "<tr>";
        popup_table = popup_table + "<td width=10><img src=\"" + image_path + "cl_upper_left.gif\" border=0 width=10 height=10></td>";
        popup_table = popup_table + "<td width=" + msg_width + " style=\"background-color:" + msg_color + "; background-image: url(" + image_path + "cl_line_top.gif);\"><img src=\"" + image_path + "cl_line_top.gif\" border=0 width=" + msg_width + " height=10></td>";
        popup_table = popup_table + "<td width=10><img src=\"" + image_path + "cl_upper_right.gif\" border=0 width=10 height=10></td>";
        popup_table = popup_table + "</tr>";
        popup_table = popup_table + "<tr>";
        popup_table = popup_table + "<td width=10 style=\"background-color:" + msg_color + "; background-image: url(" + image_path + "cl_line_left.gif);\" height=" + msg_height + "><img src=\"" + image_path + "cl_line_left.gif\" border=0 width=10 height=" + msg_height + "></td>";
        popup_table = popup_table + "<td valign=\"top\" width=" + msg_width + " height=" + msg_height + " style=\"background-color:" + msg_color + ";\">";
        
        popup_table = popup_table + "<table width=" + msg_width + " border=0 cellspacing=0 cellpadding=0>";
        popup_table = popup_table + "<tr>";
        popup_table = popup_table + "<td valign=\"top\" width=" + msg_width + " height=" + (msg_height-16) + " style=\"background-color:" + msg_color + ";\">";
        popup_table = popup_table + "<center>";
        
        popup_table = popup_table + msg_content;
        
        popup_table = popup_table + "</center>";
        popup_table = popup_table + "</td>";
        popup_table = popup_table + "</tr>";
        popup_table = popup_table + "</table>";
        
        popup_table = popup_table + "</td>";
        popup_table = popup_table + "<td width=10 style=\"background-color:" + msg_color + "; background-image: url(" + image_path + "cl_line_right.gif);\" height=" + msg_height + "><img src=\"" + image_path + "cl_line_right.gif\" border=0 width=10 height=" + msg_height + "></td>";
        popup_table = popup_table + "</tr>";
        popup_table = popup_table + "<tr>";
        popup_table = popup_table + "<td width=10><img src=\"" + image_path + "cl_lower_left.gif\" border=0 width=10 height=10></td>";
        popup_table = popup_table + "<td width=" + msg_width + "  style=\"background-color:" + msg_color + "; background-image: url(" + image_path + "cl_line_bottom.gif);\"><img src=\"" + image_path + "cl_line_bottom.gif\" border=0 width=" + msg_width + " height=10></td>";
        popup_table = popup_table + "<td width=10><img src=\"" + image_path + "cl_lower_right.gif\" border=0 width=10 height=10></td>";
        popup_table = popup_table + "</tr>";
        popup_table = popup_table + "</table>";
        popup_table = popup_table + "</div>";
        
        return popup_table;
     }

    function setContentObject_Domain(content_obj)
    {
        var obj = setContentObject_BaseStructure(content_obj);

        if ( typeof(content_obj.site_domain ) == "object" ) {
            obj.site_domain = content_obj.site_domain["#text"];
        } else
            obj.site_domain = content_obj.site_domain;

        if ( typeof(content_obj.time_zone ) == "object" ) {
            obj.time_zone = content_obj.time_zone["#text"];
        } else
            obj.time_zone = content_obj.time_zone;

        if ( typeof(content_obj.locale ) == "object" ) {
            obj.locale = content_obj.locale["#text"];
        } else
            obj.locale = content_obj.locale;

        if ( typeof(content_obj.current_year ) == "object" ) {
            obj.current_year = content_obj.current_year["#text"];
        } else
            obj.current_year = content_obj.current_year;

        if ( typeof(content_obj.calendar_year_start_month ) == "object" ) {
            obj.calendar_year_start_month = content_obj.calendar_year_start_month["#text"];
        } else
            obj.calendar_year_start_month = content_obj.calendar_year_start_month;

        if ( typeof(content_obj.show_new_content_for ) == "object" ) {
            obj.show_new_content_for = content_obj.show_new_content_for["#text"];
        } else
            obj.show_new_content_for = content_obj.show_new_content_for;


        if ( typeof(content_obj.content_days_new ) == "object" ) {
            obj.content_days_new = content_obj.content_days_new["#text"];
        } else
            obj.content_days_new = content_obj.content_days_new;


        if ( typeof(content_obj.latest_updates_days ) == "object" ) {
            obj.latest_updates_days = content_obj.latest_updates_days["#text"];
        } else
            obj.latest_updates_days = content_obj.latest_updates_days;

        if ( typeof(content_obj.latest_update_days ) == "object" ) {
            obj.latest_update_days = content_obj.latest_update_days["#text"];
        } else
            obj.latest_update_days = content_obj.latest_update_days;

        if ( typeof(content_obj.password_length ) == "object" ) {
            obj.password_length = content_obj.password_length["#text"];
        } else
            obj.password_length = content_obj.password_length;

        if ( typeof(content_obj.password_change_days ) == "object" ) {
            obj.password_change_days = content_obj.password_change_days["#text"];
        } else
            obj.password_change_days = content_obj.password_change_days;

        if ( typeof(content_obj.password_complexity_required ) == "object" ) {
            obj.password_complexity_required = content_obj.password_complexity_required["#text"];
        } else
            obj.password_complexity_required = content_obj.password_complexity_required;

        if ( typeof(content_obj.password_block_after_failed_attempts ) == "object" ) {
            obj.password_block_after_failed_attempts = content_obj.password_block_after_failed_attempts["#text"];
        } else
            obj.password_block_after_failed_attempts = content_obj.password_block_after_failed_attempts;

        if ( typeof(content_obj.password_disable_remember_me ) == "object" ) {
            obj.password_disable_remember_me = content_obj.password_disable_remember_me["#text"];
        } else
            obj.password_disable_remember_me = content_obj.password_disable_remember_me;

        if ( typeof(content_obj.password_enforce_rules_for_other_users ) == "object" ) {
            obj.password_enforce_rules_for_other_users = content_obj.password_enforce_rules_for_other_users["#text"];
        } else
            obj.password_enforce_rules_for_other_users = content_obj.password_enforce_rules_for_other_users;

        if ( typeof(content_obj.domain_id ) == "object" ) {
            obj.domain_id = content_obj.domain_id["#text"];
        } else
            obj.domain_id = content_obj.domain_id;
        
        return obj;
        
    }

    function setContentObject_DomainStructure(content_obj)
    {
        var obj = setContentObject_BaseStructure(content_obj);

        if ( typeof(content_obj.parent_description ) == "object" ) {
            obj.parent_description = content_obj.parent_description["#text"];
        } else
            obj.parent_description = content_obj.parent_description;

        if ( typeof(content_obj.domain_id ) == "object" ) {
            obj.domain_id = content_obj.domain_id["#text"];
        } else
            obj.domain_id = content_obj.domain_id;

        if ( typeof(content_obj.location_id ) == "object" ) {
            obj.location_id = content_obj.location_id["#text"];
        } else
            obj.location_id = content_obj.location_id;

        if ( typeof(content_obj.opt_domain_id ) == "object" ) {
            obj.opt_domain_id = content_obj.opt_domain_id["#text"];
        } else
            obj.opt_domain_id = content_obj.opt_domain_id;

        return obj;
    }

    function setContentObject_OrganizationStructure(content_obj)
    {
        var obj = setContentObject_DomainStructure(content_obj);

        if ( typeof(content_obj.organization_id ) == "object" ) {
            obj.organization_id = content_obj.organization_id["#text"];
        } else
            obj.organization_id = content_obj.organization_id;

        if ( typeof(content_obj.opt_org_id ) == "object" ) {
            obj.opt_org_id = content_obj.opt_org_id["#text"];
        } else
            obj.opt_org_id = content_obj.opt_org_id;

        return obj;
    }

    function setContentObject_GroupStructure(content_obj)
    {
        var obj = setContentObject_OrganizationStructure(content_obj);

        if ( typeof(content_obj.group_id ) == "object" ) {
            obj.group_id = content_obj.group_id["#text"];
        } else
            obj.group_id = content_obj.group_id;

        if ( typeof(content_obj.opt_domain_id ) == "object" ) {
            obj.opt_domain_id = content_obj.opt_domain_id["#text"];
        } else
            obj.opt_domain_id = content_obj.opt_domain_id;

        if ( typeof(content_obj.opt_grp_id ) == "object" ) {
            obj.opt_grp_id = content_obj.opt_grp_id["#text"];
        } else
            obj.opt_grp_id = content_obj.opt_grp_id;

        if ( typeof(content_obj.opt_org_id ) == "object" ) {
            obj.opt_org_id = content_obj.opt_org_id["#text"];
        } else
            obj.opt_org_id = content_obj.opt_org_id;

        return obj;
    }

    function setContentObject_Organization(content_obj)
    {
        var obj = setContentObject_DomainStructure(content_obj);

        if ( typeof(content_obj.opt_org_id ) == "object" ) {
            obj.opt_org_id = content_obj.opt_org_id["#text"];
        } else
            obj.opt_org_id = content_obj.opt_org_id;


        return obj;
        
    }
    function setContentObject_Group(content_obj)
    {
        var obj = setContentObject_OrganizationStructure(content_obj);
        
        if ( typeof(content_obj.opt_grp_id ) == "object" ) {
            obj.opt_grp_id = content_obj.opt_grp_id["#text"];
        } else
            obj.opt_grp_id = content_obj.opt_grp_id;

        return obj;
        
    }
    function setContentObject_GroupSection(content_obj)
    {
        var obj = setContentObject_GroupStructure(content_obj);

        if ( typeof(content_obj.period_id ) == "object" ) {
            obj.period_id = content_obj.period_id["#text"];
        } else
            obj.period_id = content_obj.period_id;
        
        return obj;
        
    }

    function setContentObject_BaseStructure(content_obj)
    {
        var obj = new Object();

        if ( typeof(content_obj.field1 ) == "object" ) {
            obj.field1 = content_obj.field1["#text"];
        } else
            obj.field1 = content_obj.field1;

        if ( typeof(content_obj.field2 ) == "object" ) {
            obj.field2 = content_obj.field2["#text"];
        } else
            obj.field2 = content_obj.field2;

        if ( typeof(content_obj.field3 ) == "object" ) {
            obj.field3 = content_obj.field3["#text"];
        } else
            obj.field3 = content_obj.field3;

        if ( typeof(content_obj.field4 ) == "object" ) {
            obj.field4 = content_obj.field4["#text"];
        } else
            obj.field4 = content_obj.field4;

        if ( typeof(content_obj.field5 ) == "object" ) {
            obj.field5 = content_obj.field5["#text"];
        } else
            obj.field5 = content_obj.field5;

        if ( typeof(content_obj.domain_template ) == "object" ) {
            obj.domain_template = content_obj.domain_template["#text"];
        } else
            obj.domain_template = content_obj.domain_template;
        
        if ( typeof(content_obj.id ) == "object" ) {
            obj.id = content_obj.id["#text"];
        } else
            obj.id = content_obj.id;

        if ( typeof(content_obj.key ) == "object" ) {
            obj.key = content_obj.key["#text"];
        } else
            obj.key = content_obj.key;

        if ( !obj.key )
            obj.key = "";

        if ( typeof(content_obj.description ) == "object" )
            obj.description = content_obj.description["#cdata-section"];
        else
            obj.description = content_obj.description;

        var t_active = "";
        if ( typeof(content_obj.active ) == "object" )
            t_active = content_obj.active["#text"];
        else
            t_active = content_obj.active;

        if ( t_active == "true" )
            obj.active = true;
        else
            obj.active = false;

        var t_active_exists = "";
        if ( content_obj.active_exists ) {
            if ( typeof(content_obj.active_exists ) == "object" )
                t_active_exists = content_obj.active_exists["#text"];
            else
                t_active_exists = content_obj.active_exists;
        }
        if ( t_active_exists == "true" )
            obj.active_exists = true;
        else
            obj.active_exists = false;


        if ( typeof(content_obj.logo_id ) == "object" )
            obj.logo_id = content_obj.logo_id["#text"];
        else
            obj.logo_id = content_obj.logo_id;

        if ( typeof(content_obj.membership_option ) == "object" )
            obj.membership_option = content_obj.membership_option["#text"];
        else
            obj.membership_option = content_obj.membership_option;

        if ( typeof(content_obj.directory_access ) == "object" )
            obj.directory_access = content_obj.directory_access["#text"];
        else
            obj.directory_access = content_obj.directory_access;

        if ( typeof(content_obj.template ) == "object" )
            obj.template = content_obj.template["#text"];
        else
            obj.template = content_obj.template;

        if ( typeof(content_obj.background ) == "object" )
            obj.background = content_obj.background["#text"];
        else
            obj.background = content_obj.background;

        if ( typeof(content_obj.style ) == "object" )
            obj.style = content_obj.style["#text"];
        else
            obj.style = content_obj.style;

        if ( typeof(content_obj.source ) == "object" )
            obj.source = content_obj.source["#text"];
        else
            obj.source = content_obj.source;

        return obj;
    }

    function setContentObject_Data(content_obj)
    {
        var obj = new Object();
        
        if ( typeof(content_obj.id ) == "object" ) {
            obj.id = content_obj.id["#cdata-section"];
        } else
            obj.id = content_obj.id;

        if ( typeof(content_obj.parent_id ) == "object" )
            obj.parent_id = content_obj.parent_id["#cdata-section"];
        else
            obj.parent_id = content_obj.parent_id;

        if ( typeof(content_obj.domain_id ) == "object" )
            obj.domain_id = content_obj.domain_id["#cdata-section"];
        else
            obj.domain_id = content_obj.domain_id;

        if ( typeof(content_obj.source_id ) == "object" )
            obj.source_id = content_obj.source_id["#cdata-section"];
        else
            obj.source_id = content_obj.source_id;

        if ( typeof(content_obj.security_level ) == "object" )
            obj.security_level = content_obj.security_level["#cdata-section"];
        else
            obj.security_level = content_obj.security_level;

        if ( typeof(content_obj.creation_date ) == "object" )
            obj.creation_date = content_obj.creation_date["#cdata-section"];
        else
            obj.creation_date = content_obj.creation_date;

        if ( typeof(content_obj.creation_time ) == "object" )
            obj.creation_time = content_obj.creation_time["#cdata-section"];
        else
            obj.creation_time = content_obj.creation_time;

        if ( typeof(content_obj.creation_contact_id ) == "object" )
            obj.creation_contact_id = content_obj.creation_contact_id["#cdata-section"];
        else
            obj.creation_contact_id = content_obj.creation_contact_id;

        if ( typeof(content_obj.modified_date ) == "object" )
            obj.modified_date = content_obj.modified_date["#cdata-section"];
        else
            obj.modified_date = content_obj.modified_date;

        if ( typeof(content_obj.modified_time ) == "object" )
            obj.modified_time = content_obj.modified_time["#cdata-section"];
        else
            obj.modified_time = content_obj.modified_time;

        if ( typeof(content_obj.modified_contact_id ) == "object" )
            obj.modified_contact_id = content_obj.modified_contact_id["#cdata-section"];
        else
            obj.modified_contact_id = content_obj.modified_contact_id;

        if ( typeof(content_obj.posted ) == "object" )
            obj.posted = content_obj.posted["#cdata-section"];
        else
            obj.posted = content_obj.posted;

        if ( typeof(content_obj.post_date ) == "object" )
            obj.post_date = content_obj.post_date["#cdata-section"];
        else
            obj.post_date = content_obj.post_date;

        if ( typeof(content_obj.post_urgency ) == "object" )
            obj.post_urgency = content_obj.post_urgency["#cdata-section"];
        else
            obj.post_urgency = content_obj.post_urgency;

        if ( typeof(content_obj.expires ) == "object" )
            obj.expires = content_obj.expires["#cdata-section"];
        else
            obj.expires = content_obj.expires;

        if ( typeof(content_obj.expiration_date ) == "object" )
            obj.expiration_date = content_obj.expiration_date["#cdata-section"];
        else
            obj.expiration_date = content_obj.expiration_date;

        if ( typeof(content_obj.contact_id ) == "object" )
            obj.contact_id = content_obj.contact_id["#cdata-section"];
        else
            obj.contact_id = content_obj.contact_id;

        if ( typeof(content_obj.title ) == "object" )
            obj.title = content_obj.title["#cdata-section"];
        else
            obj.title = content_obj.title;

        if ( typeof(content_obj.sub_title ) == "object" )
            obj.sub_title = content_obj.sub_title["#cdata-section"];
        else
            obj.sub_title = content_obj.sub_title;

        if ( typeof(content_obj.group_title ) == "object" )
            obj.group_title = content_obj.group_title["#cdata-section"];
        else
            obj.group_title = content_obj.group_title;

        if ( typeof(content_obj.section_title ) == "object" )
            obj.section_title = content_obj.section_title["#cdata-section"];
        else
            obj.section_title = content_obj.section_title;

        if ( typeof(content_obj.summary ) == "object" )
            obj.summary = content_obj.summary["#cdata-section"];
        else
            obj.summary = content_obj.summary;

        if ( typeof(content_obj.full_text ) == "object" )
            obj.full_text = content_obj.full_text["#cdata-section"];
        else
            obj.full_text = content_obj.full_text;

        if ( typeof(content_obj.index_0 ) == "object" )
            obj.index_0 = content_obj.index_0["#cdata-section"];
        else
            obj.index_0 = content_obj.index_0;

        if ( typeof(content_obj.index_1 ) == "object" )
            obj.index_1 = content_obj.index_1["#cdata-section"];
        else
            obj.index_1 = content_obj.index_1;

        if ( typeof(content_obj.index_2 ) == "object" )
            obj.index_2 = content_obj.index_2["#cdata-section"];
        else
            obj.index_2 = content_obj.index_2;

        if ( typeof(content_obj.index_3 ) == "object" )
            obj.index_3 = content_obj.index_3["#cdata-section"];
        else
            obj.index_3 = content_obj.index_3;

        if ( typeof(content_obj.index_4 ) == "object" )
            obj.index_4 = content_obj.index_4["#cdata-section"];
        else
            obj.index_4 = content_obj.index_4;

        if ( typeof(content_obj.index_5 ) == "object" )
            obj.index_5 = content_obj.index_5["#cdata-section"];
        else
            obj.index_5 = content_obj.index_5;

        if ( typeof(content_obj.index_6 ) == "object" )
            obj.index_6 = content_obj.index_6["#cdata-section"];
        else
            obj.index_6 = content_obj.index_6;

        if ( typeof(content_obj.index_7 ) == "object" )
            obj.index_7 = content_obj.index_7["#cdata-section"];
        else
            obj.index_7 = content_obj.index_7;

        if ( typeof(content_obj.index_8 ) == "object" )
            obj.index_8 = content_obj.index_8["#cdata-section"];
        else
            obj.index_8 = content_obj.index_8;

        if ( typeof(content_obj.index_9 ) == "object" )
            obj.index_9 = content_obj.index_9["#cdata-section"];
        else
            obj.index_9 = content_obj.index_9;

        if ( typeof(content_obj.data_path ) == "object" )
            obj.data_path = content_obj.data_path["#cdata-section"];
        else
            obj.data_path = content_obj.data_path;

        if ( typeof(content_obj.data_field ) == "object" )
            obj.data_field = content_obj.data_field["#cdata-section"];
        else
            obj.data_field = content_obj.data_field;

        if ( typeof(content_obj.data_costs ) == "object" )
            obj.data_costs = content_obj.data_costs["#cdata-section"];
        else
            obj.data_costs = content_obj.data_costs;

        return obj;
        
    }

    function setContentObject_Base(content_obj)
    {
        var obj = new Object();
        
        if ( typeof(content_obj.id ) == "object" ) {
            obj.id = content_obj.id["#text"];
        } else
            obj.id = content_obj.id;

        if ( typeof(content_obj.parent_id ) == "object" )
            obj.parent_id = content_obj.parent_id["#text"];
        else
            obj.parent_id = content_obj.parent_id;

        if ( typeof(content_obj.domain_id ) == "object" )
            obj.domain_id = content_obj.domain_id["#text"];
        else
            obj.domain_id = content_obj.domain_id;

        if ( typeof(content_obj.source_id ) == "object" )
            obj.source_id = content_obj.source_id["#text"];
        else
            obj.source_id = content_obj.source_id;

        if ( typeof(content_obj.security_level ) == "object" )
            obj.security_level = content_obj.security_level["#text"];
        else
            obj.security_level = content_obj.security_level;

        if ( typeof(content_obj.contact_id ) == "object" )
            obj.contact_id = content_obj.contact_id["#text"];
        else
            obj.contact_id = content_obj.contact_id;

        if ( typeof(content_obj.location_id ) == "object" )
            obj.location_id = content_obj.location_id["#text"];
        else
            obj.location_id = content_obj.location_id;

        if ( typeof(content_obj.location_desc ) == "object" )
            obj.location_desc = content_obj.location_desc["#text"];
        else
            obj.location_desc = content_obj.location_desc;

        if ( typeof(content_obj.deleted ) == "object" )
            obj.deleted = content_obj.deleted["#text"];
        else
            obj.deleted = content_obj.deleted;

        if ( typeof(content_obj.creation_date ) == "object" )
            obj.creation_date = content_obj.creation_date["#text"];
        else
            obj.creation_date = content_obj.creation_date;

        if ( typeof(content_obj.creation_time ) == "object" )
            obj.creation_time = content_obj.creation_time["#text"];
        else
            obj.creation_time = content_obj.creation_time;

        if ( typeof(content_obj.creation_contact_id ) == "object" )
            obj.creation_contact_id = content_obj.creation_contact_id["#text"];
        else
            obj.creation_contact_id = content_obj.creation_contact_id;

        if ( typeof(content_obj.modified_date ) == "object" )
            obj.modified_date = content_obj.modified_date["#text"];
        else
            obj.modified_date = content_obj.modified_date;

        if ( typeof(content_obj.modified_time ) == "object" )
            obj.modified_time = content_obj.modified_time["#text"];
        else
            obj.modified_time = content_obj.modified_time;

        if ( typeof(content_obj.modified_contact_id ) == "object" )
            obj.modified_contact_id = content_obj.modified_contact_id["#text"];
        else
            obj.modified_contact_id = content_obj.modified_contact_id;

        if ( typeof(content_obj.posted ) == "object" )
            obj.posted = content_obj.posted["#text"];
        else
            obj.posted = content_obj.posted;

        if ( typeof(content_obj.post_date ) == "object" )
            obj.post_date = content_obj.post_date["#text"];
        else
            obj.post_date = content_obj.post_date;

        if ( typeof(content_obj.post_urgency ) == "object" )
            obj.post_urgency = content_obj.post_urgency["#text"];
        else
            obj.post_urgency = content_obj.post_urgency;

        if ( typeof(content_obj.expires ) == "object" )
            obj.expires = content_obj.expires["#text"];
        else
            obj.expires = content_obj.expires;

        if ( typeof(content_obj.expiration_date ) == "object" )
            obj.expiration_date = content_obj.expiration_date["#text"];
        else
            obj.expiration_date = content_obj.expiration_date;

        if ( typeof(content_obj.title ) == "object" )
            obj.title = content_obj.title["#cdata-section"];
        else
            obj.title = content_obj.title;

        if ( typeof(content_obj.sub_title ) == "object" )
            obj.sub_title = content_obj.sub_title["#cdata-section"];
        else
            obj.sub_title = content_obj.sub_title;

        if ( typeof(content_obj.author ) == "object" )
            obj.author = content_obj.author["#cdata-section"];
        else
            obj.author = content_obj.author;

        if ( typeof(content_obj.description ) == "object" )
            obj.description = content_obj.description["#cdata-section"];
        else
            obj.description = content_obj.description;

        if ( typeof(content_obj.category ) == "object" )
            obj.category = content_obj.category["#cdata-section"];
        else
            obj.category = content_obj.category;

        if ( typeof(content_obj.subject ) == "object" )
            obj.subject = content_obj.subject["#cdata-section"];
        else
            obj.subject = content_obj.subject;

        if ( typeof(content_obj.key_words ) == "object" )
            obj.key_words = content_obj.key_words["#cdata-section"];
        else
            obj.key_words = content_obj.key_words;

        if ( typeof(content_obj.comments ) == "object" )
            obj.comments = content_obj.comments["#cdata-section"];
        else
            obj.comments = content_obj.comments;
            
        return obj;
        
    }

    function setContentObject_Indexed(content_obj)
    {
        var obj = setContentObject_Base(content_obj);
        
        if ( typeof(content_obj.index_1 ) == "object" )
            obj.index_1 = content_obj.index_1["#cdata-section"];
        else
            obj.index_1 = content_obj.index_1;

        if ( typeof(content_obj.index_2 ) == "object" )
            obj.index_2 = content_obj.index_2["#cdata-section"];
        else
            obj.index_2 = content_obj.index_2;

        if ( typeof(content_obj.index_3 ) == "object" )
            obj.index_3 = content_obj.index_3["#cdata-section"];
        else
            obj.index_3 = content_obj.index_3;

        if ( typeof(content_obj.index_4 ) == "object" )
            obj.index_4 = content_obj.index_4["#cdata-section"];
        else
            obj.index_4 = content_obj.index_4;

        if ( typeof(content_obj.index_5 ) == "object" )
            obj.index_5 = content_obj.index_5["#cdata-section"];
        else
            obj.index_5 = content_obj.index_5;

        if ( typeof(content_obj.index_6 ) == "object" )
            obj.index_6 = content_obj.index_6["#cdata-section"];
        else
            obj.index_6 = content_obj.index_6;

        if ( typeof(content_obj.index_7 ) == "object" )
            obj.index_7 = content_obj.index_7["#cdata-section"];
        else
            obj.index_7 = content_obj.index_7;

        if ( typeof(content_obj.index_8 ) == "object" )
            obj.index_8 = content_obj.index_8["#cdata-section"];
        else
            obj.index_8 = content_obj.index_8;

        if ( typeof(content_obj.index_9 ) == "object" )
            obj.index_9 = content_obj.index_9["#cdata-section"];
        else
            obj.index_9 = content_obj.index_9;

        if ( typeof(content_obj.index_10 ) == "object" )
            obj.index_10 = content_obj.index_10["#cdata-section"];
        else
            obj.index_10 = content_obj.index_10;

        
        return obj;
        
    }

    function setContentObject_ContentMap(content_obj)
    {
        var obj = setContentObject_Base(content_obj);

        if ( typeof(content_obj.content_name ) == "object" )
            obj.content_name = content_obj.content_name["#text"];
        else
            obj.content_name = content_obj.content_name;

        if ( typeof(content_obj.icon ) == "object" )
            obj.icon = content_obj.icon["#text"];
        else
            obj.icon = content_obj.icon;

        if ( typeof(content_obj.width ) == "object" )
            obj.width = content_obj.width["#text"];
        else
            obj.width = content_obj.width;

        if ( typeof(content_obj.structure_override_type ) == "object" )
            obj.structure_override_type = content_obj.structure_override_type["#text"];
        else
            obj.structure_override_type = content_obj.structure_override_type;

        if ( typeof(content_obj.structure_override_key ) == "object" )
            obj.structure_override_key = content_obj.structure_override_key["#text"];
        else
            obj.structure_override_key = content_obj.structure_override_key;

        if ( typeof(content_obj.screen ) == "object" )
            obj.screen = content_obj.screen["#text"];
        else
            obj.screen = content_obj.screen;

        if ( typeof(content_obj.role_id ) == "object" )
            obj.role_id = content_obj.role_id["#text"];
        else
            obj.role_id = content_obj.role_id;

        if ( typeof(content_obj.menu ) == "object" )
            obj.menu = content_obj.menu["#text"];
        else
            obj.menu = content_obj.menu;

        if ( typeof(content_obj.main_source ) == "object" )
            obj.main_source = content_obj.main_source["#text"];
        else
            obj.main_source = content_obj.main_source;

        setNodes(content_obj, obj);

        return obj;
    }

    function setNodes(content_obj, obj)
    {
        if ( content_obj.node ) {
            if ( content_obj.node.length ) {
                obj.nodes = new Array();
                for ( var i = 0; i < content_obj.node.length; i++ ) {
                    var node = setContentObject_ContentMap(content_obj.node[i]);
                    obj.nodes[obj.nodes.length] = node;
                    setNodes(content_obj.node[i],node);
                }
            } else {
                obj.nodes = new Array();
                var node = setContentObject_ContentMap(content_obj.node);
                obj.nodes[obj.nodes.length] = node;
                setNodes(content_obj.node,node);
            }
        }
    }

    function setContentObject_PhotoAlbum(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);

        if ( typeof(content_obj.has_children ) == "object" ) {
            var hc = content_obj.has_children["#text"];
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        } else {
            var hc = content_obj.has_children;
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        }        

        return obj;
    }

    function setContentObject_Folder(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);

        if ( typeof(content_obj.has_children ) == "object" ) {
            var hc = content_obj.has_children["#text"];
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        } else {
            var hc = content_obj.has_children;
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        }        

        return obj;
    }

    function setContentObject_Photo(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);

        if ( typeof(content_obj.album_id ) == "object" )
            obj.album_id = content_obj.album_id["#text"];
        else
            obj.album_id = content_obj.album_id;
        
        if ( typeof(content_obj.photo_name ) == "object" )
            obj.photo_name = content_obj.photo_name["#text"];
        else
            obj.photo_name = content_obj.photo_name;

        if ( typeof(content_obj.size ) == "object" )
            obj.size = content_obj.size["#text"];
        else
            obj.size = content_obj.size;

        if ( typeof(content_obj.mime_type ) == "object" )
            obj.mime_type = content_obj.mime_type["#text"];
        else
            obj.mime_type = content_obj.mime_type;

        return obj;
    }
    function setContentObject_FormElement(content_obj)
    {
        var obj = new Object();

        if ( typeof(content_obj.id ) == "object" ) {
            obj.id = content_obj.id["#text"];
        } else
            obj.id = content_obj.id;

        if ( typeof(content_obj.form_id ) == "object" ) {
            obj.form_id = content_obj.form_id["#text"];
        } else
            obj.form_id = content_obj.form_id;

        if ( typeof(content_obj.page_number ) == "object" ) {
            obj.page_number = content_obj.page_number["#text"];
        } else
            obj.page_number = content_obj.page_number;

        if ( typeof(content_obj.section_number ) == "object" ) {
            obj.section_number = content_obj.section_number["#text"];
        } else
            obj.section_number = content_obj.section_number;

        if ( typeof(content_obj.field_name ) == "object" ) {
            obj.field_name = content_obj.field_name["#text"];
        } else
            obj.field_name = content_obj.field_name;

        if ( typeof(content_obj.field_label ) == "object" ) {
            obj.field_label = content_obj.field_label["#text"];
        } else
            obj.field_label = content_obj.field_label;

        if ( typeof(content_obj.data_type ) == "object" ) {
            obj.data_type = content_obj.data_type["#text"];
        } else
            obj.data_type = content_obj.data_type;

        if ( typeof(content_obj.sum_data_type ) == "object" ) {
            obj.sum_data_type = content_obj.sum_data_type["#text"];
        } else
            obj.sum_data_type = content_obj.sum_data_type;

        if ( typeof(content_obj.price_field_type ) == "object" ) {
            obj.price_field_type = content_obj.price_field_type["#text"];
        } else
            obj.price_field_type = content_obj.price_field_type;

        if ( typeof(content_obj.system_field ) == "object" ) {
            obj.system_field = content_obj.system_field["#text"];
        } else
            obj.system_field = content_obj.system_field;

        if ( typeof(content_obj.default_value ) == "object" )
            obj.default_value = content_obj.default_value["#cdata-section"];
        else
            obj.default_value = content_obj.default_value;

        if ( typeof(content_obj.calculation_rules ) == "object" )
            obj.calculation_rules = content_obj.calculation_rules["#cdata-section"];
        else
            obj.calculation_rules = content_obj.calculation_rules;

        if ( typeof(content_obj.read_only ) == "object" ) {
            var hc = content_obj.read_only["#text"];
            if ( hc == "true" )
                obj.read_only = true;
            else
                obj.read_only = false;
        } else {
            var hc = content_obj.read_only;
            if ( hc == "true" )
                obj.read_only = true;
            else
                obj.read_only = false;
        }        

        if ( typeof(content_obj.hidden ) == "object" ) {
            var hc = content_obj.hidden["#text"];
            if ( hc == "true" )
                obj.hidden = true;
            else
                obj.hidden = false;
        } else {
            var hc = content_obj.hidden;
            if ( hc == "true" )
                obj.hidden = true;
            else
                obj.hidden = false;
        }        

        if ( typeof(content_obj.ignore_if_hidden ) == "object" ) {
            var hc = content_obj.ignore_if_hidden["#text"];
            if ( hc == "true" )
                obj.ignore_if_hidden = true;
            else
                obj.ignore_if_hidden = false;
        } else {
            var hc = content_obj.ignore_if_hidden;
            if ( hc == "true" )
                obj.ignore_if_hidden = true;
            else
                obj.ignore_if_hidden = false;
        }        

        if ( typeof(content_obj.branch_pages ) == "object" ) {
            obj.branch_pages = content_obj.branch_pages["#text"];
        } else
            obj.branch_pages = content_obj.branch_pages;

        if ( typeof(content_obj.unhide_sections ) == "object" ) {
            obj.unhide_sections = content_obj.unhide_sections["#text"];
        } else
            obj.unhide_sections = content_obj.unhide_sections;

        if ( typeof(content_obj.hide_sections ) == "object" ) {
            obj.hide_sections = content_obj.hide_sections["#text"];
        } else
            obj.hide_sections = content_obj.hide_sections;

        return obj;
    }
    function setContentObject_FormSection(content_obj)
    {
        var obj = new Object();

        if ( typeof(content_obj.page_number ) == "object" ) {
            obj.page_number = content_obj.page_number["#text"];
        } else
            obj.page_number = content_obj.page_number;

        if ( typeof(content_obj.section_number ) == "object" ) {
            obj.section_number = content_obj.section_number["#text"];
        } else
            obj.section_number = content_obj.section_number;

        if ( typeof(content_obj.hidden ) == "object" ) {
            var hc = content_obj.hidden["#text"];
            if ( hc == "true" )
                obj.hidden = true;
            else
                obj.hidden = false;
        } else {
            var hc = content_obj.hidden;
            if ( hc == "true" )
                obj.hidden = true;
            else
                obj.hidden = false;
        }        

        if ( typeof(content_obj.form_html ) == "object" )
            obj.form_html = content_obj.form_html["#cdata-section"];
        else
            obj.form_html = content_obj.form_html;

        if ( typeof(content_obj.has_children ) == "object" ) {
            var hc = content_obj.has_children["#text"];
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        } else {
            var hc = content_obj.has_children;
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        }        

        if ( typeof(content_obj.iconOpened ) == "object" )
            obj.iconOpened = content_iconOpened["#text"];
        else
            obj.iconOpened = content_obj.iconOpened;

        if ( typeof(content_obj.iconClosed ) == "object" )
            obj.iconClosed = content_iconClosed["#text"];
        else
            obj.iconClosed = content_obj.iconClosed;

        return obj;
    }
    function setContentObject_FormPage(content_obj)
    {
        var obj = new Object();

        if ( typeof(content_obj.page_number ) == "object" ) {
            obj.page_number = content_obj.page_number["#text"];
        } else
            obj.page_number = content_obj.page_number;

        if ( typeof(content_obj.has_children ) == "object" ) {
            var hc = content_obj.has_children["#text"];
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        } else {
            var hc = content_obj.has_children;
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        }        

        if ( typeof(content_obj.iconOpened ) == "object" )
            obj.iconOpened = content_iconOpened["#text"];
        else
            obj.iconOpened = content_obj.iconOpened;

        if ( typeof(content_obj.iconClosed ) == "object" )
            obj.iconClosed = content_iconClosed["#text"];
        else
            obj.iconClosed = content_obj.iconClosed;

        return obj;
    }
    function setContentObject_Form(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);

        if ( typeof(content_obj.email_field ) == "object" )
            obj.email_field = content_obj.email_field["#text"];
        else
            obj.email_field = content_obj.email_field;
        
        if ( typeof(content_obj.create_contact ) == "object" ) {
            var hc = content_obj.create_contact["#text"];
            if ( hc == "true" )
                obj.create_contact = true;
            else
                obj.create_contact = false;
        } else {
            var hc = content_obj.create_contact;
            if ( hc == "true" )
                obj.create_contact = true;
            else
                obj.create_contact = false;
        }        

        if ( typeof(content_obj.online_payment ) == "object" ) {
            var hc = content_obj.online_payment["#text"];
            if ( hc == "true" )
                obj.online_payment = true;
            else
                obj.online_payment = false;
        } else {
            var hc = content_obj.online_payment;
            if ( hc == "true" )
                obj.online_payment = true;
            else
                obj.online_payment = false;
        }        

        if ( typeof(content_obj.has_children ) == "object" ) {
            var hc = content_obj.has_children["#text"];
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        } else {
            var hc = content_obj.has_children;
            if ( hc == "true" )
                obj.has_children = true;
            else
                obj.has_children = false;
        }        

        if ( typeof(content_obj.iconOpened ) == "object" )
            obj.iconOpened = content_iconOpened["#text"];
        else
            obj.iconOpened = content_obj.iconOpened;

        if ( typeof(content_obj.iconClosed ) == "object" )
            obj.iconClosed = content_iconClosed["#text"];
        else
            obj.iconClosed = content_obj.iconClosed;

        return obj;
    }
    function setContentObject_Document(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);

        if ( typeof(content_obj.folder_id ) == "object" )
            obj.folder_id = content_obj.folder_id["#text"];
        else
            obj.folder_id = content_obj.folder_id;
        
        if ( typeof(content_obj.document_name ) == "object" )
            obj.document_name = content_obj.document_name["#cdata-section"];
        else
            obj.document_name = content_obj.document_name;

        if ( typeof(content_obj.size ) == "object" )
            obj.size = content_obj.size["#text"];
        else
            obj.size = content_obj.size;

        if ( typeof(content_obj.mime_type ) == "object" )
            obj.mime_type = content_obj.mime_type["#text"];
        else
            obj.mime_type = content_obj.mime_type;

        return obj;
    }
    function setContentObject_MeetType(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Customer(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);

        if ( typeof(content_obj.customer_contact_id ) == "object" )
            obj.customer_contact_id = content_obj.customer_contact_id["#text"];
        else
            obj.customer_contact_id = content_obj.customer_contact_id;

        if ( typeof(content_obj.employee_id ) == "object" )
            obj.employee_id = content_obj.employee_id["#text"];
        else
            obj.employee_id = content_obj.employee_id;

        if ( typeof(content_obj.customer_type ) == "object" )
            obj.customer_type = content_obj.customer_type["#text"];
        else
            obj.customer_type = content_obj.customer_type;
        
        return obj;
    }
    function setContentObject_ClassSection(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Announcement(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Auction(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Auction_Donor(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Article(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Blog(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Link(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Sponsor(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);

        if ( typeof(content_obj.line1_size ) == "object" ) {
            obj.line1_size = content_obj.line1_size["#cdata-section"];
        } else
            obj.line1_size = content_obj.line1_size;
        if ( typeof(content_obj.line2_size ) == "object" ) {
            obj.line2_size = content_obj.line2_size["#cdata-section"];
        } else
            obj.line2_size = content_obj.line2_size;
        if ( typeof(content_obj.line3_size ) == "object" ) {
            obj.line3_size = content_obj.line3_size["#cdata-section"];
        } else
            obj.line3_size = content_obj.line3_size;

        if ( typeof(content_obj.line1_color ) == "object" ) {
            obj.line1_color = content_obj.line1_color["#cdata-section"];
        } else
            obj.line1_color = content_obj.line1_color;
        if ( typeof(content_obj.line2_color ) == "object" ) {
            obj.line2_color = content_obj.line2_color["#cdata-section"];
        } else
            obj.line2_color = content_obj.line2_color;
        if ( typeof(content_obj.line3_color ) == "object" ) {
            obj.line3_color = content_obj.line3_color["#cdata-section"];
        } else
            obj.line3_color = content_obj.line3_color;

        if ( typeof(content_obj.line1_font ) == "object" ) {
            obj.line1_font = content_obj.line1_font["#cdata-section"];
        } else
            obj.line1_font = content_obj.line1_font;
        if ( typeof(content_obj.line2_font ) == "object" ) {
            obj.line2_font = content_obj.line2_font["#cdata-section"];
        } else
            obj.line2_font = content_obj.line2_font;
        if ( typeof(content_obj.line3_font ) == "object" ) {
            obj.line3_font = content_obj.line3_font["#cdata-section"];
        } else
            obj.line3_font = content_obj.line3_font;

        return obj;
    }
    function setContentObject_Homework(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Job(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Market(content_obj)
    {
        var obj = new Object();

        obj.zipcode = content_obj.zipcode;
        obj.zipcodes = content_obj.zipcodes;

        if ( typeof(content_obj.id ) == "object" ) {
            obj.id = content_obj.id["#text"];
        } else
            obj.id = content_obj.id;

        if ( typeof(content_obj.description ) == "object" )
            obj.description = content_obj.description["#cdata-section"];
        else
            obj.description = content_obj.description;

        return obj;
    }
    function setContentObject_Category(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        return obj;
    }
    function setContentObject_Section(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        
        if ( typeof(content_obj.section_group ) == "object" )
            obj.section_group = content_obj.section_group["#text"];
        else
            obj.section_group = content_obj.section_group;
        return obj;
    }
    function setContentObject_Email(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);
        if ( typeof(content_obj.to_list ) == "object" )
            obj.to_list = content_obj.to_list["#text"];
        else
            obj.to_list = content_obj.to_list;
        
        if ( typeof(content_obj.to_list_description ) == "object" )
            obj.to_list_description = content_obj.to_list_description["#text"];
        else
            obj.to_list_description = content_obj.to_list_description;

        if ( typeof(content_obj.reply_to ) == "object" )
            obj.reply_to = content_obj.reply_to["#text"];
        else
            obj.reply_to = content_obj.reply_to;

        if ( typeof(content_obj.mime_type ) == "object" )
            obj.mime_type = content_obj.mime_type["#text"];
        else
            obj.mime_type = content_obj.mime_type;
        
        return obj;
    }

    function setContentObject_SwimScheduleTemplate(content_obj)
    {
        var obj = setContentObject_Event(content_obj);
        return obj;
    }
    function setContentObject_SwimSchedule(content_obj)
    {
        var obj = setContentObject_Event(content_obj);
        if ( typeof(content_obj.event_host ) == "object" ) {
            obj.event_host = content_obj.event_host["#text"];
        } else
            obj.event_host = content_obj.event_host;

        return obj;
    }
    function setContentObject_SwimStructure(content_obj)
    {
        var obj = new Object();

        if ( typeof(content_obj.id ) == "object" ) {
            obj.id = content_obj.id["#text"];
        } else
            obj.id = content_obj.id;

        if ( typeof(content_obj.domain_id ) == "object" ) {
            obj.domain_id = content_obj.domain_id["#text"];
        } else
            obj.domain_id = content_obj.domain_id;

        if ( typeof(content_obj.parent_source_id ) == "object" ) {
            obj.parent_source_id = content_obj.parent_source_id["#text"];
        } else
            obj.parent_source_id = content_obj.parent_source_id;

        if ( typeof(content_obj.child_source_id ) == "object" ) {
            obj.child_source_id = content_obj.child_source_id["#text"];
        } else
            obj.child_source_id = content_obj.child_source_id;

        if ( typeof(content_obj.seed_year ) == "object" ) {
            obj.seed_year = content_obj.seed_year["#text"];
        } else
            obj.seed_year = content_obj.seed_year;

        if ( typeof(content_obj.seed_level ) == "object" ) {
            obj.seed_level = content_obj.seed_level["#text"];
        } else
            obj.seed_level = content_obj.seed_level;

        if ( typeof(content_obj.won ) == "object" ) {
            obj.won = content_obj.won["#text"];
        } else
            obj.won = content_obj.won;

        if ( typeof(content_obj.lost ) == "object" ) {
            obj.lost = content_obj.lost["#text"];
        } else
            obj.lost = content_obj.lost;

        if ( typeof(content_obj.tied ) == "object" ) {
            obj.tied = content_obj.tied["#text"];
        } else
            obj.tied = content_obj.tied;

        if ( typeof(content_obj.score ) == "object" ) {
            obj.score = content_obj.score["#text"];
        } else
            obj.score = content_obj.score;

        if ( typeof(content_obj.points ) == "object" ) {
            obj.points = content_obj.points["#text"];
        } else
            obj.points = content_obj.points;

        if ( typeof(content_obj.points_1 ) == "object" ) {
            obj.points_1 = content_obj.points_1["#text"];
        } else
            obj.points_1 = content_obj.points_1;

        if ( typeof(content_obj.points_2 ) == "object" ) {
            obj.points_2 = content_obj.points_2["#text"];
        } else
            obj.points_2 = content_obj.points_2;

        if ( typeof(content_obj.points_3 ) == "object" ) {
            obj.points_3 = content_obj.points_3["#text"];
        } else
            obj.points_3 = content_obj.points_3;

        if ( typeof(content_obj.points_4 ) == "object" ) {
            obj.points_4 = content_obj.points_4["#text"];
        } else
            obj.points_4 = content_obj.points_4;

        if ( typeof(content_obj.points_5 ) == "object" ) {
            obj.points_5 = content_obj.points_5["#text"];
        } else
            obj.points_5 = content_obj.points_5;

        if ( typeof(content_obj.won_overall ) == "object" ) {
            obj.won_overall = content_obj.won_overall["#text"];
        } else
            obj.won_overall = content_obj.won_overall;

        if ( typeof(content_obj.lost_overall ) == "object" ) {
            obj.lost_overall = content_obj.lost_overall["#text"];
        } else
            obj.lost_overall = content_obj.lost_overall;

        if ( typeof(content_obj.tied_overall ) == "object" ) {
            obj.tied_overall = content_obj.tied_overall["#text"];
        } else
            obj.tied_overall = content_obj.tied_overall;

        if ( typeof(content_obj.score_overall ) == "object" ) {
            obj.score_overall = content_obj.score_overall["#text"];
        } else
            obj.score_overall = content_obj.score_overall;

        if ( typeof(content_obj.points_overall ) == "object" ) {
            obj.points_overall = content_obj.points_overall["#text"];
        } else
            obj.points_overall = content_obj.points_overall;

        if ( typeof(content_obj.team ) == "object" ) {
            obj.team = content_obj.team["#cdata-section"];
        } else
            obj.team = content_obj.team;

        if ( typeof(content_obj.team_id ) == "object" ) {
            obj.team_id = content_obj.team_id["#text"];
        } else
            obj.team_id = content_obj.team_id;

        if ( typeof(content_obj.team_source_id ) == "object" ) {
            obj.team_source_id = content_obj.team_source_id["#text"];
        } else
            obj.team_source_id = content_obj.team_source_id;

        return obj;
    }

    function setContentObject_Event(content_obj)
    {
        var obj = setContentObject_Indexed(content_obj);

        var date_exceptions = "";
        var multiple_locations = "";

        if ( typeof(content_obj.date_exceptions ) == "object" )
            date_exceptions = content_obj.date_exceptions["#text"];
        else
            date_exceptions = content_obj.date_exceptions;

        if ( !date_exceptions )
            date_exceptions = "";

        obj.date_exceptions = getArray(date_exceptions);

        if ( typeof(content_obj.multiple_locations ) == "object" )
            multiple_locations = content_obj.multiple_locations["#text"];
        else
            multiple_locations = content_obj.multiple_locations;

        if ( !multiple_locations )
            multiple_locations = "";

        obj.multiple_locations = getArray_block(multiple_locations);

        if ( typeof(content_obj.event_group ) == "object" )
            obj.event_group = content_obj.event_group["#text"];
        else
            obj.event_group = content_obj.event_group;
        if ( !obj.event_group )
            obj.event_group = "0";

        if ( typeof(content_obj.participants ) == "object" )
            obj.participants = content_obj.participants["#text"];
        else
            obj.participants = content_obj.participants;

        if ( !obj.participants )
            obj.participants = "";

        if ( typeof(content_obj.participants_hidden ) == "object" )
            obj.participants_hidden = content_obj.participants_hidden["#text"];
        else
            obj.participants_hidden = content_obj.participants_hidden;

        if ( !obj.participants_hidden )
            obj.participants_hidden = "";

        if ( typeof(content_obj.participants_keys ) == "object" )
            obj.participants_keys = content_obj.participants_keys["#text"];
        else
            obj.participants_keys = content_obj.participants_keys;

        if ( !obj.participants_keys )
            obj.participants_keys = "";

        if ( typeof(content_obj.event_type_id ) == "object" )
            obj.event_type_id = content_obj.event_type_id["#text"];
        else
            obj.event_type_id = content_obj.event_type_id;
        
        if ( typeof(content_obj.event_date ) == "object" )
            obj.event_date = content_obj.event_date["#text"];
        else
            obj.event_date = content_obj.event_date;

        if ( !obj.event_date )
            obj.event_date = "";

        if ( typeof(content_obj.all_day ) == "object" )
            obj.all_day = content_obj.all_day["#text"];
        else
            obj.all_day = content_obj.all_day;

        if ( typeof(content_obj.event_time ) == "object" )
            obj.event_time = content_obj.event_time["#text"];
        else
            obj.event_time = content_obj.event_time;

        if ( !obj.event_time )
            obj.event_time = "";

        if ( typeof(content_obj.event_time_hr ) == "object" )
            obj.event_time_hr = content_obj.event_time_hr["#text"];
        else
            obj.event_time_hr = content_obj.event_time_hr;

        if ( !obj.event_time_hr )
            obj.event_time_hr = "";

        if ( typeof(content_obj.event_time_min ) == "object" )
            obj.event_time_min = content_obj.event_time_min["#text"];
        else
            obj.event_time_min = content_obj.event_time_min;

        if ( !obj.event_time_min )
            obj.event_time_min = "";

        if ( typeof(content_obj.event_time_xm ) == "object" )
            obj.event_time_xm = content_obj.event_time_xm["#text"];
        else
            obj.event_time_xm = content_obj.event_time_xm;

        if ( !obj.event_time_xm )
            obj.event_time_xm = "";

        if ( typeof(content_obj.event_length ) == "object" )
            obj.event_length = content_obj.event_length["#text"];
        else
            obj.event_length = content_obj.event_length;

        if ( typeof(content_obj.recurrence ) == "object" )
            obj.recurrence = content_obj.recurrence["#text"];
        else
            obj.recurrence = content_obj.recurrence;

        if ( typeof(content_obj.interval ) == "object" )
            obj.interval = content_obj.interval["#text"];
        else
            obj.interval = content_obj.interval;

        if ( typeof(content_obj.day_of_week ) == "object" )
            obj.day_of_week = content_obj.day_of_week["#text"];
        else
            obj.day_of_week = content_obj.day_of_week;

        if ( !obj.day_of_week )
            obj.day_of_week = "";

        if ( typeof(content_obj.day_of_month ) == "object" )
            obj.day_of_month = content_obj.day_of_month["#text"];
        else
            obj.day_of_month = content_obj.day_of_month;

        if ( !obj.day_of_month )
            obj.day_of_month = "";

        if ( typeof(content_obj.week ) == "object" )
            obj.week = content_obj.week["#text"];
        else
            obj.week = content_obj.week;

        if ( !obj.week )
            obj.week = "";

        if ( typeof(content_obj.month ) == "object" )
            obj.month = content_obj.month["#text"];
        else
            obj.month = content_obj.month;

        if ( !obj.month )
            obj.month = "";

        if ( typeof(content_obj.start_date ) == "object" )
            obj.start_date = content_obj.start_date["#text"];
        else
            obj.start_date = content_obj.start_date;

        if ( typeof(content_obj.end_date ) == "object" )
            obj.end_date = content_obj.end_date["#text"];
        else
            obj.end_date = content_obj.end_date;

        if ( !obj.end_date )
            obj.end_date = "";

        if ( typeof(content_obj.occurences ) == "object" )
            obj.occurences = content_obj.occurences["#text"];
        else
            obj.occurences = content_obj.occurences;

        if ( typeof(content_obj.registration_required ) == "object" )
            obj.registration_required = content_obj.registration_required["#text"];
        else
            obj.registration_required = content_obj.registration_required;

        if ( typeof(content_obj.calendar_color ) == "object" )
            obj.calendar_color = content_obj.calendar_color["#text"];
        else
            obj.calendar_color = content_obj.calendar_color;

        if ( !obj.calendar_color )
            obj.calendar_color = "";

        if ( typeof(content_obj.category_color ) == "object" )
            obj.category_color = content_obj.category_color["#text"];
        else
            obj.category_color = content_obj.category_color;

        if ( !obj.category_color )
            obj.category_color = "";

        if ( typeof(content_obj.range_0 ) == "object" )
            obj.range_0 = content_obj.range_0["#text"];
        else
            obj.range_0 = content_obj.range_0;

        if ( typeof(content_obj.range_1 ) == "object" )
            obj.range_1 = content_obj.range_1["#text"];
        else
            obj.range_1 = content_obj.range_1;

        if ( typeof(content_obj.range_2 ) == "object" )
            obj.range_2 = content_obj.range_2["#text"];
        else
            obj.range_2 = content_obj.range_2;

        if ( typeof(content_obj.range_3 ) == "object" )
            obj.range_3 = content_obj.range_3["#text"];
        else
            obj.range_3 = content_obj.range_3;

        if ( typeof(content_obj.range_4 ) == "object" )
            obj.range_4 = content_obj.range_4["#text"];
        else
            obj.range_4 = content_obj.range_4;

        if ( typeof(content_obj.range_5 ) == "object" )
            obj.range_5 = content_obj.range_5["#text"];
        else
            obj.range_5 = content_obj.range_5;

        if ( typeof(content_obj.range_6 ) == "object" )
            obj.range_6 = content_obj.range_6["#text"];
        else
            obj.range_6 = content_obj.range_6;

        if ( typeof(content_obj.repeat_by ) == "object" )
            obj.repeat_by = content_obj.repeat_by["#text"];
        else
            obj.repeat_by = content_obj.repeat_by;

        if ( typeof(content_obj.recur_ends ) == "object" )
            obj.recur_ends = content_obj.recur_ends["#text"];
        else
            obj.recur_ends = content_obj.recur_ends;
            
        return obj;
    }

    function setContentObject_Role(content_obj)
    {
        var obj = new Object();
        if ( typeof(content_obj.id ) == "object" )
            obj.id = content_obj.id["#text"];
        else
            obj.id = content_obj.id;

        if ( typeof(content_obj.rsource ) == "object" )
            obj.rsource = content_obj.rsource["#text"];
        else
            obj.rsource = content_obj.rsource;

        if ( typeof(content_obj.domain_id ) == "object" )
            obj.domain_id = content_obj.domain_id["#text"];
        else
            obj.domain_id = content_obj.domain_id;

        if ( typeof(content_obj.role_name ) == "object" )
            obj.role_name = content_obj.role_name["#text"];
        else
            obj.role_name = content_obj.role_name;

        if ( typeof(content_obj.source_types ) == "object" )
            obj.source_types = content_obj.source_types["#text"];
        else
            obj.source_types = content_obj.source_types;

        if ( typeof(content_obj.all_good ) == "object" )
            obj.all_good = content_obj.all_good["#text"];
        else
            obj.all_good = content_obj.all_good;

        if ( typeof(content_obj.source_type ) == "object" )
            obj.source_type = content_obj.source_type["#text"];
        else
            obj.source_type = content_obj.source_type;

        if ( typeof(content_obj.parent ) == "object" )
            obj.parent = content_obj.parent["#text"];
        else
            obj.parent = content_obj.parent;

        if ( obj.source_types != null && obj.source_types != "" && obj.source_types.length == 1 )
            obj.structure_all = true;
        else
            obj.structure_all = false;

        if ( typeof(content_obj.source ) == "object" )
            obj.source = content_obj.source["#text"];
        else
            obj.source = content_obj.source;

        if ( typeof(content_obj.owner ) == "object" )
            obj.owner = content_obj.owner["#text"];
        else
            obj.owner = content_obj.owner;

        return obj;
    }
    
    function setContentObject_Member(content_obj)
    {
        var obj = new Object();
        
        if ( typeof(content_obj.new_membership ) == "object" )
            obj.new_membership = content_obj.new_membership["#text"];
        else
            obj.new_membership = content_obj.new_membership;

        if ( typeof(content_obj.master_source ) == "object" )
            obj.master_source = content_obj.master_source["#text"];
        else
            obj.master_source = content_obj.master_source;

        if ( typeof(content_obj.id ) == "object" )
            obj.id = content_obj.id["#text"];
        else
            obj.id = content_obj.id;

        if ( typeof(content_obj.login_name_email ) == "object" )
            obj.login_name_email = content_obj.login_name_email["#text"];
        else
            obj.login_name_email = content_obj.login_name_email;

        if ( typeof(content_obj.login_name_email_exists ) == "object" )
            obj.login_name_email_exists = content_obj.login_name_email_exists["#text"];
        else
            obj.login_name_email_exists = content_obj.login_name_email_exists;

        if ( typeof(content_obj.verify_code ) == "object" )
            obj.verify_code = content_obj.verify_code["#text"];
        else
            obj.verify_code = content_obj.verify_code;

        if ( typeof(content_obj.verify_code_check ) == "object" )
            obj.verify_code_check = content_obj.verify_code_check["#text"];
        else
            obj.verify_code_check = content_obj.verify_code_check;

        if ( typeof(content_obj.source_id ) == "object" )
            obj.source_id = content_obj.source_id["#text"];
        else
            obj.source_id = content_obj.source_id;

        if ( typeof(content_obj.primary_email ) == "object" )
            obj.primary_email = content_obj.primary_email["#text"];
        else
            obj.primary_email = content_obj.primary_email;

        if ( typeof(content_obj.primary_email_text ) == "object" )
            obj.primary_email_text = content_obj.primary_email_text["#text"];
        else
            obj.primary_email_text = content_obj.primary_email_text;

        if ( typeof(content_obj.primary_email_receive ) == "object" )
            obj.primary_email_receive = content_obj.primary_email_receive["#text"];
        else
            obj.primary_email_receive = content_obj.primary_email_receive;

        if ( typeof(content_obj.primary_email_urgency ) == "object" )
            obj.primary_email_urgency = content_obj.primary_email_urgency["#text"];
        else
            obj.primary_email_urgency = content_obj.primary_email_urgency;

        if ( typeof(content_obj.title ) == "object" )
            obj.title = content_obj.title["#text"];
        else
            obj.title = content_obj.title;

        if ( typeof(content_obj.account_no ) == "object" )
            obj.account_no = content_obj.account_no["#text"];
        else
            obj.account_no = content_obj.account_no;

        if ( typeof(content_obj.access_level ) == "object" )
            obj.access_level = content_obj.access_level["#text"];
        else
            obj.access_level = content_obj.access_level;

        if ( typeof(content_obj.content_security_level ) == "object" )
            obj.content_security_level = content_obj.content_security_level["#text"];
        else
            obj.content_security_level = content_obj.content_security_level;

        if ( typeof(content_obj.urgency_level ) == "object" )
            obj.urgency_level = content_obj.urgency_level["#text"];
        else
            obj.urgency_level = content_obj.urgency_level;

        if ( typeof(content_obj.send_emails ) == "object" )
            obj.send_emails = content_obj.send_emails["#text"];
        else
            obj.send_emails = content_obj.send_emails;
    
        if ( typeof(content_obj.send_emails_exists ) == "object" )
            obj.send_emails_exists = content_obj.send_emails_exists["#text"];
        else
            obj.send_emails_exists = content_obj.send_emails_exists;

        if ( typeof(content_obj.post_content ) == "object" )
            obj.post_content = content_obj.post_content["#text"];
        else
            obj.post_content = content_obj.post_content;

        if ( typeof(content_obj.exists ) == "object" )
            obj.exists = content_obj.exists["#text"];
        else
            obj.exists = content_obj.exists;

        if ( typeof(content_obj.post_administrator ) == "object" )
            obj.post_administrator = content_obj.post_administrator["#text"];
        else
            obj.post_administrator = content_obj.post_administrator;

        if ( typeof(content_obj.directory_level ) == "object" )
            obj.directory_level = content_obj.directory_level["#text"];
        else
            obj.directory_level = content_obj.directory_level;

        if ( typeof(content_obj.message_aggregation ) == "object" )
            obj.message_aggregation = content_obj.message_aggregation["#text"];
        else
            obj.message_aggregation = content_obj.message_aggregation;

        if ( typeof(content_obj.expires ) == "object" )
            obj.expires = content_obj.expires["#text"];
        else
            obj.expires = content_obj.expires;

        if ( typeof(content_obj.expiration_date ) == "object" )
            obj.expiration_date = content_obj.expiration_date["#text"];
        else
            obj.expiration_date = content_obj.expiration_date;

        if ( typeof(content_obj.password ) == "object" )
            obj.password = content_obj.password["#text"];
        else
            obj.password = content_obj.password;

        if ( typeof(content_obj.password2 ) == "object" )
            obj.password2 = content_obj.password2["#text"];
        else
            obj.password2 = content_obj.password2;

        if ( typeof(content_obj.home_phone_area ) == "object" )
            obj.home_phone_area = content_obj.home_phone_area["#text"];
        else
            obj.home_phone_area = content_obj.home_phone_area;

        if ( typeof(content_obj.home_phone_ext ) == "object" )
            obj.home_phone_ext = content_obj.home_phone_ext["#text"];
        else
            obj.home_phone_ext = content_obj.home_phone_ext;
    
        if ( typeof(content_obj.home_phone_no ) == "object" )
            obj.home_phone_no = content_obj.home_phone_no["#text"];
        else
            obj.home_phone_no = content_obj.home_phone_no;

        if ( typeof(content_obj.home_phone_notes ) == "object" )
            obj.home_phone_notes = content_obj.home_phone_notes["#text"];
        else
            obj.home_phone_notes = content_obj.home_phone_notes;

        if ( typeof(content_obj.prefix ) == "object" )
            obj.prefix = content_obj.prefix["#text"];
        else
            obj.prefix = content_obj.prefix;
            
        if ( typeof(content_obj.first_name ) == "object" )
            obj.first_name = content_obj.first_name["#text"];
        else
            obj.first_name = content_obj.first_name;

        if ( typeof(content_obj.middle_name ) == "object" )
            obj.middle_name = content_obj.middle_name["#text"];
        else
            obj.middle_name = content_obj.middle_name;

        if ( typeof(content_obj.last_name ) == "object" )
            obj.last_name = content_obj.last_name["#text"];
        else
            obj.last_name = content_obj.last_name;

        if ( typeof(content_obj.suffix ) == "object" )
            obj.suffix = content_obj.suffix["#text"];
        else
            obj.suffix = content_obj.suffix;

        if ( typeof(content_obj.preferred_name ) == "object" )
            obj.preferred_name = content_obj.preferred_name["#text"];
        else
            obj.preferred_name = content_obj.preferred_name;

        if ( typeof(content_obj.key ) == "object" )
            obj.key = content_obj.key["#text"];
        else
            obj.key = content_obj.key;

        if ( typeof(content_obj.other_email1 ) == "object" )
            obj.other_email1 = content_obj.other_email1["#text"];
        else
            obj.other_email1 = content_obj.other_email1;

        if ( typeof(content_obj.other_email2 ) == "object" )
            obj.other_email2 = content_obj.other_email2["#text"];
        else
            obj.other_email2 = content_obj.other_email2;

        if ( typeof(content_obj.other_email3 ) == "object" )
            obj.other_email3 = content_obj.other_email3["#text"];
        else
            obj.other_email3 = content_obj.other_email3;

        if ( typeof(content_obj.other_email1_receive ) == "object" )
            obj.other_email1_receive = content_obj.other_email1_receive["#text"];
        else
            obj.other_email1_receive = content_obj.other_email1_receive;

        if ( typeof(content_obj.other_email2_receive ) == "object" )
            obj.other_email2_receive = content_obj.other_email2_receive["#text"];
        else
            obj.other_email2_receive = content_obj.other_email2_receive;

        if ( typeof(content_obj.other_email3_receive ) == "object" )
            obj.other_email3_receive = content_obj.other_email3_receive["#text"];
        else
            obj.other_email3_receive = content_obj.other_email3_receive;

        if ( typeof(content_obj.other_email1_urgency ) == "object" )
            obj.other_email1_urgency = content_obj.other_email1_urgency["#text"];
        else
            obj.other_email1_urgency = content_obj.other_email1_urgency;

        if ( typeof(content_obj.other_email2_urgency ) == "object" )
            obj.other_email2_urgency = content_obj.other_email2_urgency["#text"];
        else
            obj.other_email2_urgency = content_obj.other_email2_urgency;

        if ( typeof(content_obj.other_email3_urgency ) == "object" )
            obj.other_email3_urgency = content_obj.other_email3_urgency["#text"];
        else
            obj.other_email3_urgency = content_obj.other_email3_urgency;

        if ( typeof(content_obj.other_phone1_area ) == "object" )
            obj.other_phone1_area = content_obj.other_phone1_area["#text"];
        else
            obj.other_phone1_area = content_obj.other_phone1_area;

        if ( typeof(content_obj.other_phone1_ext ) == "object" )
            obj.other_phone1_ext = content_obj.other_phone1_ext["#text"];
        else
            obj.other_phone1_ext = content_obj.other_phone1_ext;

        if ( typeof(content_obj.other_phone1_no ) == "object" )
            obj.other_phone1_no = content_obj.other_phone1_no["#text"];
        else
            obj.other_phone1_no = content_obj.other_phone1_no;

        if ( typeof(content_obj.other_phone1_notes ) == "object" )
            obj.other_phone1_notes = content_obj.other_phone1_notes["#text"];
        else
            obj.other_phone1_notes = content_obj.other_phone1_notes;

        if ( typeof(content_obj.other_phone1_receive ) == "object" )
            obj.other_phone1_receive = content_obj.other_phone1_receive["#text"];
        else
            obj.other_phone1_receive = content_obj.other_phone1_receive;

        if ( typeof(content_obj.other_phone1_urgency ) == "object" )
            obj.other_phone1_urgency = content_obj.other_phone1_urgency["#text"];
        else
            obj.other_phone1_urgency = content_obj.other_phone1_urgency;

        if ( typeof(content_obj.other_phone1_sp ) == "object" )
            obj.other_phone1_sp = content_obj.other_phone1_sp["#text"];
        else
            obj.other_phone1_sp = content_obj.other_phone1_sp;

        if ( typeof(content_obj.other_phone2_area ) == "object" )
            obj.other_phone2_area = content_obj.other_phone2_area["#text"];
        else
            obj.other_phone2_area = content_obj.other_phone2_area;

        if ( typeof(content_obj.other_phone2_ext ) == "object" )
            obj.other_phone2_ext = content_obj.other_phone2_ext["#text"];
        else
            obj.other_phone2_ext = content_obj.other_phone2_ext;

        if ( typeof(content_obj.other_phone2_no ) == "object" )
            obj.other_phone2_no = content_obj.other_phone2_no["#text"];
        else
            obj.other_phone2_no = content_obj.other_phone2_no;

        if ( typeof(content_obj.other_phone2_notes ) == "object" )
            obj.other_phone2_notes = content_obj.other_phone2_notes["#text"];
        else
            obj.other_phone2_notes = content_obj.other_phone2_notes;

        if ( typeof(content_obj.other_phone2_receive ) == "object" )
            obj.other_phone2_receive = content_obj.other_phone2_receive["#text"];
        else
            obj.other_phone2_receive = content_obj.other_phone2_receive;

        if ( typeof(content_obj.other_phone2_urgency ) == "object" )
            obj.other_phone2_urgency = content_obj.other_phone2_urgency["#text"];
        else
            obj.other_phone2_urgency = content_obj.other_phone2_urgency;

        if ( typeof(content_obj.other_phone2_sp ) == "object" )
            obj.other_phone2_sp = content_obj.other_phone2_sp["#text"];
        else
            obj.other_phone2_sp = content_obj.other_phone2_sp;

        if ( typeof(content_obj.other_phone3_area ) == "object" )
            obj.other_phone3_area = content_obj.other_phone3_area["#text"];
        else
            obj.other_phone3_area = content_obj.other_phone3_area;

        if ( typeof(content_obj.other_phone3_ext ) == "object" )
            obj.other_phone3_ext = content_obj.other_phone3_ext["#text"];
        else
            obj.other_phone3_ext = content_obj.other_phone3_ext;

        if ( typeof(content_obj.other_phone3_no ) == "object" )
            obj.other_phone3_no = content_obj.other_phone3_no["#text"];
        else
            obj.other_phone3_no = content_obj.other_phone3_no;

        if ( typeof(content_obj.other_phone3_notes ) == "object" )
            obj.other_phone3_notes = content_obj.other_phone3_notes["#text"];
        else
            obj.other_phone3_notes = content_obj.other_phone3_notes;

        if ( typeof(content_obj.other_phone3_receive ) == "object" )
            obj.other_phone3_receive = content_obj.other_phone3_receive["#text"];
        else
            obj.other_phone3_receive = content_obj.other_phone3_receive;

        if ( typeof(content_obj.other_phone3_urgency ) == "object" )
            obj.other_phone3_urgency = content_obj.other_phone3_urgency["#text"];
        else
            obj.other_phone3_urgency = content_obj.other_phone3_urgency;

        if ( typeof(content_obj.other_phone3_sp ) == "object" )
            obj.other_phone3_sp = content_obj.other_phone3_sp["#text"];
        else
            obj.other_phone3_sp = content_obj.other_phone3_sp;

        if ( typeof(content_obj.address_line1 ) == "object" )
            obj.address_line1 = content_obj.address_line1["#text"];
        else
            obj.address_line1 = content_obj.address_line1;

        if ( typeof(content_obj.address_line2 ) == "object" )
            obj.address_line2 = content_obj.address_line2["#text"];
        else
            obj.address_line2 = content_obj.address_line2;

        if ( typeof(content_obj.city ) == "object" )
            obj.city = content_obj.city["#text"];
        else
            obj.city = content_obj.city;

        if ( typeof(content_obj.state ) == "object" )
            obj.state = content_obj.state["#text"];
        else
            obj.state = content_obj.state;

        if ( typeof(content_obj.zip ) == "object" )
            obj.zip = content_obj.zip["#text"];
        else
            obj.zip = content_obj.zip;

        if ( content_obj.role && content_obj.role.length && content_obj.role.length > 0 ) {
            obj.roles = new Array();
            for ( var i=0; i < content_obj.role.length; i++ )
            {
                var role = new Object();
                role.id = content_obj.role[i]["-id"];
                role.description = content_obj.role[i]["-desc"];
                role.selected = content_obj.role[i]["#text"];
                obj.roles[obj.roles.length] = role;
            }
        } else if ( content_obj.role && !content_obj.role.length ) {
            obj.roles = new Array();
            var role = new Object();
            role.id = content_obj.role["-id"];
            role.description = content_obj.role["-desc"];
            role.selected = content_obj.role["#text"];
            obj.roles[obj.roles.length] = role;
        }

        return obj;

    }

    function setContentObject_Location(content_obj)
    {
        var obj = new Object();
        
        if ( typeof(content_obj.id ) == "object" )
            obj.id = content_obj.id["#text"];
        else
            obj.id = content_obj.id;

        if ( typeof(content_obj.domain_id ) == "object" )
            obj.domain_id = content_obj.domain_id["#text"];
        else
            obj.domain_id = content_obj.domain_id;

        if ( typeof(content_obj.description ) == "object" )
            obj.description = content_obj.description["#text"];
        else
            obj.description = content_obj.description;

        if ( typeof(content_obj.active ) == "object" )
            obj.active = content_obj.active["#text"];
        else
            obj.active = content_obj.active;

        if ( typeof(content_obj.logo_id ) == "object" )
            obj.logo_id = content_obj.logo_id["#text"];
        else
            obj.logo_id = content_obj.logo_id;

        if ( typeof(content_obj.location_type ) == "object" )
            obj.location_type = content_obj.location_type["#text"];
        else
            obj.location_type = content_obj.location_type;

        if ( typeof(content_obj.building_id ) == "object" )
            obj.building_id = content_obj.building_id["#text"];
        else
            obj.building_id = content_obj.building_id;


        return obj;

    }

    function setContentObject_Racer(content_obj)
    {
        var obj = new Object();

        if ( typeof(content_obj.id ) == "object" )
            obj.id = content_obj.id["#text"];
        else
            obj.id = content_obj.id;

        if ( typeof(content_obj.full_name ) == "object" )
            obj.full_name = content_obj.full_name["#text"];
        else
            obj.full_name = content_obj.full_name;

        if ( typeof(content_obj.gender ) == "object" )
            obj.gender = content_obj.gender["#text"];
        else
            obj.gender = content_obj.gender;

        if ( typeof(content_obj.age ) == "object" )
            obj.age = content_obj.age["#text"];
        else
            obj.age = content_obj.age;

        if ( typeof(content_obj.alumnus ) == "object" )
            obj.alumnus = content_obj.alumnus["#text"];
        else
            obj.alumnus = content_obj.alumnus;

        if ( typeof(content_obj.teacher ) == "object" )
            obj.teacher = content_obj.teacher["#text"];
        else
            obj.teacher = content_obj.teacher;

        if ( typeof(content_obj.time ) == null )
            obj.time = 0;
        else if ( typeof(content_obj.time ) == "object" )
            obj.time = content_obj.time["#text"];
        else
            obj.time = content_obj.time;

        return obj;
    }

    function setContentObject_MeetTypeEvent(content_obj)
    {
        var obj = new Object();

        if ( typeof(content_obj.id ) == "object" )
            obj.id = content_obj.id["#text"];
        else
            obj.id = content_obj.id;

        if ( typeof(content_obj.domain_id ) == "object" )
            obj.domain_id = content_obj.domain_id["#text"];
        else
            obj.domain_id = content_obj.domain_id;

        if ( typeof(content_obj.description ) == "object" )
            obj.description = content_obj.description["#cdata-section"];
        else
            obj.description = content_obj.description;
        
        obj.events = new Array();
        
        if ( content_obj.events ) {
            if ( content_obj.events.stroke.length ) {
                for ( var i=0; i < content_obj.events.stroke.length; i++ ) {
                    var stroke = new Object();
                    stroke.id = content_obj.events.stroke[i].id;
                    stroke.meet_type_event_id = content_obj.events.stroke[i].meet_type_event_id;
                    stroke.seq = content_obj.events.stroke[i].seq;
                    stroke.gender = content_obj.events.stroke[i].gender;
                    stroke.stroke = content_obj.events.stroke[i].stroke;
                    stroke.age_low = content_obj.events.stroke[i].age_low;
                    stroke.age_high = content_obj.events.stroke[i].age_high;
                    stroke.length = content_obj.events.stroke[i].length;
                    stroke.meters = content_obj.events.stroke[i].meters;
                    stroke.yards = content_obj.events.stroke[i].yards;
                    stroke.relay = content_obj.events.stroke[i].relay;
                    stroke.stroke_description = content_obj.events.stroke[i].stroke_description;
                    obj.events[obj.events.length] = stroke;
                }
            } else {
                var stroke = new Object();
                stroke.id = content_obj.events.stroke.id;
                stroke.meet_type_event_id = content_obj.events.stroke.meet_type_event_id;
                stroke.seq = content_obj.events.stroke.seq;
                stroke.gender = content_obj.events.stroke.gender;
                stroke.stroke = content_obj.events.stroke.stroke;
                stroke.age_low = content_obj.events.stroke.age_low;
                stroke.age_high = content_obj.events.stroke.age_high;
                stroke.length = content_obj.events.stroke.length;
                stroke.meters = content_obj.events.stroke.meters;
                stroke.yards = content_obj.events.stroke.yards;
                stroke.relay = content_obj.events.stroke.relay;
                stroke.stroke_description = content_obj.events.stroke.stroke_description;
                obj.events[obj.events.length] = stroke;
            }
        }

        return obj;
    }
    
    var plasma_popup_on = false;

    function setPopupMoveable()
    {
        plasma_popup_on = true;
    }

    function stopPopupMoveable()
    {
        plasma_popup_on = false;
    }

    function movePopup(popup_screen)
    {
        if ( !plasma_popup_on )
            return;

        var plasma_popup = document.getElementById(popup_screen);
        var content_frame = document.getElementById(content_frame);

        //alert(plasma_popup.style.left + " - " + plasma_popup.style.top);
        //alert(window.event.clientX + " - " + window.event.clientY);
        //plasma_popup.style.top = window.event.clientY;
        //plasma_popup.style.left = window.event.clientX;
        
        //if ( content_frame != null ) {
        //    content_frame.style.top = window.event.clientY;
        //    content_frame.style.left = window.event.clientX;
        //}

    }

    function postMapFormField(postResults,required,field)
    {
        var type = "";
        var form_html = postResults.form_html;
        var error_message = postResults.error_message;

        var form_element = document.getElementById(field);
        
        //if ( field == "smlgmttpevnt_dsc" )
            //alert(form_element.value + " = " + field);
        
        if ( form_element == null )
            return;

        for ( var i=0; i < form_element.attributes.length; i++ )
        {
            if ( form_element.attributes[i].name == "type" ) {
                type = form_element.attributes[i].value;
                break;
            }
        }
        
        if ( form_element.tagName == "TEXTAREA" || form_element.tagName == "textarea" ) {
            form_html = form_html + "<textarea name=\"" + field + "\">" + form_element.value + "</textarea>";
            if ( required ) {
                if ( form_element.value.trim == "" ) {
                    error_message = error_message + field + " is required.<BR>"
                    form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                } else {
                    form_element.style.className="EDITOR_SECTION_FIELD";
                }
            }

        } else if ( form_element.tagName == "INPUT" || form_element.tagName == "input" || form_element.tagName == "HIDDEN" || form_element.tagName == "hidden" || form_element.tagName == "META" || form_element.tagName == "meta") {
            if ( type == "checkbox" || type == "CHECKBOX" ) {

                form_html = form_html + "<input type=\"checkbox\" name=\"" + field + "\"";

                if ( form_element.checked )
                    form_html = form_html + " checked>";
                else
                    form_html = form_html + ">";
                    
            } else if ( type == "password" || type == "PASSWORD" ) {
                form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
                if ( required ) {
                    if ( form_element.value.trim == "" ) {
                        error_message = error_message + field + " is required.<BR>"
                        form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                    } else {
                        form_element.style.className="EDITOR_SECTION_FIELD";
                    }
                }
            } else {
                form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
                if ( required ) {
                    if ( form_element.value.trim == "" ) {
                        error_message = error_message + field + " is required.<BR>"
                        form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                    } else {
                        form_element.style.className="EDITOR_SECTION_FIELD";
                    }
                }
            }
        } else if ( form_element.tagName == "SELECT" || form_element.tagName == "select" ) {
            form_html = form_html + "<input name=\"" + field + "\" value=\"" + form_element.value + "\">";
            
            if ( required ) {
                if ( form_element.value.trim == "" ) {
                    error_message = error_message + field + " is required.<BR>"
                    form_element.style.className="EDITOR_SECTION_FIELD_ERROR";
                } else {
                    form_element.style.className="EDITOR_SECTION_FIELD";
                }
            }
        }

        postResults.form_html = form_html;
        postResults.error_message = error_message;

        return;
    }

    function setScopeKeys(scope_key, scope_val)
    {
        var form_html = "";
        var idx = scope_val.indexOf("/");
        if ( idx > 0 ) {
            form_html = form_html + "<input type=\"hidden\" name=\"" + scope_key + "\" value=\"" + scope_val.substring(0,idx) + "\">";
            scope_val = scope_val.substring(idx+1);
        } else {
            form_html = form_html + "<input type=\"hidden\" name=\"" + scope_key + "\" value=\"" + scope_val + "\">";
        }

        while(true)
        {
            idx = scope_val.indexOf("/");
            if ( idx < 0 )
                break;

            var idx2 = scope_val.indexOf("/",idx+1);
            if ( idx2 > 0 ) {
                form_html = form_html + "<input type=\"hidden\" name=\"" + scope_val.substring(0,idx) + "\" value=\"" + scope_val.substring(idx+1,idx2) + "\">";
                scope_val = scope_val.substring(idx2+1);
            } else {
                form_html = form_html + "<input type=\"hidden\" name=\"" + scope_val.substring(0,idx) + "\" value=\"" + scope_val.substring(idx+1) + "\">";
                scope_val = "";
            }
        }

        return form_html;
    }