﻿function asj_item_over(obj) {
    var act = as_getByClassName('asjournalactions', obj);
    if (act !== null) {
        act.style.display = '';
    };
};
function asj_item_out(obj) {
    var act = as_getByClassName('asjournalactions', obj);
    if (act !== null) {
        act.style.display = 'none';
    };
};
function ams_MsgRemove(obj, row) {
    asClient.DetachEvent('OnJournalSendComplete')
    asClient.DetachEvent('OnSendCommonComplete')
    var out;
    if (row.indexOf('result') > 0) {
        out = eval(row)[0];
        out = out.result[0];
    } else {
        out = eval(row)[0];
    };
    
    if (asV(out.output)) {
        var r = asV(out.output);
        var tbl = r.parentNode;
        tbl.removeChild(r);
    };

};
function ams_MsgAction(action, msgid, senderid, obj, params) {
    params = params.split('&');
    var req = {}
    req.action = action;
    req.msgid = msgid;
    req.senderid = senderid;
    req.params = params;
    req.output = msgid;
    var fis = JSON.stringify(req);
    asClient.AttachEvent('OnSendCommonComplete', ams_MsgRemove);
    asutil_SendCommon(1, null, fis);

};
function as_addOption(select, text, value, obj) {
    var dd;
    if (select == '') {
        dd = obj;
    } else {
        dd = asVal(select);
    };
    if (asClient.IsIE == true) {
        dd.options.add(new Option(text, value));
    } else {
    var opt = document.createElement('option');
    opt.text = text;
    opt.value = value;
    dd.appendChild(opt);
    };
};
function as_getByClassName(cname, p) {
    var es;
    if (typeof (p) == 'undefined') {
        es = document.childNodes;
    } else {
    es = p.childNodes;
    }
    var iCount = es.length;
    for (var i = 0; i < iCount; i++) {
        var el = es[i];
        if (el.className == cname){
            return el;
        }; 
    };
};

function asutil_createProPic(uid, h, w) {
    var img = document.createElement('img');
    img.setAttribute('width', w);
    img.setAttribute('src', asClient.Path + 'profilepic.ashx?PortalId='+asClient.SiteId + '&uid=' + uid + '&h=' + h + '&w=' + w);
    return img;
};
function asutil_createProLink(u) {
    if (u === null) return null;
    var url = '';
    if (asutil_pvurl != '' && u.vanityname != '') {
        url = asutil_pvurl.replace('vname', u.vanityname);
    } else {
        url = asutil_pnurl.replace('userid', u.userid);
    };
    var a = document.createElement('a');
    a.setAttribute('href', url);
    a.setAttribute('title', escape(u.displayname));
    a.appendChild(document.createTextNode(u.displayname));
    return a;
};
function asutil_createProUrl(userid,vname) {
    
    var url = '';
    if (asutil_pvurl != '' && vname !==null) {
        url = asutil_pvurl.replace('vname', vname);
    } else {
        url = asutil_pnurl.replace('userid', userid);
    };
    return url;
    
};
var asEvt = {};
var event_info = {};

asEvt.SetImg = function(s, d) {
    var imgPath = asClient.Path + d;
    asVal('evtImg').innerHTML = '<img src=' + imgPath + ' />';
    event_info.img = imgPath;
};
asEvt.TED = function(obj, id) {
    if (asVal('dtToggle').style.display == 'none') {
        asVal('dtToggle').style.display = '';
    } else {
        asVal('dtToggle').style.display = 'none';
    };
}
asEvt.Save = function() {
    var title = asGet('txtEventTitle');
    var loc = asGet('txtEventLocation') + '';
    var desc = asGet('txtEventSummary') + '';
    var type = asGet('drpEventCat');
    var subtype = asGet('drpEventSubType');
    var typeid = type.value;
    var typename = type.text;
    var subtypeid = (subtype === null) ? -1 : subtype.value;
    var subtypename = (subtype === null) ? '' : subtype.text;
    var startdate = asGetTimeStamp(asGet('drpStartDatemonth').value, asGet('drpStartDateday').value, asGet('drpStartDatetime').value);
    var enddate = asGetTimeStamp(asGet('drpEndDatemonth').value, asGet('drpEndDateday').value, asGet('drpEndDatetime').value);
    event_info.action = 'save';
    event_info.id = -1;
    event_info.guid = 0;
    event_info.itemtype = 'createevent';
    event_info.title = title;
    event_info.summary = desc;
    event_info.body = '';
    event_info.url = '';
    event_info.privacy = 1; //asGet('drpAccess').value;

    event_info.object = { "title": title, "location": loc,
        "start_time": startdate,
        "end_time": enddate,
        "description": desc,
        "typeid": typeid,
        "typename": typename,
        "subtypeid": subtypeid,
        "subtypename": subtypename,

        "venue": { "street": "", "city": "", "state": "", "postalcode": "", "country": "" }
    };
    event_info.result = '';
    if (asEvt.Valid(event_info.object)) {
        var fis = JSON.stringify(event_info);
        asClient.AttachEvent('OnJournalSendComplete', 'eventEnd');
        asClient.Journal.Send(1, '0', fis);
    };
};
asEvt.Valid = function(evo) {
    var isValid = true;
    if (evo.title == '') {
        isValid = false;
    };
    if (evo.title.length <= 1) {
        isValid = false;
    };
    if (evo.startdate >= evo.enddate) {
        isValid = false;
        asForm.ShowReq(asVal('drpStartDatetime'), '[RESX:Required:StartTime]');
    };
    if (evo.typeid <= 0) {
        isValid = false;
        asForm.ShowReq(asVal('drpEventCat'), '[RESX:Required:EventCategory]');
    };
    if (evo.startdate <= asGetTimeStamp()) {
        isValid = false;

    };
    return isValid;

};
asEvt.Status = function(jid, stat) {
    if (typeof (stat) === 'undefined') {
        stat = 3;
    }
    var params = 'eid=' + jid + '|status=' + stat;
    asClient.Modal.AttachEvent('OnClick', 'asClient.ModalClose');
    asClient.ModalOpen('GEN:events/eventrsvp', '', 100, 350, params);
};
asEvt.GetGuests = function(jid) {
    var params = jid.split('&');
    jid = params[0].split('=')[1];
    asClient.AttachEvent('OnJournalSendComplete', asEvt.GuestsRender)
    var d = { "action": "getguests", "id": jid };
    asClient.Journal.Send(1, "0", JSON.stringify(d));
};
asEvt.GuestsRender = function(e, s) {
    try {
        var ji = eval(s)[0].result;
        while (asV('guests_status_1').hasChildNodes()) {
            asV('guests_status_1').removeChild(asV('guests_status_1').lastChild)
        };
        while (asV('guests_status_0').hasChildNodes()) {
            asV('guests_status_0').removeChild(asV('guests_status_0').lastChild)
        };
        while (asV('guests_status_3').hasChildNodes()) {
            asV('guests_status_3').removeChild(asV('guests_status_3').lastChild)
        };
        while (asV('guests_status_2').hasChildNodes()) {
            asV('guests_status_2').removeChild(asV('guests_status_2').lastChild)
        };
        for (var g = 0; g < ji.length; g++) {
            var n = ji[g];
            var lid = n.itemid + '_' + n.userid;
            var li = document.createElement('li');
            var link = document.createElement('a');
            link.setAttribute('href', '');
            link.onclick = function() { asEvt.DelGuest(this); return false; };
            link.setAttribute('class', 'actionlink');
            var ds = document.createElement('span');
            ds.setAttribute('class', 'icon minidelete');
            link.setAttribute('style', 'float:right;');
            ds.appendChild(document.createTextNode(''));
            link.appendChild(ds);
            li.appendChild(link);
            li.appendChild(asutil_createProPic(n.userid, 48, 48));
            var d = document.createElement('div');
            d.appendChild(document.createTextNode(n.displayname));
            li.appendChild(d);
            li.setAttribute('id', n.itemid + '_' + n.userid);
            asV('guests_status_' + n.status).appendChild(li);
            asClient.DetachEvent('OnJournalSendComplete')
        };
    } catch (err) {
        alert(err.message);
    };

};
asEvt.DelGuest = function(obj) {
    var p = obj;
    var i = 0;
    do {
        p = p.parentNode;
        i++
    } while (p.tagName != 'LI' || i == 100);
    if (confirm(ams_resx["removeguest"])) {
        var params = p.id.split('_');
        var d = { "action": "delguest", "id": params[0], "guestid": params[1] };
        asClient.AttachEvent('OnJournalSendComplete', asEvt.GuestsRender)
        asClient.Journal.Send(1, "0", JSON.stringify(d));
    };

};
asEvt.Guests = function(jid) {
    var params = 'jid=' + jid;
    asClient.ModalOpen('GEN:events/eventguests', '', 425, 435, params);
};
asEvt.Invite = function(jid) {
    var params = 'type=event&jid=' + jid;
    asClient.ModalOpen('GEN:other/invitefriends', '', 500, 450, params);
};
asEvt.StatusSave = function() {
    var p = window.document.getElementById('hidEventIdRsvp').value;
    var params = p.split('|');
    var eid = params[0].split('=')[1];
    var pnl = window.document.getElementById('pnlStart');
    var stat = -1;
    var items = pnl.getElementsByTagName('input');
    for (var i = 0; i < items.length; i++) {
        var item = items[i];
        if (item.name == 'rsvp') {
            if (item.checked) {
                stat = item.value;
            }
        }

    }
    var req = {};
    req.action = 'update';
    req.id = eid;
    req.status = stat;
    var fis = JSON.stringify(req);
    asClient.Utils.TogglePanels('none', '', 'none', 'none');
    asClient.AttachEvent('OnJournalSendComplete', asEvt.StatusChg);
    asClient.Journal.Send(1, '0', fis);
};
asEvt.StatusMsg = function(msgid, params, action, stat) {
params = params.split('&');
    
    var req = {}
    req.action = action;
    req.id = params[0].split('=')[1];
    req.status = stat;
    req.output = msgid;
    var fis = JSON.stringify(req);
    asClient.AttachEvent('OnJournalSendComplete', ams_MsgRemove)
    asClient.Journal.Send(1, '0', fis);

};
asEvt.StatusChg = function(s, r) {
    asClient.Utils.ToggleActionEnd()
};
function eventEnd(s, r) {
    window.location.reload(false);
    
};
asEvt.LoadTypes = function(obj) {
    var k = "cat" + obj.options[obj.selectedIndex].value;
    var opt = '';
    var drp = asV('drpEventSubType');
    if (drp === null) {
        drp = document.createElement('select');
        drp.setAttribute('id', 'drpEventSubType');
        drp.setAttribute('class', 'NormalTextBox');
        obj.parentNode.appendChild(drp);
    };

    while (drp.hasChildNodes()) {
        drp.removeChild(drp.lastChild)
    };
    for (var prop in asevtypes[k]) {

        var opt = document.createElement('option');
        opt.text = prop;
        opt.value = asevtypes[k][prop];
        drp.options.add(opt);
    };


};
function asutil_SendCommon(o, p, d) {
    var http = new XMLHttpRequest();
    var url = asClient.Path + 'common.ashx?PortalId=' + asClient.SiteId;
    var params = '&opt=' + o;
    http.open('POST', url, true);
    http.setRequestHeader('content-type', 'application/json');
    http.setRequestHeader('connection', 'close');
    http.onreadystatechange = function() {
        if (http.readyState == 4 && http.status == 200) {
            if (asClient.RaiseEvent('OnSendCommonComplete', http.responseText) == false) {
                asClient.DetachEvent('OnSendCommonComplete');
                return;
            };

        };
    };
    http.send(d);
};
function asutil_UserCard(u, tag, cn,link) {
    if (u === null) return null;
    var t = document.createElement(tag);
    
    if (cn !== null) {
        t.setAttribute('class', cn);
    };
    t.setAttribute('id','uc_' + u.userid);
    
    var pwrap = document.createElement('span');
    pwrap.setAttribute('class', 'picwrap50');
    var pimg = asutil_createProPic(u.userid, 50, 50);
    pwrap.setAttribute('style', 'background-image:url(' + pimg.src + ')');
   
    t.appendChild(pwrap);
    if (link == true) {
        t.appendChild(asutil_createProLink(u));
    } else {
        var sp = document.createElement('strong');
        sp.appendChild(document.createTextNode(u.displayname));
        t.appendChild(sp);
    };
    
    return t;
};

var tmpElem = null;
var asClient = {
    TempElem: null,
    Action: '',
    CloseTimer: null,
    ModalTemp: null,
    Modal: null,
    HistoryLoaded: false,
    Loader: null,
    Helper: null,
    LoadingImage: new Image(),
    Path: '',
    Listeners: {},
    Journal: null,
    SmallLoading: new Image(),
    Init: function(lid, hid, mod, path) {
        this.Loader = eval(lid);
        this.Helper = eval(hid);
        this.Modal = eval(mod);
        this.Path = path;
        this.LoadingImage = new Image();
        this.LoadingImage.src = path + 'images/loading-bar.gif';
        this.SmallLoading = new Image();
        this.SmallLoading.src = path + 'images/horz-loading.gif';
        this.SmallLoading.setAttribute('border', '0');
    },
    Callback: function() {
        this.Helper.Callback.apply(this.Helper, arguments);
    },
    LoaderRequest: function() {
        this.Loader.Callback.apply(this.Loader, arguments);
    },
    ModalOpen: function(view, title, h, w, p) {
        if (title == '') {
            title = ams_resx[view];
        };
        title = (typeof (title) === 'undefined') ? '&nbsp;' : title;
        this.ModalTemp = this.Modal;
        var m = this.Modal;
        m.view = view;
        m.title = title;
        m.height = h;
        m.width = w;
        m.params = p;
        m.Show();
        return false;

    },
    ModalClose: function(autoclose) {
        if (autoclose) {
            this.Modal.closeTimer();
        } else {
            this.Modal.Close();
            clearTimeout(asClient.CloseTimer);
        }
    },
    ModalReset: function() {
        asClient.Modal.DetachEvent();
        asClient.ModalClose();
        asClient.DetachEvent();
    },
    ShowSend: function(sid, obj) {
        tmpElem = obj;
        // this.Modal.AttachEvent("OnLoadComplete", function() { asui_appear('pnlStart', 15,15); });
        this.ModalOpen('sendmessage', '', 250, 400, sid);
    },
    MsgSend: function() {
        var sendto = asVal('txtTo').value;
        var sub = asVal('txtSub').value;
        var reqSendTo = asVal('reqSendTo');
        if (sendto == '') { reqSendTo.style.display = 'block'; return; };
        var reqSubject = asVal('reqSubject');
        if (sub == '') { reqSubject.style.display = 'block'; return; };
        if (sub.length > 255) { reqSubject.style.display = 'block'; return; };
        var msg = asVal('txtMsg').value;
        asClient.Utils.ToggleActionLoading(false);
        asClient.AttachEvent('OnHelperComplete', asClient.Utils.ToggleActionEnd);
        asClient.Callback('sendmessage', sendto, sub, msg);
    },
    FriendModal: function(view, fid, obj) {
        this.TempElem = obj;
        var mview = view + 'friend';
        this.ModalOpen(mview, '', 250, 350, fid);
       
    },
    FriendAction: function(act, fid) {
        this.Action = 'friend' + act;
        var txt = window.document.getElementById('txtFriendMsg');
        var msg = '';
        if (txt !== null) {
            msg = txt.value;
        };
        asClient.Utils.ToggleActionLoading(false);
        asClient.AttachEvent('OnHelperComplete', asClient.LinkActionComplete);
        this.Callback(this.Action, fid, msg);
    },
    Navigate: function() {
        var hash = '';
        for (var i = 0; i < arguments.length; i++) {
            hash += arguments[i];
            if (i != arguments.length - 1) {
                hash += '&';
            };
        };
        asClient.History.Add(hash, '');
    },
    LinkActionComplete: function(sender, args) {
        var text = args.Result;
        asClient.Utils.ToggleActionEnd();
        if (asClient.TempElem !== null) {
            if (asClient.TempElem.tagName == 'A') {
                asClient.TempElem.parentNode.innerHTML = text;
            } else {
                asClient.TempElem.innerHTML = text;
            };
            asClient.TempElem = null;
        };

    },
    ToggleRequired: function(el) {
        if (el != null) {
            el.className = el.className + ' asreq';
        };
    },
    CC: function() {
        var txt = '';
        var b = true;
        var error = document.getElementById('cbMainError');
        if (error !== null) {
            var txt = error.innerHTML;
            alert(txt);
            asClient.ModalReset();
            return false;

        };
        var result = document.getElementById('cbMainResult');
        if (result !== null) { txt = result.innerHTML; };
        if (asClient.Action != '') {
            asClient.Action = '';
        };
        var helper = document.getElementById('cbError');
        if (helper !== null) {
            txt += helper.innerHTML;
            b = false;
        };
        var evt = {
            Modal: this,
            Result: txt,
            Success: b
        }
        if (asClient.RaiseEvent("OnHelperComplete", evt) == false) {
            return;
        };
    },
    StatusClear: function(el) {
        asClient.TempElem = el;
        asClient.AttachEvent('OnHelperComplete', asClient.StatusClearComplete);
        asClient.Callback('statclear');
    },
    StatusClearComplete: function() {
        if (asClient.TempElem !== null) {
            var p = asClient.TempElem.parentNode;
            asClient.TempElem.style.display = 'none';
            p.firstChild.nodeValue = '';
            asClient.TempElem = null;
        }
    },
    AttachEvent: function(eventName, handler) {
        if (!asClient.Listeners[eventName]) {
            asClient.Listeners[eventName] = [];
        }
        asClient.Listeners[eventName][asClient.Listeners[eventName].length] = (asClient.ResolveFunction(handler));
    },
    RaiseEvent: function(eventName, eventArgs) {
        var outcome = true;
        var eventresult;
        if (asClient[eventName] != undefined) {
            eventResult = asClient.ResolveFunction(asClient[eventName][0])(asClient.TempElem, eventArgs);
            if (typeof (eventResult) == "undefined") {
                eventResult = true;
            };
            outcome = outcome && eventResult;
        };
        if (!asClient.Listeners[eventName]) return outcome;

        for (var i = 0; i < asClient.Listeners[eventName].length; i++) {
            var handler = asClient.Listeners[eventName][i];
            if (handler !== null) {
                eventResult = handler(this, eventArgs);
                if (typeof (eventResult) == "undefined") {
                    eventResult = true;
                };
                outcome = outcome && eventResult;
            };

        };

        return outcome;
    },
    DetachEvent: function(eventName, handler) {
        var listeners = asClient.Listeners[eventName];
        if (!listeners) {
            return false;
        };
        if (handler != undefined) {
            var funcHandler = asClient.ResolveFunction(handler);
            for (var i = 0; i < listeners.length; i++) {
                if (funcHandler == listeners[i]) {
                    listeners.splice(i, 1);
                    return true;
                };
            };
        } else {
            for (var i = 0; i < listeners.length; i++) {
                listeners[i] = null;
            };
        };
        return false;
    },
    ResolveFunction: function(func) {
        if (typeof (func) == "function") {
            return func;
        } else if (typeof (window[func]) == "function") {
            return window[func];
        } else {
            return new Function("var Sender = arguments[0]; var Arguments = arguments[1];" + func);
        };
    },
    ImageUp: function() {
        newwin = window.open(asClient.Path + 'asul.ashx?PortalId='+asClient.SiteId, 'Image', 'height=150,width=300');
        if (window.focus) { newwin.focus() }
        return false;
    },
    ImageDone: function(imgsrc) {
        if (asClient.RaiseEvent("OnUploadComplete", imgsrc) == false) {

            return;
        };
    }



};
asClient.SubSaveComplete = function(sender, eventArgs) {
var text = args.Result;
asClient.DetachEvent('OnHelperComplete');
    if (text == '') {
        text = ams_resx['savecomplete'];
    };
};
asClient.SubscriptionSave = function(div) {
    var obj = document.getElementsByTagName('input');
    var props = '';
    var iCount = obj.length;
    for (var i = 0; i < iCount; i++) {
        var el = obj[i];
        if (el.type == 'checkbox' && el.id.indexOf('chkSub_') >= 0) {
            if (el.checked) {
                var tmp = el.id;
                tmp = tmp.substring(el.id.indexOf('chkSub_') + 7);
                props += tmp + ';';
            };
        };

    };
    asClient.AttachEvent('OnHelperComplete', function() { window[div].Toggle(); });
    asClient.Callback('groupsubsave', props);
};


asClient.Utils = {
    Alert: function(msg) {
        alert('error:' + msg);
        asClient.ModalReset();
    },
    GetCheckedFriends: function() {
        var divs = document.getElementById('divFriends');
        var fids = '';
        if (divs != null) {
            var cks = divs.getElementsByTagName('input');

            for (var i = 0; i < cks.length; i++) {
                var myElement = cks[i];
                if (myElement.type == "checkbox") {
                    var id = myElement.id;

                    if (myElement.checked == true && id.indexOf('chkFriend') >= 0) {
                        fids += myElement.value + ';';
                    };
                };
            };
        };
        return fids;
    },
    GetEmailEntries: function() {
        var txt = document.getElementById('txtEmailInvite');
        var emails = '';
        if (txt != null) {
            emails = txt.value;
        };
        return emails;
    },
    ValidateEmail: function(email) {
        var emReg = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
        return String(email).search(emReg) != -1;
    },
    TogglePanels: function(start, load, end, buttons) {
        var pnlStart = document.getElementById("pnlStart");
        if (pnlStart !== null) {
            pnlStart.style.display = start;
        };
        var pnlEnd = document.getElementById("pnlEnd");
        if (pnlEnd !== null) {
            pnlEnd.style.display = end;
        };
        var pnlLoading = document.getElementById("pnlLoading");
        if (pnlLoading !== null) {
            pnlLoading.style.display = load;
        };
        var pnlButtons = document.getElementById("pnlButtons");
        if (pnlButtons !== null) {
            pnlButtons.style.display = buttons;
        };
    },
    ToggleActionLoading: function(autoclose) {
        var modal = asClient.ModalTemp;
        asClient.Utils.TogglePanels('none', '', 'none', 'none');
        var pnlLoading = document.getElementById("pnlLoading");
        if (asClient.LoadingImage !== null && pnlLoading !== null) {
            pnlLoading.appendChild(asClient.LoadingImage);

        };
        if (autoclose) {
            if (modal != null) {
                modal.closeTimer();
            } else {
                window.closeOnTimer();
            };
        };
    },
    ToggleActionEnd: function() {
        var modal = asClient.ModalTemp;
        asClient.Utils.TogglePanels('none', 'none', '', 'none');
        if (modal != null) {
            if (modal != null) {
                modal.closeTimer();
            };
        };
        asClient.ModalTemp = null;
    },
    OnlyNumbers: function(evt) {
        var charCode = (evt.which != undefined) ? evt.which : evt.keyCode;
        if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode != 46 && charCode != 44 && charCode != 45))
            return false;
        return true;
    },
    CE: function(e, obj) {
        var el = document.createElement(e);
        for (prop in obj) {
            el[prop] = obj[prop];
        };
        return el;
    }
};
asClient.InviteToSite = {
    Open: function(p) {
        asClient.ModalOpen('invite', '', 300, 350, p);

    },
    Close: function() {
        asClient.Utils.ToggleActionEnd();
    },
    Send: function() {
        var email = asVal('EmailTo');
        var sub = asVal('Subject');
        var msg = asVal('Message');
        var bValid = true;
        if (email == null) {
            bValid = false;
        };
        if (email.value == '') {
            asClient.ToggleRequired(email);
            bValid = false;
        };
        if (asClient.Utils.ValidateEmail(email.value) == false) {
            asClient.ToggleRequired(email);
            bValid = false;
        };

        if (sub == null) {
            bValid = false;
        } else if (sub.value == '') {
            asClient.ToggleRequired(sub);
            bValid = false;
        };
        if (msg == null) {
            bValid = false;
        } else if (msg.value == '') {
            bValid = false;
            asClient.ToggleRequired(msg);

        };

        if (bValid) {
            asClient.Utils.ToggleActionLoading(false);
            asClient.AttachEvent('OnHelperComplete', asClient.InviteToSite.Close);
            asClient.Callback('asinvite', email.value, sub.value, msg.value);

        };



    }
};
asClient.Groups = {
    GroupId: -1,
    SendInvites: function(gid) {
        asClient.Groups.GroupId = gid;
        asClient.Modal.AttachEvent('OnLoadComplete', asClient.Groups.Send);
        asClient.ModalOpen('GEN:Other/PleaseWait.ascx', '&nbsp;', 200, 250);
    },
    Send: function() {
        asClient.Utils.ToggleActionLoading(false);
        asClient.AttachEvent('OnHelperComplete', asClient.Groups.SendInvitesComplete);
        var fids = asClient.Utils.GetCheckedFriends();
        var em = asClient.Utils.GetEmailEntries();
        var canSend = true;
        if (asClient.Groups.GroupId <= 0 || typeof (asClient.Groups.GroupId) == "undefined") {
            canSend = false;
        };
        if (fids == '' && em == '') {
            canSend = false;
        };
        if (canSend) {
            asClient.Callback('asgroupinvite', asClient.Groups.GroupId, fids, em);
        } else {
        asClient.Utils.Alert(ams_resx['errSend']);
            asClient.ModalReset();
        };

    },
    SendInvitesComplete: function(sender, eventArgs) {
        asClient.Utils.TogglePanels('none', 'none', '', 'none');
        asClient.Groups.GroupId = -1;
        asClient.ModalClose(true);
        window.location.href = window.location.href;
    },
    Join: function(obj, gid) {
        asClient.TempElem = obj.parentNode;
        if (asClient.SmallLoading !== null) {
            asClient.TempElem.innerHTML = '';
            asClient.TempElem.appendChild(asClient.SmallLoading);
        };
        asClient.AttachEvent('OnHelperComplete', asClient.Groups.GroupActionComplete);
        asClient.Callback('gj', gid);
    },
    GroupActionComplete: function(sender, eventArgs) {

        var redir = document.getElementById('redir');
        if (redir !== null) {
            window.location.href = redir.innerHTML;
        } else {
            asClient.TempElem.innerHTML = eventArgs.Result;
            asClient.TempElem = null;
        };
    },
    Leave: function(obj, gid) {
    if (confirm(ams_resx['confirmgroupleave'])) {
            asClient.TempElem = obj.parentNode;
            if (asClient.SmallLoading !== null) {
                asClient.TempElem.innerHTML = '';
                asClient.TempElem.appendChild(asClient.SmallLoading);
            };
            
            asClient.AttachEvent('OnHelperComplete', asClient.Groups.GroupActionComplete);
            asClient.Callback('gl', gid);
        };
    },
    Accept: function(obj, gid) {
    asClient.TempElem = obj.parentNode;
        if (asClient.SmallLoading !== null) {
            asClient.TempElem.innerHTML = '';
            asClient.TempElem.appendChild(asClient.SmallLoading);
        };
        asClient.AttachEvent('OnHelperComplete', asClient.Groups.GroupActionComplete);
        asClient.Callback('gai', gid);
    }


};
asClient.ToolTip = {
    hidedelay: null,
    Show: function(obj, msg, xoffSet, yoffSet) {
        clearTimeout(this.hideDelay);
        if (xoffSet == null) {
            xoffSet = 55;
        };
        if (yoffSet == null) {
            yoffSet = 15;
        };
        var pos = asClient.UI.GetPosition(obj);
        var tt = asVal('astip');
        var tttxt = asVal('astiptext');
        tt.style.left = (pos.x - xoffSet) + 'px';
        tt.style.top = (pos.y + yoffSet) + 'px';
        tt.style.visibility = 'hidden';
        tttxt.innerHTML = msg;
        asClient.UI.Appear(tt.id);
            
       
    },
    Hide: function(obj) {
        var tt = asVal('astip');
        this.hidedelay = setTimeout(function() {
            asClient.UI.Fade(tt.id);
        }, 1500);

    }

};
asClient.UI = {
    fadeSpeed: 10,
    tranTime: null,
    setOpacity: function(domId, val) {
        var obj = window.document.getElementById(domId);
        if (val > 10) {
            val = 10;
        };
        obj.style.opacity = val / 10;
        obj.style.filter = 'alpha(opacity=' + val * 10 + ')';
    },
    Fade: function(domId) {
        var obj = window.document.getElementById(domId);
        if (typeof (obj) == "undefined") return false;
        if (obj == null) return false;
        if (obj.style.display == 'none') obj.style.display = 'block';
        if (obj.style.visibility == 'hidden') return false;
        var alpha = 10;
        obj.style.zoom = 1;
        var fspeed = asClient.UI.fadeSpeed;
        function f() {
            alpha--;
            asClient.UI.setOpacity(domId, alpha);
            if (alpha > -1) {
                asClient.UI.tranTime = setTimeout(f, fspeed);
            } else {
                var obj = window.document.getElementById(domId);
                obj.style.visibility = 'hidden';
                obj.style.display = 'none';
                clearTimeout(asClient.UI.tranTime);
                asClient.UI.OnHidden();
            };
        };
        asClient.UI.tranTime = setTimeout(f, fspeed);
    },
    Appear: function(domId, timeout) {

        var obj = window.document.getElementById(domId);
        if (typeof (obj) == "undefined") return false;
        if (obj === null) return false;
        if (obj.style.visibility == 'visible' && obj.style.display != 'none') {
            asClient.UI.setOpacity(domId, 10);
            asClient.UI.OnVisible(obj);
            return false;
        };
        this.curElement = domId;

        var alpha = 0;
        obj.style.zoom = 1;
        asClient.UI.setOpacity(domId, alpha);
        obj.style.visibility = 'visible';
        obj.style.display = 'block';
        var fspeed = asClient.UI.fadeSpeed;
        function a() {
            alpha++;
            asClient.UI.setOpacity(domId, alpha);
            if (alpha < 11) {
                timeout = setTimeout(a, fspeed);
            } else {
                var obj = window.document.getElementById(domId);
                obj.style.display = 'block';
                obj.style.visibility = 'visible';
                asClient.UI.setOpacity(domId, 10);
                clearTimeout(timeout);
                asClient.UI.OnVisible(obj);
            };
        };
        timeout = setTimeout(a, fspeed);
    },
    OnVisible: function(obj) {
        if (asClient.RaiseEvent("OnVisible", obj) == false) {
            return;
        }
        if (asClient != null) {
            asClient.DetachEvent("OnVisible");
        }
    },
    OnHidden: function(obj) {
        if (asClient.RaiseEvent("OnHidden", obj) == false) {
            return;
        }
        if (asClient != null) {
            asClient.DetachEvent("OnHidden");
        }
    },
    GetPosition: function(obj) {
        var left = 0;
        var top = 0;
        while (obj.offsetParent) {
            left += obj.offsetLeft;
            top += obj.offsetTop;
            obj = obj.offsetParent;
        }
        left += obj.offsetLeft;
        top += obj.offsetTop;
        return { x: left, y: top };
    },
    createElement: function(tag, id, classname, parent, addTextNode) {
        var el = document.createElement(tag);
        if (id) el.setAttribute('id', id);
        if (classname) {
            el.setAttribute('class', classname);
            //el.setAttribute('className', classname);
            el.className = classname;
        }

        if (parent) parent.appendChild(el);
        if (addTextNode) {
            var tn = document.createTextNode('');
            el.appendChild(tn);
        }
        return el;
    },
    createWrapper: function(id, css) {
        var el = asVal(id);
        if (el === null) return false;
        var wrap = asVal(id + '_wrap');
        if (wrap !== null) {
            return wrap;
        }
        var newId = id;

        var ascorners = asClient.UI.createElement('div', newId, 'ascorners');
        ascorners.style.visibility = 'hidden';
        ascorners.style.display = 'block';
        var ctM = this.createElement('div', null, css + ' topMid', ascorners, true);
        var wrp1 = this.createElement('div', 'aswrapcnt', '', ascorners);
        var wrp2 = this.createElement('div', 'aswrap', '', wrp1);
        var wrpreplace = asClient.UI.createElement('div', 'aswrapreplace', '', wrp2);
        asClient.UI.createElement('div', null, css + ' bottomMid', ascorners, true);
        asClient.UI.createElement('div', null, css + ' topLeft', ascorners, true);
        asClient.UI.createElement('div', null, css + ' topRight', ascorners, true);
        asClient.UI.createElement('div', null, css + ' bottomLeft', ascorners, true);
        asClient.UI.createElement('div', null, css + ' bottomRight', ascorners, true);
        return ascorners;
    },
    WrapElement: function(obj, css) {
        if (typeof (css) == 'undefined') {
            css = 'corner';
        }
        var el = asVal(obj);
        var tmpid = obj;
        if (el === null) return false;
        var p = el.parentNode;
        var wrap = asClient.UI.createWrapper(obj, css);
        el.removeAttribute('id');
        el.setAttribute('id', tmpid + '_old');
        el.style.visibility = 'visible';
        p.replaceChild(wrap, el);
        //wrap = asVal(tmpid + '_wrap');
        var wrp = asVal('aswrapreplace');
        var aswrap = wrp.parentNode;
        aswrap.replaceChild(el, wrp);
        wrap.style.visibility = 'visible';
        wrap.style.display = 'block';
        el.style.display = 'block';
        var tmptimeout;



    },
    ChangeDisplay: function(id, display, vis) {
        var obj = asVal(id);
        if (typeof (obj) == "undefined" || obj === null) return false;
        var currVis = obj.style.visibility;
        var currDisplay = obj.style.display;
        if (currVis != vis || currDisplay != display) {
            if (vis == 'hidden' || display != 'block') {
                asClient.UI.Fade(id);
                // obj.style.display = display;
            } else {
                obj.style.visibility = 'hidden';
                obj.style.display = display;
                var tmptimeout;
                asClient.UI.Appear(id, tmptimeout);

            }
        }
    },
    
    Toggle: function(id, obj) {
        var div = asVal(id);
        var p = div.parentNode;
        var ul = obj.parentNode;
        var divs = p.getElementsByTagName('div');
        for (var i = 0; i < divs.length; i++) {
            if (divs[i].id.indexOf('divAs') > 0) {
                var el = divs[i];
                if (el.id != id) {
                    if (el.style.display != 'none' || el.style.visibility == 'visible') {
                        this.ChangeDisplay(divs[i].id, 'none', 'hidden');
                    }
                }
            }
        }
        var lis = ul.getElementsByTagName('li');
        for (var i = 0; i < lis.length; i++) {
            lis[i].removeAttribute('class');
            lis[i].className = '';
        }
        this.ChangeDisplay(id, 'block', 'visible')
        obj.className = 'aslinavsel';
    }
};
function asMsgBox(type, msg, auto) {
    alert(msg);
};
asClient.jr = function() {
    return asVal('asjkr').value;
}
asClient.Gallery = {
    CB: null,
    CurrentImage: -1,
    Initialize: function(cbid, loadview, action) {
        this.CB = eval(cbid);
        if (window.location.toString().indexOf('#') >= 0) {
            var sHash = window.location.hash;
            if (sHash.indexOf('showtab=photos') > 0) {
                var params = sHash.split('&');
                var view = params[1].split("=")[1];
                var param = params[2].split("=")[1];
                this.Callback(view, 0, param);
            } else {
                this.CB.Callback(loadview, 0, '');
            }
        } else {
            this.CB.Callback(loadview, 0, '');

        }
    },
    LoadView: function(subview, action, params) {
        if (action == '0') {
            asClient.History.Add('showtab=photos&asview=' + subview + '&params=' + params, '');
        }
        if (subview == 'asimagebatch') {
            asui_Mask();
        } else if (subview == 'asimage') {
            asClient.Gallery.CurrentImage = params;
            asClient.UI.Fade('imgView');
        }

        this.CB.Callback(subview, action, params);
    },
    Next: function() {
        if (typeof (asImages) != 'undefined') {
            var idx = parseInt(this.GetIndex(this.CurrentImage), 10);
            idx += 1;
            if (idx > (asImages.length - 1)) {
                idx = 0;
            }

            this.LoadImage(idx);
        }
    },
    Prev: function() {
        if (typeof (asImages) != 'undefined') {
            var idx = parseInt(this.GetIndex(this.CurrentImage), 10);
            idx -= 1;
            if (idx < 0) {
                idx = (asImages.length - 1);
            }

            this.LoadImage(idx);
        }
    },
    LoadImage: function(index) {
        var pul = document.getElementById('ascmt');
        var list = pul.getElementsByTagName('UL');

        for (var i = 0; i < list.length; i++) {
            var el = list[i];

            pul.removeChild(el);
        }
        var idiv = document.getElementById('imgView');
        var imgTags = idiv.getElementsByTagName('img');
        var img = new Image();
        img.src = asImages[index].FilePath;
        var imgParent = imgTags[0].parentNode;
        imgParent.style.height = imgTags[0].height + 'px';
        imgParent.style.width = imgTags[0].width + 'px';
        imgParent.removeChild(imgTags[0]);
        var checktime;


        asCmtCo.Load(asImages[index].FileId, 1, pul);

        function check() {
            if (img.height === 0) {
                checktime = setTimeout(check, 10);
            } else {
                imgParent.style.height = img.height + 'px';
                imgParent.style.width = img.width + 'px';
                imgParent.appendChild(img);
                clearTimeout(checktime);
            }
        }
        checktime = setTimeout(check, 10);


        this.CurrentImage = asImages[index].FileId;


    },
    GetIndex: function(fileid) {
        for (var x in asImages) {
            if (asImages[x].FileId == fileid) {
                return asImages[x].index;
            }
        }
        return 0;
    },
    Callback: function() {
        asClient.History.Add('showtab=photos&asview=' + arguments[0] + '&params=' + arguments[2], '');
        if (arguments[0] == 'asimagebatch' || arguments[0] == 'asimage') {
            asui_Mask();

        }
        this.CB.Callback.apply(this.CB, arguments);
    },
    LoadComplete: function() {
        var ashid = document.getElementById('ashidbread');
        if (ashid !== null) {
            var brd = document.getElementById('asgalBrd');
            if (brd !== null) {
                brd.innerHTML = ashid.value;
            };
        }
        if (typeof (asVal('imgView')) != "undefined") {
            asClient.UI.WrapElement('imgView');
        }
        asui_MaskClose()
    },
    UpdateCrumb: function(text) {
        var l = document.getElementById('asgalBrd');
        l.innerHTML = text;
    },
    AlbumSave: function() {
        var isValid = true;
        var a1 = document.getElementById('a1');
        if (a1.value == '') {
            isValid = false;
            asClient.ToggleRequired(a1);
        } else {
            a1 = a1.value;
        }
        var a2 = document.getElementById('a2').value;
        var a3 = document.getElementById('a3');
        if (a3.checked) {
            a3 = 'true';
        } else {
            a3 = 'false';
        }
        var a4 = document.getElementById('a4');
        a4 = a4.options[a4.selectedIndex].value;
        var a5 = document.getElementById('a5');
        a5 = a5.options[a5.selectedIndex].value;
        var a6 = document.getElementById('a6');
        a6 = a6.options[a6.selectedIndex].value;
        var a7 = document.getElementById('a7').value;
        if (isValid) {
            asClient.Gallery.Callback('asalbumedit', 1, a7, a2, a3, a4, a5, a6, a1);
        }
    },
    BatchImages: function() {
        var data = '';
        var cnt = document.getElementById('divImages');
        var obj = cnt.getElementsByTagName('input');
        for (var i = 0; i < obj.length; i++) {
            var el = obj[i];
            if (el.type == 'hidden') {
                if (el.id.indexOf('img_') >= 0) {
                    var imgId = el.value;
                    var imgCaption = document.getElementById('txtCaption_' + imgId).value;
                    var imgAlbumId = document.getElementById('drpAlbum_' + imgId);
                    imgAlbumId = imgAlbumId.options[imgAlbumId.selectedIndex].value;
                    var imgDefault = document.getElementById('rdIsDefault_' + imgId).checked;
                    var imgNode = '<img id=\'' + imgId + '\' album=\'' + imgAlbumId + '\' isdefault=\'' + imgDefault + '\'><caption>' + imgCaption + '</caption></img>';
                    data += imgNode;
                }
            }

        }
        data = '<images>' + data + '</images>';
        this.Callback('asimagebatch', 3, '0', data);
    },
    SaveImage: function() {
        var data = '';
        var cnt = document.getElementById('divImageEdit');
        var obj = cnt.getElementsByTagName('input');
        for (var i = 0; i < obj.length; i++) {
            var el = obj[i];
            if (el.type == 'hidden') {
                if (el.id.indexOf('img_') >= 0) {
                    var imgId = el.value;
                    var imgCaption = document.getElementById('astxtCaption').value;
                    var imgAlbumId = document.getElementById('drpImageAlbum_' + imgId);
                    imgAlbumId = imgAlbumId.options[imgAlbumId.selectedIndex].value;
                    var imgDefault = document.getElementById('rdIsDefault_' + imgId).checked;
                    var imgNode = '<img id=\'' + imgId + '\' album=\'' + imgAlbumId + '\' isdefault=\'' + imgDefault + '\'><caption>' + imgCaption + '</caption></img>';
                    data += imgNode;
                }
            }
        }
        data = '<images>' + data + '</images>';
        this.Callback('asimage', 1, '0', data);
    },
    DeleteImage: function(imgId, msg) {
        if (confirm(msg)) {
            asClient.Gallery.Callback('asimage', 5, imgId, 'dl');
        }
    }
};
asClient.Nav = {
    SelectedId: null,
    Toggle: function(key, m, params) {
        if (key == this.SelectedId) {
            return false;
        }
        var tb = asVal('astab_' + key);
        var currDiv = '';
        var newDiv = 'ascnt_' + key;
        var ul = tb.parentNode;
        var lists = ul.getElementsByTagName('li');
        for (var i = 0; i < lists.length; i++) {
            var el = lists[i];
            if (el.id.indexOf('astab') >= 0) {
                el.className = 'asheader astab';
                var cnt = el.id.substring(6);
                cnt = document.getElementById('ascnt_' + cnt);
                if (cnt !== null) {
                    if (cnt.style.display != 'none') {
                        currDiv = cnt.id;
                    };
                };
            };
        };
        if (m == 1) {
            var cb = eval('astabcnt');
            cb['CBC_' + cb.id] = asClient.Nav.NavComplete;
            asClient.Nav.SelectedId = key;
            asClient.UI.Fade(cb.id);
            cb.Callback('tab', key);
        } else {
            if (currDiv != '') {
                asVal(currDiv).style.zoom = 1;
            };
            asVal(newDiv).style.zoom = 1;
            asui_transition(currDiv, newDiv, 'fade');
            var tab = document.getElementById('astab_' + key);
            if (tab !== null) {
                tab.className = 'astabsel';
            };
            var cnt = document.getElementById('ascnt_' + key);
            if (cnt !== null) {
                //asClient.UI.ChangeDisplay(cnt.id, 'block', 'visible');
                //cnt.style.display = '';
            };
            this.SelectedId = key;
            var q = 'showtab=' + key;
            if (typeof (params) != 'undefined') {
                q += '&' + params;
            };
            asClient.History.Add(q, '');
            return false;
        };

    },
    NavComplete: function() {
        var cb = eval('astabcnt');
        var key = asClient.Nav.SelectedId;
        var tab = document.getElementById('astab_' + key);
        if (tab !== null) {
            tab.className = 'astabsel';
        };
        asClient.UI.Appear(cb.id);
        asClient.History.Add('showtab=' + key, '');
    },
    CheckNav: function() {
        var t = asClient.Nav.GetShowTab();
        if (t != '') {
            asClient.Nav.Toggle(t);
        };
        if (window.location.toString().indexOf('#') >= 0) {
            var sHash = window.location.hash;
            if (sHash.length > 1) {
                sHash = sHash.substring(1);
                var params = sHash.split('&');
                if (params.length > 0) {
                    if (params[0].split('=')[0] == 'showtab') {
                        asClient.Nav.Toggle(params[0].split('=')[1]);
                    };
                };
            };

        };
    },
    GetShowTab: function() {
        var t = '';
        if (window.location.toString().indexOf('#') >= 0) {
            var sHash = window.location.hash;
            if (sHash.length > 1) {
                sHash = sHash.substring(1);
                var params = sHash.split('&');
                if (params.length > 0) {
                    if (params[0].split('=')[0] == 'showtab') {
                        t = params[0].split('=')[1];
                    };
                };
            };

        };
        return t;
    },
    GetHash: function() {
        var sHash = '';
        if (window.location.toString().indexOf('#') >= 0) {
            sHash = window.location.hash;
            sHash = sHash.substring(1);
        };
        return sHash;
    }
};
asClient.History = {
    Initialize: function() {
        if (window.dhtmlHistory) {
            window.dhtmlHistory.initialize();
            window.dhtmlHistory.create({
                toJSON: function(o) {
                    return JSON.stringify(o);
                },
                fromJSON: function(s) {
                    return JSON.parse(s);
                }
            });
            window.dhtmlHistory.addListener(asClient.History.Change);
            asClient.HistoryLoaded = true;
            asClient.Nav.CheckNav();
        };
    },
    Change: function(newLocation, historyData) {

        var historyMsg = (typeof historyData == "object" && historyData != null ? historyStorage.toJSON(historyData) : historyData);
        if (window.location.toString().indexOf('#') >= 0) {
            var sHash = window.location.hash;
            sHash = sHash.substring(1);
            var params = sHash.split('&');
            if (params[0].split('=')[0] == 'showtab') {
                asClient.Nav.Toggle(params[0].split('=')[1]);
            };
        };
    },
    Add: function(loc, data) {
        if (asClient.HistoryLoaded) {
            window.dhtmlHistory.add(loc, data);
            return false;
        };
    }
};
function asVal(eid) {
    return document.getElementById(eid);
};
function asV(id) {
    return document.getElementById(id);
};
function asGet(id) {
    var e = asVal(id);
    if (e == null) {return null; }
    var t = e.tagName;
    var required = e.getAttribute('required');
    var val = '';
    switch (t) {
        case 'INPUT':
            if (e.type == 'checkbox') {
                if (e.checked) {
                    val = true;
                } else {
                    val = false;
                };
            } else {
            val = e.value;
            };
            
            break;
        case 'SELECT':
            val = { "value": e.options[e.selectedIndex].value, "text": e.options[e.selectedIndex].text };
            break;
        case 'TEXTAREA':
            val = e.value;
        
            
        default:
            break;
    };
    if (e.getAttribute('required') && !val) {
        asForm.ShowReq(e);
    };
    return val;
};
function asSet(id, v) {
    var e = asV(id);
    if (e === null) { return false; }
    var t = e.tagName;
    if (typeof (v) == 'object') {
        if (typeof (v.length) !== 'undefined') {
            for (var i = 0; i < v.length; i++) {
                if (t == 'UL') {
                    var li = asV(e.id + '_template').cloneNode(true);
                    li.removeAttribute('id');
                    li.style.display = 'block';
                    e.appendChild(li);
                    if (li.hasChildNodes) {
                        for (var c = 0; c < li.childNodes.length; c++) {
                            var el = li.childNodes[c];
                            if (v[i][el.id]) {
                                el.innerHTML = v[i][el.id];
                                el.removeAttribute('id');
                            };
                        };
                    };
                } else {
                    for (var prop in v[i]) {
                        asSet(id + '_' + prop, v[i][prop]);
                    };
                 
                };
            
                
            }    
        } else {
            for (var prop in v) {
                asSet(id + '_' + prop, v[prop]);
            };
        };
        
      
    }
    switch (t) {
        case 'SPAN':
            e.innerHTML = v;
            break;
        case 'DIV':
            e.innerHTML = v;
            break;
        default:
            break;
    };
     
};
function asCheckTabs(params) {
    var i = 0;
    for (i = 0; i <= params.length; i++) {

        if (params[i] != '' && params[i] != undefined) {
            if (params[i].split('=')[0] == 'showtab') {
                var tab = document.getElementById('div' + params[i].split('=')[1]);
                window.am_toggleTab(tab)
                break;
            };
        };

    };

};
function asGetTimeStamp(m, d, t) {
    var dt = new Date();
    if (typeof (m) !== 'undefined') {
        var y = dt.getFullYear();
        m -= 1;
        m = (m < 0) ? 0 : m;
       
        if (m < dt.getMonth) {
            y = y + 1;
        };
        var h = t.split(':')[0];
        var mm = t.split(':')[1];
        dt = new Date(y, m, d, h, mm, 0, 0);
    };
    return dt.getTime()/1000;
};
Date.prototype.addMinutes = function(minutes) {
    var d = this;
    var m = d.getMinutes() + 15;
    if (m == 0) {
        d.setHours(d.getHours() + 1);

    };
    return d.setMinutes(m - 1);

};
var asForm = {
    Val: function(obj) {
        var bVal = true;

        if (obj.getAttribute('required') === null) { return; };
        switch (obj.tagName) {
            case 'INPUT':
                if (obj.value.trim() == '') {
                    bVal = false;
                };
                if (obj.getAttribute('maxlength') !== null && obj.value.length > obj.getAttribute('maxlength')) {
                    bVal = false;
                };
                if (obj.getAttribute('minlength') !== null && obj.value.length < obj.getAttribute('minlength')) {
                    bVal = false;
                };
                break;
            default:
                break;
        };
        if (bVal == false) {
            this.ShowReq(obj);
        };
    },
    ShowReq: function(obj, text) {
        //obj.setAttribute('class', 'aswarnreq');
        var p = obj.parentNode.nextSibling;
        var t = (typeof (text) === 'undefined') ? obj.title : text;
        if (asVal(obj.id + '_req') == null) {
            var req = document.createElement('span');
            req.setAttribute('id', obj.id + '_req');
            req.setAttribute('class', 'warn');
            req.setAttribute('style', 'float:right;width:16px;height:16px;display:block;');
            req.onmouseover = function() { asClient.ToolTip.Show(this, t) };
            req.onmouseout = function() { asClient.ToolTip.Hide(this) };
            p.appendChild(req);
            //asClient.ToolTip.Show(req, t);

        };
    }
}
String.prototype.trim = function(chars) {
    return this.ltrim(chars).rtrim(chars);
};
String.prototype.ltrim = function(chars) {
chars = chars || "\\s";
return this.replace(new RegExp("^[" + chars + "]+", "g"), "");
};
String.prototype.rtrim = function(chars) {
    chars = chars || "\\s";
    return this.replace(new RegExp("[" + chars + "]+$", "g"), "");
};
function asutil_LoadSuggest(field, prepop, type) {
    
    if (typeof (type) == 'undefined') {
        type = 0;
    };
    var canRemove = true;
    if (prepop !== null) {
        prepop = [prepop];
        canRemove = false;
    };
    var url = asClient.Path + 'autosuggest.aspx?PortalId=' + asClient.SiteId + '&t=' + type;
    
    jQuery("#" + field).tokenInput(url, {tokenLimit:1,allowRemove:canRemove,prePopulate:prepop,
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        }
    });

};
function asclient_ApplyProfiles(search, parent) {
    var tmp = asV('asph_template');
    if (tmp == null) return;

};
function as_signup() {
try{
    var h = document.createElement('input');
    h.setAttribute('type','hidden');
    h.value = 'true';
    h.setAttribute('id','asformcheck');
    window.document.body.appendChild(h);
    if (asV('asformcheck')!==null){
        if (asV('asformcheck').value == 'true'){
            return true;
        }else{
            return false;
        };
    };
}catch(err){
    return false;
    };
};