


/******************************************************************************************
         swfobject2.js
 ******************************************************************************************/

/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();


/******************************************************************************************
         swfaddress.js
 ******************************************************************************************/

/**
 * SWFAddress 2.1: Deep linking for Flash and Ajax - http://www.asual.com/swfaddress/
 *
 * SWFAddress is (c) 2006-2007 Rostislav Hristov and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * This file has been modified by vyew in various places. Search for "vyew" to find where...
 */

if (typeof com == "undefined") var com = {};
if (typeof com.asual == "undefined") com.asual = {};
if (typeof com.asual.util == "undefined") com.asual.util = {};
   
/**
 * @class Utility class that provides detailed browser information.
 * @static
 * @ignore
 */
com.asual.util.Browser = new function() {

    var _version = -1;
    var _agent = navigator.userAgent;
    var _ie = false, _camino = false, _safari = false, _opera = false, 
        _firefox = false, _netscape = false, _mozilla = false;

    var _getVersion = function(s, i) {
        return parseFloat(_agent.substr(_agent.indexOf(s) + i));
    }
    
    if (_ie = /MSIE/.test(_agent))
        _version = _getVersion('MSIE', 4);
        
    if (_safari = /AppleWebKit/.test(_agent))
        _version = _getVersion('Safari', 7);
        
    if (_opera = /Opera/.test(_agent))
        _version = parseFloat(navigator.appVersion);
        
    if (_camino = /Camino/.test(_agent))
        _version = _getVersion('Camino', 7);
        
    if (_firefox = /Firefox/.test(_agent))
        _version = _getVersion('Firefox', 8);
        
    if (_netscape = /Netscape/.test(_agent))
        _version = _getVersion('Netscape', 9);
        
    if (_mozilla = /Mozilla/.test(_agent) && /rv:/.test(_agent))
        _version = _getVersion('rv:', 3);


    /**
     * Detects the version of the browser.
     * @return {Number}
     * @static
     */
    this.getVersion = function() {
        return _version;
    }

    /**
     * Detects if the browser is Internet Explorer.
     * @return {Boolean}
     * @static
     */
    this.isIE = function() {
        return _ie;
    }

    /**
     * Detects if the browser is Safari.
     * @return {Boolean}
     * @static
     */
    this.isSafari = function() {
        return _safari;
    }

    /**
     * Detects if the browser is Opera.
     * @return {Boolean}
     * @static
     */
    this.isOpera = function() {
        return _opera;
    }

    /**
     * Detects if the browser is Camino.
     * @return {Boolean}
     * @static
     */
    this.isCamino = function() {
        return _camino;
    }

    /**
     * Detects if the browser is Firefox.
     * @return {Boolean}
     * @static
     */
    this.isFirefox = function() {
        return _firefox;
    }

    /**
     * Detects if the browser is Netscape.
     * @return {Boolean}
     * @static
     */
    this.isNetscape = function() {
        return _netscape;
    }
        
    /**
     * Detects if the browser is Mozilla.
     * @return {Boolean}
     * @static
     */
    this.isMozilla = function() {
        return _mozilla;
    }
}

/**
 * @class Utility class that provides event helpers.
 * @static
 * @ignore
 */
com.asual.util.Events = new function() {

    var _cache = [];
    var _browser = com.asual.util.Browser;
    var _dcl = 'DOMContentLoaded';

    if (_browser.isIE() || _browser.isSafari()) {
        (function (){
            try {
                if (_browser.isIE() || !/loaded|complete/.test(document.readyState))
                    document.documentElement.doScroll('left');
            } catch(e) {
                return setTimeout(arguments.callee, 0);
            }
            for (var i = 0, e; e = _cache[i]; i++)
                if (e.t == _dcl) e.l.call(null);
        })();
    }

    /**
     * Adds an event listener to an object.
     * @param {Object} obj The object that provides events.
     * @param {String} type The type of the event.
     * @param {Function} listener The event listener function.
     * @return {void}
     * @static
     */
    this.addListener = function(obj, type, listener) {
        _cache.push({o: obj, t: type, l: listener});
        if (!(type == _dcl && (_browser.isIE() || _browser.isSafari()))) {
            if (obj.addEventListener)
                obj.addEventListener(type, listener, false);
            else if (obj.attachEvent)
                obj.attachEvent('on' + type, listener);
        }
    }

    /**
     * Removes an event listener from an object.
     * @param {Object} obj The object that provides events.
     * @param {String} type The type of the event.
     * @param {Function} listener The event listener function.
     * @return {void}     
     * @static
     */
    this.removeListener = function(obj, type, listener) {
        for (var i = 0, e; e = _cache[i]; i++) {
            if (e.o == obj && e.t == type && e.l == listener) {
                _cache.splice(i, 1);
                break;
            }
        }
        if (!(type == _dcl && (_browser.isIE() || _browser.isSafari()))) {
            if (obj.removeEventListener)
                obj.removeEventListener(type, listener, false);
            else if (obj.detachEvent)
                obj.detachEvent('on' + type, listener);
        }
    }

    var _unload = function() {
        for (var i = 0, evt; evt = _cache[i]; i++) {
            if (evt.t != _dcl)
                com.asual.util.Events.removeListener(evt.o, evt.t, evt.l);
        }
    }

    this.addListener(window, 'unload', _unload);
}

/**
 * Creates a new SWFAddress event.
 * @class Event class for SWFAddress.
 * @param {String} type Type of the event.
 */
SWFAddressEvent = function(type) {
    
    /**
     * String representation of this object.
     * @ignore
     */
    this.toString = function() {
        return '[object SWFAddressEvent]';
    }

    /**
     * The type of this event.
     * @type String
     */
    this.type = type;

    /**
     * The target of this event.
     * @type Function
     */
    this.target = [SWFAddress][0];

    /**
     * The value of this event.
     * @type String
     */
    this.value = SWFAddress.getValue();

    /**
     * The path of this event.
     * @type String
     */
    this.path = SWFAddress.getPath();
    
    /**
     * The folders in the deep linking path of this event.
     * @type Array
     */
    this.pathNames = SWFAddress.getPathNames();

    /**
     * The parameters of this event.
     * @type Object
     */
    this.parameters = {};

    var _parametersNames = SWFAddress.getParameterNames();
    for (var i = 0, l = _parametersNames.length; i < l; i++)
        this.parameters[_parametersNames[i]] = SWFAddress.getParameter(_parametersNames[i]);
    
    /**
     * The parameters names of this event.
     * @type Array     
     */
     this.parametersNames = _parametersNames;
}

/**
 * Init event.
 * @type String
 * @memberOf SWFAddressEvent
 * @static
 */
SWFAddressEvent.INIT = 'init';

/**
 * Change event.
 * @type String
 * @memberOf SWFAddressEvent
 * @static 
 */
SWFAddressEvent.CHANGE = 'change';

/**
 * @class The SWFAddress class can be configured with query parameters using the following format:
 * swfaddress.js?html=false&history=1&tracker=pageTracker._trackPageview&strict=1.<br /> 
 * The list of supported options include:<br /><br />
 * <code>history:Boolean</code> - Enables or disables the creation of history entries.<br />
 * <code>html:Boolean</code> - Enables or disables the usage of swfaddress.html.<br />
 * <code>strict:Boolean</code> - Enables or disables the strict mode.<br />
 * <code>tracker:String</code> - Sets a function for page view tracking.<br />
 * @static 
 */ 
SWFAddress = new function() {

    var _browser = com.asual.util.Browser;
    var _events = com.asual.util.Events;
    var _version = _browser.getVersion();
    var _supported = false;

    if (_browser.isIE()) 
        _supported = _version >= 6;
        
    if (_browser.isSafari())
        _supported = _version >= 312;
        
    if (_browser.isOpera())
        _supported = _version >= 9.02;
        
    if (_browser.isCamino()) 
        _supported = _version >= 1;
        
    if (_browser.isFirefox())
        _supported = _version >= 1;
        
    if (_browser.isNetscape())
        _supported = _version >= 8;
        
    if (_browser.isMozilla())
        _supported = _version >= 1.8;
	
	//--- Added by vyew - try/catch statement
	//--- this was breaking iframe load accross domains
	try {
		var __test=top.document.title
    	var _t = top;
	}catch(e){ 
		var _t=window; 
	}
    var _d = _t.document;
    var _h = _t.history;
    var _l = _t.location;
    var _st = setTimeout;
    
    var FUNCTION = 'function';
    var UNDEFINED = 'undefined';
    var SWFADDRESS = 'swfaddress';

    var _iframe, _form, _url;
    var _title = _d.title;
    var _length = _h.length;
    var _silent = false;
    var _listeners = {};
    var _stack = [];
    var _ids = [];
    
    var _opts = {};
    _opts.history = true;
    _opts.html = false;
    _opts.strict = true;
    _opts.tracker = '_trackDefault';
    
    /*// commented out by vyew
      if ((!_supported && _l.href.indexOf('#') != -1) || 
        (_browser.isSafari() && _version < 412 && _l.href.indexOf('#') != -1 && _l.search != '')){
        _d.open();
        _d.write('<html><head><meta http-equiv="refresh" content="0;url=' + 
            _l.href.substr(0, _l.href.indexOf('#')) + '" /></head></html>');
        _d.close();
    }*/

    var _getHash = function() {
        var index = _l.href.indexOf('#');
        if (index != -1) {
            var hash = unescape(_l.href.substr(index + 1));
// 3 lines commented by vyew
//            if (/^[a-z0-9 ,=_&\-\.\?\+\/]*$/i.test(hash))
                return hash;
//            else
//                _l.replace(_l.href.substr(0, index));
        }
        return '';
    }

    var _value = _getHash();

    var _strictCheck = function(value, force) {
        if (_opts.strict)
            value = force ? (value.substr(0, 1) != '/' ? '/' + value : value) : (value == '' ? '/' : value);
        return value;
    }

    var _ieLocal = function(value) {
        return (_browser.isIE() && _l.protocol == 'file:') ? _value.replace(/\?/, '%3F') : value;    
    }

    var _searchScript = function(el) {
        if (el.src && /swfaddress\.js(\?.*)?$/.test(el.src)) return el;
        for (var i = 0, l = el.childNodes.length, s; i < l; i++)
            if (s = _searchScript(el.childNodes[i])) return s;
    }
    
    var _titleCheck = function() {
        if (_browser.isIE() && _d.title != _title)
            SWFAddress.setTitle(_title);
    }

    var _listen = function() {
        if (!_silent) {
            var hash = _getHash();
            if (_browser.isIE()) {
                if (_value != hash) {
					//alert("_listen: \nold:"+_value+"\nnew:"+hash);
                    if (_version < 7)
                        _l.reload();
                    else
                        SWFAddress.setValue(hash);
                }
            } else if (_browser.isSafari() && _version < 523) {
                if (_length != _h.length) {
                    _length = _h.length;
                    if (typeof _stack[_length - 1] != UNDEFINED)
                        _value = _stack[_length - 1];
                    _update();
                }
            } else if (_value != hash) {
				//alert("_listen: \nold:"+_value+"\nnew:"+hash);
                _value = hash;
                _update();
            }
            _titleCheck();
        }
    }

    var _jsDispatch = function(type) {
        if (SWFAddress.hasEventListener(type))
            SWFAddress.dispatchEvent(new SWFAddressEvent(type));
        type = type.substr(0, 1).toUpperCase() + type.substr(1);
        if(typeof SWFAddress['on' + type] == FUNCTION)
            SWFAddress['on' + type]();
    }

    var _jsInit = function() {
        _jsDispatch('init');
    }

    var _jsChange = function() {
        _jsDispatch('change');
    }

    var _swfChange = function() {
		//alert("swfChange: "+SWFAddress.getValue());
        for (var i = 0, id, value = SWFAddress.getValue(), setter = 'setSWFAddressValue'; id = _ids[i]; i++) {
            var obj = document.getElementById(id);
            if (obj) {
                if (obj.parentNode && typeof obj.parentNode.so != UNDEFINED) {
                    obj.parentNode.so.call(setter, value);
                } else {
                    if (!(obj && typeof obj[setter] != UNDEFINED)) {
                        var objects = obj.getElementsByTagName('object');
                        var embeds = obj.getElementsByTagName('embed');
                        obj = ((objects[0] && typeof objects[0][setter] != UNDEFINED) ? 
                            objects : ((embeds[0] && typeof embeds[0][setter] != UNDEFINED) ? 
                                embeds[0] : null));
                    }
                    if (obj)
                        obj[setter](value);
                } 
            } else if (obj = document[id]) {
                if (typeof obj[setter] != UNDEFINED)
                    obj[setter](value);
            }
        }
    }

    var _update = function() {
//this only works with firebug
//console.debug('_update func called');
        _swfChange();
        _jsChange();
        _st(_track, 10);
    }

    var _trackDefault = function(value) {
        if (typeof urchinTracker == FUNCTION) 
            urchinTracker(value);
        if (typeof pageTracker != UNDEFINED && typeof pageTracker._trackPageview == FUNCTION)
            pageTracker._trackPageview(value);
    }
    
    eval('var _trackDefault = ' + _trackDefault + ';');
    
    var _track = function() {
        if (typeof _opts.tracker != UNDEFINED && eval('typeof ' + _opts.tracker + ' != "' + UNDEFINED + '"')) {
            var fn = eval(_opts.tracker);
            if (typeof fn == FUNCTION)
                fn((_l.pathname + (/\/$/.test(_l.pathname) ? '' : '/') + SWFAddress.getValue()).replace(/\/\//, '/').replace(/^\/$/, ''));
        }
    }
    
    var _htmlWrite = function() {
        var doc = _iframe.contentWindow.document;
        doc.open();
        doc.write('<script>var ' + SWFADDRESS + ' = "' + _getHash() + '";</script>');
        doc.close();
    }

    var _htmlLoad = function() {
        var win = _iframe.contentWindow;
        if (_opts.html) {
            var src = win.location.href;
            _value = (src.indexOf('?') > -1) ? src.substr(src.indexOf('?') + 1) : '';
        } else {
            _value = (typeof win[SWFADDRESS] != UNDEFINED) ? win[SWFADDRESS] : '';
        }
        win.document.title = _d.title;
        if (_value != _getHash()) {
            _update();
            _l.hash = _ieLocal(_value);
        }
    }

    var _load = function() {
//only works with firebug
//console.debug('_load func called');
        var attr = 'id="' + SWFADDRESS + '" style="position:absolute;top:-9999px;"';
        if (_browser.isIE()) {
            document.body.appendChild(document.createElement('div')).innerHTML = '<iframe ' + attr + ' src="' + 
                (_opts.html ? _url.replace(/\.js(\?.*)?$/, '.html') + '?' + _getHash() : 'javascript:false;') + 
                '" width="0" height="0"></iframe>';
            _iframe = document.getElementById(SWFADDRESS);
            _st(function() {
                _events.addListener(_iframe, 'load', _htmlLoad);            
                if (!_opts.html && typeof _iframe.contentWindow[SWFADDRESS] == UNDEFINED) 
                    _htmlWrite();
            }, 10);
        } else if (_browser.isSafari()) {
            if (_version < 412) {
                document.body.innerHTML += '<form ' + attr + ' method="get"></form>';
                _form = document.getElementById(SWFADDRESS);
            }
            if (typeof _l[SWFADDRESS] == UNDEFINED) _l[SWFADDRESS] = {};
            if (typeof _l[SWFADDRESS][_l.pathname] != UNDEFINED) _stack = _l[SWFADDRESS][_l.pathname].split(',');
        } else if (_browser.isOpera() && _ids.length == 0 && typeof navigator.plugins['Shockwave Flash'] == 'object') {
            document.body.innerHTML += '<embed ' + attr + ' src="' + _url.replace(/\.js(\?.*)?$/, '.swf') + 
                '" type="application/x-shockwave-flash" />';
        }
        _st(_jsInit, 1);
        _st(_jsChange, 2);
        _st(_track, 10);
        setInterval(_listen, 1000);
    }

    /**
     * Init event.
     * @type Function
     * @event
     * @static
     */
    this.onInit = null;
    
    /**
     * Change event.
     * @type Function
     * @event
     * @static
     */
    this.onChange = null;
    
    /**
     * String representation of this class.
     * @ignore
     */
    this.toString = function() {
        return '[class SWFAddress]';
    }

    /**
     * Loads the previous URL in the history list.
     * @return {void}
     * @static
     */
    this.back = function() {
        _h.back();
    }

    /**
     * Loads the next URL in the history list.
     * @return {void}
     * @static
     */
    this.forward = function() {
        _h.forward();
    }

    /**
     * Loads a URL from the history list.
     * @param {Number} delta An integer representing a relative position in the history list.
     * @return {void}
     * @static
     */
    this.go = function(delta) {
        _h.go(delta);
    }

    /**
     * Opens a new URL in the browser. 
     * @param {String} url The resource to be opened.
     * @param {String} target Target window.
     * @return {void}
     * @static
     */
    this.href = function(url, target) {
        target = (typeof target != UNDEFINED) ? target : '_self';     
        if (target == '_self')
            self.location.href = url; 
        if (target == '_top')
            _l.href = url; 
        if (target == '_blank')
            window.open(url); 
        else
            _t.frames[target].location.href = url; 
    }

    /**
     * Opens a browser popup window. 
     * @param {String} url Resource location.
     * @param {String} name Name of the popup window.
     * @param {String} options Options which get evaluted and passed to the window.open() method.
     * @param {String} handler Optional JavaScript code for popup handling.    
     * @return {void}
     * @static
     */
    this.popup = function(url, name, options, handler) {
        var popup = window.open(url, name, eval(options));
        eval(handler);
    }

    /**
     * Registers an event listener.
     * @param {String} type Event type.
     * @param {Function} listener Event listener.
     * @return {void}
     * @static
     */
    this.addEventListener = function(type, listener) {
        if (typeof _listeners[type] == UNDEFINED)
            _listeners[type] = [];
        _listeners[type].push(listener);
    }

    /**
     * Removes an event listener.
     * @param {String} type Event type.
     * @param {Function} listener Event listener.
     * @return {void}
     * @static     
     */
    this.removeEventListener = function(type, listener) {
        if (typeof _listeners[type] != UNDEFINED) {
            for (var i = 0, l; l = _listeners[type][i]; i++)
                if (l == listener) break;
            _listeners[type].splice(i, 1);
        }
    }

    /**
     * Dispatches an event to all the registered listeners. 
     * @param {Object} event Event object.
     * @return {Boolean}
     * @static
     */
    this.dispatchEvent = function(event) {
        if (typeof _listeners[event.type] != UNDEFINED && _listeners[event.type].length) {
            event.target = this;
            for (var i = 0, l; l = _listeners[event.type][i]; i++)
                l(event);
            return true;           
        }
        return false;
    }

    /**
     * Checks the existance of any listeners registered for a specific type of event. 
     * @param {String} event Event type.
     * @return {Boolean}
     * @static
     */
    this.hasEventListener = function(type) {
        return (typeof _listeners[type] != UNDEFINED && _listeners[type].length > 0);
    }
    
    /**
     * Provides the base address of the document. 
     * @return {String}
     * @static
     */
    this.getBaseURL = function() {
        var url = _l.href;
        if (url.indexOf('#') != -1)
            url = url.substr(0, url.indexOf('#'));
        if (url.substr(url.length - 1) == '/')
            url = url.substr(0, url.length - 1);
        return url;
    }

    /**
     * Provides the state of the strict mode setting. 
     * @return {Boolean}
     * @static
     */
    this.getStrict = function() {
        return _opts.strict;
    }

    /**
     * Enables or disables the strict mode.
     * @param {Boolean} strict Strict mode state.
     * @return {void}
     * @static
     */
    this.setStrict = function(strict) {
        _opts.strict = strict;
    }

    /**
     * Provides the state of the history setting. 
     * @return {Boolean}
     * @static
     */
    this.getHistory = function() {
        return _opts.history;
    }

    /**
     * Enables or disables the creation of history entries.
     * @param {Boolean} history History state.
     * @return {void}
     * @static
     */
    this.setHistory = function(history) {
        _opts.history = history;
    }

    /**
     * Provides the tracker function.
     * @return {String}
     * @static
     */
    this.getTracker = function() {
        return _opts.tracker;
    }

    /**
     * Sets a function for page view tracking. The default value is 'urchinTracker'.
     * @param {String} tracker Tracker function.
     * @return {void}
     * @static
     */
    this.setTracker = function(tracker) {
        _opts.tracker = tracker;
    }

    /**
     * Provides a list of all the Flash objects registered. 
     * @return {Array}
     * @static
     */
    this.getIds = function() {
        return _ids;
    }

    /**
     * Provides the id the first and probably the only Flash object registered. 
     * @return {String}
     * @static
     */
    this.getId = function(index) {
        return _ids[0];
    }

    /**
     * Sets the id of a single Flash object which will be registered for deep linking.
     * @param {String} id ID of the object.
     * @return {void}
     * @static
     */
    this.setId = function(id) {
        _ids[0] = id;
    }

    /**
     * Adds an id to the list of Flash object registered for deep linking.
     * @param {String} id ID of the object.
     * @return {void}
     * @static
     */
    this.addId = function(id) {
        this.removeId(id);
        _ids.push(id);
    }

    /**
     * Removes an id from the list of Flash object registered for deep linking.
     * @param {String} id ID of the object.
     * @return {void}
     * @static
     */
    this.removeId = function(id) {
        for (var i = 0; i < _ids.length; i++) {
            if (id == _ids[i]) {
                _ids.splice(i, 1);
                break;
            }
        }
    }

    /**
     * Provides the title of the HTML document.
     * @return {String}
     * @static
     */
    this.getTitle = function() {
        return _d.title;
    }

    /**
     * Sets the title of the HTML document.
     * @param {String} title Title value.
     * @return {void}
     * @static
     */
    this.setTitle = function(title) {
        if (!_supported) return null;
        if (typeof title == UNDEFINED) return;
        if (title == 'null') title = '';
        _title = _d.title = title;
        _st(function() {
            if (_iframe && _iframe.contentWindow && _iframe.contentWindow.document && _iframe.contentWindow.title)
                _iframe.contentWindow.document.title = _title;
         }, 1000);
    }

    /**
     * Provides the status of the browser window.
     * @return {String}
     * @static
     */
    this.getStatus = function() {
        return _t.status;
    }

    /**
     * Sets the status of the browser window.
     * @param {String} status Status value.
     * @return {void}
     * @static
     */
    this.setStatus = function(status) {
        if (!_supported) return null;
        if (typeof status == UNDEFINED) return;
        if (!_browser.isSafari()) {
            status = _strictCheck((status != 'null') ? status : '', true);
            if (status == '/') status = '';
            if (!(/http(s)?:\/\//.test(status))) {
                var index = _l.href.indexOf('#');
                status = (index == -1 ? _l.href : _l.href.substr(0, index)) + '#' + status;
            }
            _t.status = status;
        }
    }

    /**
     * Resets the status of the browser window.
     * @return {void}
     * @static
     */
    this.resetStatus = function() {
        _t.status = '';
    }

    /**
     * Provides the current deep linking value.
     * @return {String}
     * @static
     */
    this.getValue = function() {
        if (!_supported) return null;
        return _strictCheck(_value, false);
    }

    /**
     * Sets the current deep linking value.
     * @param {String} value A value which will be appended to the base link of the HTML document.
     * @return {void}
     * @static
     */
    this.setValue = function(value) {
        if (!_supported) return null;
        if (typeof value == UNDEFINED) return;
		//vyew add:
		if(value.match(/\/undefined\//)){
			try{
				dbg("CAUGHT UNDEFINED ERROR:"+value);
			}catch(e){}
			return;
		}
        if (value == 'null') value = ''
        value = _strictCheck(value, true);
        if (value == '/') value = '';
        if (_value == value) return;
		//alert("setValue: "+value);
        _value = value;
        _silent = true;
        _update();
        _stack[_h.length] = _value;
        if (_browser.isSafari()) {
            if (_opts.history) {
                _l[SWFADDRESS][_l.pathname] = _stack.toString();
                _length = _h.length + 1;
                if (_version < 412) {
                    if (_l.search == '') {
                        _form.action = '#' + _value;
                        _form.submit();
                    }
                } else if (_version < 523){
                    var evt = document.createEvent('MouseEvents');
                    evt.initEvent('click', true, true);
                    var anchor = document.createElement('a');
                    anchor.href = '#' + _value;
                    anchor.dispatchEvent(evt);                
                } else {
                    _l.hash = '#' + _value;
                }
            } else {
                _l.replace('#' + _value);
            }
        } else if (_value != _getHash()) {
            if (_opts.history)
                _l.hash = '#' + _ieLocal(_value);
            else
                _l.replace('#' + _value);
        }
        if (_browser.isIE() && _opts.history) {
            if (_opts.html) {
                var loc = _iframe.contentWindow.location;
                loc.assign(loc.pathname + '?' + _getHash());
            } else {
                _htmlWrite();
            }
        }
        if (_browser.isSafari())
            _st(function(){ _silent = false; }, 1);
        else
            _silent = false;
    }

    /**
     * Provides the deep linking value without the query string.
     * @return {String}
     * @static
     */
    this.getPath = function() {
        var value = this.getValue();
        return (value.indexOf('?') != -1) ? value.split('?')[0] : value;
    }

    /**
     * Provides a list of all the folders in the deep linking path.
     * @return {Array}
     * @static
     */
    this.getPathNames = function() {
        var path = SWFAddress.getPath();
        var names = path.split('/');
        if (path.substr(0, 1) == '/')
            names.splice(0, 1);
        if (path.substr(path.length - 1, 1) == '/')
            names.splice(names.length - 1, 1);
        return names;
    }

    /**
     * Provides the query string part of the deep linking value.
     * @return {String}
     * @static
     */
    this.getQueryString = function() {
        var value = this.getValue();
        var index = value.indexOf('?');
        return (index != -1 && index < value.length) ? value.substr(index + 1) : '';
    }

    /**
     * Provides the value of a specific query parameter.
     * @param {String} param Parameter name.
     * @return {String}
     * @static
     */
    this.getParameter = function(param) {
        var value = this.getValue();
        var index = value.indexOf('?');
        if (index != -1) {
            value = value.substr(index + 1);
            var params = value.split('&');
            var p, i = params.length;
            while(i--) {
                p = params[i].split('=');
                if (p[0] == param)
                    return p[1];
            }
        }
        return '';
    }

    /**
     * Provides a list of all the query parameter names.
     * @return {Array}
     * @static
     */
    this.getParameterNames = function() {
        var value = this.getValue();
        var index = value.indexOf('?');
        var names = [];
        if (index != -1) {
            value = value.substr(index + 1);
            if (value != '' && value.indexOf('=') != -1) {
                var params = value.split('&');
                var i = 0;
                while(i < params.length) {
                    names.push(params[i].split('=')[0]);
                    i++;
                }
            }
        }
        return names;
    }

    if (_supported) {
    
        for (var i = 1; i < _length; i++)
            _stack.push('');
            
        _stack.push(_getHash());
    
        if (_browser.isIE() && _l.hash != _getHash())
            _l.hash = '#' + _ieLocal(_getHash());
    
        try {
            _url = String(_searchScript(document).src);
            var qi = _url.indexOf('?');
            if (_url && qi > -1) {
                var param, params = _url.substr(qi + 1).split('&');
                for (var i = 0, p; p = params[i]; i++) {
                    param = p.split('=');
                    if (/^(history|html|strict)$/.test(param[0]))
                        _opts[param[0]] = (isNaN(param[1]) ? eval(param[1]) : (parseFloat(param[1]) > 0));
                    if (/^tracker$/.test(param[0]))
                        _opts[param[0]] = param[1];
                }
            }
        } catch(e) {}
        if (/file:\/\//.test(_l.href)) _opts.html = false;
    
        _titleCheck();
        _events.addListener(document, 'DOMContentLoaded', _load);
    
    } else {
        _track();
    }
}

/**
 * SWFAddress embed hooks.
 * @ignore
 */
new function() {

    var _func, _args;
    var UNDEFINED = 'undefined';

    if (typeof swfobject != UNDEFINED) SWFObject = swfobject;
    if (typeof FlashObject != UNDEFINED) SWFObject = FlashObject;
    
    if (typeof SWFObject != UNDEFINED) {
        if (SWFObject.prototype && SWFObject.prototype.write) {
            _func = SWFObject.prototype.write;
            SWFObject.prototype.write = function() {
                _args = arguments;
                if (this.getAttribute('version').major < 8) {
                    this.addVariable('$swfaddress', SWFAddress.getValue());
                    ((typeof _args[0] == 'string') ? 
                        document.getElementById(_args[0]) : _args[0]).so = this;
                }
                var success;
                if (success = _func.apply(this, _args))
                    SWFAddress.addId(this.getAttribute('id'));
                return success;
            }
        } else {
            _func = SWFObject.registerObject;
            SWFObject.registerObject = function() {
                _args = arguments;
                _func.apply(this, _args);
                SWFAddress.addId(_args[0]);            
            }
            _func = SWFObject.createSWF;
            SWFObject.createSWF = function() {
                _args = arguments;
                _func.apply(this, _args);
                SWFAddress.addId(_args[0].id);            
            }
            _func = SWFObject.embedSWF;
            SWFObject.embedSWF = function() {
                _args = arguments;
                _func.apply(this, _args);
                SWFAddress.addId(_args[8].id);            
            }
        }
    }
    
    if (typeof UFO != UNDEFINED) {
        _func = UFO.create;
        UFO.create = function() {
            _args = arguments;
            _func.apply(this, _args);
            SWFAddress.addId(_args[0].id);        
        }
    }
    
    if (typeof AC_FL_RunContent != UNDEFINED) {
        _func = AC_FL_RunContent;
        AC_FL_RunContent = function() {
            _args = arguments;        
            _func.apply(this, _args);
            for (var i = 0, l = _args.length; i < l; i++)
                if (_args[i]== 'id') SWFAddress.addId(_args[i+1]);
        }
    }
}




/******************************************************************************************
         vyew.phpobject.js
 ******************************************************************************************/

/**
 * vyew.php class
 * PhpObject ported to javascript for calling json gateway
 * Copyright (c)2008 Vyew, Simulat, Inc.
 *
 * @author timh@vyew dot com (May 2008)
 * @requires jquery.js
 *
 * EXAMPLE USAGE:
 * --------------
 *	vyew.php.call("class.function", argsArray[], callbackFunc)
 *	vyew.php.call("VyewMain.login", ["user@address.com", "password"], function(result){
 *		if(result==true) //ok
 *		else //show error message
 *	});
 *
 *
 * How to make multiple func calls in one call:
 * You will have to setup a function on the server
 * to accept an options object with a "callFuncs" variable.
 * See 
 *
 */


//--- Setup namespace and init vars
if(typeof vyew=="undefined") vyew=new Object();
if(typeof vyew.php=="undefined") vyew.php=new Object();
vyew.php.gatewayUrl="";
vyew.php.DEBUG=false;
vyew.php._data="";


/**
 * Store url to json.php gateway
 * @param url
 */
vyew.php.setGateway=function(url)
{
	if(url && url.length>2)
		this.gatewayUrl=url;
}

/**
 * Tries to guess what the default gateway might be
 * First checks for top.vers variable, then parses url
 * NOTE: This function is called immediately
 */
vyew.php.init=function()
{
	try{
		var default_vers=top.vers;
	}catch(e){}
	try{ var auto_vers=document.location.href.match(/\/(v[0-9]+\.[0-9]+[^/]*)\//)[1];
	}catch(e){}
	var baseurl="/amfphp/json.php";
	if(typeof(default_vers) != "undefined"  && default_vers.match(/^v[0-9][0-9]?\.[0-9]/)){
		this.setGateway( "/" + default_vers + baseurl );
	}else if (typeof(auto_vers) != "undefined"  && auto_vers.match(/^v[0-9][0-9]?\.[0-9]/)){
 		this.setGateway( "/" + auto_vers + baseurl );
	}else{
		this.setGateway( "/latest" + baseurl ); 
		dbg("WARNING:334 - couldnt autodetect vyew version1");
	}
}
vyew.php.init();

/**
 * Call server side function
 * New: Surround the function name with "@@class.function@@" to be auto-encrypted 
 *		by the js combine.php function
 * Examples: 	call( "VyewLaunchpage.login", ["username","password"], onLogin);
 *				call( "@@VyewUtils.isValidEmail@@", ["email@address"], function(result){ ... } );
 * @param serviceName {string} - className + function: eg. "MyClass.myfunction" or "VyewMain.getUserData"
 * @param args {array} - array of arguments to pass, can be string,number,array or object
 *						 NOTE: all arguments are passed via GET, except the last one,
 *							   so if you have a large object, pack it in with the last arg
 * @param callback {function} - called with one arguement: a results object
 * @param scope {object} - object to apply callback to
 */
vyew.php.call=function( serviceName, args, callback, scope )
{
	scope = (scope)?scope:this

	//---remove @ from serviceName if needed
    if(serviceName.match(/@/)) serviceName=serviceName.replace(/@/g,'');

	//---convert args to json if needed
	for(var i=0; i<args.length; i++){
		if(typeof(args[i])!="string" && typeof(args[i])!="number"){
			args[i]=JSON.encode(args[i]);
		}
	}
	var postArg=args.pop();
	if(postArg) postArg={json:postArg};
	else postArg={};

	var argsStr=(args.length>0) ? "/"+args.join("/") : '';
	var sendURL=this.gatewayUrl+"/"+serviceName+argsStr+"?code="+getCookie('sid');
	if (sendURL.length>2000){ throw 'Warning 844: ajax/phpobject arg length exceeded, put large objects last in arg list' }

	$.post(sendURL, postArg, function(res)
	{
		if(typeof res != "undefined"){
			if(typeof callback=="function"){
				callback.apply(scope,[res]);
			}
		}else{
			throw 'Error 3994: Response not valid from '+funcname;
		}
	},"json");
}


if(typeof tr=="undefined")
{
	tr=function(x)
	{	
		try{
		if(console!="undefined"){
			if(console.debug!="undefined"){
				console.debug(x);
			}
		}
		}catch(e){}
	}
}





/******************************************************************************************
         vyewLib.js
 ******************************************************************************************/

/**
 * vyewLib.js 
 * Vyew Javascript Library 
 * Copyright (c)2007-2008 Vyew, Simulat, Inc.
 *
 * @author timh@vyew dot com
 *
 * DEPENDANCIES:
 * -------------
 * 		jquery.js
 *		vyew.phpobject.js
 *
 * INCLUDES:
 * ---------
 *		- cookie lib functions
 * 		- login checks
 *
 * CHANGES:
 *		8/29/08 - changed to depend on vyew.phpobject.js for calling json gateway instead of siteajax.php
 *
 * TODO:
 *		- handle multiple ajax calls ?? is this still relevant?
 */


//--- Setup package
if(typeof vyew=="undefined") vyew=new Object();
if(!vyew.ud) vyew.ud=new Object();
if(!vyew.od) vyew.od=new Object();
vyew.whoami="vyew object";

//make sure vyew.phpobject is loaded
if(!vyew.php || vyew.php == undefined){
	try{ var auto_vers=document.location.href.match(/(\/v[0-9]+\.[0-9]+[^/]*)\//)[1];
    }catch(e){}
	if(empty(auto_vers)) dbg("No detection: vyewLib-auto_vers");
	try{ $.getScript(auto_vers+"/js/vyew.phpobject.js"); }catch(e){}
}


/**
 * Checks users logged in status by examining session/loginID cookies
 * then retreives missing user data. Follows this logic:
 * 		if- sid cookie exists, and vyew.ud.em exists, then assume its good
 *		elseif- sid or lid exists, 
 *
 *
 * @param callback - a function to be called back with results object
 * @param scope - an optional scope object for which the callback is applied to (callback.apply(scope,args))
 * @param options - options Object: {translateMid:'string'} will translate a customID to its numeric MID
 *					and return it in result Object as :{translatedMid:NNNN}, else {translatedMid:false}
 * @return void
 */
vyew.checkLogin=function(callback,scope,options)
{
	//TODO: there is a bug here commented out.
 	// login, check tree, logout inside vyew, login as someone else, and the tree is someone elses
	// TOFIX: try tracing out all cookies and vyew.ud/vyew.od data and compare them...
	scope=(!scope) ? this : scope;
	//c_ud=getCookie('ud');
	//try{ vyew.ud=eval(c_ud); }
	//catch(e) { vyew.ud={} }
	//if(getCookie('sid') && vyew.ud && vyew.ud.em && vyew.ud.em.length > 3){
	//	dbg("check login 1");
	//	if(callback) callback.apply(scope,[vyew.ud]);
	//}else 
	if(typeof(callback)!="function") callback=new Function();
	//alert('sid:'+getCookie('sid')+"  lid:"+getCookie('lID'));
	if(getCookie('sid') || getCookie('lID')){
		vyew.getUserInfo(callback,scope,options);
	}else{ 
		if(callback) callback.apply(scope,[false]);
	}
}

	

/**
 * Gets user data based on sid or lid
 * calls callback with result object
 * @param callback - function
 * @param scope - object to apply callback to
 * @param options - options Object: {translateMid:'string'} will translate a customID to its numeric MID
 *                  and return it in result Object as :{translatedMid:NNNN}, else {translatedMid:false}
 */
vyew.getUserInfo=function(callback,scope,options)
{
	if(!vyew.php) return;
	if(typeof(callback)!="function") callback=new Function();
    var lID=getCookie('lID');
	var sid=getCookie('sid');
	//todod.... 
	//if sid, check if good, return em
	//else if lid, check, return em and sid
	if(lID){
        var ref=fs_getCookie('ref');
        var adRef=fs_getCookie('adRef');
        if(!ref)ref="none";
        if(!adRef)adRef="none";
		vyew.php.call("Login.checkLID", [lID, ref, adRef, options], 
			function(res)
			{
				if(res && res.em && res.em.length>2){
                    setCookie('em',vyew.ud.em, cookieexp);
                    setCookie('ud', res, 'session');
                    vyew.ud=res;
                    var cookieexp=(getCookie('keepLoggedIn')=="1")?'never':'session'
                    if( !(getCookie('sid').length>5) ) setCookie('sid',vyew.ud.sid,'session');
                    callback.apply(scope, [res]);
				}else{
					vyew.clearCookies();
					callback.apply(scope, [false]);
				}
			},this)

	}else if(sid){
		vyew.php.call("Login.checkSID", [options], 
            function(res)
			{
				if(res && res.em && res.em.length>2){
					setCookie('em',res.em,'session');
					setCookie('ud', res, 'session');
					vyew.ud=res;
					if(callback) callback.apply(scope, [res]);
				}else{
					callback.apply(scope, [false]);
				}
			});
    }else{
		callback.apply(this,[false]);
    }
}
vyew.getUserEmail=vyew.getUserInfo;



/**
 * Validates an email address
 * @param em - the email address
 * @return boolean
 */
vyew.isEmailAddress=function(em)
{
    if (typeof em == "undefined") return false;
    if (typeof em == "object") em = em[0];
    em=''+em;
	if(em.match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9_.-]+\.[a-zA-Z0-9]+$/)) return true;
    else return false;
}


/**
 * Simple JSON Decoder - decodes with eval(), but includes try/catch for error handling
 * If the eval fails or Json is invalid, returns an empty obj:{}
 * @param str - Json String must start and end with ( and ).
 * @return {object}
 */
vyew.jsonDecode=function(str)
{
    if(!str || typeof(str)!="string" || str.length<3) return {x:99};
    str=str.match(/^.*[}\)]/)[0]
    var obj={};
    try{ obj=eval(str); }
    catch(e){throw 'Error in JSON decode of:'+str}
    return obj; 
}

/**
 * Adds variables from sourceObj to targObj (not sure if cloned or not? todo: check it)
 * @param targObj 
 * @param sourceObj
 */
vyew.updateObj=function(targObj, sourceObj)
{
	if(typeof targObj != "object" || typeof sourceObj != "object") return;
	for(var v in sourceObj){
		targObj[v]=sourceObj[v];
	}
}

/**
 * Clears all relevant Vyew login cookies
 */
vyew.clearCookies=function()
{
    clearCookie('em'); clearCookie('lID'); clearCookie('sid'); clearCookie("keepLoggedIn"); 
	clearCookie('userdata');
	clearCookie('ud');
    clearCookie('exp_uniqueid'); clearCookie('exp_userhash');
}
vyew.logout=vyew.clearCookies;






/**
 * ------------------------------------------------------------------
 * 	MISCELLANEOUS 
 * ------------------------------------------------------------------
 */

function empty(v){
  if(typeof v == "undefined" || v==null || v==undefined) return true;
  else return false;
}
function isDefined(obj){
	return !empty(obj);
}

function getFirebugConsole()
{
	try{
	//if top frame, use that console
	if(top!=window) var win=top;
	else win=this.window;
	if(typeof win.console == "undefined"){ 
		if(!win.loadFirebugConsole) return false;
		else win.loadFirebugConsole();
	}
	if(typeof win.console != "undefined" && win.console.debug) return win.console;
	return false;
	}catch(e){ return false; }
}

function dbg()
{
	var console=getFirebugConsole();
	if (!console) return;
   	var out="";
   	for(var i=0;i<arguments.length;i++){ out+=arguments[i]+", "; }
   	out=out.substr(0,out.length-2);
 	console.debug(out);
}

function dbd(x,txt)
{
	var console=getFirebugConsole();
	if(!console) return;
	if(txt) console.debug('---------------- '+txt);
	else console.debug('----------------');
    console.dir(x);
}

//alert
function ale()
{
	var out="";
	for(var i=0;i<arguments.length;i++){ out+=arguments[i]+", "; }
	out=out.substr(0,out.length-2);
	alert(out);
}

function isNumeric(n){
	return !isNaN(n);
}

/**
 * Searches through an object array for specified key/value within an object. 
 * Usage: a=[{id:1,name'bob'},{id:2,name:'joe'}]; 
 *        a.findObj('name','joe') //returns object:{id:2,name:'joe'}
 *        a.findObj('name','joe',true) //returns 1
 * @param key - String: the text of the variable name to search through
 * @param value - the value you are searching for
 * @param returnIndex - Bool: if true, return index, else return the object itself
 * @return: The found object, or its index
 */
Array.prototype.findObj = function(key, value, returnIndex ){
  for(var i in this){
     if (this[i][key] == value){ 
		if(returnIndex==true) return i
		else return this[i]
	 }
  }
  return false;
}


/**
 * getVersDir - tries to auto detect the version of the app based on dir name
 */
vyew.getVers = function()
{
 	try{
        var default_vers=top.vers;
		if(default_vers.match(/^v[0-9][0-9]?\.[0-9]/)) return default_vers;
    }catch(e){}
	try{
		var auto_vers=document.location.href.match(/\/(v[0-9]+\.[0-9]+[^/]*)\//)[1];
		if(auto_vers.match(/^v[0-9][0-9]?\.[0-9]/)) return auto_vers;
	}catch(e){}
	return "latest";
}

/**
 * Given a url: http://domain.com/content/product/uses?a=1&b=2#hello
 * Examples:
 * 		urlSegment(0) = "content"
 *   	urlSegment(1) = "product"
 *   	urlSegment("#") = "hello"
 * 	 	urlSegment("?") = "a=1&b=2#hello"
 *   	urlSegment("?a") = "1"
 *   	urlSegment("?b") = "2"
 *		urlSegment("domain") = "domain.com"
 *		urlSegment("base") = "http://domain.com/content/product/uses"
 *		urlSegment("baserel") = /content/product/uses"
 *
 * TO SET THE URL HASH:
 *		top.location.hash = "abc"
 */
function urlSegment(num, win)
{
	if(!win) win=this;
	try{
    var loc=win.location.href.match(/\/\/(.*)/)[1];
	}catch(e){ return ""; }
    if (!loc) return "";
    if(!isNaN(num)){
		segs=loc.split("/");
        return segs[num+1];
    }else if(num=="#"){
        pl=loc.indexOf("#");
        if(pl==-1)return "";
        else {
            loc=loc.substr(pl+1);
            pl=loc.indexOf("?");
            if(pl==-1) return loc;
            else return loc.substr(0,loc.indexOf("?"));
        }
    }else if(num=="?"){
        pl=loc.indexOf("?");
        if(pl==-1)return "";
        else return loc.substr(pl+1);
    //check if "?variable"
    }else if(num.substr(0,1)=="?"){
        var getv=num.substr(1);
        if(loc.indexOf(getv)==-1) return '';
        pl=loc.indexOf("?");
        if(pl==-1) return "";
        var q=''+loc.substr(pl+1);
        if(q.indexOf(getv)==-1 || typeof q != "string") return '';
        var regx=new RegExp(getv+"=([^&#]*)");
        var res=q.match(regx)[1];
        return res;
    }else if(num=="domain"){
		return loc.match(/(.*?)\//)[1]
	}else if(num=="base"){
		var loc=win.location.href;
		pl=loc.indexOf("?");
		if(pl>=0) loc=loc.substr(0,pl);
		pl=loc.indexOf("#");
		if(pl>=0) loc=loc.substr(0,pl);
		return loc;
	}else if(num=="baserel"){
        var loc=win.location.href.match(/^.*?\/\/.*?(\/.*)/)[1];
        pl=loc.indexOf("?");
        if(pl>=0) loc=loc.substr(0,pl);
        pl=loc.indexOf("#");
        if(pl>=0) loc=loc.substr(0,pl);
        return loc;
    }

    return "";
}


/**
 * Returns specified segment after the hash (#) in url
 * A segment is text between "/" slashes
 * If no segNum passed, return whole hash string
 * Examples with url : domain.com/room#/abc/def/ghi
 *      hashUrlSegment(0) : "abc"  (leading slashes are removed)
 *      hashUrlSegment(1) : "def"
 *      hashUrlSegment()  : "/abc/def/ghi"
 * Note: To set the hash use: document.hash=""
 * @param segNum - segment number
 * @return mixed - the segment specified or false
 */
function hashUrlSegment(segNum,win)
{
    if(!win)win=this;
    var loc=win.location.href;
    pl=loc.indexOf("#");
    if(pl==-1) return false;
    if(!pl) return false;
    loc=loc.substr(pl+1)
	//todo: add browser switch thing..
    //loc=unescape(loc);            //if ie
    //loc=decodeURIComponent(loc);  //if ff
    if(segNum==null) return loc;
    segs=loc.split("/");
    if(!segs[0]) segs.shift()
    return segs[segNum];
}


/**
 * ---------------------------------------------------------------------------
 * COOKIE LIBRARY: (also provides support for flash cookie setter/getter)
 *		getCookie(cookieName, isJson)
 *		setCookie(cookieName, value)
 *
 * FLASH INSTRUCTIONS:
 *       1. copy cookieLib.js (or vyewLib) to the same place as your .html file which references your .swf
 *       2. put this lines in your .html file :
 *       ---------------------------------------------------------------------------
 *           <script src="cookieLib.js" type="text/javascript"></script>
 *       ---------------------------------------------------------------------------
 * SET A COOKIE FROM FLASH:
 *            import flash.external.*;
 *            ExternalInterface.call("fs_setCookie", "cookieName", "cookieValue", "EXPIRATION");
 *
 *            (expiration can be: "never", or "session" or a "number" representing minutes)
 *            (default expiration is "never")
 *            (session expires when the browser is closed)
 *           (minutes= "60" for 1 hour, "1440" for 1 day, etc...)
 *
 * RETRIEVE A COOKIE FROM FLASH:
 *           import flash.external.*;
 *          var cookievalue = ExternalInterface.call("fs_getCookie", "cookieName");
 *
 * ------------------------------------------------------------------
 */

function fs_getAllCookies(){
	return document.cookie;		
}

/**
 * Retrieves a cookie, converts to json if passed
 * @param a {string} - cookie name
 * @param isJson {bool} - if true, object will be converted from JSON string to object
 * @return {mixed} - cookie data, or false if cookie not found
 */
function getCookie(a,isJson){
	var e, m=" "+document.cookie+";"
	var N=" "+a+"=",s=m.indexOf(N),r="";
	if(s!=-1){
		s+=N.length;
		e=m.indexOf(";",s);
		r=unescape(m.substring(s,e))
	}
	if(typeof(r)=="undefined" || r=="") return false;
	if(r.match(/ckjson.:1/) || r.match(/ckjson:1/) || isJson==true){ 
		try {
			r=r.match(/^[ (]*(.*?)[) ]*$/)[1];		//trip and strip outer parenthesis
			r=JSON.decode(r);
			delete r.ckjson;
		}catch(e){ dbg('Err394x:Converting JSON') }
	}
	if(r=="false") r=false;
	return r
}

function clearCookie(n){
    var e=new Date();
	e.setTime(e.getTime()-20000000);
	document.cookie=n+"=0; path=/; expires="+e.toGMTString() + "; domain="+fs_getHostname();
	document.cookie=n+"=0; path=/; expires="+e.toGMTString();
}

/**
 * Set a cookie (alias fore setCookie())
 * NEW: if value is a complex object/array, it will be json'd and unjson'd automatically on getCookie()
 * @param varName - cookie name
 * @param varVal - value to be set
 * @param exp - expiration in minutes, or set to "session", or "never"
 * @param allSubDomains - boolean: set true if you want to set to ".domain.com"
 *						which will make cookie available to all subdomains
 */
function setCookie(varName,varVal,exp,allSubDomains){
    varVal=(varVal==null)?'0':varVal
	if(typeof(varVal)!="string" && typeof(varVal)!="number"){
		varVal.ckjson=1;
		varVal=JSON.encode(varVal);
	}
	//escape semicolons
	try{ varVal=varVal.replace(/;/g,"%3B"); }catch(e){}
	var e=new Date();
	if(typeof(exp)=="undefined" || exp=="null" || exp==null || exp=="" || exp=="session"){
		exp=";";
    }else if (exp=="never"||exp=="forever")
	{
		e.setFullYear(e.getFullYear() + 10);
		exp="; expires=" + e.toGMTString();
    }else{
        e.setTime(e.getTime()+(60000*exp))
		exp="; expires=" + e.toGMTString();
    }
    var ck = varName+"=" + escape(varVal) + "; path=/;" + exp;
	if(allSubDomains==true) ck += " domain="+fs_getHostname()+";";
    document.cookie = ck;
	return "1";
}

/**
 * Returns the hostname of current url:
 * ie. if url is www.domain.com/abc/dev, returns: domain.com
 */
function getHostname()
{
    var h=document.location.host;
    var p=h.lastIndexOf('.');
    p=h.lastIndexOf('.',p-1);
    if (p>-1) h=h.substr(p+1);
    return h;         
}
var fs_clearCookie=clearCookie;
var fs_getHostname=getHostname;
var fs_setCookie=setCookie;
var fs_getCookie=getCookie;



/**
 * Tecords all vyew cookies, clears them, then re-sets them
 * this is to clear out the global subdomain cookies (.domain.com)
 */
function resetVyewCookies(){
	var sid=getCookie("sid");
	var lID=getCookie("lID");
	var kli=getCookie("keepLoggedIn");
	clearCookie("sid"); clearCookie("lID"); clearCookie("keepLoggedIn");
	setCookie("sid",sid);
	if(lID && kli) setCookie("lID", lID, "forever");
	if(kli) setCookie("keepLoggedIn", kli, "forever");
}






/**
 * JSON Library
 * JSON.decode( {string} )   @returns javascript object
 * JSON.encode( {object} )   @return {string} javascript encoded object into string
 */
JSON=new function(){this.decode=function(){var filter,result,self,tmp;if($$("toString")){switch(arguments.length){case 2:self=arguments[0];filter=arguments[1];break;case 1:if($[typeof arguments[0]](arguments[0])===Function){self=this;filter=arguments[0];}
else
self=arguments[0];break;default:self=this;break;};if(rc.test(self)){try{result=e("(".concat(self,")"));if(filter&&result!==null&&(tmp=$[typeof result](result))&&(tmp===Array||tmp===Object)){for(self in result)
result[self]=v(self,result)?filter(self,result[self]):result[self];}}
catch(z){}}
else{throw new JSONError("bad data");}};return result;};this.encode=function(){var self=arguments.length?arguments[0]:this,result,tmp;if(self===null)
result="null";else if(self!==undefined&&(tmp=$[typeof self](self))){switch(tmp){case Array:result=[];for(var i=0,j=0,k=self.length;j<k;j++){if(self[j]!==undefined&&(tmp=JSON.encode(self[j])))
result[i++]=tmp;};result="[".concat(result.join(","),"]");break;case Boolean:result=String(self);break;case Date:result='"'.concat(self.getFullYear(),'-',d(self.getMonth()+1),'-',d(self.getDate()),'T',d(self.getHours()),':',d(self.getMinutes()),':',d(self.getSeconds()),'"');break;case Function:break;case Number:result=isFinite(self)?String(self):"null";break;case String:result='"'.concat(self.replace(rs,s).replace(ru,u),'"');break;default:var i=0,key;result=[];for(key in self){if(self[key]!==undefined&&(tmp=JSON.encode(self[key])))
result[i++]='"'.concat(key.replace(rs,s).replace(ru,u),'":',tmp);};result="{".concat(result.join(","),"}");break;}};return result;};this.toDate=function(){var self=arguments.length?arguments[0]:this,result;if(rd.test(self)){result=new Date;result.setHours(i(self,11,2));result.setMinutes(i(self,14,2));result.setSeconds(i(self,17,2));result.setMonth(i(self,5,2)-1);result.setDate(i(self,8,2));result.setFullYear(i(self,0,4));}
else if(rt.test(self))
result=new Date(self*1000);return result;};var c={"\b":"b","\t":"t","\n":"n","\f":"f","\r":"r",'"':'"',"\\":"\\","/":"/"},d=function(n){return n<10?"0".concat(n):n},e=function(c,f,e){e=eval;delete eval;if(typeof eval==="undefined")eval=e;f=eval(""+c);eval=e;return f},i=function(e,p,l){return 1*e.substr(p,l)},p=["","000","00","0",""],rc=null,rd=/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/,rs=/(\x5c|\x2F|\x22|[\x0c-\x0d]|[\x08-\x0a])/g,rt=/^([0-9]+|[0-9]+[,\.][0-9]{1,3})$/,ru=/([\x00-\x07]|\x0b|[\x0e-\x1f])/g,s=function(i,d){return"\\".concat(c[d])},u=function(i,d){var n=d.charCodeAt(0).toString(16);return"\\u".concat(p[n.length],n)},v=function(k,v){return $[typeof result](result)!==Function&&(v.hasOwnProperty?v.hasOwnProperty(k):v.constructor.prototype[k]!==v[k])},$={"boolean":function(){return Boolean},"function":function(){return Function},"number":function(){return Number},"object":function(o){return o instanceof o.constructor?o.constructor:null},"string":function(){return String},"undefined":function(){return null}},$$=function(m){function $(c,t){t=c[m];delete c[m];try{e(c)}catch(z){c[m]=t;return 1}};return $(Array)&&$(Object)};try{rc=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$')}
catch(z){rc=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/}};function JSONError(message){this.message=message||"";this.name="JSONError";};JSONError.prototype=new Error;



/******************************************************************************************
         jquery.js
 ******************************************************************************************/

/*
 * jQuery 1.2.6 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 * 
 * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
 * $Rev: 5685 $
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(H(){J w=1b.4M,3m$=1b.$;J D=1b.4M=1b.$=H(a,b){I 2B D.17.5j(a,b)};J u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/,62=/^.[^:#\\[\\.]*$/,12;D.17=D.44={5j:H(d,b){d=d||S;G(d.16){7[0]=d;7.K=1;I 7}G(1j d=="23"){J c=u.2D(d);G(c&&(c[1]||!b)){G(c[1])d=D.4h([c[1]],b);N{J a=S.61(c[3]);G(a){G(a.2v!=c[3])I D().2q(d);I D(a)}d=[]}}N I D(b).2q(d)}N G(D.1D(d))I D(S)[D.17.27?"27":"43"](d);I 7.6Y(D.2d(d))},5w:"1.2.6",8G:H(){I 7.K},K:0,3p:H(a){I a==12?D.2d(7):7[a]},2I:H(b){J a=D(b);a.5n=7;I a},6Y:H(a){7.K=0;2p.44.1p.1w(7,a);I 7},P:H(a,b){I D.P(7,a,b)},5i:H(b){J a=-1;I D.2L(b&&b.5w?b[0]:b,7)},1K:H(c,a,b){J d=c;G(c.1q==56)G(a===12)I 7[0]&&D[b||"1K"](7[0],c);N{d={};d[c]=a}I 7.P(H(i){R(c 1n d)D.1K(b?7.V:7,c,D.1i(7,d[c],b,i,c))})},1g:H(b,a){G((b==\'2h\'||b==\'1Z\')&&3d(a)<0)a=12;I 7.1K(b,a,"2a")},1r:H(b){G(1j b!="49"&&b!=U)I 7.4E().3v((7[0]&&7[0].2z||S).5F(b));J a="";D.P(b||7,H(){D.P(7.3t,H(){G(7.16!=8)a+=7.16!=1?7.76:D.17.1r([7])})});I a},5z:H(b){G(7[0])D(b,7[0].2z).5y().39(7[0]).2l(H(){J a=7;1B(a.1x)a=a.1x;I a}).3v(7);I 7},8Y:H(a){I 7.P(H(){D(7).6Q().5z(a)})},8R:H(a){I 7.P(H(){D(7).5z(a)})},3v:H(){I 7.3W(19,M,Q,H(a){G(7.16==1)7.3U(a)})},6F:H(){I 7.3W(19,M,M,H(a){G(7.16==1)7.39(a,7.1x)})},6E:H(){I 7.3W(19,Q,Q,H(a){7.1d.39(a,7)})},5q:H(){I 7.3W(19,Q,M,H(a){7.1d.39(a,7.2H)})},3l:H(){I 7.5n||D([])},2q:H(b){J c=D.2l(7,H(a){I D.2q(b,a)});I 7.2I(/[^+>] [^+>]/.11(b)||b.1h("..")>-1?D.4r(c):c)},5y:H(e){J f=7.2l(H(){G(D.14.1f&&!D.4n(7)){J a=7.6o(M),5h=S.3h("1v");5h.3U(a);I D.4h([5h.4H])[0]}N I 7.6o(M)});J d=f.2q("*").5c().P(H(){G(7[E]!=12)7[E]=U});G(e===M)7.2q("*").5c().P(H(i){G(7.16==3)I;J c=D.L(7,"3w");R(J a 1n c)R(J b 1n c[a])D.W.1e(d[i],a,c[a][b],c[a][b].L)});I f},1E:H(b){I 7.2I(D.1D(b)&&D.3C(7,H(a,i){I b.1k(a,i)})||D.3g(b,7))},4Y:H(b){G(b.1q==56)G(62.11(b))I 7.2I(D.3g(b,7,M));N b=D.3g(b,7);J a=b.K&&b[b.K-1]!==12&&!b.16;I 7.1E(H(){I a?D.2L(7,b)<0:7!=b})},1e:H(a){I 7.2I(D.4r(D.2R(7.3p(),1j a==\'23\'?D(a):D.2d(a))))},3F:H(a){I!!a&&D.3g(a,7).K>0},7T:H(a){I 7.3F("."+a)},6e:H(b){G(b==12){G(7.K){J c=7[0];G(D.Y(c,"2A")){J e=c.64,63=[],15=c.15,2V=c.O=="2A-2V";G(e<0)I U;R(J i=2V?e:0,2f=2V?e+1:15.K;i<2f;i++){J d=15[i];G(d.2W){b=D.14.1f&&!d.at.2x.an?d.1r:d.2x;G(2V)I b;63.1p(b)}}I 63}N I(7[0].2x||"").1o(/\\r/g,"")}I 12}G(b.1q==4L)b+=\'\';I 7.P(H(){G(7.16!=1)I;G(b.1q==2p&&/5O|5L/.11(7.O))7.4J=(D.2L(7.2x,b)>=0||D.2L(7.34,b)>=0);N G(D.Y(7,"2A")){J a=D.2d(b);D("9R",7).P(H(){7.2W=(D.2L(7.2x,a)>=0||D.2L(7.1r,a)>=0)});G(!a.K)7.64=-1}N 7.2x=b})},2K:H(a){I a==12?(7[0]?7[0].4H:U):7.4E().3v(a)},7b:H(a){I 7.5q(a).21()},79:H(i){I 7.3s(i,i+1)},3s:H(){I 7.2I(2p.44.3s.1w(7,19))},2l:H(b){I 7.2I(D.2l(7,H(a,i){I b.1k(a,i,a)}))},5c:H(){I 7.1e(7.5n)},L:H(d,b){J a=d.1R(".");a[1]=a[1]?"."+a[1]:"";G(b===12){J c=7.5C("9z"+a[1]+"!",[a[0]]);G(c===12&&7.K)c=D.L(7[0],d);I c===12&&a[1]?7.L(a[0]):c}N I 7.1P("9u"+a[1]+"!",[a[0],b]).P(H(){D.L(7,d,b)})},3b:H(a){I 7.P(H(){D.3b(7,a)})},3W:H(g,f,h,d){J e=7.K>1,3x;I 7.P(H(){G(!3x){3x=D.4h(g,7.2z);G(h)3x.9o()}J b=7;G(f&&D.Y(7,"1T")&&D.Y(3x[0],"4F"))b=7.3H("22")[0]||7.3U(7.2z.3h("22"));J c=D([]);D.P(3x,H(){J a=e?D(7).5y(M)[0]:7;G(D.Y(a,"1m"))c=c.1e(a);N{G(a.16==1)c=c.1e(D("1m",a).21());d.1k(b,a)}});c.P(6T)})}};D.17.5j.44=D.17;H 6T(i,a){G(a.4d)D.3Y({1a:a.4d,31:Q,1O:"1m"});N D.5u(a.1r||a.6O||a.4H||"");G(a.1d)a.1d.37(a)}H 1z(){I+2B 8J}D.1l=D.17.1l=H(){J b=19[0]||{},i=1,K=19.K,4x=Q,15;G(b.1q==8I){4x=b;b=19[1]||{};i=2}G(1j b!="49"&&1j b!="H")b={};G(K==i){b=7;--i}R(;i<K;i++)G((15=19[i])!=U)R(J c 1n 15){J a=b[c],2w=15[c];G(b===2w)6M;G(4x&&2w&&1j 2w=="49"&&!2w.16)b[c]=D.1l(4x,a||(2w.K!=U?[]:{}),2w);N G(2w!==12)b[c]=2w}I b};J E="4M"+1z(),6K=0,5r={},6G=/z-?5i|8B-?8A|1y|6B|8v-?1Z/i,3P=S.3P||{};D.1l({8u:H(a){1b.$=3m$;G(a)1b.4M=w;I D},1D:H(a){I!!a&&1j a!="23"&&!a.Y&&a.1q!=2p&&/^[\\s[]?H/.11(a+"")},4n:H(a){I a.1C&&!a.1c||a.2j&&a.2z&&!a.2z.1c},5u:H(a){a=D.3k(a);G(a){J b=S.3H("6w")[0]||S.1C,1m=S.3h("1m");1m.O="1r/4t";G(D.14.1f)1m.1r=a;N 1m.3U(S.5F(a));b.39(1m,b.1x);b.37(1m)}},Y:H(b,a){I b.Y&&b.Y.2r()==a.2r()},1Y:{},L:H(c,d,b){c=c==1b?5r:c;J a=c[E];G(!a)a=c[E]=++6K;G(d&&!D.1Y[a])D.1Y[a]={};G(b!==12)D.1Y[a][d]=b;I d?D.1Y[a][d]:a},3b:H(c,b){c=c==1b?5r:c;J a=c[E];G(b){G(D.1Y[a]){2U D.1Y[a][b];b="";R(b 1n D.1Y[a])1X;G(!b)D.3b(c)}}N{1U{2U c[E]}1V(e){G(c.5l)c.5l(E)}2U D.1Y[a]}},P:H(d,a,c){J e,i=0,K=d.K;G(c){G(K==12){R(e 1n d)G(a.1w(d[e],c)===Q)1X}N R(;i<K;)G(a.1w(d[i++],c)===Q)1X}N{G(K==12){R(e 1n d)G(a.1k(d[e],e,d[e])===Q)1X}N R(J b=d[0];i<K&&a.1k(b,i,b)!==Q;b=d[++i]){}}I d},1i:H(b,a,c,i,d){G(D.1D(a))a=a.1k(b,i);I a&&a.1q==4L&&c=="2a"&&!6G.11(d)?a+"2X":a},1F:{1e:H(c,b){D.P((b||"").1R(/\\s+/),H(i,a){G(c.16==1&&!D.1F.3T(c.1F,a))c.1F+=(c.1F?" ":"")+a})},21:H(c,b){G(c.16==1)c.1F=b!=12?D.3C(c.1F.1R(/\\s+/),H(a){I!D.1F.3T(b,a)}).6s(" "):""},3T:H(b,a){I D.2L(a,(b.1F||b).6r().1R(/\\s+/))>-1}},6q:H(b,c,a){J e={};R(J d 1n c){e[d]=b.V[d];b.V[d]=c[d]}a.1k(b);R(J d 1n c)b.V[d]=e[d]},1g:H(d,e,c){G(e=="2h"||e=="1Z"){J b,3X={30:"5x",5g:"1G",18:"3I"},35=e=="2h"?["5e","6k"]:["5G","6i"];H 5b(){b=e=="2h"?d.8f:d.8c;J a=0,2C=0;D.P(35,H(){a+=3d(D.2a(d,"57"+7,M))||0;2C+=3d(D.2a(d,"2C"+7+"4b",M))||0});b-=29.83(a+2C)}G(D(d).3F(":4j"))5b();N D.6q(d,3X,5b);I 29.2f(0,b)}I D.2a(d,e,c)},2a:H(f,l,k){J e,V=f.V;H 3E(b){G(!D.14.2k)I Q;J a=3P.54(b,U);I!a||a.52("3E")==""}G(l=="1y"&&D.14.1f){e=D.1K(V,"1y");I e==""?"1":e}G(D.14.2G&&l=="18"){J d=V.50;V.50="0 7Y 7W";V.50=d}G(l.1I(/4i/i))l=y;G(!k&&V&&V[l])e=V[l];N G(3P.54){G(l.1I(/4i/i))l="4i";l=l.1o(/([A-Z])/g,"-$1").3y();J c=3P.54(f,U);G(c&&!3E(f))e=c.52(l);N{J g=[],2E=[],a=f,i=0;R(;a&&3E(a);a=a.1d)2E.6h(a);R(;i<2E.K;i++)G(3E(2E[i])){g[i]=2E[i].V.18;2E[i].V.18="3I"}e=l=="18"&&g[2E.K-1]!=U?"2F":(c&&c.52(l))||"";R(i=0;i<g.K;i++)G(g[i]!=U)2E[i].V.18=g[i]}G(l=="1y"&&e=="")e="1"}N G(f.4g){J h=l.1o(/\\-(\\w)/g,H(a,b){I b.2r()});e=f.4g[l]||f.4g[h];G(!/^\\d+(2X)?$/i.11(e)&&/^\\d/.11(e)){J j=V.1A,66=f.65.1A;f.65.1A=f.4g.1A;V.1A=e||0;e=V.aM+"2X";V.1A=j;f.65.1A=66}}I e},4h:H(l,h){J k=[];h=h||S;G(1j h.3h==\'12\')h=h.2z||h[0]&&h[0].2z||S;D.P(l,H(i,d){G(!d)I;G(d.1q==4L)d+=\'\';G(1j d=="23"){d=d.1o(/(<(\\w+)[^>]*?)\\/>/g,H(b,a,c){I c.1I(/^(aK|4f|7E|aG|4T|7A|aB|3n|az|ay|av)$/i)?b:a+"></"+c+">"});J f=D.3k(d).3y(),1v=h.3h("1v");J e=!f.1h("<au")&&[1,"<2A 7w=\'7w\'>","</2A>"]||!f.1h("<ar")&&[1,"<7v>","</7v>"]||f.1I(/^<(aq|22|am|ak|ai)/)&&[1,"<1T>","</1T>"]||!f.1h("<4F")&&[2,"<1T><22>","</22></1T>"]||(!f.1h("<af")||!f.1h("<ad"))&&[3,"<1T><22><4F>","</4F></22></1T>"]||!f.1h("<7E")&&[2,"<1T><22></22><7q>","</7q></1T>"]||D.14.1f&&[1,"1v<1v>","</1v>"]||[0,"",""];1v.4H=e[1]+d+e[2];1B(e[0]--)1v=1v.5T;G(D.14.1f){J g=!f.1h("<1T")&&f.1h("<22")<0?1v.1x&&1v.1x.3t:e[1]=="<1T>"&&f.1h("<22")<0?1v.3t:[];R(J j=g.K-1;j>=0;--j)G(D.Y(g[j],"22")&&!g[j].3t.K)g[j].1d.37(g[j]);G(/^\\s/.11(d))1v.39(h.5F(d.1I(/^\\s*/)[0]),1v.1x)}d=D.2d(1v.3t)}G(d.K===0&&(!D.Y(d,"3V")&&!D.Y(d,"2A")))I;G(d[0]==12||D.Y(d,"3V")||d.15)k.1p(d);N k=D.2R(k,d)});I k},1K:H(d,f,c){G(!d||d.16==3||d.16==8)I 12;J e=!D.4n(d),40=c!==12,1f=D.14.1f;f=e&&D.3X[f]||f;G(d.2j){J g=/5Q|4d|V/.11(f);G(f=="2W"&&D.14.2k)d.1d.64;G(f 1n d&&e&&!g){G(40){G(f=="O"&&D.Y(d,"4T")&&d.1d)7p"O a3 a1\'t 9V 9U";d[f]=c}G(D.Y(d,"3V")&&d.7i(f))I d.7i(f).76;I d[f]}G(1f&&e&&f=="V")I D.1K(d.V,"9T",c);G(40)d.9Q(f,""+c);J h=1f&&e&&g?d.4G(f,2):d.4G(f);I h===U?12:h}G(1f&&f=="1y"){G(40){d.6B=1;d.1E=(d.1E||"").1o(/7f\\([^)]*\\)/,"")+(3r(c)+\'\'=="9L"?"":"7f(1y="+c*7a+")")}I d.1E&&d.1E.1h("1y=")>=0?(3d(d.1E.1I(/1y=([^)]*)/)[1])/7a)+\'\':""}f=f.1o(/-([a-z])/9H,H(a,b){I b.2r()});G(40)d[f]=c;I d[f]},3k:H(a){I(a||"").1o(/^\\s+|\\s+$/g,"")},2d:H(b){J a=[];G(b!=U){J i=b.K;G(i==U||b.1R||b.4I||b.1k)a[0]=b;N 1B(i)a[--i]=b[i]}I a},2L:H(b,a){R(J i=0,K=a.K;i<K;i++)G(a[i]===b)I i;I-1},2R:H(a,b){J i=0,T,2S=a.K;G(D.14.1f){1B(T=b[i++])G(T.16!=8)a[2S++]=T}N 1B(T=b[i++])a[2S++]=T;I a},4r:H(a){J c=[],2o={};1U{R(J i=0,K=a.K;i<K;i++){J b=D.L(a[i]);G(!2o[b]){2o[b]=M;c.1p(a[i])}}}1V(e){c=a}I c},3C:H(c,a,d){J b=[];R(J i=0,K=c.K;i<K;i++)G(!d!=!a(c[i],i))b.1p(c[i]);I b},2l:H(d,a){J c=[];R(J i=0,K=d.K;i<K;i++){J b=a(d[i],i);G(b!=U)c[c.K]=b}I c.7d.1w([],c)}});J v=9B.9A.3y();D.14={5B:(v.1I(/.+(?:9y|9x|9w|9v)[\\/: ]([\\d.]+)/)||[])[1],2k:/75/.11(v),2G:/2G/.11(v),1f:/1f/.11(v)&&!/2G/.11(v),42:/42/.11(v)&&!/(9s|75)/.11(v)};J y=D.14.1f?"7o":"72";D.1l({71:!D.14.1f||S.70=="6Z",3X:{"R":"9n","9k":"1F","4i":y,72:y,7o:y,9h:"9f",9e:"9d",9b:"99"}});D.P({6W:H(a){I a.1d},97:H(a){I D.4S(a,"1d")},95:H(a){I D.3a(a,2,"2H")},91:H(a){I D.3a(a,2,"4l")},8Z:H(a){I D.4S(a,"2H")},8X:H(a){I D.4S(a,"4l")},8W:H(a){I D.5v(a.1d.1x,a)},8V:H(a){I D.5v(a.1x)},6Q:H(a){I D.Y(a,"8U")?a.8T||a.8S.S:D.2d(a.3t)}},H(c,d){D.17[c]=H(b){J a=D.2l(7,d);G(b&&1j b=="23")a=D.3g(b,a);I 7.2I(D.4r(a))}});D.P({6P:"3v",8Q:"6F",39:"6E",8P:"5q",8O:"7b"},H(c,b){D.17[c]=H(){J a=19;I 7.P(H(){R(J i=0,K=a.K;i<K;i++)D(a[i])[b](7)})}});D.P({8N:H(a){D.1K(7,a,"");G(7.16==1)7.5l(a)},8M:H(a){D.1F.1e(7,a)},8L:H(a){D.1F.21(7,a)},8K:H(a){D.1F[D.1F.3T(7,a)?"21":"1e"](7,a)},21:H(a){G(!a||D.1E(a,[7]).r.K){D("*",7).1e(7).P(H(){D.W.21(7);D.3b(7)});G(7.1d)7.1d.37(7)}},4E:H(){D(">*",7).21();1B(7.1x)7.37(7.1x)}},H(a,b){D.17[a]=H(){I 7.P(b,19)}});D.P(["6N","4b"],H(i,c){J b=c.3y();D.17[b]=H(a){I 7[0]==1b?D.14.2G&&S.1c["5t"+c]||D.14.2k&&1b["5s"+c]||S.70=="6Z"&&S.1C["5t"+c]||S.1c["5t"+c]:7[0]==S?29.2f(29.2f(S.1c["4y"+c],S.1C["4y"+c]),29.2f(S.1c["2i"+c],S.1C["2i"+c])):a==12?(7.K?D.1g(7[0],b):U):7.1g(b,a.1q==56?a:a+"2X")}});H 25(a,b){I a[0]&&3r(D.2a(a[0],b,M),10)||0}J C=D.14.2k&&3r(D.14.5B)<8H?"(?:[\\\\w*3m-]|\\\\\\\\.)":"(?:[\\\\w\\8F-\\8E*3m-]|\\\\\\\\.)",6L=2B 4v("^>\\\\s*("+C+"+)"),6J=2B 4v("^("+C+"+)(#)("+C+"+)"),6I=2B 4v("^([#.]?)("+C+"*)");D.1l({6H:{"":H(a,i,m){I m[2]=="*"||D.Y(a,m[2])},"#":H(a,i,m){I a.4G("2v")==m[2]},":":{8D:H(a,i,m){I i<m[3]-0},8C:H(a,i,m){I i>m[3]-0},3a:H(a,i,m){I m[3]-0==i},79:H(a,i,m){I m[3]-0==i},3o:H(a,i){I i==0},3S:H(a,i,m,r){I i==r.K-1},6D:H(a,i){I i%2==0},6C:H(a,i){I i%2},"3o-4u":H(a){I a.1d.3H("*")[0]==a},"3S-4u":H(a){I D.3a(a.1d.5T,1,"4l")==a},"8z-4u":H(a){I!D.3a(a.1d.5T,2,"4l")},6W:H(a){I a.1x},4E:H(a){I!a.1x},8y:H(a,i,m){I(a.6O||a.8x||D(a).1r()||"").1h(m[3])>=0},4j:H(a){I"1G"!=a.O&&D.1g(a,"18")!="2F"&&D.1g(a,"5g")!="1G"},1G:H(a){I"1G"==a.O||D.1g(a,"18")=="2F"||D.1g(a,"5g")=="1G"},8w:H(a){I!a.3R},3R:H(a){I a.3R},4J:H(a){I a.4J},2W:H(a){I a.2W||D.1K(a,"2W")},1r:H(a){I"1r"==a.O},5O:H(a){I"5O"==a.O},5L:H(a){I"5L"==a.O},5p:H(a){I"5p"==a.O},3Q:H(a){I"3Q"==a.O},5o:H(a){I"5o"==a.O},6A:H(a){I"6A"==a.O},6z:H(a){I"6z"==a.O},2s:H(a){I"2s"==a.O||D.Y(a,"2s")},4T:H(a){I/4T|2A|6y|2s/i.11(a.Y)},3T:H(a,i,m){I D.2q(m[3],a).K},8t:H(a){I/h\\d/i.11(a.Y)},8s:H(a){I D.3C(D.3O,H(b){I a==b.T}).K}}},6x:[/^(\\[) *@?([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,2B 4v("^([:.#]*)("+C+"+)")],3g:H(a,c,b){J d,1t=[];1B(a&&a!=d){d=a;J f=D.1E(a,c,b);a=f.t.1o(/^\\s*,\\s*/,"");1t=b?c=f.r:D.2R(1t,f.r)}I 1t},2q:H(t,o){G(1j t!="23")I[t];G(o&&o.16!=1&&o.16!=9)I[];o=o||S;J d=[o],2o=[],3S,Y;1B(t&&3S!=t){J r=[];3S=t;t=D.3k(t);J l=Q,3j=6L,m=3j.2D(t);G(m){Y=m[1].2r();R(J i=0;d[i];i++)R(J c=d[i].1x;c;c=c.2H)G(c.16==1&&(Y=="*"||c.Y.2r()==Y))r.1p(c);d=r;t=t.1o(3j,"");G(t.1h(" ")==0)6M;l=M}N{3j=/^([>+~])\\s*(\\w*)/i;G((m=3j.2D(t))!=U){r=[];J k={};Y=m[2].2r();m=m[1];R(J j=0,3i=d.K;j<3i;j++){J n=m=="~"||m=="+"?d[j].2H:d[j].1x;R(;n;n=n.2H)G(n.16==1){J g=D.L(n);G(m=="~"&&k[g])1X;G(!Y||n.Y.2r()==Y){G(m=="~")k[g]=M;r.1p(n)}G(m=="+")1X}}d=r;t=D.3k(t.1o(3j,""));l=M}}G(t&&!l){G(!t.1h(",")){G(o==d[0])d.4s();2o=D.2R(2o,d);r=d=[o];t=" "+t.6v(1,t.K)}N{J h=6J;J m=h.2D(t);G(m){m=[0,m[2],m[3],m[1]]}N{h=6I;m=h.2D(t)}m[2]=m[2].1o(/\\\\/g,"");J f=d[d.K-1];G(m[1]=="#"&&f&&f.61&&!D.4n(f)){J p=f.61(m[2]);G((D.14.1f||D.14.2G)&&p&&1j p.2v=="23"&&p.2v!=m[2])p=D(\'[@2v="\'+m[2]+\'"]\',f)[0];d=r=p&&(!m[3]||D.Y(p,m[3]))?[p]:[]}N{R(J i=0;d[i];i++){J a=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];G(a=="*"&&d[i].Y.3y()=="49")a="3n";r=D.2R(r,d[i].3H(a))}G(m[1]==".")r=D.5m(r,m[2]);G(m[1]=="#"){J e=[];R(J i=0;r[i];i++)G(r[i].4G("2v")==m[2]){e=[r[i]];1X}r=e}d=r}t=t.1o(h,"")}}G(t){J b=D.1E(t,r);d=r=b.r;t=D.3k(b.t)}}G(t)d=[];G(d&&o==d[0])d.4s();2o=D.2R(2o,d);I 2o},5m:H(r,m,a){m=" "+m+" ";J c=[];R(J i=0;r[i];i++){J b=(" "+r[i].1F+" ").1h(m)>=0;G(!a&&b||a&&!b)c.1p(r[i])}I c},1E:H(t,r,h){J d;1B(t&&t!=d){d=t;J p=D.6x,m;R(J i=0;p[i];i++){m=p[i].2D(t);G(m){t=t.8r(m[0].K);m[2]=m[2].1o(/\\\\/g,"");1X}}G(!m)1X;G(m[1]==":"&&m[2]=="4Y")r=62.11(m[3])?D.1E(m[3],r,M).r:D(r).4Y(m[3]);N G(m[1]==".")r=D.5m(r,m[2],h);N G(m[1]=="["){J g=[],O=m[3];R(J i=0,3i=r.K;i<3i;i++){J a=r[i],z=a[D.3X[m[2]]||m[2]];G(z==U||/5Q|4d|2W/.11(m[2]))z=D.1K(a,m[2])||\'\';G((O==""&&!!z||O=="="&&z==m[5]||O=="!="&&z!=m[5]||O=="^="&&z&&!z.1h(m[5])||O=="$="&&z.6v(z.K-m[5].K)==m[5]||(O=="*="||O=="~=")&&z.1h(m[5])>=0)^h)g.1p(a)}r=g}N G(m[1]==":"&&m[2]=="3a-4u"){J e={},g=[],11=/(-?)(\\d*)n((?:\\+|-)?\\d*)/.2D(m[3]=="6D"&&"2n"||m[3]=="6C"&&"2n+1"||!/\\D/.11(m[3])&&"8q+"+m[3]||m[3]),3o=(11[1]+(11[2]||1))-0,d=11[3]-0;R(J i=0,3i=r.K;i<3i;i++){J j=r[i],1d=j.1d,2v=D.L(1d);G(!e[2v]){J c=1;R(J n=1d.1x;n;n=n.2H)G(n.16==1)n.4q=c++;e[2v]=M}J b=Q;G(3o==0){G(j.4q==d)b=M}N G((j.4q-d)%3o==0&&(j.4q-d)/3o>=0)b=M;G(b^h)g.1p(j)}r=g}N{J f=D.6H[m[1]];G(1j f=="49")f=f[m[2]];G(1j f=="23")f=6u("Q||H(a,i){I "+f+";}");r=D.3C(r,H(a,i){I f(a,i,m,r)},h)}}I{r:r,t:t}},4S:H(b,c){J a=[],1t=b[c];1B(1t&&1t!=S){G(1t.16==1)a.1p(1t);1t=1t[c]}I a},3a:H(a,e,c,b){e=e||1;J d=0;R(;a;a=a[c])G(a.16==1&&++d==e)1X;I a},5v:H(n,a){J r=[];R(;n;n=n.2H){G(n.16==1&&n!=a)r.1p(n)}I r}});D.W={1e:H(f,i,g,e){G(f.16==3||f.16==8)I;G(D.14.1f&&f.4I)f=1b;G(!g.24)g.24=7.24++;G(e!=12){J h=g;g=7.3M(h,H(){I h.1w(7,19)});g.L=e}J j=D.L(f,"3w")||D.L(f,"3w",{}),1H=D.L(f,"1H")||D.L(f,"1H",H(){G(1j D!="12"&&!D.W.5k)I D.W.1H.1w(19.3L.T,19)});1H.T=f;D.P(i.1R(/\\s+/),H(c,b){J a=b.1R(".");b=a[0];g.O=a[1];J d=j[b];G(!d){d=j[b]={};G(!D.W.2t[b]||D.W.2t[b].4p.1k(f)===Q){G(f.3K)f.3K(b,1H,Q);N G(f.6t)f.6t("4o"+b,1H)}}d[g.24]=g;D.W.26[b]=M});f=U},24:1,26:{},21:H(e,h,f){G(e.16==3||e.16==8)I;J i=D.L(e,"3w"),1L,5i;G(i){G(h==12||(1j h=="23"&&h.8p(0)=="."))R(J g 1n i)7.21(e,g+(h||""));N{G(h.O){f=h.2y;h=h.O}D.P(h.1R(/\\s+/),H(b,a){J c=a.1R(".");a=c[0];G(i[a]){G(f)2U i[a][f.24];N R(f 1n i[a])G(!c[1]||i[a][f].O==c[1])2U i[a][f];R(1L 1n i[a])1X;G(!1L){G(!D.W.2t[a]||D.W.2t[a].4A.1k(e)===Q){G(e.6p)e.6p(a,D.L(e,"1H"),Q);N G(e.6n)e.6n("4o"+a,D.L(e,"1H"))}1L=U;2U i[a]}}})}R(1L 1n i)1X;G(!1L){J d=D.L(e,"1H");G(d)d.T=U;D.3b(e,"3w");D.3b(e,"1H")}}},1P:H(h,c,f,g,i){c=D.2d(c);G(h.1h("!")>=0){h=h.3s(0,-1);J a=M}G(!f){G(7.26[h])D("*").1e([1b,S]).1P(h,c)}N{G(f.16==3||f.16==8)I 12;J b,1L,17=D.1D(f[h]||U),W=!c[0]||!c[0].32;G(W){c.6h({O:h,2J:f,32:H(){},3J:H(){},4C:1z()});c[0][E]=M}c[0].O=h;G(a)c[0].6m=M;J d=D.L(f,"1H");G(d)b=d.1w(f,c);G((!17||(D.Y(f,\'a\')&&h=="4V"))&&f["4o"+h]&&f["4o"+h].1w(f,c)===Q)b=Q;G(W)c.4s();G(i&&D.1D(i)){1L=i.1w(f,b==U?c:c.7d(b));G(1L!==12)b=1L}G(17&&g!==Q&&b!==Q&&!(D.Y(f,\'a\')&&h=="4V")){7.5k=M;1U{f[h]()}1V(e){}}7.5k=Q}I b},1H:H(b){J a,1L,38,5f,4m;b=19[0]=D.W.6l(b||1b.W);38=b.O.1R(".");b.O=38[0];38=38[1];5f=!38&&!b.6m;4m=(D.L(7,"3w")||{})[b.O];R(J j 1n 4m){J c=4m[j];G(5f||c.O==38){b.2y=c;b.L=c.L;1L=c.1w(7,19);G(a!==Q)a=1L;G(1L===Q){b.32();b.3J()}}}I a},6l:H(b){G(b[E]==M)I b;J d=b;b={8o:d};J c="8n 8m 8l 8k 2s 8j 47 5d 6j 5E 8i L 8h 8g 4K 2y 5a 59 8e 8b 58 6f 8a 88 4k 87 86 84 6d 2J 4C 6c O 82 81 35".1R(" ");R(J i=c.K;i;i--)b[c[i]]=d[c[i]];b[E]=M;b.32=H(){G(d.32)d.32();d.80=Q};b.3J=H(){G(d.3J)d.3J();d.7Z=M};b.4C=b.4C||1z();G(!b.2J)b.2J=b.6d||S;G(b.2J.16==3)b.2J=b.2J.1d;G(!b.4k&&b.4K)b.4k=b.4K==b.2J?b.6c:b.4K;G(b.58==U&&b.5d!=U){J a=S.1C,1c=S.1c;b.58=b.5d+(a&&a.2e||1c&&1c.2e||0)-(a.6b||0);b.6f=b.6j+(a&&a.2c||1c&&1c.2c||0)-(a.6a||0)}G(!b.35&&((b.47||b.47===0)?b.47:b.5a))b.35=b.47||b.5a;G(!b.59&&b.5E)b.59=b.5E;G(!b.35&&b.2s)b.35=(b.2s&1?1:(b.2s&2?3:(b.2s&4?2:0)));I b},3M:H(a,b){b.24=a.24=a.24||b.24||7.24++;I b},2t:{27:{4p:H(){55();I},4A:H(){I}},3D:{4p:H(){G(D.14.1f)I Q;D(7).2O("53",D.W.2t.3D.2y);I M},4A:H(){G(D.14.1f)I Q;D(7).4e("53",D.W.2t.3D.2y);I M},2y:H(a){G(F(a,7))I M;a.O="3D";I D.W.1H.1w(7,19)}},3N:{4p:H(){G(D.14.1f)I Q;D(7).2O("51",D.W.2t.3N.2y);I M},4A:H(){G(D.14.1f)I Q;D(7).4e("51",D.W.2t.3N.2y);I M},2y:H(a){G(F(a,7))I M;a.O="3N";I D.W.1H.1w(7,19)}}}};D.17.1l({2O:H(c,a,b){I c=="4X"?7.2V(c,a,b):7.P(H(){D.W.1e(7,c,b||a,b&&a)})},2V:H(d,b,c){J e=D.W.3M(c||b,H(a){D(7).4e(a,e);I(c||b).1w(7,19)});I 7.P(H(){D.W.1e(7,d,e,c&&b)})},4e:H(a,b){I 7.P(H(){D.W.21(7,a,b)})},1P:H(c,a,b){I 7.P(H(){D.W.1P(c,a,7,M,b)})},5C:H(c,a,b){I 7[0]&&D.W.1P(c,a,7[0],Q,b)},2m:H(b){J c=19,i=1;1B(i<c.K)D.W.3M(b,c[i++]);I 7.4V(D.W.3M(b,H(a){7.4Z=(7.4Z||0)%i;a.32();I c[7.4Z++].1w(7,19)||Q}))},7X:H(a,b){I 7.2O(\'3D\',a).2O(\'3N\',b)},27:H(a){55();G(D.2Q)a.1k(S,D);N D.3A.1p(H(){I a.1k(7,D)});I 7}});D.1l({2Q:Q,3A:[],27:H(){G(!D.2Q){D.2Q=M;G(D.3A){D.P(D.3A,H(){7.1k(S)});D.3A=U}D(S).5C("27")}}});J x=Q;H 55(){G(x)I;x=M;G(S.3K&&!D.14.2G)S.3K("69",D.27,Q);G(D.14.1f&&1b==1S)(H(){G(D.2Q)I;1U{S.1C.7V("1A")}1V(3e){3B(19.3L,0);I}D.27()})();G(D.14.2G)S.3K("69",H(){G(D.2Q)I;R(J i=0;i<S.4W.K;i++)G(S.4W[i].3R){3B(19.3L,0);I}D.27()},Q);G(D.14.2k){J a;(H(){G(D.2Q)I;G(S.3f!="68"&&S.3f!="1J"){3B(19.3L,0);I}G(a===12)a=D("V, 7A[7U=7S]").K;G(S.4W.K!=a){3B(19.3L,0);I}D.27()})()}D.W.1e(1b,"43",D.27)}D.P(("7R,7Q,43,85,4y,4X,4V,7P,"+"7O,7N,89,53,51,7M,2A,"+"5o,7L,7K,8d,3e").1R(","),H(i,b){D.17[b]=H(a){I a?7.2O(b,a):7.1P(b)}});J F=H(a,c){J b=a.4k;1B(b&&b!=c)1U{b=b.1d}1V(3e){b=c}I b==c};D(1b).2O("4X",H(){D("*").1e(S).4e()});D.17.1l({67:D.17.43,43:H(g,d,c){G(1j g!=\'23\')I 7.67(g);J e=g.1h(" ");G(e>=0){J i=g.3s(e,g.K);g=g.3s(0,e)}c=c||H(){};J f="2P";G(d)G(D.1D(d)){c=d;d=U}N{d=D.3n(d);f="6g"}J h=7;D.3Y({1a:g,O:f,1O:"2K",L:d,1J:H(a,b){G(b=="1W"||b=="7J")h.2K(i?D("<1v/>").3v(a.4U.1o(/<1m(.|\\s)*?\\/1m>/g,"")).2q(i):a.4U);h.P(c,[a.4U,b,a])}});I 7},aL:H(){I D.3n(7.7I())},7I:H(){I 7.2l(H(){I D.Y(7,"3V")?D.2d(7.aH):7}).1E(H(){I 7.34&&!7.3R&&(7.4J||/2A|6y/i.11(7.Y)||/1r|1G|3Q/i.11(7.O))}).2l(H(i,c){J b=D(7).6e();I b==U?U:b.1q==2p?D.2l(b,H(a,i){I{34:c.34,2x:a}}):{34:c.34,2x:b}}).3p()}});D.P("7H,7G,7F,7D,7C,7B".1R(","),H(i,o){D.17[o]=H(f){I 7.2O(o,f)}});J B=1z();D.1l({3p:H(d,b,a,c){G(D.1D(b)){a=b;b=U}I D.3Y({O:"2P",1a:d,L:b,1W:a,1O:c})},aE:H(b,a){I D.3p(b,U,a,"1m")},aD:H(c,b,a){I D.3p(c,b,a,"3z")},aC:H(d,b,a,c){G(D.1D(b)){a=b;b={}}I D.3Y({O:"6g",1a:d,L:b,1W:a,1O:c})},aA:H(a){D.1l(D.60,a)},60:{1a:5Z.5Q,26:M,O:"2P",2T:0,7z:"4R/x-ax-3V-aw",7x:M,31:M,L:U,5Y:U,3Q:U,4Q:{2N:"4R/2N, 1r/2N",2K:"1r/2K",1m:"1r/4t, 4R/4t",3z:"4R/3z, 1r/4t",1r:"1r/as",4w:"*/*"}},4z:{},3Y:H(s){s=D.1l(M,s,D.1l(M,{},D.60,s));J g,2Z=/=\\?(&|$)/g,1u,L,O=s.O.2r();G(s.L&&s.7x&&1j s.L!="23")s.L=D.3n(s.L);G(s.1O=="4P"){G(O=="2P"){G(!s.1a.1I(2Z))s.1a+=(s.1a.1I(/\\?/)?"&":"?")+(s.4P||"7u")+"=?"}N G(!s.L||!s.L.1I(2Z))s.L=(s.L?s.L+"&":"")+(s.4P||"7u")+"=?";s.1O="3z"}G(s.1O=="3z"&&(s.L&&s.L.1I(2Z)||s.1a.1I(2Z))){g="4P"+B++;G(s.L)s.L=(s.L+"").1o(2Z,"="+g+"$1");s.1a=s.1a.1o(2Z,"="+g+"$1");s.1O="1m";1b[g]=H(a){L=a;1W();1J();1b[g]=12;1U{2U 1b[g]}1V(e){}G(i)i.37(h)}}G(s.1O=="1m"&&s.1Y==U)s.1Y=Q;G(s.1Y===Q&&O=="2P"){J j=1z();J k=s.1a.1o(/(\\?|&)3m=.*?(&|$)/,"$ap="+j+"$2");s.1a=k+((k==s.1a)?(s.1a.1I(/\\?/)?"&":"?")+"3m="+j:"")}G(s.L&&O=="2P"){s.1a+=(s.1a.1I(/\\?/)?"&":"?")+s.L;s.L=U}G(s.26&&!D.4O++)D.W.1P("7H");J n=/^(?:\\w+:)?\\/\\/([^\\/?#]+)/;G(s.1O=="1m"&&O=="2P"&&n.11(s.1a)&&n.2D(s.1a)[1]!=5Z.al){J i=S.3H("6w")[0];J h=S.3h("1m");h.4d=s.1a;G(s.7t)h.aj=s.7t;G(!g){J l=Q;h.ah=h.ag=H(){G(!l&&(!7.3f||7.3f=="68"||7.3f=="1J")){l=M;1W();1J();i.37(h)}}}i.3U(h);I 12}J m=Q;J c=1b.7s?2B 7s("ae.ac"):2B 7r();G(s.5Y)c.6R(O,s.1a,s.31,s.5Y,s.3Q);N c.6R(O,s.1a,s.31);1U{G(s.L)c.4B("ab-aa",s.7z);G(s.5S)c.4B("a9-5R-a8",D.4z[s.1a]||"a7, a6 a5 a4 5N:5N:5N a2");c.4B("X-9Z-9Y","7r");c.4B("9W",s.1O&&s.4Q[s.1O]?s.4Q[s.1O]+", */*":s.4Q.4w)}1V(e){}G(s.7m&&s.7m(c,s)===Q){s.26&&D.4O--;c.7l();I Q}G(s.26)D.W.1P("7B",[c,s]);J d=H(a){G(!m&&c&&(c.3f==4||a=="2T")){m=M;G(f){7k(f);f=U}1u=a=="2T"&&"2T"||!D.7j(c)&&"3e"||s.5S&&D.7h(c,s.1a)&&"7J"||"1W";G(1u=="1W"){1U{L=D.6X(c,s.1O,s.9S)}1V(e){1u="5J"}}G(1u=="1W"){J b;1U{b=c.5I("7g-5R")}1V(e){}G(s.5S&&b)D.4z[s.1a]=b;G(!g)1W()}N D.5H(s,c,1u);1J();G(s.31)c=U}};G(s.31){J f=4I(d,13);G(s.2T>0)3B(H(){G(c){c.7l();G(!m)d("2T")}},s.2T)}1U{c.9P(s.L)}1V(e){D.5H(s,c,U,e)}G(!s.31)d();H 1W(){G(s.1W)s.1W(L,1u);G(s.26)D.W.1P("7C",[c,s])}H 1J(){G(s.1J)s.1J(c,1u);G(s.26)D.W.1P("7F",[c,s]);G(s.26&&!--D.4O)D.W.1P("7G")}I c},5H:H(s,a,b,e){G(s.3e)s.3e(a,b,e);G(s.26)D.W.1P("7D",[a,s,e])},4O:0,7j:H(a){1U{I!a.1u&&5Z.9O=="5p:"||(a.1u>=7e&&a.1u<9N)||a.1u==7c||a.1u==9K||D.14.2k&&a.1u==12}1V(e){}I Q},7h:H(a,c){1U{J b=a.5I("7g-5R");I a.1u==7c||b==D.4z[c]||D.14.2k&&a.1u==12}1V(e){}I Q},6X:H(a,c,b){J d=a.5I("9J-O"),2N=c=="2N"||!c&&d&&d.1h("2N")>=0,L=2N?a.9I:a.4U;G(2N&&L.1C.2j=="5J")7p"5J";G(b)L=b(L,c);G(c=="1m")D.5u(L);G(c=="3z")L=6u("("+L+")");I L},3n:H(a){J s=[];G(a.1q==2p||a.5w)D.P(a,H(){s.1p(3u(7.34)+"="+3u(7.2x))});N R(J j 1n a)G(a[j]&&a[j].1q==2p)D.P(a[j],H(){s.1p(3u(j)+"="+3u(7))});N s.1p(3u(j)+"="+3u(D.1D(a[j])?a[j]():a[j]));I s.6s("&").1o(/%20/g,"+")}});D.17.1l({1N:H(c,b){I c?7.2g({1Z:"1N",2h:"1N",1y:"1N"},c,b):7.1E(":1G").P(H(){7.V.18=7.5D||"";G(D.1g(7,"18")=="2F"){J a=D("<"+7.2j+" />").6P("1c");7.V.18=a.1g("18");G(7.V.18=="2F")7.V.18="3I";a.21()}}).3l()},1M:H(b,a){I b?7.2g({1Z:"1M",2h:"1M",1y:"1M"},b,a):7.1E(":4j").P(H(){7.5D=7.5D||D.1g(7,"18");7.V.18="2F"}).3l()},78:D.17.2m,2m:H(a,b){I D.1D(a)&&D.1D(b)?7.78.1w(7,19):a?7.2g({1Z:"2m",2h:"2m",1y:"2m"},a,b):7.P(H(){D(7)[D(7).3F(":1G")?"1N":"1M"]()})},9G:H(b,a){I 7.2g({1Z:"1N"},b,a)},9F:H(b,a){I 7.2g({1Z:"1M"},b,a)},9E:H(b,a){I 7.2g({1Z:"2m"},b,a)},9D:H(b,a){I 7.2g({1y:"1N"},b,a)},9M:H(b,a){I 7.2g({1y:"1M"},b,a)},9C:H(c,a,b){I 7.2g({1y:a},c,b)},2g:H(k,j,i,g){J h=D.77(j,i,g);I 7[h.36===Q?"P":"36"](H(){G(7.16!=1)I Q;J f=D.1l({},h),p,1G=D(7).3F(":1G"),46=7;R(p 1n k){G(k[p]=="1M"&&1G||k[p]=="1N"&&!1G)I f.1J.1k(7);G(p=="1Z"||p=="2h"){f.18=D.1g(7,"18");f.33=7.V.33}}G(f.33!=U)7.V.33="1G";f.45=D.1l({},k);D.P(k,H(c,a){J e=2B D.28(46,f,c);G(/2m|1N|1M/.11(a))e[a=="2m"?1G?"1N":"1M":a](k);N{J b=a.6r().1I(/^([+-]=)?([\\d+-.]+)(.*)$/),2b=e.1t(M)||0;G(b){J d=3d(b[2]),2M=b[3]||"2X";G(2M!="2X"){46.V[c]=(d||1)+2M;2b=((d||1)/e.1t(M))*2b;46.V[c]=2b+2M}G(b[1])d=((b[1]=="-="?-1:1)*d)+2b;e.3G(2b,d,2M)}N e.3G(2b,a,"")}});I M})},36:H(a,b){G(D.1D(a)||(a&&a.1q==2p)){b=a;a="28"}G(!a||(1j a=="23"&&!b))I A(7[0],a);I 7.P(H(){G(b.1q==2p)A(7,a,b);N{A(7,a).1p(b);G(A(7,a).K==1)b.1k(7)}})},9X:H(b,c){J a=D.3O;G(b)7.36([]);7.P(H(){R(J i=a.K-1;i>=0;i--)G(a[i].T==7){G(c)a[i](M);a.7n(i,1)}});G(!c)7.5A();I 7}});J A=H(b,c,a){G(b){c=c||"28";J q=D.L(b,c+"36");G(!q||a)q=D.L(b,c+"36",D.2d(a))}I q};D.17.5A=H(a){a=a||"28";I 7.P(H(){J q=A(7,a);q.4s();G(q.K)q[0].1k(7)})};D.1l({77:H(b,a,c){J d=b&&b.1q==a0?b:{1J:c||!c&&a||D.1D(b)&&b,2u:b,41:c&&a||a&&a.1q!=9t&&a};d.2u=(d.2u&&d.2u.1q==4L?d.2u:D.28.5K[d.2u])||D.28.5K.74;d.5M=d.1J;d.1J=H(){G(d.36!==Q)D(7).5A();G(D.1D(d.5M))d.5M.1k(7)};I d},41:{73:H(p,n,b,a){I b+a*p},5P:H(p,n,b,a){I((-29.9r(p*29.9q)/2)+0.5)*a+b}},3O:[],48:U,28:H(b,c,a){7.15=c;7.T=b;7.1i=a;G(!c.3Z)c.3Z={}}});D.28.44={4D:H(){G(7.15.2Y)7.15.2Y.1k(7.T,7.1z,7);(D.28.2Y[7.1i]||D.28.2Y.4w)(7);G(7.1i=="1Z"||7.1i=="2h")7.T.V.18="3I"},1t:H(a){G(7.T[7.1i]!=U&&7.T.V[7.1i]==U)I 7.T[7.1i];J r=3d(D.1g(7.T,7.1i,a));I r&&r>-9p?r:3d(D.2a(7.T,7.1i))||0},3G:H(c,b,d){7.5V=1z();7.2b=c;7.3l=b;7.2M=d||7.2M||"2X";7.1z=7.2b;7.2S=7.4N=0;7.4D();J e=7;H t(a){I e.2Y(a)}t.T=7.T;D.3O.1p(t);G(D.48==U){D.48=4I(H(){J a=D.3O;R(J i=0;i<a.K;i++)G(!a[i]())a.7n(i--,1);G(!a.K){7k(D.48);D.48=U}},13)}},1N:H(){7.15.3Z[7.1i]=D.1K(7.T.V,7.1i);7.15.1N=M;7.3G(0,7.1t());G(7.1i=="2h"||7.1i=="1Z")7.T.V[7.1i]="9m";D(7.T).1N()},1M:H(){7.15.3Z[7.1i]=D.1K(7.T.V,7.1i);7.15.1M=M;7.3G(7.1t(),0)},2Y:H(a){J t=1z();G(a||t>7.15.2u+7.5V){7.1z=7.3l;7.2S=7.4N=1;7.4D();7.15.45[7.1i]=M;J b=M;R(J i 1n 7.15.45)G(7.15.45[i]!==M)b=Q;G(b){G(7.15.18!=U){7.T.V.33=7.15.33;7.T.V.18=7.15.18;G(D.1g(7.T,"18")=="2F")7.T.V.18="3I"}G(7.15.1M)7.T.V.18="2F";G(7.15.1M||7.15.1N)R(J p 1n 7.15.45)D.1K(7.T.V,p,7.15.3Z[p])}G(b)7.15.1J.1k(7.T);I Q}N{J n=t-7.5V;7.4N=n/7.15.2u;7.2S=D.41[7.15.41||(D.41.5P?"5P":"73")](7.4N,n,0,1,7.15.2u);7.1z=7.2b+((7.3l-7.2b)*7.2S);7.4D()}I M}};D.1l(D.28,{5K:{9l:9j,9i:7e,74:9g},2Y:{2e:H(a){a.T.2e=a.1z},2c:H(a){a.T.2c=a.1z},1y:H(a){D.1K(a.T.V,"1y",a.1z)},4w:H(a){a.T.V[a.1i]=a.1z+a.2M}}});D.17.2i=H(){J b=0,1S=0,T=7[0],3q;G(T)ao(D.14){J d=T.1d,4a=T,1s=T.1s,1Q=T.2z,5U=2k&&3r(5B)<9c&&!/9a/i.11(v),1g=D.2a,3c=1g(T,"30")=="3c";G(T.7y){J c=T.7y();1e(c.1A+29.2f(1Q.1C.2e,1Q.1c.2e),c.1S+29.2f(1Q.1C.2c,1Q.1c.2c));1e(-1Q.1C.6b,-1Q.1C.6a)}N{1e(T.5X,T.5W);1B(1s){1e(1s.5X,1s.5W);G(42&&!/^t(98|d|h)$/i.11(1s.2j)||2k&&!5U)2C(1s);G(!3c&&1g(1s,"30")=="3c")3c=M;4a=/^1c$/i.11(1s.2j)?4a:1s;1s=1s.1s}1B(d&&d.2j&&!/^1c|2K$/i.11(d.2j)){G(!/^96|1T.*$/i.11(1g(d,"18")))1e(-d.2e,-d.2c);G(42&&1g(d,"33")!="4j")2C(d);d=d.1d}G((5U&&(3c||1g(4a,"30")=="5x"))||(42&&1g(4a,"30")!="5x"))1e(-1Q.1c.5X,-1Q.1c.5W);G(3c)1e(29.2f(1Q.1C.2e,1Q.1c.2e),29.2f(1Q.1C.2c,1Q.1c.2c))}3q={1S:1S,1A:b}}H 2C(a){1e(D.2a(a,"6V",M),D.2a(a,"6U",M))}H 1e(l,t){b+=3r(l,10)||0;1S+=3r(t,10)||0}I 3q};D.17.1l({30:H(){J a=0,1S=0,3q;G(7[0]){J b=7.1s(),2i=7.2i(),4c=/^1c|2K$/i.11(b[0].2j)?{1S:0,1A:0}:b.2i();2i.1S-=25(7,\'94\');2i.1A-=25(7,\'aF\');4c.1S+=25(b,\'6U\');4c.1A+=25(b,\'6V\');3q={1S:2i.1S-4c.1S,1A:2i.1A-4c.1A}}I 3q},1s:H(){J a=7[0].1s;1B(a&&(!/^1c|2K$/i.11(a.2j)&&D.1g(a,\'30\')==\'93\'))a=a.1s;I D(a)}});D.P([\'5e\',\'5G\'],H(i,b){J c=\'4y\'+b;D.17[c]=H(a){G(!7[0])I;I a!=12?7.P(H(){7==1b||7==S?1b.92(!i?a:D(1b).2e(),i?a:D(1b).2c()):7[c]=a}):7[0]==1b||7[0]==S?46[i?\'aI\':\'aJ\']||D.71&&S.1C[c]||S.1c[c]:7[0][c]}});D.P(["6N","4b"],H(i,b){J c=i?"5e":"5G",4f=i?"6k":"6i";D.17["5s"+b]=H(){I 7[b.3y()]()+25(7,"57"+c)+25(7,"57"+4f)};D.17["90"+b]=H(a){I 7["5s"+b]()+25(7,"2C"+c+"4b")+25(7,"2C"+4f+"4b")+(a?25(7,"6S"+c)+25(7,"6S"+4f):0)}})})();',62,669,'|||||||this|||||||||||||||||||||||||||||||||||if|function|return|var|length|data|true|else|type|each|false|for|document|elem|null|style|event||nodeName|||test|undefined||browser|options|nodeType|fn|display|arguments|url|window|body|parentNode|add|msie|css|indexOf|prop|typeof|call|extend|script|in|replace|push|constructor|text|offsetParent|cur|status|div|apply|firstChild|opacity|now|left|while|documentElement|isFunction|filter|className|hidden|handle|match|complete|attr|ret|hide|show|dataType|trigger|doc|split|top|table|try|catch|success|break|cache|height||remove|tbody|string|guid|num|global|ready|fx|Math|curCSS|start|scrollTop|makeArray|scrollLeft|max|animate|width|offset|tagName|safari|map|toggle||done|Array|find|toUpperCase|button|special|duration|id|copy|value|handler|ownerDocument|select|new|border|exec|stack|none|opera|nextSibling|pushStack|target|html|inArray|unit|xml|bind|GET|isReady|merge|pos|timeout|delete|one|selected|px|step|jsre|position|async|preventDefault|overflow|name|which|queue|removeChild|namespace|insertBefore|nth|removeData|fixed|parseFloat|error|readyState|multiFilter|createElement|rl|re|trim|end|_|param|first|get|results|parseInt|slice|childNodes|encodeURIComponent|append|events|elems|toLowerCase|json|readyList|setTimeout|grep|mouseenter|color|is|custom|getElementsByTagName|block|stopPropagation|addEventListener|callee|proxy|mouseleave|timers|defaultView|password|disabled|last|has|appendChild|form|domManip|props|ajax|orig|set|easing|mozilla|load|prototype|curAnim|self|charCode|timerId|object|offsetChild|Width|parentOffset|src|unbind|br|currentStyle|clean|float|visible|relatedTarget|previousSibling|handlers|isXMLDoc|on|setup|nodeIndex|unique|shift|javascript|child|RegExp|_default|deep|scroll|lastModified|teardown|setRequestHeader|timeStamp|update|empty|tr|getAttribute|innerHTML|setInterval|checked|fromElement|Number|jQuery|state|active|jsonp|accepts|application|dir|input|responseText|click|styleSheets|unload|not|lastToggle|outline|mouseout|getPropertyValue|mouseover|getComputedStyle|bindReady|String|padding|pageX|metaKey|keyCode|getWH|andSelf|clientX|Left|all|visibility|container|index|init|triggered|removeAttribute|classFilter|prevObject|submit|file|after|windowData|inner|client|globalEval|sibling|jquery|absolute|clone|wrapAll|dequeue|version|triggerHandler|oldblock|ctrlKey|createTextNode|Top|handleError|getResponseHeader|parsererror|speeds|checkbox|old|00|radio|swing|href|Modified|ifModified|lastChild|safari2|startTime|offsetTop|offsetLeft|username|location|ajaxSettings|getElementById|isSimple|values|selectedIndex|runtimeStyle|rsLeft|_load|loaded|DOMContentLoaded|clientTop|clientLeft|toElement|srcElement|val|pageY|POST|unshift|Bottom|clientY|Right|fix|exclusive|detachEvent|cloneNode|removeEventListener|swap|toString|join|attachEvent|eval|substr|head|parse|textarea|reset|image|zoom|odd|even|before|prepend|exclude|expr|quickClass|quickID|uuid|quickChild|continue|Height|textContent|appendTo|contents|open|margin|evalScript|borderTopWidth|borderLeftWidth|parent|httpData|setArray|CSS1Compat|compatMode|boxModel|cssFloat|linear|def|webkit|nodeValue|speed|_toggle|eq|100|replaceWith|304|concat|200|alpha|Last|httpNotModified|getAttributeNode|httpSuccess|clearInterval|abort|beforeSend|splice|styleFloat|throw|colgroup|XMLHttpRequest|ActiveXObject|scriptCharset|callback|fieldset|multiple|processData|getBoundingClientRect|contentType|link|ajaxSend|ajaxSuccess|ajaxError|col|ajaxComplete|ajaxStop|ajaxStart|serializeArray|notmodified|keypress|keydown|change|mouseup|mousedown|dblclick|focus|blur|stylesheet|hasClass|rel|doScroll|black|hover|solid|cancelBubble|returnValue|wheelDelta|view|round|shiftKey|resize|screenY|screenX|relatedNode|mousemove|prevValue|originalTarget|offsetHeight|keyup|newValue|offsetWidth|eventPhase|detail|currentTarget|cancelable|bubbles|attrName|attrChange|altKey|originalEvent|charAt|0n|substring|animated|header|noConflict|line|enabled|innerText|contains|only|weight|font|gt|lt|uFFFF|u0128|size|417|Boolean|Date|toggleClass|removeClass|addClass|removeAttr|replaceAll|insertAfter|prependTo|wrap|contentWindow|contentDocument|iframe|children|siblings|prevAll|wrapInner|nextAll|outer|prev|scrollTo|static|marginTop|next|inline|parents|able|cellSpacing|adobeair|cellspacing|522|maxLength|maxlength|readOnly|400|readonly|fast|600|class|slow|1px|htmlFor|reverse|10000|PI|cos|compatible|Function|setData|ie|ra|it|rv|getData|userAgent|navigator|fadeTo|fadeIn|slideToggle|slideUp|slideDown|ig|responseXML|content|1223|NaN|fadeOut|300|protocol|send|setAttribute|option|dataFilter|cssText|changed|be|Accept|stop|With|Requested|Object|can|GMT|property|1970|Jan|01|Thu|Since|If|Type|Content|XMLHTTP|th|Microsoft|td|onreadystatechange|onload|cap|charset|colg|host|tfoot|specified|with|1_|thead|leg|plain|attributes|opt|embed|urlencoded|www|area|hr|ajaxSetup|meta|post|getJSON|getScript|marginLeft|img|elements|pageYOffset|pageXOffset|abbr|serialize|pixelLeft'.split('|'),0,{}))



/******************************************************************************************
         deployJava.js
 ******************************************************************************************/

/*
 * Copyright (c)  2008 Sun Microsystems, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *   - Neither the name of Sun Microsystems nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * deployJava.js
 *
 * This file is part of the Deployment Toolkit.  It provides functions for web
 * pages to detect the presence of a JRE, install the latest JRE, and easily run
 * applets or Web Start programs.  Usage guide may be found at http://<TBD>/.
 * 
 * The "live" copy of this file may be found at 
 * http://java.com/js/deployJava.js.  
 * You are encouraged to link directly to the live copy of the file.
 *
 * @version @(#)deployJava.js	1.11 08/07/11
 */

var deployJava = {
    debug: null,

    myInterval: null,
    preInstallJREList: null,
    returnPage: null,
    brand: null,
    locale: null,
    installType: null,
    
    EAInstallEnabled: false,
    EarlyAccessURL: null,
    
    // GetJava page
    getJavaURL: 'http://java.sun.com/webapps/getjava/BrowserRedirect?host=java.com',
    
    // Apple redirect page
    appleRedirectPage: 'http://www.apple.com/support/downloads/',

    // mime-type of the DeployToolkit plugin object
    mimeType: 'application/npruntime-scriptable-plugin;DeploymentToolkit',

    // location of the Java Web Start launch button graphic
    launchButtonPNG: 'http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png',


    /**
     * Returns an array of currently-installed JRE version strings.  
     * Version strings are of the form #.#[.#[_#]], with the function returning
     * as much version information as it can determine, from just family 
     * versions ("1.4.2", "1.5") through the full version ("1.5.0_06").
     *
     * Detection is done on a best-effort basis.  Under some circumstances 
     * only the highest installed JRE version will be detected, and 
     * JREs older than 1.4.2 will not always be detected.
     */
    getJREs: function() {
        var list = new Array();
        if (deployJava.isPluginInstalled()) {
            var plugin =  deployJava.getPlugin();
            for (var i = 0; i < plugin.jvms.getLength(); i++) {
                list[i] = plugin.jvms.get(i).version;
            }
        } else {
            var browser = deployJava.getBrowser();
        
            if (browser == 'MSIE') {
                if (deployJava.testUsingActiveX('1.8.0')) {
                    list[0] = '1.8.0';
                } else if (deployJava.testUsingActiveX('1.7.0')) {
                    list[0] = '1.7.0';
                } else if (deployJava.testUsingActiveX('1.6.0')) {
                    list[0] = '1.6.0';
                } else if (deployJava.testUsingActiveX('1.5.0')) {
                    list[0] = '1.5.0';
                } else if (deployJava.testUsingActiveX('1.4.2')) {
                    list[0] = '1.4.2';
                } else if (deployJava.testForMSVM()) {
                    list[0] = '1.1';
                }
            }
            else if (browser == 'Netscape Family') {
                if (deployJava.testUsingMimeTypes('1.8')) {
                    list[0] = '1.8.0';
                } else if (deployJava.testUsingMimeTypes('1.7')) {
                    list[0] = '1.7.0';
                } else if (deployJava.testUsingMimeTypes('1.6')) {
                    list[0] = '1.6.0';
                } else if (deployJava.testUsingMimeTypes('1.5')) {
                    list[0] = '1.5.0';
                } else if (deployJava.testUsingMimeTypes('1.4.2')) {
                    list[0] = '1.4.2';
                }
            } else if (browser == 'Safari') {
                if (deployJava.testUsingPluginsArray('1.8.0')) {
                    list[0] = '1.8.0';
                } else if (deployJava.testUsingPluginsArray('1.7.0')) {
                    list[0] = '1.7.0';
                } else if (deployJava.testUsingPluginsArray('1.6.0')) {
                    list[0] = '1.6.0';
                } else if (deployJava.testUsingPluginsArray('1.5.0')) {
                    list[0] = '1.5.0';
                } else if (deployJava.testUsingPluginsArray('1.4.2')) {
                    list[0] = '1.4.2';
                }
            }
        }
            
        if (deployJava.debug) {
            for (var i = 0; i < list.length; ++i) {
                alert('We claim to have detected Java SE ' + list[i]);
            }
        }
    
        return list;
    },
    
    /**
     * Triggers a JRE installation.  The exact effect of triggering an 
     * installation varies based on platform, browser, and if the 
     * Deployment Toolkit plugin is installed.
     *
     * The requestVersion string is of the form #[.#[.#[_#]]][+|*], 
     * which includes strings such as "1.4", "1.5.0*", and "1.6.0_02+".  
     * A star (*) means "any version starting within this family" and 
     * a plus (+) means "any version greater or equal to this".  
     * "1.5.0*" * matches 1.5.0_06 but not 1.6.0_01, whereas 
     * "1.5.0+" matches both.
     *
     * If the Deployment Toolkit plugin is not present, this will just call 
     * deployJava.installLatestJRE(). 
     */
    installJRE: function(requestVersion) {
        var ret = false;
        if (deployJava.isPluginInstalled()) {
            if (deployJava.getPlugin().installJRE(requestVersion)) {
                deployJava.refresh();
                if (deployJava.returnPage != null) {
                    document.location = deployJava.returnPage;
                }
                return true;
            } else {
                return false;
            }
        } else {
            return deployJava.installLatestJRE();
        }
    },


    /**
     * Triggers a JRE installation.  The exact effect of triggering an 
     * installation varies based on platform, browser, and if the 
     * Deployment Toolkit plugin is installed.
     *
     * In the simplest case, the browser window will be redirected to the 
     * java.com JRE installation page, and (if possible) a redirect back to 
     * the current URL upon successful installation.  The return redirect is 
     * not always possible, as the JRE installation may require the browser to 
     * be restarted.
     *
     * In the best case (when the Deployment Toolkit plugin is present), this
     * function will immediately cause a progress dialog to be displayed 
     * as the JRE is downloaded and installed.
     */
    installLatestJRE: function() {
        if (deployJava.isPluginInstalled()) {
            if (deployJava.getPlugin().installLatestJRE()) {
                deployJava.refresh();
                if (deployJava.returnPage != null) {
                    document.location = deployJava.returnPage;
                }
                return true;
            } else {
                return false;
            }
        } else {
            var browser = deployJava.getBrowser();
            var platform = navigator.platform.toLowerCase();
            if ((deployJava.EAInstallEnabled == 'true') && 
                (platform.indexOf('win') != -1) && 
                (deployJava.EarlyAccessURL != null)) {

                deployJava.preInstallJREList = deployJava.getJREs();
                if (deployJava.returnPage != null) {
                    deployJava.myInterval = 
                        setInterval("deployJava.poll()", 3000);
                }

                location.href = deployJava.EarlyAccessURL;

                // we have to return false although there may be an install
                // in progress now, when complete it may go to return page
                return false;
            } else {
                if (browser == 'MSIE') {
                    return deployJava.IEInstall();
                } else if ((browser == 'Netscape Family') && 
                           (platform.indexOf('win32') != -1)) {
                    return deployJava.FFInstall();
                } else {
                    location.href = deployJava.getJavaURL + 
                        ((deployJava.returnPage != null) ?
                        ('&returnPage=' + deployJava.returnPage) : '') + 
                        ((deployJava.locale != null) ?
                        ('&locale=' + deployJava.locale) : '') +
                        ((deployJava.brand != null) ? 
                         ('&brand=' + deployJava.brand) : '');
                }
                // we have to return false although there may be an install
                // in progress now, when complete it may go to return page
                return false;
            }
        }
    },


    /**
     * Ensures that an appropriate JRE is installed and then runs an applet.
     * minimumVersion is of the form #[.#[.#[_#]]], and is the minimum 
     * JRE version necessary to run this applet.  minimumVersion is optional, 
     * defaulting to the value "1.1" (which matches any JRE).  
     * If an equal or greater JRE is detected, runApplet() will call 
     * writeAppletTag(attributes, parameters) to output the applet tag, 
     * otherwise it will call installJRE(minimumVersion + '+').
     *
     * After installJRE() is called, the script will attempt to detect that the 
     * JRE installation has completed and begin running the applet, but there
     * are circumstances (such as when the JRE installation requires a browser
     * restart) when this cannot be fulfilled.
     *
     * As with writeAppletTag(), this function should only be called prior to 
     * the web page being completely rendered.  Note that version wildcards 
     * (star (*) and plus (+)) are not supported, and including them in the 
     * minimumVersion will result in an error message.
     */
    runApplet: function(attributes, parameters, minimumVersion) {
        if (minimumVersion == 'undefined' || minimumVersion == null) {
            minimumVersion = '1.1';
        }

        var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";

        var matchData = minimumVersion.match(regex);

        if (deployJava.returnPage == null) {
            // if there is an install, come back here and run the applet
            deployJava.returnPage = document.location;
        }

        if (matchData != null) {
            var browser = deployJava.getBrowser();
            if ((browser != '?') && (browser != 'Safari')) {
                if (deployJava.versionCheck(minimumVersion + '+')) {
                    deployJava.writeAppletTag(attributes, parameters);
                } else if (deployJava.installJRE(minimumVersion + '+')) {
                    // after successfull install we need to refresh page to pick
                    // pick up new plugin
                    deployJava.refresh();
                    location.href = document.location;
                    deployJava.writeAppletTag(attributes, parameters);
                }
            } else {
                // for unknown or Safari - just try to show applet
                deployJava.writeAppletTag(attributes, parameters);
            }
        } else {
            if (deployJava.debug) {
                alert('Invalid minimumVersion argument to runApplet():' + 
                      minimumVersion);
            }
        }
    },

    
    /**
     * Outputs an applet tag with the specified attributes and parameters, where
     * both attributes and parameters are associative arrays.  Each key/value 
     * pair in attributes becomes an attribute of the applet tag itself, while
     * key/value pairs in parameters become <PARAM> tags.  No version checking 
     * or other special behaviors are performed; the tag is simply written to 
     * the page using document.writeln().
     *
     * As document.writeln() is generally only safe to use while the page is 
     * being rendered, you should never call this function after the page 
     * has been completed.
     */
    writeAppletTag: function(attributes, parameters) {
        var s = '<' + 'applet ';
        for (var attribute in attributes) {
            s += (' ' + attribute + '="' + attributes[attribute] + '"');
        }
        s += '>';
        document.write(s);
    
        if (parameters != 'undefined' && parameters != null) {
            for (var parameter in parameters) {
                s = '<param name="' + parameter + '" value="' + 
                    parameters[parameter] + '">';
                document.write(s);
            }
        }
        document.write('<' + '/' + 'applet' + '>');
    },
    
    
     /**
      * Returns true if there is a matching JRE version currently installed 
      * (among those detected by getJREs()).  The versionPattern string is 
      * of the form #[.#[.#[_#]]][+|*], which includes strings such as "1.4", 
      * "1.5.0*", and "1.6.0_02+".  
      * A star (*) means "any version within this family" and a plus (+) means 
      * "any version greater or equal to the specified version".  "1.5.0*"
      * matches 1.5.0_06 but not 1.6.0_01, whereas "1.5.0+" matches both.
      *
      * If the versionPattern does not include all four version components 
      * but does not end with a star or plus, it will be treated as if it 
      * ended with a star.  "1.5" is exactly equivalent to "1.5*", and will 
      * match any version number beginning with "1.5".
      *
      * If getJREs() is unable to detect the precise version number, a match 
      * could be ambiguous.  For example if getJREs() detects "1.5", there is 
      * no way to know whether the JRE matches "1.5.0_06+".  versionCheck() 
      * compares only as much of the version information as could be detected, 
      * so versionCheck("1.5.0_06+") would return true in in this case.
      *
      * Invalid versionPattern will result in a JavaScript error alert.  
      * versionPatterns which are valid but do not match any existing JRE 
      * release (e.g. "32.65+") will always return false.
      */
    versionCheck: function(versionPattern)
    {
        var index = 0;
        var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$";

        var matchData = versionPattern.match(regex);

        if (matchData != null) {
            var familyMatch = true;

            var patternArray = new Array();

            for (var i = 1; i < matchData.length; ++i) {
                // browser dependency here.
                // Fx sets 'undefined', IE sets '' string for unmatched groups
                if ((typeof matchData[i] == 'string') && (matchData[i] != '')) {
                    patternArray[index] = matchData[i];
                    index++;
                }
            }

            if (patternArray[patternArray.length-1] == '+') {
                familyMatch = false;
                patternArray.length--;
            } else {
                if (patternArray[patternArray.length-1] == '*') {
                    patternArray.length--;
                }
            }

            var list = deployJava.getJREs();       
            for (var i = 0; i < list.length; ++i) {
                if (deployJava.compareVersionToPattern(list[i], patternArray, 
                                                       familyMatch)) {
                    return true;
                }
            }
  
            return false;
        } else {
            alert('Invalid versionPattern passed to versionCheck: ' + 
                  versionPattern);
            return false;
        }
    },


    /**
     * Returns true if an installation of Java Web Start of the specified 
     * minimumVersion can be detected.  minimumVersion is optional, and 
     * if not specified, '1.4.2' will be used. 
     * (Versions earlier than 1.4.2 may not be detected.)
     */
    isWebStartInstalled: function(minimumVersion) {

        var browser = deployJava.getBrowser();
        if ((browser == '?') || (browser == 'Safari')) {
            // we really don't know - better to try to use it than reinstall
            return true;
        }

        if (minimumVersion == 'undefined' || minimumVersion == null) {
            minimumVersion = '1.4.2';
        }

        var retval = false;
        var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
        var matchData = minimumVersion.match(regex);

        if (matchData != null) {
            retval = deployJava.versionCheck(minimumVersion + '+');
        } else {
            if (deployJava.debug) {
                alert('Invalid minimumVersion argument to isWebStartInstalled(): ' + minimumVersion);
            }
            retval = deployJava.versionCheck('1.4.2+');
        }
        return retval;
    },
  
  
    /**
     * Outputs a launch button for the specified JNLP URL.  When clicked, the 
     * button will ensure that an appropriate JRE is installed and then launch 
     * the JNLP application.  minimumVersion is of the form #[.#[.#[_#]]], and 
     * is the minimum JRE version necessary to run this JNLP application.  
     * minimumVersion is optional, and if it is not specified, '1.4.2' 
     * will be used.
     * If an appropriate JRE or Web Start installation is detected, 
     * the JNLP application will be launched, otherwise installLatestJRE() 
     * will be called.
     *
     * After installLatestJRE() is called, the script will attempt to detect 
     * that the JRE installation has completed and launch the JNLP application,
     * but there are circumstances (such as when the JRE installation 
     * requires a browser restart) when this cannot be fulfilled.
     */
    createWebStartLaunchButton: function(jnlp, minimumVersion) { 

        if (deployJava.returnPage == null) {
            // if there is an install, come back and run the jnlp file
            deployJava.returnPage = jnlp;
        }

        var url = 'javascript:' +
                  'if (!deployJava.isWebStartInstalled(&quot;' + 
                      minimumVersion + '&quot;)) {' + 
                      'if (deployJava.installLatestJRE()) {' + 
                        'if (deployJava.launch(&quot;' + jnlp + '&quot;)) {}' +
                      '}' +
                  '} else {' +
                      'if (deployJava.launch(&quot;' + jnlp + '&quot;)) {}' +
                  '}';

        document.write('<' + 'a href="' + url + 
                       '" onMouseOver="window.status=\'\'; ' +
                       'return true;"><' + 'img ' +
                       'src="' + deployJava.launchButtonPNG + '" ' + 
                       'border="0" /><' + '/' + 'a' + '>');
    },


    /**
     * Launch a JNLP application, (using the plugin if available)
     */
    launch: function(jnlp) {
        if (deployJava.isPluginInstalled()) {
            return deployJava.getPlugin().launch(jnlp);
        } else {
            document.location=jnlp;
            return true;
        }
    },

    
    /*
     * returns true if the ActiveX or XPI plugin is installed
     */
    isPluginInstalled: function() {
        var plugin = deployJava.getPlugin();
        if (plugin && plugin.jvms) {
            return true;
        } else {
            return false;
        }
    },
    
    /* 
     * returns true if the plugin is installed and AutoUpdate is enabled
     */
    isAutoUpdateEnabled: function() {
        if (deployJava.isPluginInstalled()) {
            return deployJava.getPlugin().isAutoUpdateEnabled();
        }
        return false;
    },

    /* 
     * sets AutoUpdate on if plugin is installed
     */
    setAutoUpdateEnabled: function() { 
        if (deployJava.isPluginInstalled()) { 
            return deployJava.getPlugin().setAutoUpdateEnabled(); 
        }
        return false;
    },

    /*
     * sets the preferred install type : null, online, kernel
     */
    setInstallerType: function(type) {
        deployJava.installType = type;
        if (deployJava.isPluginInstalled()) {
            return deployJava.getPlugin().setInstallerType(type);
        }
        return false;
    },

    /*
     * sets additional package list - to be used by kernel installer
     */
    setAdditionalPackages: function(packageList) {
        if (deployJava.isPluginInstalled()) {
            return deployJava.getPlugin().setAdditionalPackages(
                                                     packageList);
        }
        return false;
    },

    /*
     * sets preference to install Early Access versions if available
     */
    setEarlyAccess: function(enabled) {
        deployJava.EAInstallEnabled = enabled;
    },

    /*
     * Determines if the next generation plugin (Plugin II) is default
     */
    isPlugin2: function() {
        if (deployJava.isPluginInstalled()) {
            try {
                return deployJava.getPlugin().isPlugin2();
            } catch (err) {
                // older plugin w/o isPlugin2() function - just fall through
            }
        }
        return false;
    },
       

    getPlugin: function() {
        deployJava.refresh();
        var ret = document.getElementById('deployJavaPlugin');
        return ret;
    },

    compareVersionToPattern: function(version, patternArray, familyMatch) {
        var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
        var matchData = version.match(regex);  

        if (matchData != null) { 
            var index = 0;
            var result = new Array();

            for (var i = 1; i < matchData.length; ++i) {
                if ((typeof matchData[i] == 'string') && (matchData[i] != ''))
                {
                    result[index] = matchData[i];
                    index++;
                }
            }

            var l = Math.min(result.length, patternArray.length);

            if (familyMatch) {
                for (var i = 0; i < l; ++i) {
                    if (result[i] != patternArray[i]) return false;
                }

                return true;
            } else {
                for (var i = 0; i < l; ++i) {
                    if (result[i] < patternArray[i]) {
                        return false;
                    } else if (result[i] > patternArray[i]) {
                        return true;
                    }
                }
                
                return true;
            }
        } else {
            return false;
        }
    },

  
    getBrowser: function() {
        var browser = navigator.userAgent.toLowerCase();
    
        if (deployJava.debug) {
            alert('userAgent -> ' + browser);
        }
    
        if ((navigator.vendor) && 
            (navigator.vendor.toLowerCase().indexOf('apple') != -1) &&
            (browser.indexOf('safari') != -1)) {
            if (deployJava.debug) {
                alert('We claim to have detected "Safari".');
            }
            return 'Safari';
        } else if (browser.indexOf('msie') != -1) {
            if (deployJava.debug) {
                alert('We claim to have detected "IE".');
            }
            return 'MSIE';
        } else if ((browser.indexOf('mozilla') != -1) || 
                   (browser.indexOf('firefox') != -1)) {
            if (deployJava.debug) {
                alert('We claim to have detected a Netscape family browser.');
            }
            return 'Netscape Family';
        } else {
            if (deployJava.debug) {
                alert('We claim to have failed to detect a browser.');
            }
            return '?';
        }
    },
    
    
    testUsingActiveX: function(version) {
        var objectName = 'JavaWebStart.isInstalled.' + version + '.0';
    
        if (!ActiveXObject) {
            if (deployJava.debug) {
              alert ('Browser claims to be IE, but no ActiveXObject object?');
            }
            return false;
        }
    
        try {
            return (new ActiveXObject(objectName) != null);
        } catch (exception) {
            return false;
        }
    },
    

    testForMSVM: function() {
        var clsid = '{08B0E5C0-4FCB-11CF-AAA5-00401C608500}';

        if (typeof oClientCaps != 'undefined') {
            var v = oClientCaps.getComponentVersion(clsid, "ComponentID");
            if ((v == '') || (v == '5,0,5000,0')) {
                return false;
            } else {
                return true;
            } 
        } else {
            return false;
        }
    },

    
    testUsingMimeTypes: function(version) {
        if (!navigator.mimeTypes) {
            if (deployJava.debug) {
                alert ('Browser claims to be Netscape family, but no mimeTypes[] array?');
            }
            return false;
        }
    
        for (var i = 0; i < navigator.mimeTypes.length; ++i) {
            s = navigator.mimeTypes[i].type;
            var m = s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/);
            if (m != null) {
                if (deployJava.compareVersions(m[1], version)) {
                    return true;   
                }
            }
        }
        return false;
    },
    
    
    testUsingPluginsArray: function(version) {
        if ((!navigator.plugins) || (!navigator.plugins.length)) {
            if (deployJava.debug) {
                alert ('Browser claims to be Safari, but no plugins[] array?');
            }
            return false;
        }

        for (var i = 0; i < navigator.plugins.length; ++i) {
            s = navigator.plugins[i].description;
    
            if (s.search(/^Java Switchable Plug-in/) != -1) {
                return true;
            }
    
            m = s.match(/^Java (1\.4\.2|1\.5|1\.6|1\.7).* Plug-in/);
            if (m != null) {
                if (deployJava.compareVersions(m[1], version)) return true; 
            }
        }
        return false;
    },
    
    IEInstall: function() {
    
        location.href = deployJava.getJavaURL + 
            ((deployJava.returnPage != null) ?
            ('&returnPage=' + deployJava.returnPage) : '') +
            ((deployJava.locale != null) ?
            ('&locale=' + deployJava.locale) : '') +
            ((deployJava.brand != null) ? ('&brand=' + deployJava.brand) : '') +
            ((deployJava.installType != null) ? 
             ('&type=' + deployJava.installType) : '');

         // should not actually get here
         return false;
    },
    
    done: function (name, result) {
    },
    
    FFInstall: function() {

        location.href = deployJava.getJavaURL + 
            ((deployJava.returnPage != null) ?
            ('&returnPage=' + deployJava.returnPage) : '') +
            ((deployJava.locale != null) ?
            ('&locale=' + deployJava.locale) : '') +
            ((deployJava.brand != null) ? ('&brand=' + deployJava.brand) : '') +
            ((deployJava.installType != null) ? 
                ('&type=' + deployJava.installType) : '');

         // should not actually get here
         return false;
    },

    // return true if 'installed' (considered as a JRE version string) is
    // greater than or equal to 'required' (again, a JRE version string).
    compareVersions: function(installed, required) {

        var a = installed.split('.');
        var b = required.split('.');
    
        for (var i = 0; i < a.length; ++i) {
            a[i] = Number(a[i]);
        }
        for (var i = 0; i < b.length; ++i) {
            b[i] = Number(b[i]);
        }
        if (a.length == 2) {
            a[2] = 0;      
        }
    
        if (a[0] > b[0]) return true;
        if (a[0] < b[0]) return false;
    
        if (a[1] > b[1]) return true;
        if (a[1] < b[1]) return false;
    
        if (a[2] > b[2]) return true;
        if (a[2] < b[2]) return false;
    
        return true;
    },
    
    
    enableAlerts: function() {
        deployJava.debug = true;
    },

    poll: function() {

        deployJava.refresh();
        var postInstallJREList = deployJava.getJREs();           

        if ((deployJava.preInstallJREList.length == 0) && 
            (postInstallJREList.length != 0)) {
            clearInterval(deployJava.myInterval);
            if (deployJava.returnPage != null) {
                location.href = deployJava.returnPage;
            };
        }

        if ((deployJava.preInstallJREList.length != 0) && 
            (postInstallJREList.length != 0) &&
            (deployJava.preInstallJREList[0] != postInstallJREList[0])) {
            clearInterval(deployJava.myInterval);
            if (deployJava.returnPage != null) {
                location.href = deployJava.returnPage;
            }
        }

    },
    
    writePluginTag: function() {
        var browser = deployJava.getBrowser();
        if (browser == 'MSIE') {
            document.write('<' + 
                'object classid="clsid:CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA" ' +
                'id="deployJavaPlugin" width="0" height="0">' +
                '<' + '/' + 'object' + '>');
        } else if (browser == 'Netscape Family') {
            if (navigator.mimeTypes != null) for (var i=0; 
                    i < navigator.mimeTypes.length; i++) {
                if (navigator.mimeTypes[i].type == deployJava.mimeType) {
                    if (navigator.mimeTypes[i].enabledPlugin) {
                        document.write('<' + 
                            'embed id="deployJavaPlugin" type="' + 
                            deployJava.mimeType + '" hidden="true" />');
                    }
                }
           }
        }
    },

    refresh: function() {
        navigator.plugins.refresh(false);

        var browser = deployJava.getBrowser();
        if (browser == 'Netscape Family') {
            var plugin = document.getElementById('deployJavaPlugin');
            // only do this again if no plugin
            if (plugin == null) {
                if (navigator.mimeTypes != null) for (var i=0;
                    i < navigator.mimeTypes.length; i++) {
                    if (navigator.mimeTypes[i].type == deployJava.mimeType) {
                        if (navigator.mimeTypes[i].enabledPlugin) {
                            document.write('<' +
                                'embed id="deployJavaPlugin" type="' +
                                deployJava.mimeType + '" hidden="true" />');
                        }
                    }
               }
            }
        }
    },

    do_initialize: function() {
        deployJava.writePluginTag();
        if (deployJava.locale == null) {
            var loc = null;

            if (loc == null) try {
                loc = navigator.userLanguage;
            } catch (err) { }

            if (loc == null) try {
                loc = navigator.systemLanguage;
            } catch (err) { }
    
            if (loc == null) try {
                loc = navigator.language;
            } catch (err) { }
    
            if (loc != null) {
                loc.replace("-","_")
                deployJava.locale = loc;
            }
        }
    }
      
};
deployJava.do_initialize();




/******************************************************************************************
         vyewmain.js
 ******************************************************************************************/

/**
 * vyewmain.js
 * Supporting functions for content/vyewmain.php
 * Copyright (c)2006-2008 Vyew, Simulat, Inc.
 *
 * FUNCTION CATEGORIES:
 * 	- init and ajax comm/relay stuff
 * 	- Screencap/Java stuff 
 * 	- Utils/Getters/Setters
 * 	- Window Manip Stuff
 *
 * CHANGE LOG:
 * -----------
 *		TODO: isolate which functions are not needed anymore and clean them out
 *		TODO: check for url calls to the lobby (no book passed after # in url)
 *					and call out to main frame to open myhome frame first before flash
 *		4/22/09 - ajaxForDocEx, controls whether ajax should be used at all
 *				  but the final word on whether it is used, is based on user pref in cakes
 *				  which is set by vyew.checkLogin, and set as myhome="ajax" cookie
 *
 * 		9/16/08 - There was a problem with calling hash functions when vyewmain was put
 * 				  into an iframe. For now they ahve been wrapped in if(ajaxForDocEx),
 *				  but later, probably vyew will not work in an iframe because of ajax docex
 *		8/26/08 - Moved all functions out of vyewmain.php into vyewmain.js	
 *
 *
 */

//-- USE AJAX FOR MYHOME/DOC EXPLORER?
//-- If changing this var, also change in content/data/umeeting.xml
//-- This variable sets whether ajax for be loaded dynamically or not
var ajaxForDocEx=true;	// global - whether ajax should be used at all
						// but it being actually used then is still dependant
						// on users own pref_myhome cake
var reqType;
var reqType;
var myhomeTop=62;

funcsCalled='';

/**
 * Init follows this logic for deciding what to do:
 * Examing incoming top.window.url...
 * if lobby String is passed, need to find out what that mid translates to
 * 	isBookRequest?
 *  	case 1: load flash and continue like normal
 *	else isLobby:
 * 		check for SID in db
 * 		isUser Valid and Owner of room??
 * 		case 2: NO: Load flash frame
 * 		case 3: YES: 
 *			Check user cookie prefs for myhome=ajax,
 *		case 4:  IF AJAX, load ajax Myhome first, and flash in bg
 *		case 5:  ELSE load old flash myhome
 */
function initVyewmain() 
{
	initCalled=true;
	if(ajaxForDocEx){
		qs_mid=urlSegment("?mid");
		if(qs_mid && qs_mid.match(/[0-9]+_.+/i)) reqType="book";
		else reqType=(hashUrlSegment(1,top)) ? "book" : "lobby";
		var chkLoginOpts={}, requestedMid=hashUrlSegment(0,top);
		//--- If mid isnt numeric, need to translate it: custId->mID
		if (isNaN(requestedMid)){ chkLoginOpts={callFuncs:{customID2MID:requestedMid}}; }
	}


	//setup onMouseMove
/*
	if (document.captureEvents && Event.MOUSEMOVE)
    	document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = function(){
		try{
			dbg('onmousemove',bAlert,bAlert.onMouseMove);
			bAlert.onMouseMove();
		}catch(e){}		
	}
*/

	browserType = 1;
	if($.browser.msie) browserType = 1;
	if($.browser.mozilla) browserType = 2;
	if($.browser.safari) browserType = 3;

	//case 1
	if(!ajaxForDocEx || reqType=="book")	init2('flash');
	else {
		//case 2
		if(getCookie('home')=='1'){ return init2('myhome'); }

        vyew.checkLogin(function(res) {
            if(typeof res != "undefined" && res.uid){		//--- is logged in
															//---check if user owns this meeting
				try{ requestedMid=parseInt(res.calledFuncs.customID2MID) }
				catch(e){ }	
				if(requestedMid!=res.baseMID) requestedMid=res.baseMID;
				// case 3
				if(!empty(requestedMid)) { 
					if(getCookie("myhome")=="ajax"){
						return init2('myhome'); 	//case 4
					}else{
						return init2('flash'); 		//case 5
					}
				}
            }
			// all else fails, load flash
			init2('flash');
        },this, chkLoginOpts);
	}
	try{
		vyew.sidChecker.init();
	}catch(e){}
}


/**
 * id could either be "myhome", "flash"
 * Ext.onReady(myhome.app.init, myhome.app);
 */
function init2(id)
{
 	if(!id || !ajaxForDocEx) id="flash";
	ajax="&useajax=";
	ajax+=(getCookie("myhome")=="ajax") ? "yes" : "no";
	if(id=="myhome"){ 
		loadMyHomeIfNotLoaded('firstload=1');
		openMyHome('firstload=1');
		setTimeout("makeSwf('"+ajax+"')",10000);
		setTimeout("fixIframeHeight()", 5000);
	}else{
		resize=screenCapture=ii=flashinstalled=flashversion=browserType=0;
		traceVal=action="";
		windowState = "max";
		sharing = false;
		makeSwf(ajax);
		$('#myHomeBox').hide();
	}

}


/**
 * Writes SWF object stuff to proper DIV. 
 * Depends on global var: serverQS(query string) to be set
 */
function makeSwf(opt)
{ 
	opt=(opt) ? opt : "";
	funcsCalled+=' makeSwf() ,';
	if(swfIsMade) return;
	swfIsMade=true;
	try {
		serverQS=(serverQS) ? serverQS : ''; 
	}catch(e){ serverQS=''; }
	var baseURL="/"+vyew.getVers()+"/content/";
    var swfURL="sm_main.swf?browserVersion="+BrowserDetect.version+"&browserType="
                +browserType+"&bgColor=0x9E9E9E&lcID=meet1234&"+serverQS+opt;
	var flashvars = {};
	var params = {scale:"noscale"};
	var attributes = {id:"sm_main"};
	attributes.id = "sm_main";
	$('#flashcontent').show();
	var flashHeight=(getCookie("myhome")=="ajax" && reqType!="book") ? myhomeTop+"px" : "100%"; /*myhomeheight*/
	swfobject.embedSWF(swfURL, "flashcontent", "100%", flashHeight,
			"9.0", baseURL+"expressInstall.swf", flashvars, params, attributes);
	//if(reqType=="lobby") $(getMovie('sm_main')).css('height',60);

	//--- set up events
	window.onbeforeunload = function()
	{
		try{getMovie('sm_main').shutdown();}
		catch(e){}
	}
	window.onresize = onResize;
}
swfIsMade=false;




/**
 * Refreshes flash obj to check for socket connection 
 * @param port - Number, the local port to attempt to connect to
 * @param id - unique ID, for communication back via localconncetion
 */
function sockcheck(port,id)
{
	funcsCalled+=' sockcheck(port,id) ,';
	var swfurl="sockcheck.swf?port="+port+"&id="+id;
	$("#sockcheck").html("<div id='sockcheck_inside'><div>");
	var attributes = {id:"sockcheck_inside"};
	swfobject.embedSWF(swfurl, "sockcheck_inside", "1", "1", "8.0.0",
		false, {}, {}, attributes);
}

/**
 * Css nightmare: Cant get the myHomeBox iframe to start at 62px from top,
 * and go all the way to exact bottom of screen. if you set height at 100%
 * it goes 62px past bottom. If i set iframe to 0px at top, it interferes with flash
 * So i have to calculate the screen height, and subtract height of flash header
 */
function fixIframeHeight()
{
	var s=getStageDims();
	if(s.h && s.h>100){
		$("#myHomeBox").css('height',s.h-myhomeTop);	 /*myhomeheight*/
	}
}

function getmyhome(){ return frames['myHomeBox']; }

/**
 * Loads myhome if not already loaded
 * @param initAfterLoad {bool} - whether myhome.app.init() should be called
 * @param callback {func} - calls after load with one param: true=done loading, 
 * 							false=was already loaded before
 */
function loadMyHomeIfNotLoaded(args)
{
	var src=$("#myHomeBox").attr('src');
	if(src && src.match(/^myhome.html/)) return;	
	if(args && args.length>1)	$("#myHomeBox").attr('src','myhome.html?'+args);	
	else $("#myHomeBox").attr('src','myhome.html');
}










/**
 * -------------------------------------------------------------------
 * EXTERNAL INTERFACE CALLS FROM FLASH
 * -------------------------------------------------------------------
 */

function openMyHome(args)
{
	$(getMovie('sm_main')).css('height',myhomeTop) /*myhomeheight*/
	$("#commentsViewerBox").hide();
    $('#myHomeBox').show();	
	loadMyHomeIfNotLoaded(args);
	if(frames['myHomeBox'] && frames['myHomeBox'].gMsg )
		frames['myHomeBox'].gMsg.fireEvent('onActivateMyHome');
	
}
function openCommentsViewer(bid,sid)
{
	var href = "CommentsViewer.php?bid="+bid+"&sid="+sid;
	 $(getMovie('sm_main')).css('height',0)
	$("#commentsViewerBox").attr('src',href);
	$("#commentsViewerBox").show();
}
function closeCommentsViewer()
{
	$("#commentsViewerBox").hide();
	$(getMovie('sm_main')).css('height','100%')
}
function closeFrame()
{
	$(getMovie('sm_main')).css('height','100%')
	$('#myHomeBox').hide();
}
var closeImageEditor=closeFrame;


/**
 * Open the bottom frame for Picnik integration
 * @param url - String, the URL to load into the bottom frame
 */
function openImageEditor(url)
    {
	funcsCalled+=' openImageEditor(url) ,';
        if(url) parent.openImageEditor(url);
    }

/**
 * Close the bottom frame
 */
function closeImageEditor()
    {
	funcsCalled+=' closeImageEditor() ,';
        parent.closeImageEditor();
    }

/**
 * Call a javascript function defined in the parent frameset
 * NOTE: CHANGE!! This func now calls in current frame not parent,
 * reason: so it will work in an iframe when someone refs vyewmain directly
 * @param cmd - String, the name of the function to call
 * @param var1 - first argument to pass
 * @param var2 - second argument to pass
 */
function callFrameset(cmd,var1,var2)
    {
	funcsCalled+=' callFrameset(cmd,var1,var2) ,';
        this[cmd](var1,var2);
    }

/**
 * Helper function to pass events from flash to the Ajax MyHome page
 * @param name - name of the event to pass
 * @param var1 - first argument
 * @param var2 - second argument
 */
function onSendAjaxEvent( name, var1, var2 )
    {
		funcsCalled+=' onSendAjaxEvent( ,';
        try{
            //nf parent.botframe.myhome.app.onSendAjaxEvent( name, var1, var2 );
            frames['myHomeBox'].myhome.app.onSendAjaxEvent( name, var1, var2 );
        }catch(e){ dbg('Error 9984: onSendAjaxEvent fail') }
    }



function getMyLang(){
	var lang = navigator.browserLanguage;
	if(lang == 'undefined' || lang == undefined){
		lang = navigator.language;
	}
	//alert("Language: " + lang);
	return lang;
}









/**
 * -------------------------------------------------------------------
 * SCREEN CAPTURE  
 * -------------------------------------------------------------------
 */

var appletLoaded = 0;
var appletLoadedLive =0;


/**
 * Calls out to other frame to tell it to load the capture applet
 * The applet auto-captures on first load, which is why we pass all the same
 * args as with takeScreen()
 * This function is called by takeScreen() if applet not loaded
 * @see doLoadCapture - not sure what the diff is?!
 */
function loadCapture(x,y,w,h,w2,c)
{
	funcsCalled+=' loadCapture(x,y,w,h,w2,c) ,';
        traceln('loadCapture called from vyew1');
        var agt=navigator.userAgent.toLowerCase();
        var is_major = parseInt(navigator.appVersion);

        var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
        && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
        && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
        var is_nav4up = (is_nav && (is_major >= 4));

        var okToLoadJava = true;

        if(is_nav4up) {
        // Refresh 'navigator.plugins' to get newly installed plugins.
        // Use 'navigator.plugins.refresh(false)' to refresh plugins
        // without refreshing open documents (browser windows)
            //if(navigator.plugins) {
            //  navigator.plugins.refresh(false);
            //}

        //gotMsg("after navigator.plugins");

            // check for Java plugin in installed plugins
            if(navigator.mimeTypes) {
                //gotMsg("navigator.mimeTypes");
                for (i=0; i < navigator.mimeTypes.length; i++) {
                    //gotMsg("inside mimeTypes for loop");
                    if( (navigator.mimeTypes[ i].type != null)
                        && (navigator.mimeTypes[i].type.indexOf("application/x-java-applet;jpi-version=1.3") != -1) ) {
                        gotMsg("JS: uninstall Java v1.3");
                        alert("Due to incompatiblity between Java Runtime v1.3 and Firefox, please uninstall JRE v1.3.");
                        okToLoadJava = false;
                        break;
                    }
                }
            }
        }

        if (typeof okToLoadJava != "undefined" && okToLoadJava) {
            gotMsg("okToLoadJava");
            appletLoaded = 1;
            //parent.capture.loadCapture(x,y,w,h,w2,c);
            doLoadCapture(x,y,w,h,w2,c);
        }
        traceln('loadCapture complete');
}


function doLoadCapture(x, y, w, h, w2, c)
{
	funcsCalled+=' doLoadCapture(x, ,';
        var obj = document.getElementById('capt1');
        var h = "";
        if (browserType == 1)
        {
            h += '<OBJECT name="Scr" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="760" HEIGHT="50" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_03-windows-i586.cab#Version=1,4,2,0"> ';
            h += '<PARAM NAME="name" VALUE="Vyew Screen Capture"> ';
            h += '<PARAM NAME="ARCHIVE" VALUE="/'+vyew.getVers()+'/content/ScreenCapture.jar"> ';
            h += '<PARAM NAME="CODE" VALUE="org.sim.ScreenCapture.class"> ';
            h += '<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4.2">';
            h += '<PARAM NAME="CX" VALUE="'+x+'"> ';
            h += '<PARAM NAME="CY" VALUE="'+y+'"> ';
            h += '<PARAM NAME="CW" VALUE="'+w+'"> ';
            h += '<PARAM NAME="CH" VALUE="'+h+'"> ';
            h += '<PARAM NAME="CW2" VALUE="'+w2+'"> ';
            h += '<PARAM NAME="CAPID" VALUE="'+c+'"> ';
            h += '<PARAM NAME="bType" VALUE="ie"> ';
            h += '<PARAM NAME="scriptable" value="true"> ';
            h += '<PARAM NAME="mayscript" VALUE="true"> ';
            h += '<PARAM NAME="uploadURL" VALUE="'+HTTP_HEAD+"://"+HTTP_SERVER+'/screendev/upload.php"> ';
            h += '<PARAM NAME="uploadLoc" VALUE="'+HTTP_HEAD+"://"+HTTP_SERVER+'/screendev/"> ';
            h += 'No Java 2 Platform, Standard Edition, v 1.4+';
            h += '</OBJECT> ';
        }
        else
        {
                h += '<applet name="Vyew Screen Capture" id="Scr" code="org.sim.ScreenCapture" ';
                h += '  archive="/'+vyew.getVers()+'/content/ScreenCapture.jar"';
                h += '  height="50"';
                h += '          width="760"';
                h += '  MAYSCRIPT>';
            h += '<PARAM NAME="CX" VALUE="'+x+'"> ';
            h += '<PARAM NAME="CY" VALUE="'+y+'"> ';
            h += '<PARAM NAME="CW" VALUE="'+w+'"> ';
            h += '<PARAM NAME="CH" VALUE="'+h+'"> ';
            h += '<PARAM NAME="CW2" VALUE="'+w2+'"> ';
            h += '<PARAM NAME="CAPID" VALUE="'+c+'"> ';
            h += '<PARAM NAME="bType" VALUE="ie"> ';
            h += '<PARAM NAME="scriptable" value="true"> ';
            h += '<PARAM NAME="mayscript" VALUE="true"> ';
            h += '<PARAM NAME="uploadURL" VALUE="'+HTTP_HEAD+"://"+HTTP_SERVER+'/screendev/upload.php"> ';
            h += '<PARAM NAME="uploadLoc" VALUE="'+HTTP_HEAD+"://"+HTTP_SERVER+'/screendev/"> ';
                h += '  Sorry, no java found';
                h += '</applet>';
        }

        obj.innerHTML = h;
    }

/**
 * Called by startshare2
 */
function doLoadLiveCapture(mid, uid, start)
    {
dbg('doload live cap',mid,uid,start);
		gotMsg("load live");
		funcsCalled+=' doLoadLiveCapture(mid, ,';
        //alert("load live capture '"+mid+"', "+uid+" - "+browserType);
        var obj = $("#capt");
        var h = "";

		if(obj == null)
			gotMsg("ERROR!! capt element null??");
		dbg('loadlivecap:c');
        if (browserType == 1)
        {
			gotMsg("btype 1");
            h += '<OBJECT name="Scr1" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="760" HEIGHT="50" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_03-windows-i586.cab#Version=1,4,2,0"> ';
            h += '<PARAM NAME="name" VALUE="Real-time Desktop Sharing"> ';
            h += '<PARAM NAME="ARCHIVE" VALUE="/'+vyew.getVers()+'/content/SDesktopSharingApplet.jar"> ';
            h += '<PARAM NAME="CODE" VALUE="dsapplet.DSApplet"> ';
            h += '<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4.2">';
                h += '<PARAM NAME="start" VALUE="1"> ';
                h += '  <PARAM name="meetingID" value="'+mid+'">';
                h += '  <PARAM name="userID" value="'+uid+'">';
                h += '  <PARAM name="captureDelay" value="100">';
                h += '  <PARAM name="frameKeyQuality" value="65">';
                h += '  <PARAM name="frameDeltaQuality" value="45">';
                h += '  <PARAM name="uploading" value="true">';
                h += '  <PARAM name="useJavascript" value="true">';
                h += '  <PARAM name="browserWindowName" value="Vyew">';
                h += '  <PARAM name="useScreenCapture" value="false">';
                h += '  <PARAM name="useMenuRestore" value="false">';
                h += '  <PARAM name="canSingleApplication" value="false">';
                h += '  <PARAM name="serverURL" value='+HTTP_HEAD+"://"+HTTP_SERVER+'/screens/live/upload.php?mid='+mid+'&uid='+uid+'">';
            h += '<PARAM NAME="scriptable" value="true"> ';
            h += '<PARAM NAME="mayscript" VALUE="true"> ';
            h += 'No Java 2 Platform, Standard Edition, v 1.6+';
            h += '</OBJECT> ';
        }
        else
       {
			gotMsg("btype 2");
                h += '<applet name="Real-time Desktop Sharing" id="dsapplet" code="dsapplet.DSApplet" ';
                h += '  archive="/'+vyew.getVers()+'/content/SDesktopSharingApplet.jar"';
                h += '  height="50"';
                h += '          width="760"';
                h += '  MAYSCRIPT>';
                h += '  <PARAM name="meetingID" value="'+mid+'">';
                h += '  <PARAM name="userID" value="'+uid+'">';
                h += '  <PARAM name="captureDelay" value="100">';
                h += '  <PARAM name="frameKeyQuality" value="65">';
                h += '  <PARAM name="frameDeltaQuality" value="45">';
                h += '  <PARAM name="uploading" value="true">';
                h += '  <PARAM name="useJavascript" value="true">';
                h += '  <PARAM name="browserWindowName" value="Vyew">';
                h += '  <PARAM name="useScreenCapture" value="false">';
                h += '  <PARAM name="useMenuRestore" value="false">';
                h += '  <PARAM name="canSingleApplication" value="false">';
                h += '  <PARAM name="serverURL" value='+HTTP_HEAD+"://"+HTTP_SERVER+'/screens/live/upload.php?mid='+mid+'&uid='+uid+'">';
                h += '  Sorry, no java found';
                h += '</applet>';

        }

		gotMsg("obj = "+obj);
        obj.html(h);
		gotMsg("loaded?");
    }

/** loadtype could be "frame" */
function loadCommentsBrowser(bid, sid, loadtype){
	if(1==1 || loadtype=="frame"){
		openCommentsViewer(bid,sid);
	}else{
		if (!window.focus) return true;
		var href = "../content/CommentsViewer.swf?bid="+bid+"&sid="+sid;
		window.open(href, "Comments Viewer", 'width=800,height=600,scrollbars=no');
		NewWindow.focus();
		void(0);
	}
}

/**
 * Check if needed java is installed, show error if not
 */
function javaInstalled()
{
    // query list of installed java plugins
    var list = deployJava.getJREs();
    var warning = false;

    if (list.length == 0) {        // no java detected
        warning = "nojava";
    } else {
		var versions = list[0];
		if(list.length>1){
			for (var i=1; i<list.length; i++) {
				versions += ", " + list[i];
			}
		}

        if(list.length > 1) {     // more than one java detected, might cause problems?
            warning = "manyversions";
        }

        // check for at least version 1.5
        var parts = list[0].split(".");
        if(parts[0] < 1 || (parts[0] == 1 && parts[1] < 5)) {
            warning = "lowversion";
        }
    }
	if(!warning || warning=="manyversions") return true;
	if(warning=="nojava"){
		parent.vyew.SysAlert.openTopFrame("vlatest/content/javaWarning.php",60);
	}else if (warning=="lowversion"){
		parent.vyew.SysAlert.openTopFrame("vlatest/content/javaWarning.php?id=old",60);
		//alert("Your version of Java is too old ("+versions+").\nJava 1.6 is required.");
	}
	return false;
}	

//Durgesh
function loadedSuccessfully()
{
      funcsCalled+='loadedSuccessfully() ,';
      //alert("Applet Loaded Successfully");
}

function checkForFlash10()
{
	var c=getCookie('hideFlashNotice');
    if(c=="1") return;
    if(!swfobject.hasFlashPlayerVersion("10")){
		parent.vyew.SysAlert.openTopFrame("/vlatest/content/flashWarning.php",60);
    }
}

/**
 * Called by flash to request a screen capture
 */
function takeScreen(x, y, width, height, scaleWidth, capID)
    {
	if( !javaInstalled() ) return;
	funcsCalled+=' takeScreen(x, ,';
        action  = 'screenCapture';
        traceln('takeScreen called');
        screenCapture = 1;
        if(appletLoaded == 0)
        {
            gotMsg("JS: Java applet not loaded! Loading him 1...");
            loadCapture(x,y,width,height,scaleWidth,capID);
            return;
        }
        gotMsg('JS: calling JAVA');

        //parent.capture.document.Scr.doCaptureScreen(x, y, width, height, 800, capID);
        document.Scr.doCaptureScreen(x, y, width, height, 800, capID);
        gotMsg('JS: Java capture function returned to JS. '+capID);
        traceln('takeScreen complete');
    }
	
	//??
function requestCapID()
    {
	funcsCalled+=' requestCapID() ,';
        getMovie('sm_main').requestCapID();
    }
	
	//??
function sendCapID(ID)
    {
	funcsCalled+=' sendCapID(ID) ,';
        //alert("sendCapID "+ ID)
        //parent.capture.document.Scr.sendCapID(ID);
        document.Scr.sendCapID(ID);
    }

function startSharing(mid, uid, start)
    {   
	action = 'desktopShare';
	funcsCalled+=' startSharing(mid, ,';
        sharing = true;
        //if (screenCapture == 1) {
            //parent.capture.document.Scr.destroy();
        //}
            // alert("startSharing("+mid+", "+uid+") "+appletLoadedLive);
        traceln('startSharing called');
        screenCapture = 0;
        //alert("startSharing "+ mid+" " +uid+ " "+ start +" "+ appletLoadedLive  );
        if(appletLoadedLive == 0)
        {
            gotMsg("JS: Java applet not loaded! Loading him 2...");
            //parent.capture.loadLiveCapture(mid, uid, start);
            doLoadLiveCapture(mid, uid, start);
            appletLoadedLive = 1;
            if( (document.Scr1 != undefined) && (!start ) )
            {
                confirmLoaded();
            }
            else if ( (document.Scr1 == undefined) && (!start ) )
            {
                unableToLoad();
            }
        }
        else
        {
            if( (start == false) && (appletLoadedLive  == 1 )  && (document.Scr1 != undefined))
            {
                //alert("loadAppletTest 2");
                confirmLoaded();
            }
            else if((start == false) && (appletLoadedLive  == 1 )  && (document.Scr1 == undefined) )
            {
                unableToLoad();
            }
        }
    }

/**
 * Logging for java success/fails. Called by flash & java
 */
function logJavaStat(userID,desc,val,msg)
{
	if(msg == "security") {
		// Tell user they need to accept security dialog (showJavaCertFail)
		getMovie('sm_main').showJavaCertFail();
    }
	if(!vyew || !vyew.php || !vyew.php.call) return "no genstat";
	vyew.php.call("genstat.log", [getCookie('sid'), desc, val, userID]);
	return "sent genstat";
}
//logJavaStat(434534,'dshare','ok');

function logdump(logfile)
{
	if(!vyew || !vyew.php || !vyew.php.call) return "no logdump";
	vyew.php.call("genstat.logdump", [getCookie('sid'), logfile]);
	return "sent logdump";
}


/**
 * Called by java to test JS communication
 */
function confirmJSJAVA(info) {
	//alert("java says: "+info);
	var res=0;
	try {
		res = gotMsg("java says: "+info);
		if(res == true)
			res = 1;
		else
			res = 2;
	} catch (e) {
		res = 3;
	}
	
	return "thanks from JS "+res;
}

/**
 * Called initially from flash 
 */
function startSharing2(mid, uid)
    {
	if( !javaInstalled() ) return;
	funcsCalled+=' startSharing2(mid, ,';
        action = 'desktopShare';
        traceln('startSharing called');
        screenCapture = 0;
        doLoadLiveCapture(mid, uid, true);
        appletLoadedLive = 1;
        return "JS is trying to load applet";
    }

function getUploadLocation()
    {
	funcsCalled+=' getUploadLocation() ,';
        return HTTP_HEAD+"://"+HTTP_SERVER+"/screens/live/";
    }

function onResize()
{
	fixIframeHeight();	
	//stopScreenshot();
}

function stopSharing()
    {
	funcsCalled+=' stopSharing() ,';
        //alert("stopSharing");
        traceln ('stopSharing  ');
        if(appletLoadedLive ==1)
        {
            //parent.capture.document.Scr1.stopScreenShot()
            document.Scr1.stopScreenShot()
            sharing = false;
        }
        //parent.capture.document.Scr1.stopSharing();
    }

function stopSharingFlash() {
        traceln ('stopSharingFlash  ');
        getMovie('sm_main').stopShare();
    }

function stopScreenShot()
    {
	funcsCalled+=' stopScreenShot() ,';
        if((resize == 0) ){
            resize =1;
        }else if((resize ==1) ){
            if(sharing) stopSharing();
            resize = 0;
        }
    }

	/**
	 * Called by flash to let java know it got the screen capture URL
	 */
function gotCapture()
    {
	funcsCalled+=' gotCapture() ,';
        traceln ('gotCapture  ');
        //parent.capture.document.Scr.gotItThanks();
        document.Scr.gotItThanks();
    }

function gotImage()
    {
	funcsCalled+=' gotImage() ,';
        //parent.capture.document.Scr1.gotItThanks();
        document.Scr1.gotItThanks();
    }
function imageSent(id, ix, iy, type)
    {
	funcsCalled+=' imageSent(id, ,';
        var newid = ""+id;
        var newix = ""+ix;
        var newiy = ""+iy;
        traceln("id"+newid+" ix"+newix+" iy"+newiy);
        //document.embeds['sm_main'].imageSent(newid, newix, newiy); // type used to sent, but no one seems to want it anymore.
        getMovie('sm_main').imageSent(newid, newix, newiy);
    }

function gotMsg(msg) //u
{
    gm=getMovie('sm_main');
    try{
	    if(gm && gm.jMsg) {
			gm.jMsg(""+msg);
			return true;
		}
    	else
		{
        	dbg('getmovie or gmsg failed, gotmovie returned:');
	        dbd(gm);
			return false;
    	}
    }catch(e){
		dbg('gotmsg failed in trycatch');
	}
	return false;
}







/**
 * -------------------------------------------------------------------
 * UTILS
 * -------------------------------------------------------------------
 */

	function getMainFlash(){ return getMovie('sm_main'); }

    /**
	 * Returns ref to flash object of id name that is passed
	 */
function getMovie(movieName)
    {
	funcsCalled+=' getMovie(movieName) ,';
		try{
        if(typeof movieName == "undefined") movieName="sm_main";
        var obj = swfobject.getObjectById(movieName);
        if (typeof obj == "undefined" || !obj)
        obj = document.getElementById(movieName);
        return obj;
		}catch(e){
		return false;
		}
    }


/**
 * Returns specified segment after the hash (#) in url
 * A segment is text between "/" slashes
 * FIX FOR CASE WHERE NNNN_NNNN (full MID) is passed.
 * Check if segment 0 is NNNN_.* and further split by _
 * Examples with url : domain.com/room#/abc/def/ghi
 *      hashUrlSegment(0) : "abc"  (leading slashes are removed)
 *      hashUrlSegment(1) : "def"
 *      hashUrlSegment() :
 * @param segNum - segment number
 * @param win - ref to window for which to check url. Defaults to current.
 * @return mixed
 */
function hashUrlSegment(segNum,win)
{
    if(!segNum) segNum=0;
    if(!win)win=this;
	try{
    	var loc=win.location.href;
	}catch(e){
		var loc=this.location.href;
	}
	if(empty(loc)) return;
    pl=loc.indexOf("#");
    if(pl==-1) return false;
    if(!pl) return false;
    loc=loc.substr(pl+1)
    segs=loc.split("/");
    if(!segs[0]) segs.shift()
    //check for NNN_NNN
    if(segs[0].match(/[0-9]+_/)){  
       var tmp=segs[0].split("_");
       var tmp2=segs;
       var segs=tmp.concat(tmp2);
    }
    return segs[segNum];
}

function updateMouse(x, y)
    {
	funcsCalled+=' updateMouse(x, ,';
        traceln ('updateMouse  ');
        getMovie('sm_main').updateMouse(x, y);
    }


function traceln(message) {
        return;
        /*
        traceVal+=(message+"\n");
        parent.capture.document.outputfld.currY2.value=traceVal;
        //if(getMovie('sm_main') != null) getMovie('sm_main').traceln(message);
        */

    }

function updateMouseLocation(x, y)
    {
	funcsCalled+=' updateMouseLocation(x, ,';
        var newx = ""+x;
        var newy = ""+y;
        getMovie('sm_main').updateMouseLocation(newx, newy);
    }











/**
 * -------------------------------------------------------------------
 * WINDOW MANIP FUNCS
 * -------------------------------------------------------------------
 */
function popupWindow()
    {
	funcsCalled+=' popupWindow() ,';
		try{
        	var url = parent.window.location.toString();
		}catch(e){  return; }
        var first = url.substring(0,url.indexOf('#'));
        var sec = url.substring(url.indexOf('#'), url.length );
        var w = screen.width;
        var h = screen.height;
        url = first+'?max=1'+ sec;
        var win = parent.window.open(url, 'vyewWin', 'width='+w+', height='+h+
                          ', scrollbars=no, scrolling=no, location=no, menubar=no, '+
                          'resizable=yes, status=no, toolbar=no ');
                win.moveTo(0,0);
        win.focus();
        if(win)
            getMovie('sm_main').shutdown();

        setTimeout(closeWin, 500);

        return "Goodbye";
    }


/** Returns object:{w:WIDTH, h:HEIGHT} of document */
function getStageDims()
{
	var myWidth = 0, myHeight = 0;
	var w = screen.width;
	var h = screen.height;

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement 
		&& ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	 	//IE 4 compatible
	 	myWidth = document.body.clientWidth;
	 	myHeight = document.body.clientHeight;
  	}
	return {w:myWidth, h:myHeight};
}


function closeWin()
    {
	funcsCalled+=' closeWin() ,';
		try {
        var obj = document.getElementById('flashcontent');
        obj.innerHTML = "<br><br>VYEW was maximized to another window. Please close this window.<br>If you have closed the VYEW popup and wish to reconnect in this window, you can reload the page. <a href=\"javascript: window.location.reload()\">Click to Reload Window</a>";
        parent.window.close();
		}catch(e){}
    }

 	//// 'minimize' the browser window for screencapture
function Minimize()
    {
		return;
	funcsCalled+=' Minimize() ,';
        if( browserType == 1 || browserType == 3){
            parent.window.moveTo(0, 0);
            parent.window.resizeTo(100,100);
        }else{
            w_outerWidth= window.outerWidth;
            w_outerHeight = window.outerHeight;
            w_screenX = window.screenX;
            w_screenY = window.screenY;

            parent.window.outerWidth = 100;
            parent.window.outerHeight = 100
            parent.window.screenX = screen.width;
            parent.window.screenY = screen.height;
            alwaysLowered = true;
        }
        //if(action=='desktopShare') {getMovie('sm_main').messageToPod("Starting desktop Share");}
    }






/**
 * -------------------------------------------------------------------
 * BROWSER DETECTION CRAP
 * -------------------------------------------------------------------
 */



function detectJava() {
    return deployJava.getJREs();
}

function installJava() {
    return deployJava.installLatestJRE();
}

var BrowserDetect = {
        /* browserType codes;
            0 = unknown
            1 = IE6+, win
            2 = Firefox, win
            3 = Safari, Mac
            4 = Firefox, Mac
            5 = Opera, Win
            6 = Opera, Mac
            7 = Modzilla, win
            8 = Modzilla, Mac
            9 = Other, win
            10 = Other, Mac
        */

        init: function () {
            this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
            this.version = this.searchVersion(navigator.userAgent)
                || this.searchVersion(navigator.appVersion)
                || "an unknown version";
            this.OS = this.searchString(this.dataOS) || "an unknown OS";
        },
        searchString: function (data) {
            for (var i=0;i<data.length;i++) {
                var dataString = data[i].string;
                var dataProp = data[i].prop;
                this.versionSearchString = data[i].versionSearch || data[i].identity;
                if (dataString) {
                    if (dataString.indexOf(data[i].subString) != -1)
                        return data[i].identity;
                }
                else if (dataProp)
                    return data[i].identity;
            }
        },
        searchVersion: function (dataString) {
            var index = dataString.indexOf(this.versionSearchString);
            if (index == -1) return;
            return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
        },
        dataBrowser: [
            {
                string: navigator.vendor,
                subString: "Apple",
                identity: "Safari"
            },
            {
                prop: window.opera,
                identity: "Opera"
            },
            {
                string: navigator.vendor,
                subString: "iCab",
                identity: "iCab"
            },
            {
                string: navigator.vendor,
                subString: "KDE",
                identity: "Konqueror"
            },
            {
                string: navigator.userAgent,
                subString: "Firefox",
                identity: "Firefox"
            },
            {       // for newer Netscapes (6+)
                string: navigator.userAgent,
                subString: "Netscape",
                identity: "Netscape"
            },
            {
                string: navigator.userAgent,
                subString: "MSIE",
                identity: "Explorer",
                versionSearch: "MSIE"
            },
            {
                string: navigator.userAgent,
                subString: "Gecko",
                identity: "Mozilla",
                versionSearch: "rv"
            },
            {       // for older Netscapes (4-)
                string: navigator.userAgent,
                subString: "Mozilla",
                identity: "Netscape",
                versionSearch: "Mozilla"
            }
        ],
     dataOS : [
            {
                string: navigator.platform,
                subString: "Win",
                identity: "Windows"
            },
            {
                string: navigator.platform,
                subString: "Mac",
                identity: "Mac"
            },
            {
                string: navigator.platform,
                subString: "Linux",
                identity: "Linux"
            }
        ]

    };











/**
 * -------------------------
 * OLD / NOTES
 * -------------------------
 


function checkTimeZone() {
        var rightNow = new Date();
        var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
        var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
        var temp = date1.toUTCString();
        var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
        var temp = date2.toUTCString();
        var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
        var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);
        var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);

        var rt = "";
        if (hoursDiffDaylightTime == hoursDiffStdTime) {
            //alert("Time zone is UTC " + hoursDiffStdTime + ".\nDaylight Saving Time is NOT observed here.");
            rt = hoursDiffStdTime + "," + 0;
        } else {
            //alert("Time zone is UTC " + hoursDiffStdTime + ".\nDaylight Saving Time is observed here.");
            rt = hoursDiffStdTime + "," + 1;
        }

        return rt;
    }

 */




/******************************************************************************************
         vyew.time.js
 ******************************************************************************************/

/**
 * vyew.time.js
 * Vyew Time Library - set/get server time, and tim conversions
 * Copyright (c)2007-2008 Vyew, Simulat, Inc.
 *
 * @author timh@vyew dot com
 *
 * 		TIME LIBRARY
 *		For keeping track of the servers time, without calling there all the time
 *      Usage: call vyew.time.set( unix_epoch_time ) once at initialization
 *				this should be the time from the server
 * 				then at any time, call vyew.time.get() to retrieve that time
 *				This lib also includes a lot of useful time conversion funcitons
 * ..
 */


//--- Setup package
if(typeof vyew=="undefined") vyew=new Object();
vyew.time={};

/**
 * Set server time
 * @param sec - epoch unix time of server
 */
vyew.time.set=function(sec)
{
	vyew.time.serverTimeStamp_sec=sec;
	var d=new Date()
	vyew.time.localTimeStamp_sec=Math.round(d.getTime()/1000)
}

/**
 * Retrieve the estimated server time based on what was set() previously
 * @param format - possible: 
 *						"iso" or "str" - YYYY-MM-DD HH:MM:SS
 *						"sec" (default) - unix epoch time
 * @return mixed - based on format given
 */
vyew.time.get=function(format)
{
	var d=new Date()
	var sec,now=Math.round(d.getTime()/1000);
	if(this.serverTimeStamp_sec && this.serverTimeStamp_sec > 10000) 
		sec=this.serverTimeStamp_sec+(now-this.localTimeStamp_sec);
	else
		sec=Math.round(d.getTime()/1000)+d.getTimezoneOffset( )*60;
	switch(format){
		case "iso":
		case "str":
			return this.sec2str(sec);
			break;
		case "sec":
		default:
			return sec;

	}
}
vyew.time.get_sec=vyew.time.get;


/**
 * TIME CONVERSION FUNCTIONS:
 * Glossary:
 *		"str" = "iso" = YYYY-MM-DD HH:MM:SS
 *		"sec" = epoch unix time (seconds since 1970)
 *      "human friendly" = converts 120 sec to "2 mins" and 3600 sec to "1 hour", etc
 *
 * sec2str(sec) - convert seconds to str format
 * str2sec(str) - convert str format to seconds
 * getDiff_sec(time1,time2) - gets the difference between times returns human friendly time
 * getHumanTime_sec() - gets human friendly time
 *
 */
vyew.time.sec2str=function(sec)
{
	var monthOffset=1; 		//fix for javascript counts january as 0 instead of 1.
	var d=new Date(sec*1000);
	return d.getFullYear()+"-"+this.padTwoDigit(d.getMonth()+monthOffset)+"-"
			+this.padTwoDigit(d.getDate())+" "+this.padTwoDigit(d.getHours())+":"
			+this.padTwoDigit(d.getMinutes())+":"+this.padTwoDigit(d.getSeconds());
}

vyew.time.padTwoDigit=function(s)
{
		if(typeof(s)=="number")
		s=new String(s);
		if(s.length==1)
		s="0"+s;
		return s;
}

vyew.time.getDiff_sec = function(t1,t2)
{
	    if(!t1) return false;
		if(!t2) t2 = this.get_sec();
		t1=parseInt(t1);
		t2=parseInt(t2);
	    var t=Math.abs(t1-t2);
		return this.getHumanTime_sec(t);
}

//converts seconds into friendly human time, like "1 hour, 3 mins" or "4 days, 11 hours"
vyew.time.getHumanTime_sec = function(t)
{
		var min,m,h,d,m2,y,o;
	    min=60
	    m=(t/min) //conv to min
	    if(t<1)return "1 min"
	    m=Math.ceil(t/min);

	    if(m==1)return m+" min"
	    if(m<59)return m+" mins"
	    h=Math.ceil(m/60)
	    if(h==1)return h + " hr"
	    if(h<24)return h + " hrs"
	    d=Math.ceil(h/24)
	    if (d==1)return "1 day"
	    if(d<40) return d + " days"
	    m=Math.ceil(d/30);
	    if (m==1) return "1 month"
	    if (m<12) return m+" months"
	    y=Math.ceil(m/12)
	    m2=y%m;
	    if(y==1) o = y+" year, "
	    else o = y+" years, "
	    if(m2==1) o+=m2+"month"
	    else o+= m2+" months"
	    return o;
}

/** Takes a given gmt time (str format) and changes it to specific zone 
 * eg localizeTime("2009-01-01 15:00:00", -8) = "2009-01-01 07:00:00"
 */
vyew.time.localizeTime = function(time,zoneOffset)
{	
	var sec=this.str2sec(time);
	secOffset=zoneOffset * 3600;
	return this.sec2str(sec+secOffset);
}

vyew.time.getDiff_str = function(t1,t2)
{
	return this.getDiff_sec( this.str2sec(t1), this.str2sec(t2) );
}

//str format example: "2008-08-07 23:40:51" or "2008-08-07 23:40" or "2008-08-07"
vyew.time.str2sec=function(dateStr)
{
        if(!dateStr) return false;
        var monthOffset=-1; //Is january 0 or 1... ? javascript is 0, so offset -1
        var y=dateStr.substr(0,4);
        if(dateStr.substr(4,1)=="-") dateStr=dateStr.substr(5);
        else dateStr=dateStr.substr(4);
        var m=dateStr.substr(0,2);
        if( !isNumeric(m.substr(1,1)) ){
            m=m.substr(0,1);
            dateStr=dateStr.substr(1);
        }else dateStr=dateStr.substr(2);

        if(dateStr.substr(0,1)=="-") dateStr=dateStr.substr(1);
        var d;
        if(dateStr.length>1)
            d=dateStr.substr(0,2);
        else{ d=dateStr; dateStr="000000" }
        if( !isNumeric(d.substr(1,1)) ){
            d=d.substr(0,1);
            dateStr=dateStr.substr(2);
        }else{
            if(dateStr.length>3)
                dateStr=dateStr.substr(3);
            else
                dateStr="0000000";
        }
        if(m.substr(0,1)=="0")m=m.substr(1);
        if(d.substr(0,1)=="0")d=d.substr(1);
        m=parseInt(m)+monthOffset;

        var pl=dateStr.indexOf(":");
        var h,min,s
        if(pl>-1){ h=dateStr.substr(0,pl); dateStr=dateStr.substr(pl+1); }
        else{ h=dateStr; dateStr="00000";}
        pl=dateStr.indexOf(":");
        if(pl>-1){ min=dateStr.substr(0,pl); dateStr=dateStr.substr(pl+1);
            s=dateStr.substr(0,2);
        }else{ min=dateStr; s=0;}

        var dt=new Date(y,m,d,h,min,s,0)
        return Math.round(dt.valueOf()/1000);
}






 



/******************************************************************************************
         vyew.sidChecker.js
 ******************************************************************************************/

/**
 * Vyew Session Checker
 * Periodically checks that the vyew sid is valid, else throws a warning and logs out the user
 */

if(typeof vyew=="undefined")vyew={}
vyew.sidChecker={

	// Flag to show whether an initial valid sid was received
	initalizedSid: false

	/**
	 * Wait a few mins to make sure an SID gets reg'd in cookie, then begin validating,
 	 * But only start validating after an initial valid session has registered
	 * Time settings, 1min = 60000, 15min = 900000;
	 */
	,init: function()
	{
//		setTimeout("vyew.sidChecker.aqcuireSid()", 60000);
//		setTimeout("vyew.sidChecker.chkStanding()",3000);
		setTimeout("vyew.sidChecker.chkStanding()",12000);
	}

	,aqcuireSid: function()
	{
		this.isValidSid(function(isValid)
		{
			if(isValid){
				vyew.sidChecker.initalizedSid=true;
				setInterval("vyew.sidChecker.chk()", 900000);
			}else{
				vyew.sidChecker.init();
			}
		});
	}

	/** Check for valid sid, if not, then log them out */
	,chk: function()
	{
		this.isValidSid(function(isValid)
        {
            if(!isValid && !didAlert){
				try{ vyew.clearCookies(); }catch(e){}
				didAlert=true;
				alert("Your session has expired, please login again.");
				top.document.location="/go/logout";
			}
        });
	}

	/** 
	 * Calls callback with BOOLEAN - whether passed SID (or pulled from cookie if none passed) is valid
	 */
	,isValidSid: function(callback,scope)
	{
		if(!scope) scope=vyew.sidChecker;
		try{ vyew.php; vyew.php.call; } catch(e){ throw "Error 51967: sidchk cant find vyew.php.caller"; }
		vyew.php.call("smAuth.getAuth", [], 
			function(res)
			{
				try{
				if(res.valid==1 || res.valid=="1"){
					callback.apply(scope,[true]);
				}else{
					callback.apply(scope,[false]);
				}
				}catch(e){}
			}
		);
	}

	/** 
	 * Check if user account in good standing 
	 * @param onlyChkLocal - if true, check vyew.ud.standing, instead of going remote to check
	 */
	,chkStanding: function(onlyChkLocal)
	{
		//if vyew.ud exists and vyew.ud.ptype is null or 'pers' then skip
		try{
			if(onlyChkLocal){
				if(!empty(vyew.ud.em) && !empty(vyew.ud.standing)){
					if(vyew.ud.standing==-66) top.document.location='/webutils/acctSuspended.php';
					if(vyew.ud.standing==-65) top.vyew.SysAlert.openTopFrame('/webutils/acctProbation.php', 51);
				}
				return;
			}
		}catch(e){}
		try{ vyew.php; vyew.php.call; } catch(e){ throw "Error 51967: sidchk cant find vyew.php.caller"; }
		vyew.php.call("smAuth.chkStanding", [],
            function(res)
            {
                try{
                if(res==-65)
					top.vyew.SysAlert.openTopFrame('/webutils/acctProbation.php', 53);
				else if(res==-66)
					top.document.location='/webutils/acctSuspended.php';
                }catch(e){}
            }
        );
	}

};


    window.onerror=function(msg, url, linenumber){
        try{
            msg+=" ON line "+linenumber+" IN "+url;
            if(vyew && vyew.php && vyew.php.call){
                vyew.php.call("genstat.log", [getCookie('sid'), 'jserror', msg, 467]);
            }
            return true
        }catch(e){}
    }




/******************************************************************************************
         BrowserAlert.js
 ******************************************************************************************/

/*
 *		BrowserAlert.js - Tim Hon - 7/25/06
 *
 *		Supports sim.BrowserAlert class for Flash
 *
 *		To use, add this line to your HTML file:
 *		<SCRIPT SRC="BrowserAlert.js" LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT"></script>
 *
 *		Then change the settings below:
 *
 */
	//These are the 2 icons that will be rotating in the alert,
	//relative path to the .html file
	//Norm, should be the normal fav icon of the website
	//set both to 0 if you do not want to alert with an icon animation

	// see if we can access top, else, use this...
	function getWin(){
		try{
			if(top.document.title) return top;
			else return this;
		}catch(e){return this;}
	}


	var bAlert={};
	bAlert.defaultAnimateTime=1000;
	
	bAlert.origTitle=(!getWin().document.title)?" ":getWin().document.title; 
	bAlert.tMsg=true; bAlert.flip=-1;
	bAlert.iv_instance;
	bAlert.iv_stopAlertInterval;
	bAlert.iv_stopAlert;

	bAlert.stopAlert=function(){ 
		this.tMsg=false;
	}
		
	bAlert.startAlert=function(msg, alertTime)
	{
return;
		clearTimeout(this.iv_stopAlertInterval);
		clearTimeout(this.iv_instance);
		//this.origTitle=(!top.document.title)?" ":top.document.title;
		if (isDefined(alertTime))
			this.iv_stopAlertInterval = setTimeout("bAlert.stopAlert();", alertTime);
		this.doTitleAlert(msg)
	}
	bAlert.doTitleAlert=function(msg){
		if (msg!="recurse")	this.tMsg=msg; 
		if (this.tMsg==false){
			getWin().document.title=this.origTitle;
		}else{
			trp('dotitlealer');
			this.flip *= -1; 
			var ta_msgnow=(this.flip>0)?this.tMsg:this.origTitle;
			getWin().document.title=ta_msgnow;
			this.iv_instance = setTimeout('bAlert.doTitleAlert("recurse")',this.defaultAnimateTime);
		}
	}
	bAlert.onMouseMove=function(){
dbg('ba onmousemove');
		this.stopAlert();
	}
	bAlert.setTitle=function(msg){	getWin().document.title = msg;}		
	bAlert.setFavIcon=function(ico){ favicon.change(ico); }

//^^^^^^^^^^^^^^^^^^ End Browser Alert Stuff ^^^^^^^^^^^^^^^^^^^^^^^





function setFocus()
{
	bAlert.hasFocus=true;
	bAlert.stopAlert();
	//window.status="setfocus"
}
function setUnfocus()
{
	//alert("asdf");
	bAlert.hasFocus=false;
	trp('unset:'+bAlert.hasFocus);
	//window.status="un   fo   cus"
}
function tr(x)
{
	//window.status=x
}
function trp(x)
{
	//window.status+=x
}





////////////////// ui class
var ui={};
ui.bEnabled=true;
ui.connectedEvents=new Object();
var globalEvents=new Object();


ui.enableEvents=function(){
	ui.bEnabled=true;
};

ui.disableEvents=function(_4b4){
	ui.bEnabled=false;
};

ui.assignEvent=function(_4b5,_4b6,f){
	if(!_4b5||!_4b6||!f){
		return;
	}
	if(!_4b5.eventHash){
		_4b5.eventHash=new Object();
	}
	if(_4b5.eventHash[_4b6]&&(_4b5.eventHash[_4b6]!=f)){
		ui.disconnectEvent(_4b5,_4b6,_4b5.eventHash[_4b6]);
	}
	if(_4b5.attachEvent){
		_4b5.attachEvent("on"+_4b6,f);
	}else{
		if(_4b5.addEventListener){
			_4b5.addEventListener(_4b6,f,true);
		}
	}

	_4b5.eventHash[_4b6]=f;
};

ui.retrieveEventId=function(_4b8){
	if(!_4b8){
		return;
	}
	if(!_4b8.hasAttributes||!_4b8.hasAttributes()){
		return;
	}
	if(_4b8.getAttribute("eventid")){
		return _4b8.getAttribute("eventid");
	}
	var id=getUniqueId();
	_4b8.setAttribute("eventid",id);
	return id;
};

ui.connectGlobalEvent=function(_4ba,func){
	globalEvents[_4ba]=func;
};
ui.disconnectGlobalEvent=function(_4bc){
	globalEvents[_4bc]=null;
};



//ui.connectEvent(document,"focusin",this,"setFocus",true,true);
//connectEvent( target, event, targetCallback, callbackName, ?, ?);
ui.connectEvent=function(eventTarget,eventName,obj,ftn,_4c1,_4c2)
{
	if(!eventTarget||!eventName||!obj||!ftn){
		return;
	}

	var args=argsToArray(arguments);
	args=args.slice(6,args.length);
	var f=function(evnt){
		if(!ui.bEnabled){
			return;
		}
		var o=obj;
		var e=eventTarget;
		var ev=evnt;
		var r=0;
		var eVa=new Array(ev,e);
		if(_4c1&&_4c2){
			eval("r = o."+ftn+".apply(o, eVa.concat(args));");
		}else{
			if(_4c1){
				eval("r = o."+ftn+".apply(o, new Array(eVa[0]).concat(args));");
			}else{
				if(_4c2){
					eval("r = o."+ftn+".apply(o, new Array(eVa[1]).concat(args));");
				}else{
					eval("r = o."+ftn+".apply(o, args);");
				}
			}
		}
		/*
		if(eventTarget.id){
			//eventlog(eventTarget.id+" "+eventName+" "+ftn);
			tr(eventTarget.id+" "+eventName+" "+ftn);
		}else{
			//eventlog(eventTarget+" "+eventName+" "+ftn);
			tr(eventTarget+" "+eventName+" "+ftn);
		}
		*/
		return r;
	};
	ui.assignEvent(eventTarget,eventName,f);
	var id=ui.retrieveEventId(eventTarget);
	if(!ui.connectedEvents[id]){
		ui.connectedEvents[id]=new Object();
	}
	ui.connectedEvents[id][eventName]={elem:eventTarget,func:f};
};






//Setup handlers for focussing
if(isDefined(document.onfocusin)&&isDefined(document.onfocusout)){
	ui.connectEvent(document,"focusin",this,"setFocus",true,true);
	ui.connectEvent(document,"focusout",this,"setUnfocus",true,true);
}else{
	if(isDefined(window.onfocus)&&isDefined(window.onblur)){
		ui.connectEvent(window,"focus",this,"setFocus",true,true);
		ui.connectEvent(window,"blur",this,"setUnfocus",true,true);
	}else{
		ui.connectEvent(document,"focus",this,"setFocus",true,true);
		ui.connectEvent(document,"blur",this,"setUnfocus",true,true);
	}
}








// supporting util functions
function isDefined(obj){
	if(typeof obj=="undefined"){
		return false;
	}
	return true;
}

function argsToArray(args){
	if(!args||!args.length){
		return args;
	}
	var arr=new Array();
	for(var i=0;i<args.length;i++){
		arr=arr.concat(args[i]);
	}
	return arr;
}








// Favicon.js - Change favicon dynamically [http://ajaxify.com/run/favicon].
// Copyright (c) 2006 Michael Mahemoff. Only works in Firefox and Opera.
// Background and MIT License notice at end of file, see the homepage for more.

// USAGE:
// * favicon.change("/icon/active.ico");  (Optional 2nd arg is new title.)
// * favicon.animate(new Array("icon1.ico", "icon2.ico", ...));
//     Tip: Use "" as the last element to make an empty icon between cycles.
//     To stop the animation, call change() and pass in the new arg.
//     (Optional 2nd arg is animation pause in millis, overwrites the default.)
// * favicon.defaultPause = 5000;

var favicon = {

// -- "PUBLIC" ----------------------------------------------------------------

defaultPause: 2000,

change: function(iconURL, optionalDocTitle) {
  clearTimeout(this.loopTimer);
  if (optionalDocTitle) {
    getWin().document.title = optionalDocTitle;
  }
  if (iconURL!=0 && iconURL!="nochange" && iconURL!="same")
  	this.addLink(iconURL, true);
},

animate: function(iconSequence, optionalDelay) {
  this.preloadIcons(iconSequence);
  this.iconSequence = iconSequence;
  this.sequencePause = (optionalDelay) ?  optionalDelay : this.defaultPause;
  favicon.index = 0;
  favicon.change(iconSequence[0]);
  this.loopTimer = setInterval(function() {
    favicon.index = (favicon.index+1) % favicon.iconSequence.length;
    favicon.addLink(favicon.iconSequence[favicon.index], false);
  }, favicon.sequencePause);
},

// -- "PRIVATE" ---------------------------------------------------------------

loopTimer: null,

preloadIcons: function(iconSequence) {
  var dummyImageForPreloading = getWin().document.createElement("img");
  for (var i=0; i<iconSequence.length; i++) {
    dummyImageForPreloading.src = iconSequence[i];
  }
},

addLink: function(iconURL) {
  var link = getWin().document.createElement("link");
  link.type = "image/x-icon";
  link.rel = "shortcut icon";
  link.href = iconURL;
  this.removeLinkIfExists();
  this.docHead.appendChild(link);
},

removeLinkIfExists: function() {
  var links = this.docHead.getElementsByTagName("link");
  for (var i=0; i<links.length; i++) {
    var link = links[i];
    if (link.type=="image/x-icon" && link.rel=="shortcut icon") {
      this.docHead.removeChild(link);
      return; // Assuming only one match at most.
    }
  }
},

docHead:getWin().document.getElementsByTagName("head")[0]
}

// BACKGROUND
// The main point of this script is to give you a means of alerting the user
// something has happened while your application is in a background tab. Serves
// a similar task to notifications in the operating system taskbar. A secondary
// function is to support favicon animation.
//
// This script works by DOM manipulation. After a call, there will be exactly one
// "rel='icon'" link and one "rel='shortcut icon'" link under the head element.
// Both of these are required for portability reasons. It would be nice  (from
// a performance perspective) if we could just update an existing link, if it
// already exists, but it turns out we can't. Firefox (and others?) will ignore
// changes to the link's attributes; it's only interested in a new link being
// added. So we have to delete and re-add in all cases.

// LEGAL
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
// copies of the Software, and to permit persons to whom the Software is 
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE.



	if (isDefined(bAlert.iconNormal) && bAlert.iconNormal != 0)
		favicon.change(bAlert.iconNormal);


