if (!this.JSON) {
    JSON = {};
}
(function() {
    function f(n) {
        return n < 10 ? '0' + n : n;
    }
    if (typeof Date.prototype.toJSON !== 'function') {
        Date.prototype.toJSON = function(key) {
            return this.getUTCFullYear() + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate()) + 'T' +
                 f(this.getUTCHours()) + ':' +
                 f(this.getUTCMinutes()) + ':' +
                 f(this.getUTCSeconds()) + 'Z';
        };
        String.prototype.toJSON =
        Number.prototype.toJSON =
        Boolean.prototype.toJSON = function(key) {
            return this.valueOf();
        };
    }
    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap,
        indent,
        meta = {    
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"': '\\"',
            '\\': '\\\\'
        },
        rep;
    function quote(string) {
        escapable.lastIndex = 0;
        return escapable.test(string) ?
            '"' + string.replace(escapable, function(a) {
                var c = meta[a];
                return typeof c === 'string' ? c :
                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            }) + '"' :
            '"' + string + '"';
    }
    function str(key, holder) {
        var i,
            k,
            v,
            length,
            mind = gap,
            partial,
            value = holder[key];
        if (value && typeof value === 'object' &&
                typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }
        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }
        switch (typeof value) {
            case 'string':
                return quote(value);
            case 'number':
                return isFinite(value) ? String(value) : 'null';
            case 'boolean':
            case 'null':
                return String(value);
            case 'object':
                if (!value) {
                    return 'null';
                }
                gap += indent;
                partial = [];
                if (Object.prototype.toString.apply(value) === '[object Array]') {
                    length = value.length;
                    for (i = 0; i < length; i += 1) {
                        partial[i] = str(i, value) || 'null';
                    }
                    v = partial.length === 0 ? '[]' :
                    gap ? '[\n' + gap +
                            partial.join(',\n' + gap) + '\n' +
                                mind + ']' :
                          '[' + partial.join(',') + ']';
                    gap = mind;
                    return v;
                }
                if (rep && typeof rep === 'object') {
                    length = rep.length;
                    for (i = 0; i < length; i += 1) {
                        k = rep[i];
                        if (typeof k === 'string') {
                            v = str(k, value);
                            if (v) {
                                partial.push(quote(k) + (gap ? ': ' : ':') + v);
                            }
                        }
                    }
                } else {
                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = str(k, value);
                            if (v) {
                                partial.push(quote(k) + (gap ? ': ' : ':') + v);
                            }
                        }
                    }
                }
                v = partial.length === 0 ? '{}' :
                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
                        mind + '}' : '{' + partial.join(',') + '}';
                gap = mind;
                return v;
        }
    }
    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function(value, replacer, space) {
            var i;
            gap = '';
            indent = '';
            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }
            } else if (typeof space === 'string') {
                indent = space;
            }
            rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                    (typeof replacer !== 'object' ||
                     typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }
            return str('', { '': value });
        };
    }
    if (typeof JSON.parse !== 'function') {
        JSON.parse = function(text, reviver) {
            var j;
            function walk(holder, key) {
                var k, v, value = holder[key];
                if (value && typeof value === 'object') {
                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }
            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function(a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }
            if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
                j = eval('(' + text + ')');
                return typeof reviver === 'function' ?
                    walk({ '': j }, '') : j;
            }
            throw new SyntaxError('JSON.parse');
        };
    }
} ());
window.dhtmlHistory={isIE:false,isOpera:false,isSafari:false,isKonquerer:false,isGecko:false,isSupported:false,create:function(_1){var _2=this;var UA=navigator.userAgent.toLowerCase();var _4=navigator.platform.toLowerCase();var _5=navigator.vendor||"";if(_5==="KDE"){this.isKonqueror=true;this.isSupported=false;}else{if(typeof window.opera!=="undefined"){this.isOpera=true;this.isSupported=true;}else{if(typeof document.all!=="undefined"){this.isIE=true;this.isSupported=true;}else{if(_5.indexOf("Apple Computer, Inc.")>-1){this.isSafari=true;this.isSupported=(_4.indexOf("mac")>-1);}else{if(UA.indexOf("gecko")!=-1){this.isGecko=true;this.isSupported=true;}}}}}window.historyStorage.setup(_1);if(this.isSafari){this.createSafari();}else{if(this.isOpera){this.createOpera();}}var _6=this.getCurrentLocation();this.currentLocation=_6;if(this.isIE){this.createIE(_6);}var _7=function(){_2.firstLoad=null;};this.addEventListener(window,"unload",_7);if(this.isIE){this.ignoreLocationChange=true;}else{if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.ignoreLocationChange=true;this.firstLoad=true;historyStorage.put(this.PAGELOADEDSTRING,true);}else{this.ignoreLocationChange=false;this.fireOnNewListener=true;}}var _8=function(){_2.checkLocation();};setInterval(_8,100);},initialize:function(){if(this.isIE){if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.fireOnNewListener=false;this.firstLoad=true;historyStorage.put(this.PAGELOADEDSTRING,true);}else{this.fireOnNewListener=true;this.firstLoad=false;}}},addListener:function(_9){this.listener=_9;if(this.fireOnNewListener){this.fireHistoryEvent(this.currentLocation);this.fireOnNewListener=false;}},addEventListener:function(o,e,l){if(o.addEventListener){o.addEventListener(e,l,false);}else{if(o.attachEvent){o.attachEvent("on"+e,function(){l(window.event);});}}},add:function(_d,_e){if(this.isSafari){_d=this.removeHash(_d);historyStorage.put(_d,_e);this.currentLocation=_d;window.location.hash=_d;this.putSafariState(_d);}else{var _f=this;var _10=function(){if(_f.currentWaitTime>0){_f.currentWaitTime=_f.currentWaitTime-_f.waitTime;}_d=_f.removeHash(_d);if(document.getElementById(_d)&&_f.debugMode){var e="Exception: History locations can not have the same value as _any_ IDs that might be in the document,"+" due to a bug in IE; please ask the developer to choose a history location that does not match any HTML"+" IDs in this document. The following ID is already taken and cannot be a location: "+_d;throw new Error(e);}historyStorage.put(_d,_e);_f.ignoreLocationChange=true;_f.ieAtomicLocationChange=true;_f.currentLocation=_d;window.location.hash=_d;if(_f.isIE){_f.iframe.src=asScriptPath + "blank.html?"+_d;}_f.ieAtomicLocationChange=false;};window.setTimeout(_10,this.currentWaitTime);this.currentWaitTime=this.currentWaitTime+this.waitTime;}},isFirstLoad:function(){return this.firstLoad;},getVersion:function(){return "0.6";},getCurrentLocation:function(){var r=(this.isSafari?this.getSafariState():this.getCurrentHash());return r;},getCurrentHash:function(){var r=window.location.href;var i=r.indexOf("#");return (i>=0?r.substr(i+1):"");},PAGELOADEDSTRING:"DhtmlHistory_pageLoaded",listener:null,waitTime:200,currentWaitTime:0,currentLocation:null,iframe:null,safariHistoryStartPoint:null,safariStack:null,safariLength:null,ignoreLocationChange:null,fireOnNewListener:null,firstLoad:null,ieAtomicLocationChange:null,createIE:function(_15){this.waitTime=400;var _16=(historyStorage.debugMode?"width: 800px;height:80px;border:1px solid black;":historyStorage.hideStyles);var _17="rshHistoryFrame";var _18="<iframe frameborder=\"0\" id=\""+_17+"\" style=\""+_16+"\" src=\"" + asScriptPath + "blank.html?"+_15+"\"></iframe>";document.write(_18);this.iframe=document.getElementById(_17);},createOpera:function(){this.waitTime=400;var _19="<img src=\"javascript:location.href='javascript:dhtmlHistory.checkLocation();';\" style=\""+historyStorage.hideStyles+"\" />";document.write(_19);},createSafari:function(){var _1a="rshSafariForm";var _1b="rshSafariStack";var _1c="rshSafariLength";var _1d=historyStorage.debugMode?historyStorage.showStyles:historyStorage.hideStyles;var _1e=(historyStorage.debugMode?"width:800px;height:20px;border:1px solid black;margin:0;padding:0;":historyStorage.hideStyles);var _1f="<form id=\""+_1a+"\" style=\""+_1d+"\">"+"<input type=\"text\" style=\""+_1e+"\" id=\""+_1b+"\" value=\"[]\"/>"+"<input type=\"text\" style=\""+_1e+"\" id=\""+_1c+"\" value=\"\"/>"+"</form>";document.write(_1f);this.safariStack=document.getElementById(_1b);this.safariLength=document.getElementById(_1c);if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.safariHistoryStartPoint=history.length;this.safariLength.value=this.safariHistoryStartPoint;}else{this.safariHistoryStartPoint=this.safariLength.value;}},getSafariStack:function(){var r=this.safariStack.value;return historyStorage.fromJSON(r);},getSafariState:function(){var _21=this.getSafariStack();var _22=_21[history.length-this.safariHistoryStartPoint-1];return _22;},putSafariState:function(_23){var _24=this.getSafariStack();_24[history.length-this.safariHistoryStartPoint]=_23;this.safariStack.value=historyStorage.toJSON(_24);},fireHistoryEvent:function(_25){var _26=historyStorage.get(_25);this.listener.call(null,_25,_26);},checkLocation:function(){if(!this.isIE&&this.ignoreLocationChange){this.ignoreLocationChange=false;return;}if(!this.isIE&&this.ieAtomicLocationChange){return;}var _27=this.getCurrentLocation();if(_27==this.currentLocation){return;}this.ieAtomicLocationChange=true;if(this.isIE&&this.getIframeHash()!=_27){this.iframe.src=asScriptPath + "blank.html?"+_27;}else{if(this.isIE){return;}}this.currentLocation=_27;this.ieAtomicLocationChange=false;this.fireHistoryEvent(_27);},getIframeHash:function(){var doc=this.iframe.contentWindow.document;var _29=String(doc.location.search);if(_29.length==1&&_29.charAt(0)=="?"){_29="";}else{if(_29.length>=2&&_29.charAt(0)=="?"){_29=_29.substring(1);}}return _29;},removeHash:function(_2a){var r;if(_2a===null||_2a===undefined){r=null;}else{if(_2a===""){r="";}else{if(_2a.length==1&&_2a.charAt(0)=="#"){r="";}else{if(_2a.length>1&&_2a.charAt(0)=="#"){r=_2a.substring(1);}else{r=_2a;}}}}return r;},iframeLoaded:function(_2c){if(this.ignoreLocationChange){this.ignoreLocationChange=false;return;}var _2d=String(_2c.search);if(_2d.length==1&&_2d.charAt(0)=="?"){_2d="";}else{if(_2d.length>=2&&_2d.charAt(0)=="?"){_2d=_2d.substring(1);}}window.location.hash=_2d;this.fireHistoryEvent(_2d);}};window.historyStorage={setup:function(_2e){if(typeof _2e!=="undefined"){if(_2e.debugMode){this.debugMode=_2e.debugMode;}if(_2e.toJSON){this.toJSON=_2e.toJSON;}if(_2e.fromJSON){this.fromJSON=_2e.fromJSON;}}var _2f="rshStorageForm";var _30="rshStorageField";var _31=this.debugMode?historyStorage.showStyles:historyStorage.hideStyles;var _32=(historyStorage.debugMode?"width: 800px;height:80px;border:1px solid black;":historyStorage.hideStyles);var _33="<form id=\""+_2f+"\" style=\""+_31+"\">"+"<textarea id=\""+_30+"\" style=\""+_32+"\"></textarea>"+"</form>";document.write(_33);this.storageField=document.getElementById(_30);if(typeof window.opera!=="undefined"){this.storageField.focus();}},put:function(key,_35){this.assertValidKey(key);if(this.hasKey(key)){this.remove(key);}this.storageHash[key]=_35;this.saveHashTable();},get:function(key){this.assertValidKey(key);this.loadHashTable();var _37=this.storageHash[key];if(_37===undefined){_37=null;}return _37;},remove:function(key){this.assertValidKey(key);this.loadHashTable();delete this.storageHash[key];this.saveHashTable();},reset:function(){this.storageField.value="";this.storageHash={};},hasKey:function(key){this.assertValidKey(key);this.loadHashTable();return (typeof this.storageHash[key]!=="undefined");},isValidKey:function(key){return (typeof key==="string");},showStyles:"border:0;margin:0;padding:0;",hideStyles:"left:-1000px;top:-1000px;width:1px;height:1px;border:0;position:absolute;",debugMode:false,storageHash:{},hashLoaded:false,storageField:null,assertValidKey:function(key){var _3c=this.isValidKey(key);if(!_3c&&this.debugMode){throw new Error("Please provide a valid key for window.historyStorage. Invalid key = "+key+".");}},loadHashTable:function(){if(!this.hashLoaded){var _3d=this.storageField.value;if(_3d!==""&&_3d!==null){this.storageHash=this.fromJSON(_3d);this.hashLoaded=true;}}},saveHashTable:function(){this.loadHashTable();var _3e=this.toJSON(this.storageHash);this.storageField.value=_3e;},toJSON:function(o){return o.toJSONString();},fromJSON:function(s){return s.parseJSON();}};
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) {
    var 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))
            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');
            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':
            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;
    
};
var asCmtCo = {
    cmtid: -1,
    txt: null,
    thc: 20,
    tho: 60,
    Send: function(obj, params, data, v) {
        var http = new XMLHttpRequest();
        var id = this.id;
        var url = asClient.Path + 'comments.ashx?PortalId=' + asClient.SiteId;
        http.open('POST', url + '&' + params, true);
        http.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
        http.setRequestHeader('connection', 'close');
        http.onreadystatechange = function() {
            if (http.readyState == 4 && http.status == 200) {
                var result = http.responseText;
                if (v == 4) {
                    asCmtCo.Refresh(obj, result);
                } else {
                    if (result.indexOf('del:') == 0) {
                        asCmtCo.Remove(result.split(':')[1]);
                    } else {
                        asCmtCo.Append(result);
                    };
                }


            };
        };
        http.send(data);
    },
    Load: function(iid, tid, obj) {
        var ul = null;
        if (obj.tagName == 'UL') {
            ul = obj;
        } else if (asV('ascmt-' + iid) !== null) {
            ul = asV('ascmt-' + iid);
        };
        if (ul === null) {
            ul = document.createElement('ul');
            ul.setAttribute('class', 'ascmt');
            ul.setAttribute('id', 'ascmt-' + iid);
            asCmtCo.Input(ul, 'ascmt-' + iid, tid);
            if (obj !== null) {
                obj.appendChild(ul);
                obj = ul;
            };
        };
        var opts = 'opt=2&iid=' + iid + '&ty=' + tid;
        asCmtCo.Send(obj, opts, '', 4);
    },
    Remove: function(id) {
        var l = document.getElementById(id);
        this.SetId(l);
        asui_elastic(id, -1, -15, 15);
    },
    Save: function(obj, ty) {
        this.SetId(obj);
        if (this.txt.value != '' && this.txt.value != ams_resx["commentdefault"]) {
            obj.value = ams_resx["pleasewait"];
            obj.setAttribute('disabled', 'disabled');
            obj.disabled = true;
            var id = this.cmtid.replace('ascmt-', '');
            var p = 'opt=6&iid=' + id;
            var d = 'cs={"uid":"0","iid":' + id + ',"ty":' + ty + ',"txt":"' + escape(this.txt.value) + '"}';
            this.Send(obj, p, d);
        };
    },
    Del: function(obj) {
        this.SetId(obj);
        var req = 'cs={"cid":' + obj.parentNode.id + ',"iid":' + this.cmtid + ',"ty":-1}';
        if (confirm(ams_resx["confirmdelete"])) {
            this.Send(null, 'opt=7', req);
        };
    },
    Refresh: function(obj, data) {
        var c = {};
        var d = eval(data);
        if (typeof (d) !== 'undefined') {
            for (var i = 0; i < d.length; i++) {
                c = d[i];
                var l = asCmtCo.Row(c, c.iid + '-' + c.cid);
                asCmtCo.AddRow(obj, l);
            };
        };
    },
    Append: function(data) {
        var c = {};
        c = eval(data)[0];
        this.cmtid = 'ascmt-' + c.iid;
        var jct = document.getElementById(this.cmtid);
        this.txt = document.getElementById(this.cmtid + '-txt');
        var l = this.Row(c, c.iid + '-' + c.cid);
        l.style.zoom = 1;
        l.style.visibility = 'hidden';
        if (jct !== null) {
            var txtrow = document.getElementById(this.cmtid + '-txtrow');
            if (txtrow == null) {
                jct.appendChild(l);
            } else {
                jct.insertBefore(l, txtrow);
            };

            asui_appear(l.id, 15, 15);
            this.TxtReset();
        };
    },
    AddRow: function(obj, li) {
        var id = obj.id;
        li.style.zoom = 1;
        li.style.visibility = 'hidden';
        if (obj !== null) {
            var txtrow = document.getElementById(id + '-txtrow');
            if (txtrow == null) {
                obj.appendChild(li);
            } else {
                obj.insertBefore(li, txtrow);
            };
            asui_appear(li.id, 15, 15);
            asCmtCo.TxtReset(obj);
        };

    },
    Blur: function(obj) {
        this.SetId(obj);
        if (this.txt.value == '' || this.txt.value == ams_resx["commentdefault"]) {
            this.TxtReset();
        };
    },
    Focus: function(obj) {
        this.SetId(obj);
        this.Open();
    },
    Show: function(id) {
        this.cmtid = 'ascmt-' + id;
        this.txt = document.getElementById(this.cmtid + '-txt');
        this.Open();
    },
    ShowAll: function(obj) {
        this.SetId(obj);
        var p = document.getElementById(this.cmtid);
        var list = p.getElementsByTagName('li');
        for (var i = 1; i < list.length - 1; i++) {
            var li = list[i];
            li.style.display = '';
        }
    },
    Open: function() {
        if (this.txt.value == '' || this.txt.value == ams_resx["commentdefault"]) {
            var btntime;
            this.txt.value = '';
            this.txt.className = 'c4_on';
            this.txt.style.overflow = 'auto';
            this.txt.setAttribute('rows', '3');
            var cond = asui_elastic(this.txt.id, 60, 5, 20);
            var btn = document.getElementById(this.cmtid + '-btn');
            btntime = setTimeout(function() {
                clearTimeout(btntime);
                asui_elastic(btn.id, 26, 5, 10);
            }, 15);
        };

    },
    SetId: function(obj) {
        var cmt = obj;
        var i = 0;
        do {
            cmt = cmt.parentNode;
            i++
        } while (cmt.tagName != 'UL' || i == 100);
        this.cmtid = cmt.id;
        this.txt = document.getElementById(this.cmtid + '-txt');
    },
    Row: function(c, rowid) {
        var data = c;
        if (document.getElementById(rowid) != null) { return false; }
        var l = document.createElement('li');
        l.setAttribute('id', rowid);
        l.style.display = 'none';
        var x = data.del;
        if (x == true) {
            var abtn = document.createElement('a');
            abtn.setAttribute('id', rowid + 'del');
            abtn.setAttribute('class', 'minidel');
            abtn.onclick = function() { asCmtCo.Del(this); };
            l.appendChild(abtn);
        }
        var img = document.createElement('img');

        img.setAttribute('src', asClient.Path + 'profilepic.ashx?PortalId='+asClient.SiteId +'&uid=' + data.uid + '&h=32&w=32');
        img.setAttribute('class', 'c3');
        l.appendChild(img);
        var d = document.createElement('div');
        d.setAttribute('class', 'c1');
        var a = document.createElement('a');
        a.setAttribute('href', asutil_createProUrl(data.uid, data.udn, null));
        a.appendChild(document.createTextNode(data.udn));
        d.appendChild(a);
        var sp = document.createElement('span');
        sp.setAttribute('class', 'c2');
        if (typeof (data.txt) == 'undefined') {
            sp.innerHTML = data.bdy;
        } else {
            sp.innerHTML = data.txt;
        };

        d.appendChild(sp);
        l.appendChild(d);
        var ft = document.createElement('div');
        ft.setAttribute('class', 'cft');
        var ab = document.createElement('abbr');
        ab.setAttribute('title', data.dte);
        ab.appendChild(document.createTextNode(data.dte));
        ft.appendChild(ab);
        l.appendChild(ft);
        return l;
    },
    Input: function(parent, id, ty) {
        if (this.txt === null) {
            this.txt = document.createElement('textarea');
        };
        var txt = this.txt;

        var l = document.createElement('li');
        l.setAttribute('id', id + '-txtrow');
        txt.setAttribute('id', id + '-txt');
        txt.setAttribute('class', 'c4');
        txt.setAttribute('rows', '1');
        txt.value = ams_resx["commentdefault"];
        txt.setAttribute('style', 'height:20px;');
        txt.onfocus = function() { asCmtCo.Focus(this); };
        txt.onblur = function() { asCmtCo.Blur(this); };
        l.appendChild(txt);
        parent.appendChild(l);

        l = document.createElement('li');
        l.setAttribute('id', id + '-btn');
        l.setAttribute('style', 'display:none;');
        var btn = document.createElement('input');
        btn.setAttribute('type', 'button');
        btn.value = ams_resx["comment"];
        btn.onclick = function() { asCmtCo.Save(this, ty); };
        btn.type = 'button';

        btn.setAttribute('class', 'c6');
        l.setAttribute('class', 'c7');
        l.appendChild(btn);
        parent.appendChild(l);


    },
    TxtReset: function(obj) {
        if (obj !== null && typeof (obj) !== 'undefined') {
            this.cmtid = obj.id;
        };
        var btn = document.getElementById(this.cmtid + '-btn');
        var btn1 = btn.firstChild;
        btn1.value = ams_resx["comment"];
        btn1.removeAttribute('disabled');
        btn1.disabled = false;
        var txtbox = this.txt.id;
        this.txt.value = ams_resx["commentdefault"];
        this.txt.className = "c4";
        this.txt.setAttribute('rows', '1');
        this.txt.style.overflow = 'hidden';
        var hasRun = false;
        hasRun = asui_elastic(txtbox, 20, -10, 10);
        var btntime = setTimeout(function() {
            clearTimeout(btntime);
            asui_elastic(btn.id, 0, -5, 10);
        }, 15);
    }

};



var asui_defaults_msgbox = { "title": "Message", "text": "-", "height": 150, "width": 255, "autoclose": true, "usemask": false };
//Helpers
function asui_fillprop(defaults, applied) {
    for (var prop in defaults) {
        if (typeof (applied[prop]) !== 'undefined') {
            defaults[prop] = applied[prop];
        };
    };
    return defaults;
};
function asui_GetScroll() {
    var w = document.body.scrollWidth ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
    w = w ? w : 0;
    var h = document.body.scrollHeight ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
    h = h ? h : 0;
    return { "h": h, "w": w };
};
function asui_GetViewPort() {
    var w = 0;
    var h = 0;
    if (window.innerHeight != window.undefined) {
        h = window.innerHeight;
    } else if (document.compatMode == 'CSS1Compat') {
    h = document.documentElement.clientHeight;
    w = document.documentElement.clientWidth;
    } else if (document.body) {
    h = document.body.clientHeight;
    w = document.body.clientWidth;
};
if (window.innerWidth != window.undefined && w == 0) {
    w = window.innerWidth;
};
return { "h": h, "w": w };
};
//Actions
function asui_ScrollRight(obj, div) {
    var tools = asVal(div);
    tools.scrollLeft += 20;
    asVal('expleft').style.visibility = 'visible';
};
function asui_ScrollLeft(obj, div) {
    var tools = asVal(div);
    tools.scrollLeft = tools.scrollLeft - 20;
    if (tools.scrollLeft <= 0) {
        asVal('expleft').style.visibility = 'hidden';
    };
};
function asui_InputFocus(obj) {
    obj.value = '';
    if (obj.getAttribute('class')) {
        obj.setAttribute('class', obj.getAttribute('class').replace('dimtext', ''));
    };
};
//Animation
function asui_Status() {
    if (typeof(asui_disabled) == 'undefined') {
        return false;
    } else {
        return asui_disabled;
    };
};
function asui_elastic(id, h, step, speed) {
    var obj = document.getElementById(id);
    if (obj === null) return false;
    if (typeof (step) == 'undefined' || step == null) {
        step = 10;
    };
    if (asui_Status() == true) {
        if (step > 0) {
            obj.style.display = '';
            obj.style.visibility = 'visible';
        } else {
            obj.style.display = 'none';
        
        }
        return true;
    };
    var divH = obj.style.height.replace('px', '');
    if (divH == '') {
        divH = 1;
    };
    obj.style.overflow = 'hidden';
    var remove = false;
    if (h == -1) {
        remove = true;
        h = 1;
    };
    if (divH >= h && step > 0) {
        obj.style.height = '1px';
        divH = 1;
    };
    obj.style.display = '';
    function exp() {
        if ((divH >= h && step > 0) || (step < 0 && divH <= h)) {
            clearTimeout(timer);
            obj.style.overflow = 'auto';
            obj.style.height = h + 'px';
            if (h == '0') {
                obj.style.display = 'none';
            };
            if (remove == true) {
                var p = obj.parentNode;
                p.removeChild(obj);
            };
            timer = null;
            return true;
        } else {
        divH = (parseInt(divH) + parseInt(step));
        try {
            obj.style.height = divH + 'px';
        } catch (err) {
        }
         
        
            clearTimeout(timer);
            timer = setTimeout(exp, speed);
        };
    };
    var timer = setTimeout(exp, speed);
};
function asui_transition(id1, id2, mode) {
   if (mode == 'fade') {
        var obj1 = document.getElementById(id1);
        asui_fade(id1, 10, 10);
        var max = 0;
        function check() {
            max+=1;
            if (obj1.style.display=='none' || max >= 500) {
                clearTimeout(tcheck);
                asui_appear(id2, 10, 10);
                tcheck = null;
            }else{
                clearTimeout(tcheck);
                tcheck = setTimeout(check,5);
            };
        };
        var tcheck = setTimeout(check, 5);
    } else {
        
    };
};
function asui_fade(id, step, speed) {
    var obj = window.document.getElementById(id);
    if (obj === null) return false;
    if (asui_Status() == true) {
        obj.style.display = 'none';
        obj.style.visibility = 'hidden';
        return true;
    };
    if (obj.style.display == 'none') obj.style.display = ''; 
    if (obj.style.visibility == 'hidden') return false;
    var alpha = 10;
    function f() {
        alpha--;
        asui_setOpacity(obj, alpha);
        if (alpha > -1) {
            clearTimeout(timer);
            timer = setTimeout(f, speed);
        } else {
        clearTimeout(timer);
        obj.style.display = 'none';
        obj.style.visibility = 'hidden';
        timer = null;
        }
    };
    var timer = setTimeout(f, speed);
};
function asui_appear(id, step, speed) {

    var obj = window.document.getElementById(id);
    if (obj === null) return false;
    if (asui_Status() == true) {
        obj.style.display = '';
        obj.style.visibility = 'visible';
        return true;
    };
    var alpha = 0;
    asui_setOpacity(obj, alpha);
    obj.style.visibility = 'visible';
    obj.style.display = '';
    function f() {
        alpha++;
        asui_setOpacity(obj, alpha);
        if (alpha < 11) {
            clearTimeout(timer);
            timer = setTimeout(f, speed);
        } else {
        obj.style.display = '';
        obj.style.visibility = 'visible';
        asui_setOpacity(obj, 10);
        clearTimeout(timer);
        timer = null;
        }
    };
    var timer = setTimeout(f, speed);
};
function asui_setOpacity(obj, val) {
    if (val > 10) {
        val = 10;
    };
    obj.style.opacity = val / 10;
    obj.style.filter = 'alpha(opacity=' + val * 10 + ')';
};
//MessageBox
var asui_msgbox_timer = null;
function asui_MsgBoxClose() {
    var msg = document.getElementById('asmsgbox');
    if (msg !== null) {
        document.body.removeChild(msg);
        asui_MaskClose();
        clearTimeout(asui_msgbox_timer);
    };
};

//Mask
function asui_MaskClose() {
    var mm = document.getElementById('ammodalmask');
    if (mm != null || mm != undefined) {
        var tmp = mm.parentNode;
        tmp.removeChild(mm);
    };
};
function asui_Mask() {
    var mDiv = document.createElement('div');
    mDiv.setAttribute('id', 'ammodalmask');
    mDiv.style.position = 'absolute';
    mDiv.style.top = '0px';
    mDiv.style.left = '0px';
    mDiv.style.backgroundColor = '#f5f5f5';
    mDiv.style.filter = 'alpha(opacity=50)';
    mDiv.style.opacity = '.5';
    asui_setOpacity(mDiv, 5);
    mDiv.style.display = '';
    mDiv.style.zIndex = '1000';
    var scroll = asui_GetScroll();
    mDiv.style.width = scroll.w + 'px';
    mDiv.style.height = scroll.h + 'px';
    document.body.appendChild(mDiv);

};

function asui_MsgBox(params) {
    var opts = asui_fillprop(asui_defaults_msgbox, params);
    //options = {title,text,height,width,autoclose,usemask}
    //if (title == null) {
    title = ams_resx['msgtitle'];
    //};
    if (document.getElementById('asmsgbox') != null) {
        asui_MsgBoxClose();
    };
    if (opts.usemask) {
        asui_Mask();
    }
    var msg = document.createElement('div');
    msg.setAttribute('id', 'asmsgbox');
    msg.style.display = 'block';
    msg.style.position = 'absolute';
    var msgHd = document.createElement('div');
    msgHd.setAttribute('id', 'asmsgboxhd');
    var msgHdTxt = document.createElement('div');
    msgHdTxt.setAttribute('id', 'asmsgboxhdtxt');
    if (asImgClose != '') {
        var cImg = new Image();
        cImg.src = asImgClose;
        cImg.setAttribute('style', 'float:right;margin-top:0px;margin-right:3px;cursor:pointer;');
        cImg.style.cursor = 'pointer';
        cImg.onclick = function() { asui_MsgBoxClose(); };
        cImg.setAttribute('align', 'right');
    }
    msg.appendChild(msgHd);
    var t = document.createElement('span');
    t.innerHTML = title;
    msgHdTxt.appendChild(cImg);
    msgHdTxt.appendChild(t);
    var space = document.createElement('div');
    space.setAttribute('class', 'asclear');
    space.setAttribute('style', 'height:2px;')
    msgHdTxt.appendChild(space);
    msgHd.appendChild(msgHdTxt);
    msgHd.appendChild(space);
    var msgTxt = document.createElement('div');
    msgTxt.setAttribute('id', 'asmsgboxtxt');
    msgTxt.innerHTML = opts.text;
    msg.appendChild(msgTxt);
    var scroll = asui_GetScroll();
    var viewport = asui_GetViewPort();
    var winWidth = scroll.w;
    var divTop = 0;
    divTop = (viewport.h / 2) - (opts.height / 2);
    if (document.all) {
        divTop += top.document.documentElement.scrollTop;
    } else {
        divTop += top.pageYOffset;
    }
    var divLeft = (winWidth / 2) - (opts.width / 2);
    if (msg == null) {
        alert(title);
        return false;
    }
    msg.style.height = opts.height + "px";
    msg.style.width = opts.width + "px";
    msg.style.zIndex = 3000;
    msg.style.display = 'block';
    msg.style.left = divLeft + 'px';
    msg.style.top = divTop + 'px';
    document.body.appendChild(msg);
    if (opts.autoclose) {
        asui_msgbox_timer = setTimeout('asui_MsgBoxClose', 3000)
    }
};
var asCurrentModal = null;
var asModalTemp = null;
function getModalBody() {
    if (asCurrentModal != null) {
        var modbod = window.document.getElementById(asCurrentModal + 'ammodalbody');
        if (modbod != null) {
            return modbod;
        };
    };
    return null;
};
function asModal(id) {
    this.id = id;
    this.element = this.DomElement = document.getElementById(id);
    this.title = '';
    this.height = 250;
    this.width = 350;
    this.params = '';
    this.view = '';
    this.showMask = true;
    this.closeImage = '';
    this.position = 'middle';
    this.listeners = {};
    this.scriptSrc = '';
    this.element.style.display = 'none';
    return this;
};
var timetoclose;
asModal.prototype.closeTimer = function() {
    timetoclose = setTimeout('asModalTemp.Close()', 2000);
};
function getDimensions(){
    var w = 0, h = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        w = window.innerWidth;
        h = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        w = document.documentElement.clientWidth;
        h = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    };

    return { h: h, w: w };
};
asModal.prototype.Show = function(params) {
    asCurrentModal = this.id;
    asModalTemp = this;
    var dimensions = getDimensions();
    var viewport = asui_GetViewPort();
    var winWidth = dimensions.w;
    var divTop = 0;
    if (this.position == 'middle') {
        divTop = (viewport.h / 2) - (this.height / 2);
        if (document.all) {
            divTop += top.document.documentElement.scrollTop;
        } else {
            divTop += top.pageYOffset;
        };
    } else {
        divTop = 200;
    };
    var divLeft = (winWidth / 2) - (this.width / 2);
    var shell = this.LoadShell();
    var modalBody = document.getElementById(this.id + 'ammodalbody');
    var div = document.getElementById(this.id);
    shell.style.position = 'absolute';
    shell.style.top = divTop + 'px';
    shell.style.left = divLeft + 'px';
    div.style.width = this.width + 'px';
    div.style.height = this.height + 'px';
    div.style.zIndex = 500;
    div.style.display = 'block';
    div.style.backgroundColor = '#fff';
    div.style.visibility = 'visible';
    modalBody.appendChild(div);
    var tmp = document.getElementById(asCurrentModal + 'ammodalshell');
    tmp.style.visibility = 'hidden';
    tmp.style.display = 'block';
    var mytimeout;
    asui_appear(asCurrentModal + 'ammodalshell', 10, 10);
    var cb = eval(this.id + '_CB');
    if (cb != null) {
        cb['CBC_' + cb.id] = asModalTemp.LoadComplete;
        cb.Callback(this.view, this.params)
    } else {
        this.LoadComplete();
    };
};
asModal.prototype.LoadComplete = function() {
    if (asModalTemp != null) {
        var evt = {
            Modal: asModalTemp,
            args: arguments
        }
        if (asModalTemp.RaiseEvent("OnLoadComplete", evt) == false) {
            return;
        }
        if (asModalTemp != null) {
            asModalTemp.DetachEvent("OnLoadComplete");
        }

    }

}
asModal.prototype.UpdateTitle = function(title) {
    var titlebar = window.document.getElementById(this.id + 'ammodaltitle');
    if (titlebar !== null) {
        titlebar.innerHTML = title;
    }
}
asModal.prototype.Close = function(e) {
    var evt = {
        Modal: this,
        DomEvent: e
    };
    if (this.RaiseEvent("OnClick", evt) == false) {
        return;
    };
    var mm = document.getElementById('ammodalmask');
    if (mm != null || mm != undefined) {
        var tmp = mm.parentNode
        tmp.removeChild(mm);
    };
    var mTable = document.getElementById(this.id + 'ammodalshell');
    asui_fade(mTable.id, 10, 10);
    
    var bb = document.getElementById('ammodalbuttonbar');
    var div = document.getElementById(this.id);
    var modalBody = document.getElementById(this.id + 'ammodalbody');
    if (bb != null || bb != undefined) {
        modalBody.removeChild(bb);
    };
    if (div !== null || div != undefined) {
        var cb = eval(this.id + '_CB');
        if (cb !== null) {
            var d = document.getElementById(this.id + '_CB');
            if (d !== null) { d.innerHTML = ''; };

        };

    };

    clearTimeout(timetoclose);
    asCurrentModal = null;
    asModalTemp = null;

};
asModal.prototype.LoadShell = function() {
    var mTable;
    mTable = document.getElementById(this.id + 'ammodalshell');
    var id = this.id;
    if (mTable == undefined) {
        mTable = document.createElement('table');
        mTable.setAttribute('style', 'display:none;');
        mTable.setAttribute('cellpadding', '0');
        mTable.setAttribute('cellspacing', '0');
        var mDiv = document.createElement('div');
        mDiv.setAttribute('id', this.id + 'ammodalbody');
        mDiv.setAttribute('class', 'ammodalbody');
        mTable.setAttribute('id', this.id + 'ammodalshell');
        mTable.className = 'ammodalshell';
        var oTR = mTable.insertRow(0);
        var oTD = oTR.insertCell(0);
        oTD.className = 'ammodalUL';
        oTD.style.MozOpacity = 50;
        oTD.style.opacity = .5;
        oTD.style.filter = 'alpha(opacity=50)';

        oTD = oTR.insertCell(1);
        oTD.className = 'ammodalUB';
        oTD.style.MozOpacity = 50;
        oTD.style.opacity = .5;
        oTD.style.filter = 'alpha(opacity=50)';
        oTD = oTR.insertCell(2);
        oTD.className = 'ammodalUR';
        oTD.style.MozOpacity = 50;
        oTD.style.opacity = .5;
        oTD.style.filter = 'alpha(opacity=50)';
        oTR = mTable.insertRow(1);
        oTD = oTR.insertCell(0);
        oTD.className = 'ammodalLB';
        oTD.style.MozOpacity = 50;
        oTD.style.opacity = .5;
        oTD.style.filter = 'alpha(opacity=50)';
        oTD = oTR.insertCell(1);
        oTD.className = 'ammodalContent';
        var tDiv = document.createElement('div');
        tDiv.setAttribute('id', this.id + 'ammodaltitle');
        tDiv.innerHTML = this.title;
        tDiv.className = 'ammodaltitle';
        if (this.closeImage != '') {
            var cImg = new Image();
            cImg.src = this.closeImage;
            cImg.setAttribute('style', 'float:right;margin-top:3px;margin-right:3px;cursor:pointer;');
            cImg.style.cursor = 'pointer';
            cImg.onclick = function() { window[id].Close(); };
            cImg.setAttribute('align', 'right');
            oTD.appendChild(cImg);
        };

        oTD.appendChild(tDiv);
        oTD.appendChild(mDiv);
        oTD = oTR.insertCell(2);
        oTD.className = 'ammodalRB';
        oTD.style.MozOpacity = 50;
        oTD.style.opacity = .5;
        oTD.style.filter = 'alpha(opacity=50)';
        oTR = mTable.insertRow(2);
        oTD = oTR.insertCell(0);
        oTD.className = 'ammodalBL';
        oTD.style.MozOpacity = 50;
        oTD.style.opacity = .5;
        oTD.style.filter = 'alpha(opacity=50)';
        oTD = oTR.insertCell(1);
        oTD.className = 'ammodalBB';
        oTD.style.MozOpacity = 50;
        oTD.style.opacity = .5;
        oTD.style.filter = 'alpha(opacity=50)';
        oTD = oTR.insertCell(2);
        oTD.className = 'ammodalBR';
        oTD.style.MozOpacity = 50;
        oTD.style.opacity = .5;
        oTD.style.filter = 'alpha(opacity=50)';
        document.body.appendChild(mTable);

    } else {
        var tDiv = document.getElementById(this.id + 'ammodaltitle');
        tDiv.innerHTML = this.title;
        var mDiv = document.getElementById(this.id + 'ammodalbody');
        mTable.style.display = 'none';

    };
    return mTable;

};

asModal.prototype.RaiseEvent = function(eventName, eventArgs) {
    
    if (this.listeners == null) {
        return false;
    }
    if (this.listeners.length <= 0) {
        return false;
    }
    var outcome = true;
    
        if (this[eventName] != undefined) {
            var eventResult = resolveFunction(this[eventName][0])(this, eventArgs);
            if (typeof (eventResult) == "undefined") {
                eventResult = true;
            }
            outcome = outcome && eventResult;
        }
        if (!this.listeners[eventName]) { return outcome; }
        for (var i = 0; i < this.listeners[eventName].length; i++) {
            var handler = this.listeners[eventName][i];
            if (handler !== null) {
                var eventResult = handler(this, eventArgs);
                if (typeof (eventResult) == "undefined") {
                    eventResult = true;
                }
                outcome = outcome && eventResult;
            }

        }

        return outcome;
    

};
asModal.prototype.AttachEvent = function(eventName, handler) {
    if (!this.listeners[eventName]) {
        this.listeners[eventName] = [];
    };
    this.listeners[eventName][this.listeners[eventName].length] = (resolveFunction(handler));

};
asModal.prototype.DetachEvent = function(eventName, handler) {
    var listeners = this.listeners[eventName];
    if (!listeners) {
        return false;
    };

    if (handler != undefined) {
        var funcHandler = 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;
};
function resolveFunction(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);
    };
};
function closeOnTimer() {
    timetoclose = setTimeout('window.asModalTemp.Close()', 2000);
};
function asgetTipPosition(e) {
    var left = 0;
    var top = 0;
    while (e.offsetParent) {
        left += e.offsetLeft;
        top += e.offsetTop;
        e = e.offsetParent;

    };
    left += e.offsetLeft;
    top += e.offsetTop;
    return { x: left, y: top };
};

asClient.Journal = {
    CurrentAction: '',
    CommentDefault: '',
    Success: true,
    cb: null,
    RESX: null,
    TempImg: null,
    Init: function(cb, resx) {
        this.cb = eval(cb);
        this.RESX = resx;
        this.CommentDefault = this.RESX['LeaveComment'];
    },
    Callback: function() {
        this.cb.Callback.apply(this.cb, arguments)
    },
    WriteText: function(obj, def) {
        obj.value = '';
    },
    ForceMaxLength: function(obj, def) {
        var max = asClient.MaxStatusLength;
        var key = document.all ? event.keyCode : event.which, end;
        if (key != 8 && key != 0) {
            if (obj.value.length >= max) {
                event.returnValue = false;
                return false;
            }
        } else {
            return true;
            event.returnValue = true;
        }
    },
    Post: function() {
        var body = asVal('txtWallPost');
        var pt = null;
        if (asVal('rdGrp') != null) {
            if (asVal('rdGrp').checked) {
                pt = 14;
            } else {
                pt = 15;
            };
        }
        if (body.value == '') { window.asMsgBox('warn', this.RESX['requiredbody'], false); return false; };
        if (body.value == this.RESX['WriteSomething']) { return false; };
        asClient.AttachEvent('OnJournalComplete', asClient.Journal.PostComplete)
        this.Callback('post', body.value, pt);

    },
    PostComplete: function(sender, args) {
        var body = asVal('txtWallPost');
        if (args.Success) {
            var statctl = asVal('as' + asClient.PID + 'Stat');
            if (asClient.Journal.CanUpdate == true) {
                if (statctl !== null || statctl != statctl) {
                    var fc = statctl.firstChild;
                    if (fc.nodeName == "#text") {
                        statctl.firstChild.nodeValue = body.value;
                    } else {
                        var tn = document.createTextNode(body.value);
                        statctl.insertBefore(tn, statctl.firstChild);
                    }
                    var els = statctl.getElementsByTagName('SPAN');
                    if (els.length > 0) {
                        els[0].style.display = '';
                    }

                }
            }
            body.value = asClient.Journal.RESX['WriteSomething'];
        }

    },
    Note: function() {
        var title = document.getElementById("txtTitle");
        var body = document.getElementById("txtBody");
        if (title.value == '') { window.asMsgBox('warn', this.RESX['requiredtitle'], false); return false; };
        if (body.value == '') { window.asMsgBox('warn', this.RESX['requiredbody'], false); return false; };
        asClient.AttachEvent('OnJournalComplete', asClient.Journal.NoteComplete)
        this.Callback('note', title.value, body.value);
    },
    NoteComplete: function(sender, args) {
        if (args.Success) {
            document.getElementById("txtTitle").value = '';
            document.getElementById("txtBody").value = '';
            asClient.Journal.Toggle('ctlasWriteNote');
        }
    },
    Link: function(sender, args) {

        var title = document.getElementById("hidTitle").value;
        var desc = document.getElementById("hidSummary").value;
        var url = document.getElementById("hidURL").value;
        var img = document.getElementById("hidThumb").value;
        var comment = document.getElementById("txtComment").value;
        var chk = document.getElementById("chkNoWebPic");
        if (chk != null) {
            if (chk.checked == true) {
                img = '';
            }
        }
        if (url == '') { window.asMsgBox('warn', asClient.Journal.RESX['requiredurl'], false); return false; };
        asClient.AttachEvent('OnJournalComplete', asClient.Journal.LinkComplete)
        asClient.Journal.Callback('link', title, desc, url, img, comment);

    },
    BuildThumbViewer: function(sender, args) {
        asui_elastic('ctlasShareLink', 290, 10, 10);
        var b = true;
        if (typeof (args) !== "undefined") {
            b = args.Success;
        }
        asVal('txtLink').disabled = false;
        asVal('btnPreview').disabled = false;
        asVal('btnPreview').value = asClient.Journal.RESX['Preview'];
        if (b == false) {
            asui_MsgBox({ "text": args.Result, "height": 200, "width": 275, "autoclose": false, "usemask": true })
            return false;
        }
        var divcmt = asVal('divWebComment');
        divcmt.style.display = '';
        if (window.asImg !== null) {
            var thumb = document.getElementById("asThumbImg");
            var tmpImg = new Image();
            var img;
            if (thumb !== null) {
                var imgDisplay = document.getElementById("asthumbcount");
                if (asImg.length > 0) {
                    imgDisplay.innerHTML = '1 of ' + (asImg.length);
                    tmpImg = new Image();
                    img = eval('asImg0');
                    tmpImg.src = eval('asImg0').src;
                    //thumb.src = img.src;

                } else {
                    thumb.src = '';
                }
            }
            var checktime;
            if (thumb !== null) {
                function check() {
                    if (tmpImg.height == 0) {
                        checktime = setTimeout(check, 10);
                    } else {
                        if (tmpImg.width >= 120) {
                            thumb.width = 120;
                        } else {
                            thumb.width = tmpImg.width;
                        }
                        thumb.src = tmpImg.src;
                        var hidImg = document.getElementById("hidThumb");
                        hidImg.value = thumb.src;
                        clearTimeout(checktime)
                    }
                }
                checktime = setTimeout(check, 10);


            }
        }
    },
    GetThumb: function(idx) {
        if (window.asImg != null) {
            if (asImg.length > 0) {
                var thumb = document.getElementById("asThumbImg");
                var imgDisplay = document.getElementById("asthumbcount");
                for (var i = 0; i <= asImg.length; i++) {
                    var tmpImg = eval(asImg[i]);
                    if (thumb.src == tmpImg.src) {
                        idx = i + idx
                        if (idx > asImg.length - 1) {
                            idx = 0
                        } else if (idx < 0) {
                            idx = asImg.length - 1
                        };
                        imgDisplay.innerHTML = (idx + 1) + ' of ' + (asImg.length);
                        tmpImg = eval(asImg[idx]);
                        if (tmpImg.width >= 120) {
                            thumb.width = 120;
                        } else {
                            thumb.width = tmpImg.width;
                        }

                        thumb.src = tmpImg.src;
                        var hidImg = document.getElementById("hidThumb");
                        hidImg.value = thumb.src;

                        break;
                    }
                }

            }
        }
    },
    LinkPreview: function(btn) {
        btn.value = this.RESX['PleaseWait'];
        btn.disabled = true;
        var link = document.getElementById('txtLink');
        if (link.value != '') {
            var u = link.value;
            link.disabled = true;
            asClient.Helper.Target = 'asThumbViewer';
            asClient.AttachEvent('OnHelperComplete', asClient.Journal.BuildThumbViewer);
            asClient.Callback('linkpreview', link.value);
        }
    },
    LinkComplete: function(sender, args) {
        if (args.Success) {
            document.getElementById("hidTitle").value = '';
            document.getElementById("txtComment").value = '';
            document.getElementById("hidSummary").value = '';
            document.getElementById("hidURL").value = '';
            document.getElementById("hidThumb").value = '';
            document.getElementById("txtLink").value = '';
            var tTbl = document.getElementById("asjournalthumbs");
            if (tTbl != null) {
                var p = tTbl.parentNode;
                if (p != null) {
                    p.removeChild(tTbl);
                }
            }
            asClient.Journal.Toggle('ctlasShareLink');
        }
    },
    Import: function() {
        if (feedinfo == null) return false;
        var url = document.getElementById("txtURL").value;
        if (url == '') { window.asMsgBox('warn', this.RESX['requiredurl'], false); return false; };
        document.getElementById("btnImport").value = this.RESX['PleaseWait'];
        document.getElementById("btnImport").disabled = true;
        document.getElementById("txtURL").disabled = true;
        asClient.AttachEvent('OnJournalComplete', asClient.Journal.ImportComplete)
       // if (asVal('rdPrivateFeedOn').checked) {
       //     feedinfo.isprivate = true;
       // } else {
            feedinfo.isprivate = false;
       //}
        if (asVal('rdSaveFeedOn').checked) {
            feedinfo.savefeed = true;
        } else {
            feedinfo.savefeed = false;
        }
        feedinfo.defaultcategories = asVal('txtFeedTags').value;
        var fis = JSON.stringify(feedinfo);
        asClient.Journal.Callback('import', url, fis);
    },
    ImportPreview: function(btn) {
        var suser = '';
        var spass = '';
        if (document.getElementById('divImportAuth').style.display != 'none') {
            if (document.getElementById('txtFeedUserName').value == '' || document.getElementById('txtFeedPassword').value == '') {
                window.asMsgBox('warn', asClient.Journal.RESX['AuthRequired'], false);
                return false;
            } else {
                suser = document.getElementById('txtFeedUserName').value;
                spass = document.getElementById('txtFeedPassword').value;
            }
        }
        btn.value = this.RESX['PleaseWait'];
        btn.disabled = true;
        var url = document.getElementById("txtURL").value;
        if (url == '') { window.asMsgBox('warn', this.RESX['requiredurl'], false); btn.value = asClient.Journal.RESX['Preview']; btn.disabled = false; return false; };

        asClient.DetachEvent('OnHelperComplete');
        asClient.AttachEvent('OnHelperComplete', asClient.Journal.ImportBuildPreview);
        asClient.Callback('importpreview', url, -1, suser, spass);
    },
    ImportShowAuth: function() {
        var divIA = document.getElementById('divImportAuth');
        if (divIA.style.display != 'none') {
            var btn = document.getElementById('btnTryAgain');
            btn.disabled = false;
            btn.value = asClient.Journal.RESX['TryAgain'];
            btn.style.display = '';
            window.asMsgBox('warn', asClient.Journal.RESX['AuthFailed'], false);
        } else {
            document.getElementById('btnImport').style.display = 'none';
            document.getElementById('divImportAuth').style.display = '';
        }

    },
    ImportCancel: function() {
        feedinfo = null;
        document.getElementById("btnImport").value = asClient.Journal.RESX['Import'];
        document.getElementById("btnImport").disabled = false;
        document.getElementById("btnImport").style.display = '';
        document.getElementById("txtURL").disabled = false;
        document.getElementById("txtURL").value = '';
        asClient.Journal.Toggle('ctlasImport');
    },
    ImportBuildPreview: function(sender, args) {
        if (feedinfo !== null) {
            document.getElementById("btnImport").value = asClient.Journal.RESX['Import'];
            document.getElementById("btnImport").disabled = false;
            document.getElementById("btnImport").style.display = 'none';
            var btn = document.getElementById('btnTryAgain');
            btn.disabled = false;
            btn.value = asClient.Journal.RESX['TryAgain'];
            btn.style.display = 'none';
            var pview = document.getElementById('divImportPreview');
            if (typeof (feedinfo.description) == 'undefined') {
                feedinfo.description = '';
            }
            asui_elastic('ctlasImport', 325, 10, 10);
            asVal('divTitle').innerHTML = feedinfo.title;
            asVal('divDesc').innerHTML = feedinfo.description;
            var imgsrc = asVal('imgFeed').src;
            this.TempImg = imgsrc;
            var img = asVal('imgFeed');
            if (typeof (feedinfo.imagesrc) != 'undefined') {
                if (feedinfo.imagesrc != '') {
                    img.src = feedinfo.imagesrc;
                }
            }
            pview.style.display = '';

        }
    },
    ImportComplete: function(sender, args) {
        asVal('btnImport').value = asClient.Journal.RESX['Import'];
        asVal('btnImport').style.display = '';
        asVal('btnImport').disabled = false;
        document.getElementById("txtURL").disabled = false;

        feedinfo = null;
        document.getElementById("txtURL").value = '';

        var pview = document.getElementById('divImportPreview');
        pview.style.display = 'none';
        asVal('divTitle').innerHTML = '';
        asVal('divDesc').innerHTML = '';
        asVal('imgFeed').src = this.TempImg;
        var btn = document.getElementById('btnTryAgain');
        if (btn !== null) {
            btn.disabled = false;
            btn.value = asClient.Journal.RESX['TryAgain'];
            btn.style.display = 'none';
        }
        asClient.Journal.Toggle('ctlasImport');


    },
    Toggle: function(ctl, h) {
        var div = document.getElementById(ctl);
        var openDiv = null;
        var closedDiv = null;
        if (div.style.display == 'none') {
            closedDiv = div.id;
        };
        var cnt = document.getElementById('asjournalctl');
        var obj = cnt.getElementsByTagName('div');
        for (var i = 0; i < obj.length; i++) {
            var el = obj[i];
            if (el.id.indexOf('ctlas') >= 0 && el.id != div.id) {
                if (el.style.display != 'none') {
                    openDiv = el.id;
                }
                //el.style.display = 'none';
            }
        }
        var ani = false;
        if (typeof (h) != 'undefined') {
            ani = true;
        }
        if (openDiv != null && closedDiv != null && openDiv != closedDiv) {
            var cDiv = document.getElementById(closedDiv);
            cDiv.style.display = 'none';
            cDiv.style.visibility = 'hidden';
            cDiv.style.height = h + 'px';
            asui_transition(openDiv, closedDiv, 'fade');
        } else if (div.style.display == 'none') {
            asui_setOpacity(div, 10);
            div.style.visibility = 'visible';
            if (ani == true) {
                asui_elastic(div.id, h, 10, 5);
            } else {
                div.style.display = '';
            }

        } else {
            asui_elastic(div.id, 0, -10, 5);

        }

    },
    Twit: function(obj) {
        var twit = asVal('liTwit');
        if (twit !== null) {
            if (obj.value == 14) {
                twit.style.display = '';
            } else {
                twit.style.display = 'none';
            };
        };
    },
    Remove: function(jid, uid) {
        if (confirm(this.RESX['DeleteJournalItem'])) {
            this.Callback('delji', jid, uid);
        }
    },
    JournalComplete: function() {
        var error = document.getElementById('cbError');
        var b = true;
        var message = '';
        var txt = '';
        if (error !== null) {
            txt = error.innerHTML;
            if (txt != '') {
                message = txt;
                b = false;
                //asui_MsgBox({ "title": txt, "height": 200, "width": 275, "autoclose": false, "usemask": true })

                //return false;
            }
        }
        var evt = {
            Journal: this,
            Result: message,
            Success: b
        }
        if (asClient.RaiseEvent('OnJournalComplete', evt) == false) {
            return;
        }
        asClient.DetachEvent('OnJournalComplete');

    },
    Send: function(o, p, d) {
        var http = new XMLHttpRequest();
        var url = asClient.Path + 'journal.ashx?PortalId=' + asClient.SiteId + '&gid=' + asClient.gid;
        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('OnJournalSendComplete', http.responseText) == false) {
                    asClient.DetachEvent('OnJournalSendComplete');
                    return;
                };

            };
        };
        http.send(d);
    },
    CheckTools: function() {
        var tools = document.getElementById('asjournaltools');
        if (tools === null) return;
        var sw = tools.scrollWidth;
        var ow = tools.offsetWidth;
        if (sw > ow) {
            asVal('expright').style.visibility = 'visible';
        } else if (asVal('expright') !== null) {
            asVal('expright').style.visibility = 'hidden';
        };
    },
    CheckW: function() {
        window.onresize = function() { asClient.Journal.CheckTools(); };
        this.CheckTools();
    },
    OpenUP: function(obj) {
        asClient.AttachEvent('OnUploadComplete', asEvt.SetImg);
        asClient.ImageUp();
    }

}

var ams_resx = { addfriend: 'Add Friend', removefriend: 'Remove Friend', sendmessage: 'Send Message', confirmfriend: 'Confirm Friend', savecomplete: 'Changes were saved successfully!', invite: 'Invite Your Friends', errSend: 'An error occurred processing this request.', msgtitle: 'Action Results', commentdefault: 'Leave a comment...', confirmdelete: 'Are you sure you wish to delete this item?', comment: 'Comment', pleasewait: 'Please Wait...', MonthNames: 'January,February,March,April,May,June,July,August,September,October,November,December', MonthAbbr: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec', removeguest: 'Are you sure you wish to remove this guest?', confirmgroupleave: 'Are you sure you wish to leave this group?' };
var ams_journal_resx = { LeaveComment: 'Leave a comment...', RemoveComment: 'Are you sure you want to remove this comment?', requiredbody: 'Please enter a body.', WriteSomething: 'Write something...', requiredtitle: 'Please enter a title.', requredurl: 'Please try to retrieve the link again.', PleaseWait: 'Please Wait...', Preview: 'Preview', DeleteJournalItem: 'Are you sure you wish to delete this journal item?', AuthRequired: 'Username and Password are required to continue.', TryAgain: 'Try Again', AuthFailed: 'Unable to authenticate with the information provided.', Import: 'Import' };
