function sortSelect(obj)
{
	var o = new Array();

	if(!obj.options.length)
		return false;

	for(var i = 0; i < obj.options.length; i++)
	{
		o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
	}

	if(o.length == 0)
		return false;

	o = o.sort(
		function(a,b)
		{
			if ((a.text.toLowerCase()+"") < (b.text.toLowerCase()+"")) { return -1; }
			if ((a.text.toLowerCase()+"") > (b.text.toLowerCase()+"")) { return 1; }
			return 0;
		}
		);

	for(var i = 0; i < o.length; i++)
	{
		obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	}
}

function setStatus(msg, id)
{
	document.getElementById(id).innerHTML = 'Status: ' + msg;
	return true;
}

function getNotificationObj(xml)
{
	var o = new Object();
    
    var Notifications = xml.getElementsByTagName("notification");
    
    if(Notifications && Notifications.length > 0)
    {
        var Notification = Notifications[0];
        
        o.error = (Notification.getElementsByTagName("error").length > 0 && Notification.getElementsByTagName("error")[0].childNodes.length > 0) ?
                  Notification.getElementsByTagName("error")[0].firstChild.nodeValue :
                  false;

        o.message = (Notification.getElementsByTagName("message").length > 0 && Notification.getElementsByTagName("message")[0].childNodes.length > 0) ?
                  Notification.getElementsByTagName("message")[0].firstChild.nodeValue :
                  false;

        o.data_id = (Notification.getElementsByTagName("data-return").length > 0 && Notification.getElementsByTagName("data-return")[0].childNodes.length > 0) ?
                  Notification.getElementsByTagName("data-return")[0].getAttribute('id') :
                  false;
                  
        o.data_title = (Notification.getElementsByTagName("data-return").length > 0 && Notification.getElementsByTagName("data-return")[0].childNodes.length > 0) ?
                  Notification.getElementsByTagName("data-return")[0].firstChild.nodeValue :
                  false;
    }
    else
    {
        o.error = false;
        o.message = false;
        o.data_id = false;
        o.data_title = false;
    }
                       
	return o;
}