home *** CD-ROM | disk | FTP | other *** search
/ ftp6.securdisc.net / ftp6.securdisc.net.tar / ftp6.securdisc.net / SecurDiscViewer_Plk.chm / scripts / common.core.js next >
Text File  |  2010-08-08  |  20KB  |  754 lines

  1. function Schema ( ) { }; 
  2.  
  3. // =============================================================================
  4. //                         Cross browser XMLHttpRequest
  5. // =============================================================================
  6.  
  7. if ( typeof XMLHttpRequest == "undefined" ) 
  8. {
  9.     XMLHttpRequest = function ( ) {
  10.         try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch (e) { }
  11.         try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch (e) { }
  12.         try { return new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { }
  13.         try { return new ActiveXObject("Microsoft.XMLHTTP") } catch (e) { }
  14.         return ( undefined );
  15.     }
  16. };
  17.  
  18.  
  19. // =============================================================================
  20. //                                 EVENT SYSTEM
  21. // =============================================================================
  22.  
  23. Schema.Event = function ( ) { };
  24.  
  25. Schema.Event.AddListener = function ( obj, functionName, functionCode, ctx, tag )
  26. {
  27.     if ( !ctx )
  28.         ctx = obj;
  29.         
  30.     var fn = null;
  31.     if ( obj.addEventListener )
  32.     { 
  33.         fn = function ( e ) { functionCode.call(ctx, e, tag); e.cancelBubble=true; if(e.stopPropagation){e.stopPropagation();} };
  34.         obj.addEventListener ( functionName, fn, false );
  35.     }
  36.     else if ( obj.attachEvent )
  37.     {
  38.         fn = function ( e ) { var event = window.event; functionCode.call(ctx, event, tag); event.cancelBubble = true; if(event.stopPropagation){event.stopPropagation();} };
  39.         obj.attachEvent ( "on" + functionName, fn );
  40.     }
  41.     return ( fn );
  42. };
  43.  
  44.  
  45. Schema.Event.OnDomContentLoaded = function ( fn )
  46. {
  47.     if ( !fn )
  48.         return;
  49.  
  50.     if ( document.addEventListener )
  51.         document.addEventListener ( "DOMContentLoaded", fn, false );
  52.     else
  53.     {
  54.         document.onreadystatechange = function() 
  55.         {
  56.             if ( document.readyState == "interactive" || document.readyState == "complete" )
  57.                 fn ( );
  58.         }
  59.     }
  60. }
  61.  
  62.  
  63. Schema.Event.RemoveListener = function ( obj, functionName, functionCode )
  64. {
  65.     if ( obj.removeEventListener )
  66.         obj.removeEventListener ( functionName, functionCode, true );
  67.     else if ( obj.detachEvent )
  68.         obj.detachEvent ( "on" + functionName, functionCode );
  69. }
  70.  
  71.  
  72.  
  73. // =============================================================================
  74. //                               LANGUAGE FEATURES
  75. // =============================================================================
  76.  
  77. Schema.I18N = function ( ) { };
  78. Schema.I18N.currentLang = 'en';
  79. Schema.I18N.currentGuiLang = 'en';
  80. Schema.I18N.data = {'all': {}, 'de': {}, 'en':{}};
  81.  
  82. Schema.I18N.GetTranslation = function ( index, gui )
  83. {
  84.     var dict = gui ? Schema.I18N.data[Schema.I18N.currentGuiLang] : Schema.I18N.data[Schema.I18N.currentLang];
  85.     var result;
  86.     
  87.     if ( dict && dict[index] )
  88.         result = dict[index];
  89.         
  90.     if ( !result && ((!gui && Schema.I18N.currentLang != 'all') || (gui && Schema.I18N.currentGuiLang != 'sys')) )
  91.     {
  92.         dict = Schema.I18N.data['all'];
  93.         if ( dict && dict[index] )
  94.             result = dict[index];
  95.     }
  96.  
  97.     if ( result )
  98.     {
  99.         if ( arguments.length > 1 )
  100.         {
  101.             var call = [];
  102.             call.push ( result );
  103.             for ( var i = 2; i < arguments.length; i++ )
  104.                 call.push ( arguments[i] );
  105.                 
  106.             return ( Schema.String.Format.apply(this,call) );
  107.         }
  108.         else
  109.             return ( result );
  110.     }
  111.     
  112.     return ( "" );
  113. }
  114.  
  115.  
  116. function _ ( index )
  117. {
  118.     var args = [];
  119.     args.push ( index );
  120.     args.push ( false );
  121.     for ( var i = 1; i < arguments.length; i++ )
  122.         args.push ( arguments[i] );
  123.         
  124.     return ( Schema.I18N.GetTranslation.apply(this,args) );
  125. }
  126.  
  127.  
  128. function __ ( index )
  129. {
  130.     var args = [];
  131.     args.push ( index );
  132.     args.push ( true );
  133.     for ( var i = 1; i < arguments.length; i++ )
  134.         args.push ( arguments[i] );
  135.         
  136.     return ( Schema.I18N.GetTranslation.apply(this,args) );
  137. }
  138.  
  139.  
  140.  
  141. // =============================================================================
  142. //                                REGEXP EXTENSION
  143. // =============================================================================
  144.  
  145. Schema.Regex = function ( ) { };
  146. Schema.Regex.Create = function ( value, options )
  147. {
  148.     var regexOpt = "";
  149.     if ( (options & Schema.Regex.Options.AllMatches) != 0 )
  150.         regexOpt += "g";
  151.     if ( (options & Schema.Regex.Options.IgnoreCase) != 0 )
  152.         regexOpt += "i";
  153.     if ( (options & Schema.Regex.Options.Multiline) != 0 )
  154.         regexOpt += "m";
  155.  
  156.     var sp = Schema.Regex.Unicode.Separator + Schema.Regex.Unicode.Punctuation;
  157.             
  158.     value = Schema.Regex.Encode ( value );
  159.     
  160.     if ( (options & Schema.Regex.Options.Exact) != 0 )
  161.     {
  162.         string = "^" + value + "$";
  163.     }
  164.     else if ( (options & Schema.Regex.Options.WholeWord) != 0 )
  165.     {
  166.         string = "^" + value + "(?=[" + sp + "]+)|[" + sp + "]" + value + "(?=[" + sp + "])|[" + sp + "]" + value + "$|^" + value + "$";  
  167.     }
  168.     else if ( (options & Schema.Regex.Options.StartWord) != 0 )
  169.     {
  170.         string = "^" + value + "|[" + sp + "]" + value;  
  171.     }
  172.     else
  173.         string = value;
  174.          
  175.     return ( new RegExp(string, regexOpt) );
  176. }
  177.  
  178.  
  179. Schema.Regex.Encode = function ( value )
  180. {
  181.     return ( value.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1').replace(/\s+/g, "\\s") );
  182. }
  183.  
  184.  
  185.  
  186. Schema.Regex.Options = function ( ) { };
  187. Schema.Regex.Options.None = 0;
  188. Schema.Regex.Options.IgnoreCase = 1;
  189. Schema.Regex.Options.WholeWord = 2;
  190. Schema.Regex.Options.StartWord = 4;
  191. Schema.Regex.Options.Exact = 8;
  192. Schema.Regex.Options.AllMatches = 16;
  193. Schema.Regex.Options.Multiline = 32;
  194.  
  195. Schema.Regex.Unicode = function ( ) { };
  196. Schema.Regex.Unicode.Punctuation = "\\u0021-\\u0023\\u0025-\\u002A\\u002C-\\u002F\\u003A\\u003B\\u003F\\u0040\\u005B-\\u005D\\u005F\\u007B\\u007D\\u00A1\\u00AB\\u00B7\\u00BB\\u00BF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061E\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0964\\u0965\\u0970\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u104A-\\u104F\\u10FB\\u1361-\\u1368\\u166D\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1800-\\u180A\\u1944\\u1945\\u19DE\\u19DF\\u1A1E\\u1A1F\\u1B5A-\\u1B60\\u1C3B-\\u1C3F\\u1C7E\\u1C7F\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2E00-\\u2E2E\\u2E30\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA60D-\\uA60F\\uA673\\uA67E\\uA874-\\uA877\\uA8CE\\uA8CF\\uA92E\\uA92F\\uA95F\\uAA5C-\\uAA5F\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65";
  197. Schema.Regex.Unicode.Separator   = "\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000";
  198.  
  199.  
  200.  
  201.  
  202. // =============================================================================
  203. //                               REQUEST HANDLER
  204. // =============================================================================
  205.  
  206. Schema.Web = function ( ) { };
  207.  
  208. Schema.Web.Navigate = function ( url, init )
  209. {
  210.     var getstring = "";
  211.     if ( init.get )
  212.     {
  213.         for ( var name in init.get )
  214.         {
  215.             if ( getstring != "" )
  216.                 getstring += "&";
  217.             getstring += encodeURI(name) + "=" + encodeURI(init.get[name]);
  218.         }
  219.     }
  220.  
  221.     if ( init.post )
  222.     {
  223.         var form = document.createElement ( "form" );
  224.         form.method = 'POST';
  225.         form.action = url + ((getstring != "") ? "?" + getstring : "");
  226.         for ( var name in init.post )
  227.         {
  228.             var input = Schema.DOM.CreateInput("hidden");
  229.             input.name = name;
  230.             input.value = init.post[name];
  231.             form.appendChild ( input );
  232.         }
  233.         document.getElementsByTagName("body")[0].appendChild ( form );
  234.         form.submit();
  235.     }
  236.     else
  237.     {
  238.         var loc = url;
  239.         if ( getstring != "" )
  240.             loc += "?" + getstring;
  241.         location.href = loc;
  242.     }
  243. }
  244.  
  245.  
  246. Schema.Web.Request = function ( url, init )
  247. {
  248.     this.callback = (init) ? init.callback : null;
  249.     this.request = null;
  250.     this.params = (init && init.params) ? init.params : [];
  251.     this.async = (init) ? (init.async == true) : true;
  252.     this.url = url;
  253.  
  254.     this.Execute = function ( )
  255.     {
  256.         var body = '';
  257.         if ( this.params )
  258.         {
  259.             for ( key in this.params )
  260.             {
  261.                 if ( body != "" )
  262.                     body += "&";
  263.                 
  264.                 value = this.params[key];
  265.                 if ( value && typeof(value) == "string" )
  266.                 {
  267.                     value = value.replace ( "%", "%25" );
  268.                     value = value.replace ( "&", "%26" );
  269.                     value = value.replace ( "\r", "%0D" );
  270.                     value = value.replace ( "\n", "%0A" );
  271.                     value = value.replace ( " ", "%20" );
  272.                 }
  273.                 body += key + "=" + value;
  274.             }
  275.         }
  276.  
  277.         this.request = new XMLHttpRequest ( );
  278.         this.request.open ( "POST", this.url, this.async );
  279.         this.request.setRequestHeader ( "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" );
  280.         this.request.setRequestHeader ( "Content-Length", body.length );
  281.         this.request.setRequestHeader ( "Connection", "close" );
  282.         
  283.         var req = this.request;
  284.         var self = this;
  285.         if ( this.async )
  286.         {
  287.             this.request.onreadystatechange = function ( ) 
  288.             { 
  289.                 if ( req.readyState == 4 ) 
  290.                 { 
  291.                     if ( self.callback ) 
  292.                         self.callback(self); 
  293.                 }
  294.                      
  295.             };
  296.             this.request.send ( body );
  297.         }
  298.         else
  299.         {
  300.             this.request.send ( body );
  301.             return ( this.request.responseText );                
  302.         }
  303.     };
  304.     
  305.     
  306.     
  307.     this.GetJsonObjects = function ( )
  308.     {
  309.         var text = this.GetResponseText ( );
  310.         if ( text == "" )
  311.             return ( null );
  312.         else            
  313.             return ( Schema.Json.Evaluate(text) ); 
  314.     };
  315.     
  316.     
  317.     this.GetResponseText = function ( )
  318.     {
  319.         return ( this.request.responseText );
  320.     };
  321. };
  322.  
  323.  
  324. // =============================================================================
  325. //                                STRING FUNCTIONS
  326. // =============================================================================
  327.  
  328.  
  329. Schema.String = function ( ) { };
  330. Schema.String.Format = function ( org )
  331. {
  332.     for ( var i = 1; i < arguments.length; i++ )
  333.     {
  334.         org = org.replace ( new RegExp("\\{" + (i-1) + "\\}", "g"), arguments[i] );
  335.     }
  336.         
  337.     return ( org );
  338. }
  339.  
  340. Schema.String.IsNumber = function ( obj )
  341. {
  342.     return ( obj.replace( /[\+-]?\s*\d+/, "") = "" );
  343. }
  344.  
  345.  
  346.  
  347. Schema.String.Tokenize = function ( tokenStream )
  348. {
  349.     tokenStream = tokenStream.replace(/\s+/g, " ");
  350.     var tokens = [];
  351.     var pos = 0;
  352.     
  353.     while ( pos < tokenStream.length )
  354.     {
  355.         var token = Schema.String.TokenizeNext ( tokenStream, pos );
  356.         if ( !token )
  357.             break;
  358.  
  359.         tokens.push ( token.value );
  360.         pos = token.end+1;
  361.     }
  362.     
  363.     return ( tokens );
  364. };
  365.  
  366.  
  367. Schema.String.TokenizeNext = function ( tokenStream, pos )
  368. {
  369.     while ( pos < tokenStream.length && tokenStream.substr(pos, 1) == " " )
  370.         pos++;
  371.     
  372.     if ( pos >= tokenStream.length )
  373.         return ( null );
  374.     
  375.     var st = pos;
  376.     var inner = false;
  377.     var lastIsEscape = false;
  378.         
  379.     while ( pos < tokenStream.length )
  380.     {
  381.         var c = tokenStream.substr ( pos, 1 );
  382.  
  383.         if ( c == ' ' && !inner )
  384.         {
  385.             pos--;
  386.             break;
  387.         }
  388.         else if ( c == '\\' && inner )
  389.             lastIsEscape = !lastIsEscape;
  390.         else if ( c == '"' && !lastIsEscape )
  391.             inner = !inner;
  392.         else
  393.             lastIsEscape = false;
  394.         
  395.         pos++;                  
  396.     }
  397.         
  398.     return ( {"value": tokenStream.substr(st,pos-st+1), "end": pos+1} );
  399. };
  400.  
  401. Schema.String.Trim = function(str)
  402. {
  403.     if(!str || str == "")
  404.         return str;
  405.     
  406.     var res = "";
  407.     var i;
  408.     
  409.     // look from beginning until a non-whitespace char
  410.     for(i = 0; i < str.length; ++i)
  411.     {
  412.         if(str.charAt(i) == ' ')
  413.             continue;
  414.         else
  415.             break;
  416.     }
  417.     res = str.substring(i);
  418.     
  419.     // look from end until a non-whitespace char
  420.     for(i = res.length-1; i >= 0; --i)
  421.     {
  422.         if(res.charAt(i) == ' ')
  423.             continue;
  424.         else
  425.             break;
  426.     }
  427.     return res.substring(0, i+1);
  428. }
  429.  
  430.  
  431.  
  432. // =============================================================================
  433. //                               UTILITY FUNCTIONS
  434. // =============================================================================
  435.  
  436. Schema.Utils = function ( ) { };
  437.  
  438. Schema.Utils.Apply = function ( source, target )
  439. {
  440.     if ( source && target )
  441.     {
  442.         for ( var name in source )
  443.             target[name] = source[name];
  444.     }
  445.     return ( target );
  446. };
  447.  
  448.  
  449. Schema.Utils.ClearSelection = function ( )
  450. {
  451.     var sel;
  452.     if ( document.selection && document.selection.empty ) 
  453.         document.selection.empty();
  454.     else if ( window.getSelection ) 
  455.     {
  456.         sel = window.getSelection();
  457.         if ( sel && sel.removeAllRanges )
  458.             sel.removeAllRanges();
  459.     }
  460. }
  461.  
  462.  
  463. Schema.Utils.Contains = function ( obj, name )
  464. {
  465.     if ( obj.length && obj.length > 0 )
  466.     {
  467.         for ( var i = 0; i < obj.length; i++ )
  468.         {
  469.             if ( obj[i] == name )
  470.                 return ( true );
  471.         }
  472.     }
  473.     
  474.     return ( false );
  475. }
  476.  
  477.  
  478. Schema.Utils.Clone = function ( obj )
  479. {
  480.     var result = {};
  481.     if ( !obj )
  482.         return ( result );
  483.     for ( var name in obj )
  484.         result[name] = obj[name];
  485.         
  486.     return ( result );
  487. }
  488.  
  489. Schema.Utils.GetClientSize = function ( )
  490. {
  491.     var clientX, clientY;
  492.     if (self.innerHeight)
  493.     {
  494.         clientX = self.innerWidth;
  495.         clientY = self.innerHeight;
  496.     }
  497.     else if (document.documentElement && document.documentElement.clientHeight)
  498.     {
  499.         clientX = document.documentElement.clientWidth;
  500.         clientY = document.documentElement.clientHeight;
  501.     }
  502.     else if (document.body)
  503.     {
  504.         clientX = document.body.clientWidth;
  505.         clientY = document.body.clientHeight;
  506.     }
  507.     
  508.     return ( {"Width":clientX, "Height":clientY} );
  509. };
  510.  
  511.  
  512. Schema.Utils.GetPosition = function ( elem )
  513. {
  514.     var left = 0;
  515.     var top = 0;
  516.     do
  517.     {
  518.         if ( elem.offsetParent )
  519.         {
  520.             left += (elem.offsetLeft || 0);
  521.             top += (elem.offsetTop || 0);
  522.         }
  523.     }
  524.     while ( elem = elem.offsetParent )
  525.     return ( {'x': left, 'y':top} );
  526. }
  527.  
  528.  
  529. Schema.Utils.SplitObject = function ( obj, names )
  530. {
  531.     var result = {};
  532.     for ( var key in obj )
  533.     {
  534.         if ( Schema.Utils.Contains(names, key) )
  535.             result[key] = obj[key];
  536.     }
  537.  
  538.     for ( var i = 0; i < names.length; i++ )
  539.     {
  540.         if ( obj[names[i]] )
  541.             delete obj[names[i]];
  542.     }
  543.     return ( result );
  544. }
  545.  
  546.  
  547.  
  548.  
  549. // =============================================================================
  550. //                              JSON HANDLING
  551. // =============================================================================
  552.  
  553.  
  554. Schema.Json = function ( ) { };
  555.  
  556. Schema.Json.Evaluate = function ( text )
  557. {
  558.     if ( /^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) 
  559.         return ( eval('(' + text + ')') );
  560.     else
  561.         return ( null );
  562. }
  563.  
  564.  
  565.  
  566. // =============================================================================
  567. //                                DOM HELPERS
  568. // =============================================================================
  569.  
  570. Schema.DOM = function ( ) { };
  571.  
  572. Schema.DOM.AppendChild = function ( node, parent )
  573. {
  574.     parent.appendChild ( node );
  575. }
  576.  
  577.  
  578. Schema.DOM.Create = function ( init )
  579. {
  580.     var result = new Array ( );
  581.     for ( var i = 0; i < init.length; i++ )
  582.     {
  583.         if ( init[i] && init[i].length > 0 )
  584.         {
  585.             var elem = document.createElement ( init[i][0] );
  586.             result.push ( elem );
  587.             
  588.             if ( init[i].length > 1 && init[i][1] )
  589.                 result.push ( Schema.DOM.Create(init[i][1]) );
  590.         }
  591.     }
  592.     
  593.     return ( result );
  594. };
  595.  
  596.  
  597. Schema.DOM.CreateEx = function ( init )
  598. {
  599.     var result = new Array ( );
  600.     for ( var i = 0; i < init.length; i++ )
  601.     {
  602.         var elem = document.createElement ( init[i].name );
  603.         result.push ( elem );
  604.         
  605.         if ( init[i].attributes )
  606.         {
  607.             for ( var key in init[i].attributes )
  608.                 elem.setAttribute ( key, init[i].attributes[key] );
  609.         }
  610.         if ( init[i].style )
  611.         {
  612.             for ( var key in init[i].attributes )
  613.                 elem.style.setAttribute ( key, init[i].style[key] );
  614.         }
  615.         if ( init[i].text )
  616.             elem.innerText = init[i].text;
  617.         if ( init[i].html )
  618.             elem.innerHTML = init[i].html;
  619.         if ( init[i].children )
  620.             result.push ( Schema.DOM.CreateEx(init[i].children) );
  621.     }
  622.     
  623.     return ( result );
  624. };
  625.  
  626.  
  627. Schema.DOM.CreateInput = function ( type )
  628. {
  629.     if ( document.all && !window.opera )
  630.         return ( document.createElement('<input type="' + type + '" />') );
  631.     else
  632.     {
  633.         var elem = document.createElement ( "input" );
  634.         elem.setAttribute ( "type", type );
  635.         return ( elem );
  636.     }
  637. };
  638.  
  639.  
  640. Schema.DOM.InsertAfter = function ( node, org )
  641. {
  642.     if ( !node || !org )
  643.         return;
  644.         
  645.     if ( org.nextSibling )
  646.         org.parentNode.insertBefore ( node, org.nextSibling );
  647.     else
  648.         org.parentNode.appendChild ( node );
  649. };
  650.  
  651.  
  652. Schema.DOM.InsertBefore = function ( node, org )
  653. {
  654.     if ( node && org )
  655.         org.parentNode.insertBefore ( node, org ); 
  656. };
  657.  
  658.  
  659. Schema.DOM.PrependChild = function ( node, parent )
  660. {
  661.     if ( parent.firstChild )
  662.         Schema.DOM.InsertBefore ( node, parent.firstChild ); 
  663.     else
  664.         Schema.DOM.AppendChild ( node, parent );
  665. };
  666.  
  667.  
  668. Schema.DOM.RemoveChildren = function ( node )
  669. {
  670.     while ( node.firstChild )
  671.         Schema.DOM.RemoveElement ( node.firstChild );
  672. };
  673.  
  674.  
  675. Schema.DOM.RemoveElement = function ( node )
  676. {
  677.     if ( typeof(node) == 'string' )
  678.         node = document.getElementById(node);
  679.         
  680.     if ( node && node.parentNode )
  681.         node.parentNode.removeChild ( node );
  682. };
  683.  
  684.  
  685. Schema.DOM.SetStyle = function ( node, style )
  686. {
  687.     if ( node && style )
  688.     {
  689.         for ( var entry in style )
  690.             node.style[String(entry)] = style[entry];
  691.     }
  692. };
  693.  
  694. Schema.DOM.InnerHTML = function (node)
  695. {
  696.     if(node.nodeType == 3)   // text node
  697.         return node.nodeValue;
  698.     else
  699.     {
  700.         var res = "";
  701.         var n = node.firstChild;
  702.         while(n)
  703.         {
  704.             if(n.nodeType == 3)
  705.                 res += n.nodeValue;
  706.             else if(n.nodeType == 1)  // element node
  707.                 res += Schema.DOM.InnerHTML(n);
  708.                 
  709.             n = n.nextSibling;
  710.         }
  711.         return res;
  712.     }
  713. };
  714.  
  715. // =============================================================================
  716. //                                DOM HELPERS
  717. // =============================================================================
  718.  
  719. Schema.Cookies = function ( ) { };
  720. Schema.Cookies.Get = function ( key )
  721. {
  722.     Schema.Cookies.Parse ( );
  723.     return ( Schema.Cookies._obj[key] );
  724. }
  725.  
  726. Schema.Cookies.Parse = function ( )
  727. {
  728.     if ( Schema.Cookies._obj )
  729.         return;
  730.         
  731.     Schema.Cookies._obj = {};
  732.     if ( document.cookie )
  733.     {
  734.         var elements = document.cookie.split ( ";" );
  735.         for ( var i = 0; i < elements.length; i++ )
  736.         {
  737.             var pair = elements[i].split("=");
  738.             Schema.Cookies._obj[Schema.String.Trim(pair[0])] = unescape(Schema.String.Trim(pair[1]));
  739.         }
  740.     }
  741. }
  742.  
  743. Schema.Cookies.Set = function ( key, value, expiredays )
  744. {
  745.     if( !key )
  746.         return;
  747.         
  748.     Schema.Cookies.Parse ( );
  749.     Schema.Cookies._obj[key]= value;
  750.     
  751.     var exdate=new Date();
  752.     exdate.setDate(exdate.getDate()+expiredays);
  753.     document.cookie=key+"=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
  754. }