( function( )
{
var _connector = new XConnector;
var _script = new XScript;
var _location = window.location;
function Link( )
{
var _path = ( arguments.length && arguments[ 0 ].constructor == String ) ? arguments[ 0 ] : '/';
_path = (
( ( _path.indexOf( _location.protocol ) != 0 ) ? _location.protocol + '//' : '' )
+ ( ( _path.indexOf( _location.host ) != 0 ) ? _location.host : '' )
+ ( ( _path.indexOf( '/' ) != 0 ) ? '/' : '' )
) + _path;
var _last_request = null;
var _handlers_registred = {
after : null,
before : null,
data : null
};
if ( _location.protocol + '//' + _location.host + _location.pathname != _path )
window.location.href = _path + (
( _location.hash ) ?
_location.hash : '#' + String( _location.protocol + '//' + _location.host + _location.pathname + _location.search ).substr( _path.length )
);
function _click( _action, _cache )
{
switch ( _action.indexOf( _location.pathname ) )
{
case -1 :
_action = _path + ( ( _action.indexOf( '/' ) == 0 ) ? _action.substr( 1 ) : _action );
break;
case 0 :
_action = _action.replace( _location.pathname, _path );
break;
default :
if ( _action.indexOf( _path ) != 0 )
_action = _path + _action;
}
var _post = ( arguments.length == 3 && arguments[ 2 ] && arguments[ 2 ].constructor == String ) ? arguments[ 2 ] : null;
if ( _post == null && _action == _last_request )
return false;
if ( _handlers_registred.before )
_handlers_registred.before( );
_connector.go(
{
'access' : _action,
'cache' : _cache,
'handler' : _manipulator,
'post' : _post
} );
_last_request = _action;
window.location = '#' + (
( _action.indexOf( _path ) < 0 ) ?
_action : _action.substr( _action.indexOf( _path ) + _path.length )
);
}
function _intercept( pLink )
{
var action = pLink.href;
if ( action == '' )
return false;
var a = ( action.indexOf( 'javascript:' ) === 0 );
a = ( a || ( action.indexOf( '#' ) === 0 ) );
a = ( a || ( action.indexOf( window.location + '#' ) === 0 ) );
a = ( a || ! ( action.indexOf( 'workflow' ) < 0 ) );
if ( ! a )
pLink.onclick = function( )
{
var _cacheit = false;//( ( pLink.hasAttribute( 'cacheit' ) && pLink.getAttribute( 'cacheit' ) === 'true' ) ? true : false );
_click( action, _cacheit );
return false;
};
}
function _manipulator( _pData )
{
if ( ! ( _pData.constructor == String ) )
return false;
if ( _handlers_registred.data )
_pData = _handlers_registred.data( _pData );
var _line_feed = '__LINE_FEED_CHARACTER_' + ( Date.parse( new Date ) ) + '__';
_pData = _pData.trim( ).replace( /[\r\t]/g, '' ).replace( /\n/g, _line_feed );
_line_feed = new RegExp( _line_feed, 'g' );
var _css = _pData.match( new RegExp( ']*\/>', 'gi' ) );
if ( _css )
for ( var i = 0; _css, i < _css.length; i++ )
{
_pData = _pData.replace( _css[ i ], '' );
XStyle.add( ( /<[^>]*href="(\S+)"[^>]*\/>/i ).exec( _css[ i ] )[ 1 ] );
}
var _js = _pData.match( new RegExp( '