﻿//json2005.js compressed. The JSON class is copyright 2005 JSON.org
Array.prototype.______array='______array';var JSON={org:'http://www.JSON.org',copyright:'(c)2005 JSON.org',license:'http://www.crockford.com/JSON/license.html',stringify:function(a){var c,i,l,s='',v;switch(typeof a){case'object':if(a){if(a.______array=='______array'){for(i=0;i<a.length;++i){v=this.stringify(a[i]);if(s){s+=','}s+=v}return'['+s+']'}else if(typeof a.toString!='undefined'){for(i in a){v=a[i];if(typeof v!='undefined'&&typeof v!='function'){v=this.stringify(v);if(s){s+=','}s+=this.stringify(i)+':'+v}}return'{'+s+'}'}}return'null';case'number':return isFinite(a)?String(a):'null';case'string':l=a.length;s='"';for(i=0;i<l;i+=1){c=a.charAt(i);if(c>=' '){if(c=='\\'||c=='"'){s+='\\'}s+=c}else{switch(c){case'\b':s+='\\b';break;case'\f':s+='\\f';break;case'\n':s+='\\n';break;case'\r':s+='\\r';break;case'\t':s+='\\t';break;default:c=c.charCodeAt();s+='\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16)}}}return s+'"';case'boolean':return String(a);default:return'null'}},parse:function(b){var c=0;var d=' ';function error(m){throw{name:'JSONError',message:m,at:c-1,text:b}}function next(){d=b.charAt(c);c+=1;return d}function white(){while(d!=''&&d<=' '){next()}}function str(){var i,s='',t,u;if(d=='"'){outer:while(next()){if(d=='"'){next();return s}else if(d=='\\'){switch(next()){case'b':s+='\b';break;case'f':s+='\f';break;case'n':s+='\n';break;case'r':s+='\r';break;case't':s+='\t';break;case'u':u=0;for(i=0;i<4;i+=1){t=parseInt(next(),16);if(!isFinite(t)){break outer}u=u*16+t}s+=String.fromCharCode(u);break;default:s+=d}}else{s+=d}}}error("Bad string")}function arr(){var a=[];if(d=='['){next();white();if(d==']'){next();return a}while(d){a.push(val());white();if(d==']'){next();return a}else if(d!=','){break}next();white()}}error("Bad array")}function obj(){var k,o={};if(d=='{'){next();white();if(d=='}'){next();return o}while(d){k=str();white();if(d!=':'){break}next();o[k]=val();white();if(d=='}'){next();return o}else if(d!=','){break}next();white()}}error("Bad object")}function num(){var n='',v;if(d=='-'){n='-';next()}while(d>='0'&&d<='9'){n+=d;next()}if(d=='.'){n+='.';while(next()&&d>='0'&&d<='9'){n+=d}}if(d=='e'||d=='E'){n+='e';next();if(d=='-'||d=='+'){n+=d;next()}while(d>='0'&&d<='9'){n+=d;next()}}v=+n;if(!isFinite(v)){error("Bad number")}else{return v}}function word(){switch(d){case't':if(next()=='r'&&next()=='u'&&next()=='e'){next();return true}break;case'f':if(next()=='a'&&next()=='l'&&next()=='s'&&next()=='e'){next();return false}break;case'n':if(next()=='u'&&next()=='l'&&next()=='l'){next();return null}break}error("Syntax error")}function val(){white();switch(d){case'{':return obj();case'[':return arr();case'"':return str();case'-':return num();default:return d>='0'&&d<='9'?num():word()}}return val()}};

// rsh.compressed.js
window.dhtmlHistory={isIE:false,isOpera:false,isSafari:false,isKonquerer:false,isGecko:false,isSupported:false,create:function(_1){var _2=this;var UA=navigator.userAgent.toLowerCase();var _4=navigator.platform.toLowerCase();var _5=navigator.vendor||"";if(_5==="KDE"){this.isKonqueror=true;this.isSupported=false;}else{if(typeof window.opera!=="undefined"){this.isOpera=true;this.isSupported=true;}else{if(typeof document.all!=="undefined"){this.isIE=true;this.isSupported=true;}else{if(_5.indexOf("Apple Computer, Inc.")>-1){this.isSafari=true;this.isSupported=(_4.indexOf("mac")>-1);}else{if(UA.indexOf("gecko")!=-1){this.isGecko=true;this.isSupported=true;}}}}}window.historyStorage.setup(_1);if(this.isSafari){this.createSafari();}else{if(this.isOpera){this.createOpera();}}var _6=this.getCurrentLocation();this.currentLocation=_6;if(this.isIE){this.createIE(_6);}var _7=function(){_2.firstLoad=null;};this.addEventListener(window,"unload",_7);if(this.isIE){this.ignoreLocationChange=true;}else{if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.ignoreLocationChange=true;this.firstLoad=true;historyStorage.put(this.PAGELOADEDSTRING,true);}else{this.ignoreLocationChange=false;this.fireOnNewListener=true;}}var _8=function(){_2.checkLocation();};setInterval(_8,100);},initialize:function(){if(this.isIE){if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.fireOnNewListener=false;this.firstLoad=true;historyStorage.put(this.PAGELOADEDSTRING,true);}else{this.fireOnNewListener=true;this.firstLoad=false;}}},addListener:function(_9){this.listener=_9;if(this.fireOnNewListener){this.fireHistoryEvent(this.currentLocation);this.fireOnNewListener=false;}},addEventListener:function(o,e,l){if(o.addEventListener){o.addEventListener(e,l,false);}else{if(o.attachEvent){o.attachEvent("on"+e,function(){l(window.event);});}}},add:function(_d,_e){if(this.isSafari){_d=this.removeHash(_d);historyStorage.put(_d,_e);this.currentLocation=_d;window.location.hash=_d;this.putSafariState(_d);}else{var _f=this;var _10=function(){if(_f.currentWaitTime>0){_f.currentWaitTime=_f.currentWaitTime-_f.waitTime;}_d=_f.removeHash(_d);if(document.getElementById(_d)&&_f.debugMode){var e="Exception: History locations can not have the same value as _any_ IDs that might be in the document,"+" due to a bug in IE; please ask the developer to choose a history location that does not match any HTML"+" IDs in this document. The following ID is already taken and cannot be a location: "+_d;throw new Error(e);}historyStorage.put(_d,_e);_f.ignoreLocationChange=true;_f.ieAtomicLocationChange=true;_f.currentLocation=_d;window.location.hash=_d;if(_f.isIE){_f.iframe.src="blank.html?"+_d;}_f.ieAtomicLocationChange=false;};window.setTimeout(_10,this.currentWaitTime);this.currentWaitTime=this.currentWaitTime+this.waitTime;}},isFirstLoad:function(){return this.firstLoad;},getVersion:function(){return "0.6";},getCurrentLocation:function(){var r=(this.isSafari?this.getSafariState():this.getCurrentHash());return r;},getCurrentHash:function(){var r=window.location.href;var i=r.indexOf("#");return (i>=0?r.substr(i+1):"");},PAGELOADEDSTRING:"DhtmlHistory_pageLoaded",listener:null,waitTime:200,currentWaitTime:0,currentLocation:null,iframe:null,safariHistoryStartPoint:null,safariStack:null,safariLength:null,ignoreLocationChange:null,fireOnNewListener:null,firstLoad:null,ieAtomicLocationChange:null,createIE:function(_15){this.waitTime=400;var _16=(historyStorage.debugMode?"width: 800px;height:80px;border:1px solid black;":historyStorage.hideStyles);var _17="rshHistoryFrame";var _18="<iframe frameborder=\"0\" id=\""+_17+"\" style=\""+_16+"\" src=\"blank.html?"+_15+"\"></iframe>";document.write(_18);this.iframe=document.getElementById(_17);},createOpera:function(){this.waitTime=400;var _19="<img src=\"javascript:location.href='javascript:dhtmlHistory.checkLocation();';\" style=\""+historyStorage.hideStyles+"\" />";document.write(_19);},createSafari:function(){var _1a="rshSafariForm";var _1b="rshSafariStack";var _1c="rshSafariLength";var _1d=historyStorage.debugMode?historyStorage.showStyles:historyStorage.hideStyles;var _1e=(historyStorage.debugMode?"width:800px;height:20px;border:1px solid black;margin:0;padding:0;":historyStorage.hideStyles);var _1f="<form id=\""+_1a+"\" style=\""+_1d+"\">"+"<input type=\"text\" style=\""+_1e+"\" id=\""+_1b+"\" value=\"[]\"/>"+"<input type=\"text\" style=\""+_1e+"\" id=\""+_1c+"\" value=\"\"/>"+"</form>";document.write(_1f);this.safariStack=document.getElementById(_1b);this.safariLength=document.getElementById(_1c);if(!historyStorage.hasKey(this.PAGELOADEDSTRING)){this.safariHistoryStartPoint=history.length;this.safariLength.value=this.safariHistoryStartPoint;}else{this.safariHistoryStartPoint=this.safariLength.value;}},getSafariStack:function(){var r=this.safariStack.value;return historyStorage.fromJSON(r);},getSafariState:function(){var _21=this.getSafariStack();var _22=_21[history.length-this.safariHistoryStartPoint-1];return _22;},putSafariState:function(_23){var _24=this.getSafariStack();_24[history.length-this.safariHistoryStartPoint]=_23;this.safariStack.value=historyStorage.toJSON(_24);},fireHistoryEvent:function(_25){var _26=historyStorage.get(_25);this.listener.call(null,_25,_26);},checkLocation:function(){if(!this.isIE&&this.ignoreLocationChange){this.ignoreLocationChange=false;return;}if(!this.isIE&&this.ieAtomicLocationChange){return;}var _27=this.getCurrentLocation();if(_27==this.currentLocation){return;};this.ieAtomicLocationChange=true;if(this.isIE&&this.getIframeHash()!=_27){this.iframe.src="blank.html?"+_27;}else{if(this.isIE){return;}};this.currentLocation=_27;this.ieAtomicLocationChange=false;this.fireHistoryEvent(_27);},getIframeHash:function(){var doc=this.iframe.contentWindow.document;var _29=String(doc.location.search);if(_29.length==1&&_29.charAt(0)=="?"){_29="";}else{if(_29.length>=2&&_29.charAt(0)=="?"){_29=_29.substring(1);}}return _29;},removeHash:function(_2a){var r;if(_2a===null||_2a===undefined){r=null;}else{if(_2a===""){r="";}else{if(_2a.length==1&&_2a.charAt(0)=="#"){r="";}else{if(_2a.length>1&&_2a.charAt(0)=="#"){r=_2a.substring(1);}else{r=_2a;}}}}return r;},iframeLoaded:function(_2c){if(this.ignoreLocationChange){this.ignoreLocationChange=false;return;}var _2d=String(_2c.search);if(_2d.length==1&&_2d.charAt(0)=="?"){_2d="";}else{if(_2d.length>=2&&_2d.charAt(0)=="?"){_2d=_2d.substring(1);}}window.location.hash=_2d;this.fireHistoryEvent(_2d);}};window.historyStorage={setup:function(_2e){if(typeof _2e!=="undefined"){if(_2e.debugMode){this.debugMode=_2e.debugMode;}if(_2e.toJSON){this.toJSON=_2e.toJSON;}if(_2e.fromJSON){this.fromJSON=_2e.fromJSON;}}var _2f="rshStorageForm";var _30="rshStorageField";var _31=this.debugMode?historyStorage.showStyles:historyStorage.hideStyles;var _32=(historyStorage.debugMode?"width: 800px;height:80px;border:1px solid black;":historyStorage.hideStyles);var _33="<form id=\""+_2f+"\" style=\""+_31+"\">"+"<textarea id=\""+_30+"\" style=\""+_32+"\"></textarea>"+"</form>";document.write(_33);this.storageField=document.getElementById(_30);if(typeof window.opera!=="undefined"){this.storageField.focus();}},put:function(key,_35){this.assertValidKey(key);if(this.hasKey(key)){this.remove(key);};this.storageHash[key]=_35;this.saveHashTable();},get:function(key){this.assertValidKey(key);this.loadHashTable();var _37=this.storageHash[key];if(_37===undefined){_37=null;}return _37;},remove:function(key){this.assertValidKey(key);this.loadHashTable();delete this.storageHash[key];this.saveHashTable();},reset:function(){this.storageField.value="";this.storageHash={};},hasKey:function(key){this.assertValidKey(key);this.loadHashTable();return (typeof this.storageHash[key]!=="undefined");},isValidKey:function(key){return (typeof key==="string");},showStyles:"border:0;margin:0;padding:0;",hideStyles:"left:-1000px;top:-1000px;width:1px;height:1px;border:0;position:absolute;",debugMode:false,storageHash:{},hashLoaded:false,storageField:null,assertValidKey:function(key){var _3c=this.isValidKey(key);if(!_3c&&this.debugMode){throw new Error("Please provide a valid key for window.historyStorage. Invalid key = "+key+".");}},loadHashTable:function(){if(!this.hashLoaded){var _3d=this.storageField.value;if(_3d!==""&&_3d!==null){this.storageHash=this.fromJSON(_3d);this.hashLoaded=true;}}},saveHashTable:function(){this.loadHashTable();var _3e=this.toJSON(this.storageHash);this.storageField.value=_3e;},toJSON:function(o){return o.toJSONString();},fromJSON:function(s){return s.parseJSON();}};

// ViewManager

function ViewManager(id, viewsData, menuContainerId) {
    
    // private fields
    
    this._sep = "&";
    this._currentViewId = null;
    this._viewsData = viewsData;
    this._menuContainerId = menuContainerId;
    this._currentChild = null;
    
    // properties
    
    this.menuTemplateStart = "<table align='center' cellspacing='0' cellpadding='0' border='0' style='margin-top:11px'><tr>";
    this.menuTemplateEnd = "</tr></table>";
    this.menuTemplateItemStart = "<td style='text-align: center; vertical-align:middle; white-space:nowrap;' nowrap>";
    this.menuTemplateItemEnd = "</td>";
    this.menuTemplateSelectedItem = "{menuItemText}"
    this.menuTemplateItem = "{menuItemText}";
    this.uriMapping = {};
    
    // event handlers
    
    this.onViewChange = function() {};
       
    // functions

    this.initialize = function() {
        window.dhtmlHistory.initialize();
        window.dhtmlHistory.addListener(window[id].navigate);
    }
    
    this.navigate = function(uri, historyData) {
        window[id].switchView(uri, historyData);
        if(window[id]._currentChild) window[id]._currentChild.switchView(uri, historyData);        
    }

    this.switchView = function(uri, ignoreHistory) {

        var oldViewId = this._currentViewId;
        var viewId = null;
        var viewArgs = {};
        var sepIndex = uri.indexOf(window[id]._sep);
        if(sepIndex!=-1) {
            viewId = uri.substring(0, sepIndex);
            eval("viewArgs = {"+uri.substring(sepIndex+1).replace(/=([^&]+)/g, ":'$1'").replace(/&/g, ",")+"}");
        } else {
            viewId = uri;
        }
        var mappedUri = window[id].uriMapping["_"+viewId.replace(/[\/]/g, "$")];
        if(mappedUri!=null){
            window[id].switchView(mappedUri+(sepIndex!=-1?uri.substring(sepIndex):""), true);
            return;
        }
        window[id].renderMenu(viewId);
        if(!ignoreHistory) dhtmlHistory.add(uri, true);
        if(this._currentViewId!=null) {
            document.getElementById('view_'+this._currentViewId.replace(/[\/]/g, "$")).style.display = "none";
        }
        var view = document.getElementById('view_' + viewId.replace(/[\/]/, "$"));
        if(view!=null) view.style.display = "block";
        else {
            this.navigate("home");
            return;
        }
        this._currentViewId = viewId;
        window[id].onViewChange({oldViewId:oldViewId, newViewId:viewId, args:viewArgs});
    }

    this.renderMenu = function(activeViewId) {
        var menuItem = null;
        var menuHTML = this.menuTemplateStart;
        for(var i=0; i < this._viewsData.length; i++){
            menuHTML += this.menuTemplateItemStart;
            menuItem = this._viewsData[i];
            if(menuItem.id==activeViewId || this.uriMapping["_"+menuItem.id] == activeViewId)
                menuHTML += this.menuTemplateSelectedItem.replace("{menuItemText}", menuItem.text);
            else 
                menuHTML += ("<a href=\"#"+menuItem.id+"\" style=\"text-decoration: none\">"+this.menuTemplateItem.replace("{menuItemText}", menuItem.text)+"</a>")
            menuHTML += this.menuTemplateItemEnd;
            
            if(menuItem.id==activeViewId) this._currentChild = window[menuItem.childVMId]; 
        }
        menuHTML += this.menuTemplateEnd;
        document.getElementById(this._menuContainerId).innerHTML = menuHTML;
    }
    
    // init
    window.dhtmlHistory.create({
            debugMode: false
            , toJSON: function(o) {
                    return JSON.stringify(o);
            }
            , fromJSON: function(s) {
                    return JSON.parse(s);
            }
    });    
    window[id] = this;
}