OSDN Git Service

fixed overlay.hide()
[pettanr/pettanr.git] / public / assets / common.js
index c0f241c..23649d6 100644 (file)
@@ -1,10 +1,78 @@
 /*\r
  * pettanR common.js\r
- *   version 0.4.2\r
+ *   version 0.4.21\r
  * \r
  * author: itozyun\r
  */\r
 \r
+/*\r
+ * http://pettanr.sourceforge.jp/test/type.html
+ */\r
+       var Type = {\r
+               isObject : function(v) {\r
+                       return v !== null && Type.isArray(v) === false && typeof v === 'object';\r
+               },\r
+               isFunction : function(v) {\r
+                       return typeof v === 'function';\r
+               },\r
+               isArray : function(v) {\r
+                       return Object.prototype.toString.call(v) === "[object Array]";\r
+               },\r
+               isBoolean : function(v) {\r
+                       return typeof v === 'boolean';\r
+               },\r
+               isString : function(v) {\r
+                       return typeof v === 'string';\r
+               },\r
+               isNumber : function(v) {\r
+                       return typeof v === 'number';\r
+               },\r
+               isFinite : function(v){\r
+                       return Type.isNumber(v) === true && isFinite(v);\r
+               },\r
+               isHTMLElement : function(v){\r
+                       if( 'HTMLElement' in window ){\r
+                               Type.isHTMLElement = function(v){\r
+                                       return v instanceof HTMLElement;\r
+                               }\r
+                       } else {\r
+                               Type.isHTMLElement = function(v) {\r
+                                       if( Type.isObject(v) === false ){\r
+                                               return false;\r
+                                       }\r
+                                       var r;\r
+                                       if(v && v.nodeType === 1){\r
+                                               try{\r
+                                                       r = v.cloneNode(false);\r
+                                               } catch(n) {\r
+                                                       return false;\r
+                                               }\r
+                                               if(r === v) return false;\r
+                                               try{\r
+                                                       r.nodeType = 9;\r
+                                                       return r.nodeType === 1;\r
+                                               } catch(n) {}\r
+                                               return true;\r
+                                       }\r
+                                       return false;\r
+                               }\r
+                       }\r
+                       return Type.isHTMLElement(v);\r
+               },\r
+               /*\r
+               isElementCollection : function(v) {\r
+                       return (Object.prototype.toString.call(v) === "[object HTMLCollection]");\r
+               },\r
+               */\r
+               isNull : function(v) {\r
+                       return v === null;\r
+               },\r
+               isUndefined : function(v) {\r
+                       return typeof v === 'undefined';\r
+               }\r
+       };\r
+\r
+\r
 var pettanr = ( function(){\r
        var     FUNCTION_ARRAY = [],\r
                URL = document.location.href.split( '#')[ 0],\r
@@ -15,19 +83,19 @@ var pettanr = ( function(){
                    if( 1 < l){\r
                        var     query = search.substring( 1),\r
                                        params = query.split( '&'),\r
-                                       ret = {}, elm, name;\r
+                                       ret = {}, elm, name, v;\r
                        while( params.length > 0){\r
                            elm = params.shift().split( '=');\r
                                        name = decodeURIComponent( elm[ 0]);\r
                                        if( elm.length === 2){\r
-                                   ret[ name] = ( function( v){\r
-                                                       if( '' + parseFloat( v) === v) return parseFloat( v);\r
-                                                       if( v === 'true') return true;\r
-                                                       if( v === 'false') return false;\r
-                                                       if( v === 'null') return null;\r
-                                                       if( v === 'undefined') return undefined;\r
-                                                       return v;\r
-                                               })( decodeURIComponent( elm[ 1]));\r
+                                               v = decodeURIComponent( elm[ 1]);\r
+                                               if( '' + parseFloat( v) === v) v = parseFloat( v);\r
+                                               if( '' + parseInt( v, 10 ) === '0' + v) v = parseInt( v, 10 );\r
+                                               if( v === 'true') v = true;\r
+                                               if( v === 'false') v = false;\r
+                                               if( v === 'null') v = null;\r
+                                               if( v === 'undefined') v = undefined;\r
+                                   ret[ name] = v;\r
                                        } else\r
                                        if( elm.length === 1){\r
                                                ret[ name] = true;\r
@@ -37,10 +105,10 @@ var pettanr = ( function(){
                    }\r
                    return {};\r
                })(),\r
-               IS_DEBUG = typeof URL_PARAMS.debug === 'boolean' ? URL_PARAMS.debug : IS_LOCAL === true,\r
+               IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true,\r
                jqWindow , jqDocument , jqBody;\r
        return {\r
-               version: '0.4.2',\r
+               version: '0.4.21',\r
                init: function(){\r
                        jqWindow = $( window);\r
                        jqDocument = $( document);\r
@@ -50,7 +118,7 @@ var pettanr = ( function(){
                                _fn;\r
                        for( var i=0; i<l; i++){\r
                                _fn = FUNCTION_ARRAY[ i];\r
-                               _fn.init && _fn.init( _fn === pettanr.view ? FUNCTION_ARRAY : undefined);\r
+                               _fn.init && _fn.init( _fn === pettanr.view ? FUNCTION_ARRAY : undefined );\r
                        }\r
                        \r
                        delete pettanr.init;\r
@@ -143,16 +211,24 @@ pettanr.util = ( function(){
        nodeNoscript = noscript = null;\r
        \r
        function cleanCommnetNode( _targetElm){\r
-               _targetElm = _targetElm || document;\r
-               var _nodes = _targetElm.all || _targetElm.getElementsByTagName( '*'),\r
-                       _array = [],\r
-                       _elm;\r
-               for(var i=0, l = _nodes.length; i<l; ++i){\r
-                       _array.push( _nodes[ i]);\r
-               }\r
-               for( i=0; i<l; ++i){\r
-                       _elm = _array[ i];\r
-                       _elm.nodeType === 8 && _elm.parentNode && _elm.parentNode.removeChild( _elm);\r
+               search( _targetElm || document.body );\r
+               \r
+               function search( _elm){\r
+                       if( !_elm) return;\r
+                       if( _elm.nodeType === 8){\r
+                               _elm.parentNode.removeChild( _elm);\r
+                               return;\r
+                       }\r
+                       var i, l, _children = _elm.childNodes, _array = [];\r
+                       if( _children && typeof _children.length === 'number'){\r
+                               // liveNode > array\r
+                               for( i=0, l=_children.length; i<l; ++i){\r
+                                       _array.push( _children[ i ] );\r
+                               }\r
+                               while( _array.length !== 0 ){\r
+                                       search( _array.shift());\r
+                               }\r
+                       }\r
                }\r
        }\r
        return {\r
@@ -227,7 +303,9 @@ pettanr.util = ( function(){
                                displayNone = img.style.display === 'none';\r
                        if( displayNone === true) img.style.display = '';\r
                        IMG_SIZE_GETTER.appendChild( img);\r
+                       \r
                        var size = getActualDimension( img);\r
+                       \r
                        IMG_SIZE_GETTER.removeChild( img);\r
                        if( displayNone === true) img.style.display = 'none';\r
                        if( nextElm){\r
@@ -238,7 +316,6 @@ pettanr.util = ( function(){
                        } else {\r
                                parentElm && parentElm.appendChild( img);\r
                        }\r
-                       return size;\r
                        \r
                /* LICENSE: MIT\r
                 * AUTHOR: uupaa.js@gmail.com\r
@@ -268,20 +345,6 @@ pettanr.util = ( function(){
                                                run.width  = mem.w; // restore\r
                                                run.height = mem.h;\r
                                        } else { // for Opera and Other\r
-                                       /*\r
-                                               function fn() {\r
-                                                       w = image.width;\r
-                                                       h = image.height;\r
-                                               }\r
-                                               mem = { w: image.width, h: image.height }; // keep current style\r
-                                               image.removeAttribute("width");\r
-                                               image.addEventListener("DOMAttrModified", fn, false);\r
-                                               image.removeAttribute("height");\r
-                                               // call fn\r
-                                               image.removeEventListener("DOMAttrModified", fn, false);\r
-                                               image.width  = mem.w; // restore\r
-                                               image.height = mem.h;\r
-                                       */\r
                                                mem = { w: image.width, h: image.height }; // keep current style\r
                                                image.removeAttribute("width");\r
                                                image.removeAttribute("height");\r
@@ -295,6 +358,8 @@ pettanr.util = ( function(){
                                // HTMLCanvasElement\r
                                return { width: image.width, height: image.height };\r
                        }\r
+                       \r
+                       return size;\r
                },\r
                loadImage: function( URLorELM, onLoad, onError, delay, timeout){\r
                        delay = delay || 250;\r
@@ -432,7 +497,7 @@ pettanr.util = ( function(){
                        if( !IDorELM) return;\r
                        IDorELM.parentNode && IDorELM.parentNode.removeChild( IDorELM);\r
                        if( IDorELM.id && IDorELM.id.indexOf( 'templete-') === 0){\r
-                               IDorELM.id = '';\r
+                               IDorELM.removeAttribute( 'id');\r
                        }\r
                        return IDorELM;\r
                },\r
@@ -442,20 +507,20 @@ pettanr.util = ( function(){
                                _node, _classes, ret = [];\r
                        for( var i=0, l = _nodes.length; i<l; ++i){\r
                                _node = _nodes[ i];\r
-                               if( _node.nodeType === 1){\r
-                                       _classes = _node.className.split( ' ');\r
-                                       for( var j=0, m=_classes.length; j<m; ++j){\r
-                                               if( _classes[ j] === _className){\r
-                                                       ret.push( _node);\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-                               }\r
+                               _node.nodeType === 1 && this.hasClassName( _node, _className) === true && ret.push( _node);\r
                        }\r
                        return ret;\r
                },\r
+               getChildIndex: function( _parent, _child){\r
+                       var _children = _parent.getElementsByTagName( _child.tagName ),\r
+                               l = _children.length;\r
+                       for(var i=0; i<l; ++i){\r
+                               if( _children[ i] === _child) return i;\r
+                       }\r
+                       return -1;\r
+               },\r
                hasClassName: function( _elm, _className){\r
-                       var _classes = _elm.className.split( ' ');\r
+                       var _classes = ( _elm.className || '').split( ' ');\r
                        for( var i=0, l=_classes.length; i<l; ++i){\r
                                if( _classes[ i] === _className) return true;\r
                        }\r
@@ -472,6 +537,28 @@ pettanr.util = ( function(){
                                _node.parentNode && _node.parentNode.removeChild( _node);\r
                        }\r
                },\r
+               getIndex: function( _array, _element){\r
+                       if( Array.prototype.indexof ){\r
+                               pettanr.util.getIndex = function( _array, _element){\r
+                                       return _array.indexof( _element);\r
+                               }\r
+                       } else {\r
+                               pettanr.util.getIndex = function( _array, _element){\r
+                                       for( var i=0, l = _array.length; i<l; ++i){\r
+                                               if( _array[ i] === _element) return i;\r
+                                       }\r
+                                       return -1;                                      \r
+                               }\r
+                       }\r
+                       return pettanr.util.getIndex( _array, _element);\r
+               },\r
+               copyArray: function( _array ){\r
+                       var ret = new Array( l );\r
+                       for(var i=0, l = _array.length; i<l; ++i){\r
+                               ret[ i ] = _array[ i ];\r
+                       }\r
+                       return ret;\r
+               },\r
                /*\r
                 * \r
                 */\r
@@ -518,6 +605,43 @@ pettanr.util = ( function(){
                                }\r
                        }\r
                        return randomKey;\r
+               },\r
+               createIframe: function( id, callback){\r
+                       var ua = pettanr.ua;\r
+            var el = document.createElement( ua.isIE ? '<iframe name="' + id + '" frameborder="0" scrolling="no">' : 'iframe');\r
+\r
+            if( ua.isIE){\r
+                               el.onreadystatechange = detect;\r
+            } else {\r
+               // iron(chrome) の場合、append の前に onload を指定しないと onload が呼ばれない\r
+               el.onload = onLoad;\r
+               //setTimeout( asynkCallback, 0 );\r
+                       }\r
+\r
+                       document.body.appendChild( el);\r
+            el.id = el.name = id;\r
+            el.setAttribute( 'name', id);\r
+            el.style.cssText = 'width:1px;height:1px;visibility:hidden;position:absolute;top:1px;left:1px;';\r
+                       // http://d.hatena.ne.jp/onozaty/20070830/p1\r
+                       // [JavaScript]IE6ではJavaScriptで動的に作成したiframeに対してsubmitできない(IE7は未確認) ->解決\r
+                       el.contentWindow.name = id;                                     \r
+            \r
+            window[id] = el;\r
+\r
+            function detect(){\r
+                if ( this.readyState === "complete") {\r
+                    this.onreadystatechange = new Function();\r
+                    this.onreadystatechange = null;\r
+                    setTimeout( asynkCallback, 0 );\r
+                }\r
+            }\r
+                       function onLoad(){\r
+                               el.onload = null;\r
+                               setTimeout( asynkCallback, 0 );\r
+                       }\r
+                       function asynkCallback(){\r
+                               callback( el );\r
+                       }\r
                }\r
        }\r
 })();\r
@@ -557,33 +681,54 @@ pettanr.ua = ( function(){
                ieVersion = isIE === true ? parseInt( navigator.appVersion.toLowerCase().replace( /.*msie[ ]/, '').match( /^[0-9]+/)) : 0,\r
                ieRenderingVersion = ieVersion === 8 ? document.documentMode : ieVersion,\r
                isStanderdMode = document.compatMode === 'CSS1Compat',\r
-               VML = ( function(){\r
+               ActiveX = ( function(){\r
                        if( isIE === false || ieVersion > 8) return false;\r
+                       var     b = document.body,\r
+                               c = b.className || '',\r
+                               x,\r
+                               ret = pettanr.URL_PARAMS.ActiveX,\r
+                               ns = 'pettanr-ActiveX-',\r
+                               enabled = 'enabled',\r
+                               disabled = 'disabled';\r
+                       if( ret !== true && ret !== false){\r
+                               if( pettanr.util.hasClassName( b, ns + enabled) === true) return true;\r
+                               if( pettanr.util.hasClassName( b, ns + disabled) === true) return false;\r
+                               x = document.createElement('div');\r
+                               b.appendChild(x);\r
+                               x.style.cssText = 'width:1px;height:1px;line-height:1px;filter:progid:DXImageTransform.Microsoft.Shadow()';\r
+                               ret = x.offsetHeight > 1;\r
+                               b.removeChild(x);\r
+                       }\r
+                       b.className += [ c !== '' ? ' ' : c, ns, ret === true ? enabled : disabled ].join( '');\r
+                       return ret;\r
+               })(),\r
+               VML = ( function(){\r
+                       if( ActiveX === false || isIE === false || ieVersion > 8) return false;\r
                        var globalObjectName = pettanr.util.createGlobalUniqueName(),\r
-                               script;\r
-                       document.write( [ '<!--[if gte vml 1]><script id="detectVML">window', '.', globalObjectName, '=1;<\/script><![endif]-->'].join( ''));\r
+                               script,\r
+                               id = 'detectVML';\r
+                       document.write( [ '<!--[if gte vml 1]><script id="', id, '">window', '.', globalObjectName, '=1;<\/script><![endif]-->'].join( ''));\r
                        if( window[globalObjectName] === 1){\r
-                               script = document.getElementById( 'detectVML');\r
+                               script = document.getElementById( id);\r
                                script.parentNode.removeChild( script);\r
-                               window[globalObjectName] = script = null;\r
+                               window[globalObjectName] = null;\r
                                return true;\r
                        }\r
-                       //pettanr.util.cleanCommnetNode();\r
                        return false;\r
                })(),\r
                isStandAloneMode = ( function(){\r
                        if( isIE === false) return false;\r
                        if( VML === true) return false;\r
                        var globalObjectName = pettanr.util.createGlobalUniqueName(),\r
-                               script;\r
-                       document.write( [ '<!--[if IE ', Math.floor( ieVersion), ']><script id="detectStandAlone">window', '.', globalObjectName, '=1;<\/script><![endif]-->'].join( ''));\r
+                               script,\r
+                               id = 'detectStandAlone';\r
+                       document.write( [ '<!--[if IE ', Math.floor( ieVersion), ']><script id="', id, '">window', '.', globalObjectName, '=1;<\/script><![endif]-->'].join( ''));\r
                        if( window[globalObjectName] === 1){\r
-                               script = document.getElementById( 'detectStandAlone');\r
+                               script = document.getElementById( id);\r
                                script.parentNode.removeChild( script);\r
-                               window[globalObjectName] = script = null;\r
+                               window[globalObjectName] = null;\r
                                return false;\r
                        }\r
-                       //pettanr.util.cleanCommnetNode();\r
                        return true;\r
                })();\r
        return {\r
@@ -610,24 +755,7 @@ pettanr.ua = ( function(){
                        }\r
                        return '';\r
                })(),\r
-               ACTIVEX: ( function(){\r
-                       if( isIE === false || ieVersion > 8) return false;\r
-                       var     b = document.body,\r
-                               c = b.className || '',\r
-                               x,\r
-                               ret = pettanr.URL_PARAMS.ActiveX;\r
-                       if( ret === undefined){\r
-                               if( pettanr.util.hasClassName( b, 'pettanr-ActiveX-enabled') === true) return true;\r
-                               if( pettanr.util.hasClassName( b, 'pettanr-ActiveX-disabled') === true) return false;\r
-                               x = document.createElement('div');\r
-                               b.appendChild(x);\r
-                               x.style.cssText = 'width:1px;height:1px;filter:progid:DXImageTransform.Microsoft.Shadow()';\r
-                               ret = x.offsetHeight > 1;\r
-                               b.removeChild(x);\r
-                       }\r
-                       b.className += [ c !== '' ? ' ' : c, 'pettanr-ActiveX-', ret === true ? 'enabled' : 'disabled'].join( '');\r
-                       return ret;\r
-               })(),\r
+               ACTIVEX: ActiveX,\r
                VML: VML,\r
                STANDALONE: isStandAloneMode,\r
                startVML: function(){\r
@@ -644,21 +772,32 @@ pettanr.ua = ( function(){
 \r
 pettanr.CONST = ( function(){\r
        var isLocal = pettanr.LOCAL === true || pettanr.URL_PARAMS.exjson === false,\r
-               RETTANR_ROOOT_PATH = 'http:\/\/pettanr.heroku.com\/';\r
+               isLocalhost = document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0,\r
+               PETTANR_ROOT_PATH = isLocalhost === true ? 'http:\/\/localhost:3000\/' : 'http:\/\/pettanr.heroku.com\/';\r
+               \r
        return {\r
-               PETTANR_ROOT_PATH:                      RETTANR_ROOOT_PATH,\r
-               URL_ORIGINAL_PICTURES_JSON: ( isLocal === true ? 'json\/' : RETTANR_ROOOT_PATH) + 'original_pictures.json',\r
-               URL_PANELS_JSON:                        ( isLocal === true ? 'json\/' : RETTANR_ROOOT_PATH) + 'panels.json',\r
+               PETTANR_ROOT_PATH:                      PETTANR_ROOT_PATH,\r
+               URL_ORIGINAL_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'original_pictures.json',\r
+               URL_RESOURCE_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'resource_pictures.json',\r
+               URL_COMICS_JSON:                        ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'comics.json',\r
+               URL_PANELS_JSON:                        ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'panels.json',\r
                NS_PETTANR_COMIC:                       'pettanr-comic',\r
-               RESOURCE_PICTURE_PATH:          ( isLocal === true ? pettanr.ROOT_PATH : RETTANR_ROOOT_PATH) + 'resource_pictures\/'\r
+               RESOURCE_PICTURE_PATH:          ( isLocal === true ? '' : PETTANR_ROOT_PATH) + 'resource_pictures\/',\r
+               CREATE_COMIC_JS:                        isLocal === true ? 'js\/create_new_comic.js' : PETTANR_ROOT_PATH + 'comics\/new.js',\r
+               CREATE_PANEL_JS:                        isLocal === true ? 'js\/create_new_panel.js' : PETTANR_ROOT_PATH + 'panels\/new.js',\r
+               UPLOAD_PICTURE_JS:                      isLocal === true ? 'js\/upload_picture.js' : PETTANR_ROOT_PATH + 'original_pictures\/new.js',\r
+               REGISTER_ARTIST_JS:                     isLocal === true ? 'js\/register_artist.js' : PETTANR_ROOT_PATH + 'artists\/new.js',\r
+               JQUERY_URL:                                     isLocal === true ? 'javascripts\/jquery-1.6.2.min.js' : PETTANR_ROOT_PATH + 'assets\/jquery-162_min.js'\r
        }\r
 })();\r
 \r
-\r
 pettanr.view = ( function(){\r
        /* create iframe overlay for user console */\r
        var location = document.location.pathname,\r
-               isWorkPage = location.indexOf( '\/work.html') !== -1 || location.indexOf( '\work.html') !== -1,\r
+               isWorkPage =    document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0 ||\r
+                                               document.location.href.indexOf( pettanr.CONST.PETTANR_ROOT_PATH ) === 0 ||\r
+                                               location.indexOf( '\/work.html') !== -1 ||\r
+                                               location.indexOf( '\work.html') !== -1, // for ie6\r
                deep =  location.indexOf( '\/diary\/') !== -1 ||\r
                                location.indexOf( '\/test\/') !== -1 ||\r
                                location.indexOf( '\/help\/') !== -1 ||\r
@@ -667,207 +806,29 @@ pettanr.view = ( function(){
                LoginUserNavi;\r
 \r
        if( isWorkPage === false){\r
-               LoginUserNavi = ( function(){\r
-                       var _body = document.body,\r
-                               _root = document.getElementsByTagName( 'html')[ 0],\r
-                               filter,\r
-                               iframe, visible = false;\r
-                       return {\r
-                               init: function( viewIndex){\r
-                                       filter = document.createElement( 'div');\r
-                                       filter.style.position = 'absolute';\r
-                                       filter.style.left = filter.style.top = '0px';\r
-                                       filter.style.width = filter.style.height ='100%';\r
-                                       filter.style.backgroundColor = '#fff';\r
-       \r
-                                       var ua = pettanr.ua,\r
-                                               id = 'work',\r
-                                               src = [\r
-                                                               deep === true ? '../' : '',\r
-                                                               'work.html',\r
-                                                               typeof viewIndex === 'number' ? '?view=' +viewIndex : ''\r
-                                               ].join( '');\r
-                                       \r
-                                       var el = document.createElement(ua.isIE ? '<iframe name="' + id + '" src="' + src + '">' : 'iframe');\r
-                                       el.id = el.name = id;\r
-                                       el.setAttribute( 'name', id);\r
-                                       \r
-                                       el.style.position = 'absolute';\r
-                                       el.style.left = el.style.top = '0px';\r
-                                       el.style.width = el.style.height ='100%';\r
-                                       //el.style.overflow = 'hidden';\r
-                                       el.hspace = el.vspace = el.marginheight = el.marginwidth = 0;\r
-                                       \r
-                                       _body.appendChild(el);\r
-                                       window[id] = el;\r
-                                       iframe = el;\r
-                                       \r
-                                       if (!ua.isIE) {\r
-                                               var idoc;//WebKit > 521 corresponds with Safari 3, which started with 522 WebKit version.\r
-                                               if (ua.isWebKit > 521) {\r
-                                                       idoc = el.contentWindow.document;\r
-                                               } else if (ua.isSafari) {\r
-                                                       idoc = el.document;\r
-                                               } else { //  if(d.isMozilla){\r
-                                                       idoc = el.contentWindow;\r
-                                               }\r
-                                               \r
-                                               if ( !idoc) {\r
-                                                       try {\r
-                                                               el.src = src;\r
-                                                               el.contentWindow.location.replace = src;                                                        \r
-                                                       } catch (e){}\r
-                                                       try {\r
-                                                               //el.contentWindow.location = src;                                                      \r
-                                                       } catch (e){}\r
-                                                       try {\r
-                                                               el.location = src; // for Safari 2.0.3 ??\r
-                                                       } catch (e){}\r
-                                                       \r
-                                               } else if( ua.isOpera){\r
-                                                       el.src = src; // for Opera\r
-                                                       el.contentWindow.location.replace = src; // for Opera\r
-                                               } else {\r
-                                                       //el.src = src; // for firefox\r
-                                                       idoc.location.replace(src);\r
-                                               }\r
-                                       }\r
-                                       \r
-                                       delete LoginUserNavi.init;\r
-                               },\r
-                               show: function(){\r
-                                       if(visible === true) return;\r
-                                       if (_root) {\r
-                                               _root.style.overflow = 'hidden';\r
-                                       }\r
-                                       _body.style.overflow = 'hidden';\r
-                                       \r
-                                       var index = ( function( a){\r
-                                               var node = a.parentNode.getElementsByTagName( 'a'),\r
-                                                       l = node.length;\r
-                                               for( var i=0; i<l; ++i){\r
-                                                       if( node[ i] === a) return i\r
-                                               }\r
-                                               return -1;\r
-                                       })( this);\r
-                                       if( index === -1) return false;\r
-                                       \r
-                                       LoginUserNavi.init && LoginUserNavi.init( index);\r
-                                       \r
-                                       iframe.parentNode !== _body && _body.appendChild( iframe);\r
-                                       \r
-                                       _body.insertBefore( filter, iframe);\r
-                                       \r
-                                       visible = true;\r
-                                       \r
-                                       return false;\r
-                               },\r
-                               hide: function(){\r
-                                       if(visible === false) return;\r
-                                       \r
-                                       _body.removeChild(filter);\r
-                                       _body.style.overflow = '';\r
-                                       if (_root) {\r
-                                               _root.style.overflow = '';\r
-                                       }\r
-                                       _body.removeChild(iframe);\r
-                                       \r
-                                       visible = false;\r
-                               }\r
-                       }\r
-               })();\r
-       } else {\r
-               LoginUserNavi = ( function(){\r
-                       return {\r
-                               show: function(){\r
-                                       var _nodes = this.parentNode.getElementsByTagName( 'a');\r
-                                       for( var i=0, l=_nodes.length; i<l; ++i){\r
-                                               if( _nodes[ i] === this){\r
-                                                       pettanr.view.show( i);\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-                                       return false;\r
-                               },\r
-                               hide: function(){}\r
-                       }\r
-               })();\r
-\r
-               if( pettanr.IS_IFRAME === true){\r
-                       var _nodes = document.getElementsByTagName( 'a'),\r
-                               _a, _href;\r
-                       for(var i=0, l = _nodes.length; i<l; i++){\r
-                               _a = _nodes[ i];\r
-                               _href = _a.href.split('?')[0].split('#')[0];\r
-                               if( pettanr.util.getAbsolutePath( _href) !== location) _a.target = '_parent';\r
-                       }\r
+               LoginUserNavi = {\r
+                       show: function(){\r
+                               var i = pettanr.util.getChildIndex( this.parentNode, this );\r
+                               document.location.href = [\r
+                                               deep === true ? '../' : '',\r
+                                               'work.html',\r
+                                               typeof i === 'number' ? '?view=' + i : ''\r
+                                       ].join( '');\r
+                               return false;\r
+                       },\r
+                       hide: function(){}\r
                }\r
-               \r
-               if( pettanr.DEBUG === true){\r
-                       var elmDl = document.getElementById( 'useragent'),\r
-                               elmDt, elmDd,\r
-                               data = {\r
-                                       pettanR:        pettanr.version,\r
-                                       ua:                     navigator.userAgent,\r
-                                       platform:       navigator.platform,\r
-                                       appVersion:     navigator.appVersion,\r
-                                       appCodeName:navigator.appCodeName,\r
-                                       appName:        navigator.appName,\r
-                                       language:       navigator.browserLanguage || navigator.language,\r
-                                       ActiveX:        pettanr.ua.ACTIVEX\r
-                               },\r
-                               ua = pettanr.ua;\r
-                       if( ua.IE){\r
-                               //data.ua = 'Internet Explorer';\r
-                               data.version = ua.IE;\r
-                               if( ua.ieVersion >= 8) data.RenderingVersion = ua.ieRenderingVersion;\r
-                               data.browserType = ua.STANDALONE === true ? 'Standalone' : 'bundle';\r
-                               if( ua.ieVersion < 9) {\r
-                                       data.vml = ua.VML;\r
-                               } else {\r
-                                       data.svg = ua.SVG;\r
-                               }\r
-                       }\r
-                       data.RenderingMode = ua.isStanderdMode === true ? 'Standerd' : 'Quirks';\r
-                       \r
-                       for( var key in data){\r
-                               elmDt = document.createElement( 'dt');\r
-                               elmDt.innerHTML = key;\r
-                               elmDd = document.createElement( 'dd');\r
-                               elmDd.innerHTML = '' + data[ key];\r
-                               if( !data[ key]) elmDd.style.color = 'red';\r
-                               elmDl.appendChild( elmDt);\r
-                               elmDl.appendChild( elmDd);\r
-                       }\r
-               } else {\r
-                       var _debug = document.getElementById( 'debug');\r
-                       if( _debug){\r
-                               pettanr.util.removeAllChildren( _debug);\r
-                               _debug.parentNode.removeChild( _debug);\r
-                       }\r
+       } else {\r
+               LoginUserNavi = {\r
+                       show: function(){\r
+                               var i = pettanr.util.getChildIndex( this.parentNode, this );\r
+                               i !== -1 && bootApplication( i );\r
+                               return false;\r
+                       },\r
+                       hide: function(){}\r
                }\r
        }\r
 \r
-       /* global-navi */\r
-       var navi = document.getElementById('global-navi'),\r
-               origin = document.createElement('a'),\r
-               items = ( function(){\r
-                       var ret = ['Home', 'Comic list', 'Picture', 'Setting'];\r
-                       pettanr.DEBUG === true && ret.push( 'debug');\r
-                       return ret;\r
-               })(),\r
-               l = items.length,\r
-               item;\r
-       origin.href = '#';\r
-       for(var i=0; i<l; ++i){\r
-               item = origin.cloneNode( true);\r
-               item.innerHTML = items[ i];\r
-               item.onclick = LoginUserNavi.show;\r
-               navi.appendChild( item);\r
-       }\r
-       navi.style.width = ( ( item.offsetWidth || 80) * l) +'px';\r
-       location = origin = item = null;\r
-       \r
        /* debug info */\r
        // ua version, lang, os, plugin ( vml, svg), standerdmode, balloon, rimg\r
 \r
@@ -879,107 +840,234 @@ pettanr.view = ( function(){
  */\r
 \r
        var jqWindow,\r
-               funcArray,\r
-               HOME_ID = 'entrance',\r
-               VIEW_ID_ARRAY = [ HOME_ID, 'cabinet', 'gallery', 'backyard'],\r
-               elmCurrent,\r
-               currentView,\r
-               currentID = ( function( _view){\r
-                       var _viewID;\r
-                       \r
-                       if( typeof _view === 'number' && _view < VIEW_ID_ARRAY.length){\r
-                               _viewID = VIEW_ID_ARRAY[ _view];\r
-                       } else\r
-                       if( typeof _view === 'string'){\r
-                               _viewID = _view;\r
+               APPLICATION_LIST = [],\r
+               LUNCHER_APPLICATION_LIST = [],\r
+               currentApplication = null;\r
+       \r
+       var AbstractBasicPane = function(){\r
+               this.onPaneResize = function( _w, _h ){}\r
+               this.resize = function( _w, _h ){\r
+                       if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){\r
+                               if( Type.isHTMLElement( this.rootElement ) === true ){\r
+                                       // 小さすぎる!、と表示\r
+                               }\r
+                               return;\r
+                       }\r
+                       this.onPaneResize( _w, _h );\r
+               }\r
+               this.MIN_WIDTH = 240;\r
+               this.MIN_HEIGHT = 240;\r
+       }\r
+       \r
+       var AbstractApplication = function(){\r
+               this.displayName = 'app name';\r
+               this.ID = 'app id';\r
+               this.rootElement = null;\r
+               this.parentElement = null;\r
+               this.nextSibling = null;\r
+               this.open = function( _w, _h /*, _option */ ){\r
+                       if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){\r
+                               if( Type.isHTMLElement( this.rootElement ) === true ){\r
+                                       // 小さすぎる!、と表示\r
+                               }\r
+                       }\r
+                       if( arguments.length > 2){\r
+                               // argumentsRellay( this.onOpen, arguments );\r
+                               this.onOpen.apply( this, arguments );\r
                        } else {\r
-                               _viewID = HOME_ID;\r
+                               this.onOpen( _w, _h );\r
                        }\r
-\r
-                       if( document.getElementById( _viewID)){\r
-                               return _viewID;\r
+               }\r
+               this.close = function(){\r
+                       if( this.onClose() === false ){\r
+                               return false;\r
                        }\r
-                       return HOME_ID;\r
-               })( pettanr.URL_PARAMS.view);\r
-       \r
-       pettanr.DEBUG === true && VIEW_ID_ARRAY.push( 'debug');\r
+               }\r
+               this.onOpen = function( _w, _h /*, _option */ ){\r
+                       // overrride\r
+               };\r
+               this.onClose = function(){\r
+                       // overrride\r
+                       return true;\r
+               } // false の場合、close の拒否 \r
+       }\r
+       AbstractApplication.prototype = new AbstractBasicPane();\r
        \r
-       show();\r
+       var ApplicationReference = function( application ){\r
+               this.inOverlay = false;\r
+               this.getUID = function(){\r
+                       return pettanr.util.getIndex( APPLICATION_LIST, application );\r
+               }\r
+               this.boot = function( /* _option */ ){\r
+                       if( arguments.length > 0 ){\r
+                               bootApplication( application, pettanr.util.copyArray( arguments ) );\r
+                       } else {\r
+                               bootApplication( application );\r
+                       }\r
+               }\r
+               this.bootInOverlay = function( /* _option */ ){\r
+                       this.inOverlay = true;\r
+                       pettanr.overlay.show( application, pettanr.util.copyArray( arguments ) );\r
+               }\r
+               this.shutdown = function(){\r
+                       if( this.inOverlay === true ){\r
+                               pettanr.overlay.hide();\r
+                               this.inOverlay = false;\r
+                       } else {\r
+                               bootApplication( 0 );\r
+                       }\r
+               }\r
+               this.addToLancher = function(){\r
+                       if( pettanr.util.getIndex( LUNCHER_APPLICATION_LIST, application ) !== -1 ) return;\r
+                       LUNCHER_APPLICATION_LIST.push( application );\r
        \r
-       function onWindowResize(){\r
-               var _fn,\r
-                       l = funcArray.length,\r
-                       w = jqWindow.width(),\r
-                       h = jqWindow.height();\r
-               //for( var i=0; i<l; ++i){\r
-               //      _fn = funcArray[ i];\r
-               //      _fn.onWindowResize && _fn.onWindowResize( w, h);\r
-               //}\r
-               currentView && currentView.onWindowResize && currentView.onWindowResize( w, h);\r
-               pettanr.overlay.currentID !== null && pettanr.overlay.onWindowResize( w, h);\r
+                       var navi = document.getElementById('global-navi'),\r
+                               item = document.createElement('a');\r
+                       navi.appendChild( item );\r
+                       navi.style.width = ( ( item.offsetWidth || 80 ) * LUNCHER_APPLICATION_LIST.length ) + 'px';\r
+                       item.href = '#';\r
+                       item.appendChild( document.createTextNode( application.displayName ));\r
+                       item.onclick = LoginUserNavi.show;\r
+               }\r
        }\r
-       function show(){\r
-               if( isWorkPage === false) return;\r
+\r
+       function bootApplication( APPLICATIONorINDEX, _arguments ){\r
+               if( isWorkPage === false ) return;\r
+\r
+               var _application,\r
+                       i, j, l, \r
+                       nodesA = document.getElementById('global-navi').getElementsByTagName( 'a') || [],\r
+                       _index = -1;\r
+               if( typeof APPLICATIONorINDEX === 'number' && APPLICATIONorINDEX < LUNCHER_APPLICATION_LIST.length){\r
+                       _application = LUNCHER_APPLICATION_LIST[ APPLICATIONorINDEX ];\r
+               } else\r
+               if( typeof APPLICATIONorINDEX === 'string' ){\r
+                       for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
+                               if( APPLICATIONorINDEX === APPLICATION_LIST[ i ].ID ){\r
+                                       _application = APPLICATION_LIST[ i ];\r
+                                       break;\r
+                               }\r
+                       }\r
+               } else\r
+               if( pettanr.view.isApplicationInstance( APPLICATIONorINDEX ) === true ){\r
+                       _application = APPLICATIONorINDEX;\r
+               } else\r
+               if( !currentApplication ){\r
+                       _application = LUNCHER_APPLICATION_LIST[ 0 ];\r
+               } else {\r
+                       return;\r
+               }\r
                \r
-               var _elm = document.getElementById( currentID);\r
-               if( elmCurrent) elmCurrent.style.display = 'none';\r
-               _elm.style.display = 'block';\r
-               elmCurrent = _elm;\r
+               if( !_application ) return;\r
                \r
-               var     nodesA = navi.getElementsByTagName( 'a') || [],\r
-                       l = nodesA.length,\r
-                       _a;\r
-               for(var i=0; i<l; ++i){\r
-                       if( nodesA[ i]){\r
-                               nodesA[ i].className = VIEW_ID_ARRAY[ i] === currentID ? 'current' : '';\r
+               for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
+                       if( _application === LUNCHER_APPLICATION_LIST[ i ] ){\r
+                               for( j=0, l=nodesA.length; j<l; ++j ){\r
+                                       nodesA[ j ].className = i === j ? 'current' : '';\r
+                               }                                       \r
+                               break;\r
                        }\r
                }\r
                \r
-               if( !pettanr.view || pettanr.view.init !== undefined) return;\r
-               currentView = pettanr[ currentID];\r
-               if( !currentView) return;\r
-               typeof currentView.onOpen === 'function' && currentView.onOpen();\r
-               setTimeout( onWindowResize, 0);\r
+               if( currentApplication === _application ) return;\r
+               if( currentApplication ){\r
+                       currentApplication.close();\r
+                       currentApplication.rootElement && currentApplication.rootElement.parentNode &&\r
+                               currentApplication.rootElement.parentNode.removeChild( currentApplication.rootElement );\r
+               }\r
+                       \r
+               currentApplication = _application;\r
+               \r
+               if( _application.nextSibling && _application.nextSibling.parentNode === _application.parentElement ){\r
+                       _application.parentElement.insertBefore( _application.rootElement, _application.nextSibling );\r
+               } else\r
+               if( _application.parentElement ){\r
+                       _application.parentElement.appendChild( _application.rootElement );\r
+               } else {\r
+                       _application.rootElement && document.body.appendChild( _application.rootElement );\r
+               }\r
+                       \r
+               if( _arguments ){\r
+                       _arguments.unshift( jqWindow.width(), jqWindow.height() );\r
+                       _application.open.apply( _application, _arguments );\r
+                       // argumentsRellay( _application.open, _arguments );\r
+               } else {\r
+                       _application.open( jqWindow.width(), jqWindow.height() );\r
+               }\r
+               pettanr.view.currentID = _application.ID;\r
+       }\r
+       \r
+       function argumentsRellay( _method, _arguments ){\r
+               alert( typeof _method )\r
+               l = _arguments.length;\r
+               if( l > 0 ){\r
+                       var _arg = [];\r
+                       for( i=0; i<l; ++i ){\r
+                               _arg.push( 'a[' + i + ']' );\r
+                       }\r
+                       window['_method'] = _method;\r
+                       //eval( '_method(' + _arg.join(',') + ')' );\r
+                       var f = new Function( 'a', '_method(' + _arg.join(',') + ')' );\r
+                       f( _arguments );\r
+                       window['_method'] = undefined;\r
+               } else {\r
+                       _method();\r
+               }               \r
+       }\r
+       \r
+       function onWindowResize(){\r
+               var w = jqWindow.width(),\r
+                       h = jqWindow.height();\r
+               currentApplication && currentApplication.resize( w, h );\r
+               pettanr.overlay.onWindowResize( w, h );\r
        }\r
+\r
        return {\r
-               init: function( _funcArray){\r
-                       funcArray = _funcArray;\r
+               init: function( _funcArray ){\r
                        jqWindow = pettanr.jqWindow();\r
-                       jqWindow.resize( onWindowResize);\r
+                       jqWindow.resize( onWindowResize );\r
                        \r
-                       currentView = currentView || pettanr[ currentID];\r
-                       currentView && typeof currentView.onOpen === 'function' && currentView.onOpen();\r
+                       var _option = {}; // urlパラメータ\r
                        \r
-                       setTimeout( onWindowResize, 100);\r
+                       onWindowResize();\r
+                       \r
+                       bootApplication( pettanr.URL_PARAMS.view || 0 );\r
                        \r
                        delete pettanr.view.init;\r
                },\r
-               show: function( _viewID){\r
-                       if( typeof _viewID === 'number' && _viewID < VIEW_ID_ARRAY.length){\r
-                               _viewID = VIEW_ID_ARRAY[ _viewID];\r
-                       } else\r
-                       if( typeof _viewID === 'string'){\r
-                               _viewID = _viewID;\r
-                       } else {\r
-                               _viewID = HOME_ID;\r
-                       }\r
-                       for( var key in pettanr.view){\r
-                               if( pettanr.view[ key] === _viewID){\r
-                                       if( currentID !== _viewID && document.getElementById( _viewID)){\r
-                                               this.currentID = currentID = _viewID;\r
-                                               show();\r
-                                       }\r
-                                       return;\r
-                               }\r
+               createBasicPane: function( _class, _options ){\r
+                       _class.prototype = new AbstractBasicPane();\r
+                       return new _class( _options );\r
+               },\r
+               _getAbstractApplication: function(){\r
+                       return new AbstractApplication();\r
+               },\r
+               registerApplication: function( _class, _options ){\r
+                       _class.prototype = new AbstractApplication();\r
+                       _application = new _class( _options );\r
+                       \r
+                       var elm = _application.rootElement;\r
+                       if( Type.isHTMLElement( elm ) === false ) return null;\r
+                        \r
+                       _application.parentElement = elm.parentNode;\r
+                       _application.nextSibling = elm.nextSibling;\r
+                       \r
+                       if( elm.parentNode ){\r
+                               elm.parentNode.removeChild( elm );\r
                        }\r
-                       alert( _viewID);\r
+                       APPLICATION_LIST.push( _application );\r
+                       return new ApplicationReference( _application );\r
+               },\r
+               isBasicPaneInstance: function( _basicPane ){\r
+                       return  _basicPane instanceof AbstractBasicPane;\r
                },\r
-               currentID:      currentID,\r
-               HOME:           HOME_ID,\r
-               COMICS:         VIEW_ID_ARRAY[ 1],\r
-               IMAGES:         VIEW_ID_ARRAY[ 2],\r
-               SETTING:        VIEW_ID_ARRAY[ 3],\r
-               DEBUG:          VIEW_ID_ARRAY[ 4],\r
+               isApplicationInstance: function( _application ){\r
+                       return _application instanceof AbstractApplication;\r
+               },\r
+               isApplicationReference: function( _reference ){\r
+                       return _reference instanceof ApplicationReference;\r
+               },\r
+               currentID:      null,\r
                EDITOR:         'editor',\r
                OVERLAY:        'overlay'\r
        }\r
@@ -987,279 +1075,93 @@ pettanr.view = ( function(){
 \r
 pettanr.overlay = ( function(){\r
        var SHADOW_OPACITY = 0.5,\r
+               ELM_CONTAINER = document.getElementById( 'overlay-container' ),\r
                jqConteiner, jqShadow, jqCloseButton,// jqBody, \r
                currentOverlay = null,\r
+               bootParams = null,\r
                visible = false,\r
                windowW, windowH;\r
 \r
-\r
-       var IMAGE_GROUP_EXPROLER = ( function(){\r
-               var ICON_ARRAY = [],\r
-                       WHEEL_DELTA = 64,\r
-                       containerW, containerH, wrapX,\r
-                       jqWrap, jqContainer, jqItemOrigin,\r
-                       itemW, itemH,\r
-                       jqName, jqButton, buttonW,\r
-                       folder, onUpdateFunction,\r
-                       winW,\r
-                       onEnterInterval = null;\r
-               \r
-               var BASE_PATH = pettanr.LOCAL === false ? 'http://pettan.heroku.com/images/' : 'images/',\r
-                       THUMB_PATH = BASE_PATH, // + 'thumbnail/',\r
-                       LIMIT_FILESIZE = 1024 * 10; // 10KB\r
-               var IMAGE_DATA = 0;\r
-               \r
-               var ImageGroupIconClass = function( INDEX, data){\r
-                       var JQ_ICON_WRAP = jqItemOrigin.clone( true),\r
-                               SRC = [ BASE_PATH, data.id, '.', data.ext].join( ''),\r
-                               LOW_SRC = data.filesize && data.filesize > LIMIT_FILESIZE ? [ THUMB_PATH, data.id, '.', data.ext].join( '') : null,\r
-                               reversibleImage = null,\r
-                               actualW, actualH,\r
-                               onEnterFlag = false;\r
-                       JQ_ICON_WRAP.children( 'div').eq( 0).html( data.filesize + 'bytes');\r
-                       jqContainer.append( JQ_ICON_WRAP.css( { left: INDEX * itemW}));\r
-                       \r
-                       function onLoad( url, _imgW, _imgH){\r
-                               if( reversibleImage === null) {\r
-                                       alert( url);\r
-                                       return;\r
-                               }\r
-                               actualW = _imgW || 64;\r
-                               actualH = _imgH || 64;\r
-                               JQ_ICON_WRAP.children( 'div').eq( 1).html( actualW +'x' +actualH);\r
-                               var zoom = 128 /( actualW > actualH ? actualW : actualH),\r
-                                       _h = Math.floor( actualH *zoom),\r
-                                       _w = Math.floor( actualW *zoom);\r
-                               reversibleImage.elm.style.width = _w +'px';\r
-                               reversibleImage.elm.style.height = _h +'px';\r
-                               reversibleImage.elm.style.margin = Math.floor( itemH /2 -_h /2)+'px 0 0';\r
-                               reversibleImage.resize( _w, _h);\r
-                               JQ_ICON_WRAP.click( onClick);\r
-                       }\r
-                       \r
-                       function onClick( e){\r
-                               pettanr.overlay.hide();\r
-                               if (onUpdateFunction) {\r
-                                       if( LOW_SRC === null){\r
-                                               onUpdateFunction( SRC, actualW, actualH);\r
-                                       } else {\r
-                                               onCloseUpdate( onUpdateFunction); // close()で値が消えるので、クロージャに保持\r
-                                       }\r
-                               }\r
-                               close();                                \r
-                       }\r
-                       \r
-                       function onCloseUpdate( onUpdate){\r
-                               pettanr.util.loadImage( SRC,\r
-                                       function( _abspath, imgW, imgH){\r
-                                               onUpdate( SRC, imgW, imgH);\r
-                                               onUpdate = null;\r
-                                       },\r
-                                       function( _abspath){\r
-                                               onUpdate( SRC, data.width || 64, data.height || 64);\r
-                                               onUpdate = null;\r
-                                       }\r
-                               );\r
-                       }\r
-                       \r
-                       return {\r
-                               onEnter: function(){\r
-                                       if( onEnterFlag === true) return;\r
-                                       reversibleImage = pettanr.image.createReversibleImage( LOW_SRC || SRC, itemW, itemH, onLoad);\r
-                                       JQ_ICON_WRAP.children( 'img').replaceWith( reversibleImage.elm);\r
-                                       onEnterFlag = true;                             \r
-                               },\r
-                               destroy: function(){\r
-                                       reversibleImage && reversibleImage.destroy();\r
-                                       JQ_ICON_WRAP.remove();\r
-                                       reversibleImage = JQ_ICON_WRAP = null;\r
-                                       delete this.destroy;\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               function close(){\r
-                       jqContainer.stop().animate( {\r
-                                       height: 0,\r
-                                       top:    Math.floor( windowH /2)\r
-                               }, function(){\r
-                                       jqWrap.hide()\r
-                               });\r
-                       while( ICON_ARRAY.length > 0){\r
-                               ICON_ARRAY.shift().destroy();\r
-                       }\r
-                       onEnterInterval !== null && window.clearTimeout( onEnterInterval);\r
-                       onUpdateFunction = onEnterInterval = null;\r
-               }\r
-               function onEnterShowImage(){\r
-                       var l = ICON_ARRAY.length,\r
-                               _start = -wrapX /itemW -1,\r
-                               _end = _start + winW /itemW +1;\r
-                       for( var i=0; i<l; ++i){\r
-                               _start < i && i < _end && ICON_ARRAY[ i].onEnter();\r
-                       }\r
-                       onEnterInterval !== null && window.clearTimeout( onEnterInterval);\r
-                       onEnterInterval = null;\r
-               }\r
-               function onCloseClick(){\r
-                       pettanr.overlay.hide();\r
-                       // onUpdateFunction && onUpdateFunction( textElement);\r
-                       close();\r
-               }\r
-               function onMouseWheel( e, delta){\r
-                       if( winW < containerW){\r
-                               wrapX += delta *WHEEL_DELTA;\r
-                               wrapX = wrapX > 0 ? 0 : wrapX < winW -containerW ? winW -containerW : wrapX;\r
-                               jqContainer.css( { left: wrapX});\r
-                               \r
-                               onEnterInterval !== null && window.clearTimeout( onEnterInterval);\r
-                               onEnterInterval = window.setTimeout( onEnterShowImage, 500);\r
-                       }\r
-                       //e.stopPropagation();\r
-                       return false;                   \r
-               }\r
-               return {\r
-                       init: function(){\r
-                               this.jqWrap = jqWrap = $( '#image-gruop-wrapper').hide();\r
-                               jqContainer = $( '#image-icon-container').mousewheel( onMouseWheel);\r
-                               containerH = pettanr.util.getElementSize( jqContainer.get( 0)).height;\r
-                               jqItemOrigin = $( $( '#imageGruopItemTemplete').remove().html());\r
-                               var itemSize = pettanr.util.getElementSize( jqItemOrigin.get( 0));\r
-                               itemW = itemSize.width;\r
-                               itemH = itemSize.height;\r
-                               jqName = $( '#gruop-name-display');\r
-                               jqButton = $( '#image-gruop-button').click( onCloseClick);\r
-                               buttonW = pettanr.util.getElementSize( jqButton.get( 0)).width;\r
-                               \r
-                               delete IMAGE_GROUP_EXPROLER.init;\r
-                       },\r
-                       jqWrap: null,\r
-                       show: function( _folder, _onUpdateFunction){\r
-                               this.init !== undefined && this.init();\r
-                               \r
-                               folder = _folder;\r
-                               onUpdateFunction = _onUpdateFunction;\r
-                               pettanr.overlay.show( this);\r
-                               \r
-                               var l = _folder.getChildFileLength();\r
-                               for( var i=0; i<l; ++i){\r
-                                       ICON_ARRAY.push( new ImageGroupIconClass( i, _folder.getChildFileByIndex( i)));\r
-                               }\r
-                               wrapX = 0;\r
-                               containerW = l * itemW;\r
-                               \r
-                               winW = windowW;\r
-                               var w = winW > containerW ? winW : containerW,\r
-                                       h = windowH > containerH ? containerH : windowH;\r
-                               \r
-                               jqWrap.show();\r
-                               jqContainer.css( {\r
-                                       width:          w,\r
-                                       height:         0,\r
-                                       left:           0,\r
-                                       top:            Math.floor( windowH /2)\r
-                               }).stop().animate( {\r
-                                       height:         h,\r
-                                       top:            Math.floor( windowH /2 -h /2)\r
-                               });\r
-                               \r
-                               jqButton.css( {\r
-                                       left:           Math.floor( winW /2 -buttonW /2),\r
-                                       top:            Math.floor( windowH /2 +containerH /2 +10)\r
-                               });\r
-                               \r
-                               onEnterShowImage();\r
-                       },\r
-                       onWindowResize: function( _windowW, _windowH){\r
-                               var w = _windowW > containerW ? _windowW : containerW,\r
-                                       h = _windowH > containerH ? containerH : _windowH,\r
-                                       offsetW = Math.floor( _windowW /2 -winW /2);\r
-                               winW = _windowW;\r
-                               if( offsetW <= 0){ // smaller\r
-                                       jqContainer.css( {\r
-                                               left:                           offsetW,\r
-                                               width:                          w\r
-                                       }).animate( {\r
-                                               left:                           0,\r
-                                               top:                            Math.floor( _windowH /2 -h /2)\r
-                                       });                                     \r
-                               } else {\r
-                                       jqContainer.css( { // bigger\r
-                                               left:                           0,\r
-                                               width:                          w,\r
-                                               borderLeftWidth:        offsetW\r
-                                       }).animate( {\r
-                                               top:                            Math.floor( _windowH /2 -h /2),\r
-                                               borderLeftWidth:        0\r
-                                       });\r
-                               }\r
-                               jqButton.css( {\r
-                                       left:           Math.floor( _windowW /2 -buttonW /2),\r
-                                       top:            Math.floor( _windowH /2 +containerH /2 +10)\r
-                               });\r
-                               onEnterShowImage();\r
-                       },\r
-                       onClose: close,\r
-                       ID: 'imageGroupExproler'\r
-               }\r
-       })();\r
-       /*\r
-        * \r
-        */\r
-\r
-       function close(){\r
-               currentOverlay && currentOverlay.onClose && currentOverlay.onClose();\r
-               pettanr.overlay.hide();         \r
-       }\r
        function asyncResize(){\r
-               currentOverlay.onWindowResize( windowW, windowH);\r
+               currentOverlay.resize( windowW, windowH);\r
        }\r
        function onCloseClick( e){\r
-               close();\r
+               pettanr.overlay.hide();\r
                e.preventDefault();\r
                return false;           \r
        }\r
+       function onFadeInComplete(){\r
+\r
+       }\r
+       function onFadeOutComplete(){\r
+               if( currentOverlay.rootElement && currentOverlay.rootElement.parentNode === ELM_CONTAINER ){\r
+                       ELM_CONTAINER.removeChild( currentOverlay.rootElement );\r
+               }\r
+               currentOverlay = null;\r
+       }\r
        return {\r
                init: function(){\r
                        //jqBody = pettanr.jqBody();\r
                        jqConteiner = $( '#overlay-container');\r
                        jqShadow = $( '#overlay-shadow');\r
-                       jqCloseButton = $( '#overlay-close-button').click( onCloseClick);\r
+                       jqCloseButton = $( '#overlay-close-button').click( onCloseClick );\r
                        \r
-                       pettanr.key.addKeyDownEvent( pettanr.view.OVERLAY, 27, false, false, close); // 27.esc\r
+                       pettanr.key.addKeyDownEvent( pettanr.view.OVERLAY, 27, false, false, pettanr.overlay.hide ); // 27.esc\r
                        \r
                        delete pettanr.overlay.init;\r
                },\r
-               show: function( _currentOverlay){\r
-                       if( visible === true && currentOverlay === _currentOverlay) return;\r
+               show: function( _overlay, _bootParams ){\r
+                       if( visible === true && currentOverlay === _overlay ) return;\r
+                       if( pettanr.view.isApplicationInstance( _overlay ) === false ) return;\r
+                       \r
+                       document.body.style.overflow = 'hidden';\r
+                       \r
+                       this.visible = visible = true;\r
+                       this.currentID = _overlay.ID;\r
+                       currentOverlay = _overlay;\r
+                       bootParams = _bootParams;\r
+\r
                        jqConteiner.stop().css( {\r
                                filter:         '',\r
-                               opacity:        ''\r
-                       }).fadeIn();\r
-                       this.visible = visible = true;\r
-                       currentOverlay = _currentOverlay;\r
-                       this.currentID = _currentOverlay.ID;\r
-                       jqCloseButton.toggle( !!_currentOverlay.onClose);\r
+                               opacity:        '',\r
+                               top:            document.documentElement.scrollTop || document.body.scrollTop\r
+                       }).fadeIn( onFadeInComplete );\r
+\r
+                       ELM_CONTAINER.insertBefore( currentOverlay.rootElement, document.getElementById( 'overlay-close-button' ));\r
+       \r
+                       if( Type.isArray( bootParams ) === true ){\r
+                               bootParams.unshift( windowW, windowH )\r
+                               currentOverlay.open.apply( currentOverlay, bootParams );\r
+                       } else {\r
+                               currentOverlay.open( windowW, windowH, bootParams );\r
+                       }\r
                },\r
                hide: function(){\r
-                       currentOverlay = null;\r
                        if( visible === false) return;\r
+                       document.body.style.overflow = '';\r
                        jqConteiner.stop().css( {\r
                                filter:         '',\r
                                opacity:        ''\r
-                       }).fadeOut();\r
+                       }).fadeOut( onFadeOutComplete );\r
+                       currentOverlay.close();\r
                        this.visible = visible = false;\r
                        this.currentID = null;\r
                },\r
                visible: visible,\r
                currentID: null,\r
-               onWindowResize: function( _windowW, _windowH){\r
-                       jqConteiner.css( { height:      _windowH});\r
-                       jqShadow.css( { height: _windowH});\r
+               onWindowResize: function( _windowW, _windowH ){\r
                        windowW = _windowW;\r
-                       windowH = _windowH;\r
+                       windowH = _windowH;                     \r
+                       \r
+                       if( currentOverlay === null ) return;\r
+                       \r
+                       jqConteiner.css({\r
+                               height:         _windowH,\r
+                               top:            document.documentElement.scrollTop || document.body.scrollTop\r
+                       });\r
+                       jqShadow.css( { height: _windowH });\r
                        // 先にeditorのcanvasを確定する。\r
-                       currentOverlay && currentOverlay.onWindowResize && setTimeout( asyncResize, 0);\r
+                       setTimeout( asyncResize, 0);\r
                }\r
        }\r
 })();\r
@@ -1423,14 +1325,14 @@ pettanr.form = ( function(){
        var InputTextClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater){\r
                validater = typeof validater === 'function' ? validater : null;\r
                \r
-               var elmValue = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'editable-value')[ 0],\r
+               var elmValue = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'editable-value' )[ 0],\r
                        value,\r
                        index = GROUP_ID ? FORM_GROUP_TABLE[ GROUP_ID].length : -1,\r
                        instance,\r
                        focus = false,\r
                        visible = true,\r
                        enabled = true,\r
-                       elmA = ELM_A_ORIGIN.cloneNode( true);\r
+                       elmA = ELM_A_ORIGIN.cloneNode( true );\r
                \r
                if( elmValue === undefined){\r
                        alert( 'error!');\r
@@ -1438,9 +1340,13 @@ pettanr.form = ( function(){
                value = elmValue.innerHTML;\r
                elmValue.innerHTML = '';\r
                elmValue.className += ' editable-text';\r
+               try {\r
+                       elmA.innerHTML = value;\r
+               } catch(e){\r
+                       alert( value + elmA)\r
+               }\r
                \r
-               elmA.innerHTML = value;\r
-               elmValue.appendChild( elmA);\r
+               elmValue.appendChild( elmA );\r
                WRAPPER_ELM.onclick = onClick;\r
                \r
                function onClick( e){\r
@@ -1460,7 +1366,7 @@ pettanr.form = ( function(){
                                instance = this;\r
                                delete this.init;\r
                        },\r
-                       update: function( _value){\r
+                       value: function( _value){\r
                                if( _value !== undefined){\r
                                        elmA.innerHTML = _value;\r
                                        value = _value;\r
@@ -1470,6 +1376,7 @@ pettanr.form = ( function(){
                                        }\r
                                }\r
                                currentItem === instance && this.finish();\r
+                               return value;\r
                        },\r
                        start: function(){\r
                                onClick();\r
@@ -1486,7 +1393,64 @@ pettanr.form = ( function(){
                                \r
                                ON_UPDATE_FUNCTION && _newValue !== value && ON_UPDATE_FUNCTION( _newValue, value);\r
                                finish( instance);\r
-                               \r
+                               value = _newValue;\r
+                               focus = false;\r
+                       },\r
+                       enabled: function(){\r
+                               return enabled;\r
+                       },\r
+                       visible: function( _visible){\r
+                               if( _visible === true){\r
+                                       WRAPPER_ELM.style.display = '';\r
+                                       visible = true;\r
+                               } else\r
+                               if( _visible === false){\r
+                                       WRAPPER_ELM.style.display = 'none';\r
+                                       visible = false;\r
+                               }\r
+                               return visible;\r
+                       },\r
+                       index : index,\r
+                       groupID: GROUP_ID\r
+               }\r
+       }\r
+\r
+       var FileInputClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater, elmFileInput){\r
+               validater = typeof validater === 'function' ? validater : null;\r
+               \r
+               var elmFilePath = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'file-path')[ 0],\r
+                       value,\r
+                       index = GROUP_ID ? FORM_GROUP_TABLE[ GROUP_ID].length : -1,\r
+                       instance,\r
+                       focus = false,\r
+                       visible = true,\r
+                       enabled = true;\r
+               elmFileInput = WRAPPER_ELM.getElementsByTagName('input')[0] || elmFileInput || document.createElement( 'input');\r
+               elmFileInput.type = 'file';\r
+               elmFileInput.style.visivility = 'hidden';\r
+\r
+               WRAPPER_ELM.onclick = onClick;\r
+               elmFileInput.onchenge = onChange;\r
+               \r
+               function onClick( e){\r
+                       focus = true;\r
+                       start( instance);\r
+                       elmFileInput.click();\r
+                       return false;\r
+               }\r
+               \r
+               function onChange(){\r
+                       elmFilePath.innerHTML = elmFileInput.value;\r
+               }\r
+               return {\r
+                       init: function(){\r
+                               instance = this;\r
+                               delete this.init;\r
+                       },\r
+                       start: function(){\r
+                               onClick();\r
+                       },\r
+                       finish: function( keep){\r
                                focus = false;\r
                        },\r
                        enabled: function(){\r
@@ -1562,6 +1526,15 @@ pettanr.form = ( function(){
                        _groupID && FORM_GROUP_TABLE[ _groupID].push( ret);\r
                        return ret;\r
                },\r
+               createFileInput: function( _elm, _onUpdate, _groupID, _validater, _elmFileInput){\r
+                       if( typeof _groupID === 'string' && !FORM_GROUP_TABLE[ _groupID]){\r
+                               FORM_GROUP_TABLE[ _groupID] = [];\r
+                       }\r
+                       var ret = FileInputClass( _elm, _onUpdate, _groupID, _validater, _elmFileInput);\r
+                       ret.init();\r
+                       _groupID && FORM_GROUP_TABLE[ _groupID].push( ret);\r
+                       return ret;\r
+               },\r
                createCheckBox: function(){\r
                        \r
                },\r
@@ -1903,7 +1876,7 @@ pettanr.image = ( function(){
                        }\r
                }\r
                var activexImage = css3Image;\r
-               var vmlImage = function( url, w, h, onLoadCallback){\r
+               var vmlImage = function( url, w, h, onLoadCallback ){\r
                        var elmWrap = document.createElement( 'div'),\r
                                vmlImg,\r
                                loaded = false,\r
@@ -1935,7 +1908,7 @@ pettanr.image = ( function(){
                                vmlImg.style.width = w < 0 ? -w : w +'px';\r
                                vmlImg.style.height = h < 0 ? -h : h +'px';\r
                                //if( flipH !== _flipH || flipV !== _flipV){\r
-                                       vmlImg.parentNode === elmWrap && elmWrap.removeChild( vmlImg);\r
+                                       vmlImg.parentNode === elmWrap && elmWrap.removeChild( vmlImg );\r
                                //}\r
                                        vmlImg.className = w < 0 || h < 0 ? ( 'img-flip-' + ( w < 0 && h < 0 ? 'vh' : ( w < 0 ? 'h' : 'v'))) : '';\r
                                        elmWrap.appendChild( vmlImg);\r
@@ -1955,15 +1928,15 @@ pettanr.image = ( function(){
                        \r
                }\r
                \r
-               return function( url, w, h, onLoadCallback){\r
+               return function( url, w, h, onLoadCallback ){\r
                                var flipH = w < 0,\r
                                        flipV = h < 0,\r
                                        onLoadCallbackAsync = onLoadCallback,// ? function(){ setTimeout( onLoadCallback, 0);} : undefined,// 一度読み込んだ画像は即座にonLoadになるため遅延\r
-                                       xBackendImage = ( function( urlIsXDomain){\r
-                                               if( BACKEND === IS_CSS3) return css3Image.apply( {}, [ url, w, h, onLoadCallbackAsync]);\r
-                                               if( BACKEND === IS_VML) return vmlImage.apply( {}, [ url, w, h, onLoadCallbackAsync]);\r
-                                               if( BACKEND === IS_ACTIVEX) return activexImage.apply( {}, [ url, w, h, onLoadCallbackAsync]);\r
-                                               return serverImage.apply( {}, [ url, w, h, onLoadCallbackAsync]);\r
+                                       xBackendImage = ( function( urlIsXDomain ){\r
+                                               if( BACKEND === IS_CSS3) return new css3Image( url, w, h, onLoadCallbackAsync );\r
+                                               if( BACKEND === IS_VML) return new vmlImage( url, w, h, onLoadCallbackAsync );\r
+                                               if( BACKEND === IS_ACTIVEX) return new activexImage( url, w, h, onLoadCallbackAsync );\r
+                                               return new serverImage( url, w, h, onLoadCallbackAsync );\r
                                        })();\r
                                return {\r
                                        elm: xBackendImage.elm,\r
@@ -1992,7 +1965,7 @@ pettanr.image = ( function(){
 })();\r
 \r
 /*\r
- * bind : 出版
+ * bind : 製本
  */\r
 pettanr.bind = ( function(){\r
        var BIND_WORKER_ARRAY = [],\r
@@ -2197,6 +2170,7 @@ var VisualEffect = ( function(){
                TIMER = null,\r
                FILTER = 'filter',\r
                OPACITY = 'opacity',\r
+               REG_ALPHA = /alpha\([^)]*\)/i,\r
                CORON = ':',\r
                EMPTY = '',\r
                SEMICORON = ';';\r
@@ -2211,7 +2185,29 @@ var VisualEffect = ( function(){
                        }\r
                }\r
                //  coputedStyle と _cssObject を比較して , 一致及び非数は削除しつつ コピー\r
+               //  filter opacity の追加 REG_ALPHA.test( _value ) ? _value.replace( REG_ALPHA, opacity ) : _value + " " + opacity\r
+               /*\r
+                * cssObject をまわす\r
+                * 非数は削除\r
+                * cssText と一致も削除\r
+                * coputedStyle と一致も削除\r
+                * updateTraget ととして記録\r
+                * 初期値を cssObject としてセット\r
+                * cssTest にセット zoom もセット 
+                */\r
+               \r
                //\r
+               /*\r
+                       var style = elem.style,\r
+                               currentStyle = elem.currentStyle,\r
+                               opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",\r
+                               filter = currentStyle && currentStyle.filter || style.filter || "";\r
+\r
+                       // IE has trouble with opacity if it does not have layout\r
+                       // Force it by setting the zoom level\r
+                       style.zoom = 1;
+                */\r
+               \r
                var _currentParameters = [],\r
                        _offsetParameters = [],\r
                        _endParameters = [],\r
@@ -2250,7 +2246,7 @@ var VisualEffect = ( function(){
                if( _numAttributes > 1){\r
                        var _cssTexts = _elm.style.cssText.split( ';'), _css,\r
                                _separate,\r
-                               _cssObject = {}, _target, _value, _number, _type, _new,\r
+                               _cssObject = {}, _target, _value, _number, _px,\r
                                j;\r
                        for(var i=0, l=_cssTexts.length; i<l; ++i){\r
                                _css = _cssTexts[ i];\r
@@ -2264,9 +2260,10 @@ var VisualEffect = ( function(){
                                        if( _target === FILTER){\r
                                                for( j=0; j<_numAttributes; ++j){\r
                                                        if( _targetAttributes[ j] === OPACITY){\r
-                                                               \r
-                                                               \r
-                                                               \r
+                                                               _cssTexts[ i] = [\r
+                                                                               _target, ':',\r
+                                                                               _value.replace( REG_ALPHA, "alpha(opacity=" + _updateParameters[ j] * 100 + ")")\r
+                                                                       ].join( '');\r
                                                                break;\r
                                                        }\r
                                                }\r
@@ -2275,11 +2272,11 @@ var VisualEffect = ( function(){
                                         */\r
                                        } else {\r
                                                _number = '' + parseFloat( _value);\r
-                                               _type = _value.indexOf( _number);\r
-                                               _type = _type > 0 ? _value.substr( _type + _number.length) : '';\r
+                                               _px = _value.indexOf( _number);\r
+                                               _px = _px > 0 ? _value.substr( _px + _number.length) : '';\r
                                                for( j=0; j<_numAttributes; ++j){\r
                                                        if( _targetAttributes[ j] === _target){\r
-                                                               _cssTexts[ i] = [ _target, ':', _updateParameters[ j], _type].join( '');\r
+                                                               _cssTexts[ i] = [ _target, ':', _updateParameters[ j], _px].join( '');\r
                                                                break;\r
                                                        }\r
                                                }                                               \r
@@ -2292,7 +2289,6 @@ var VisualEffect = ( function(){
                /*\r
                 * 一度に update する Attributes が少ない場合、cssText は使用しない.
                 */\r
-               \r
        }\r
        \r
        var AnimationTaskClass = function( ELM, currentParameters, offsetParameters, endParameters, targetAttributes, onComplete, onEnterFrame, numFrames){\r
@@ -2300,16 +2296,16 @@ var VisualEffect = ( function(){
                return {\r
                        elm:    ELM,\r
                        onEnterFrame: function(){\r
-                               var _updateCss = {};\r
+                               var _updateCss = {}, i;\r
                                if( numFrames === 1){\r
-                                       for( var i=0; i<l; ++i){\r
+                                       for( i=0; i<l; ++i){\r
                                                _updateCss[ targetAttributes[ i]] = endParameters[ i];\r
                                                ++i;\r
                                        }\r
                                        updateCss( ELM, currentParameters, targetAttributes, l);\r
                                        onComplete !== null && onComplete();\r
                                } else {\r
-                                       for( var i=0; i<l; ++i){\r
+                                       for( i=0; i<l; ++i){\r
                                                _updateCss[ targetAttributes[ i]] = currentParameters[ i] = Math.floor( currentParameters[ i] + offsetParameters[ i]);\r
                                                ++i;\r
                                        }\r
@@ -2328,7 +2324,7 @@ var VisualEffect = ( function(){
        var VisualEffectClass = function( ELM){\r
                var isHtmlElement;\r
                \r
-               function resisterAnime( _cssObject, _onComplete, _onEnterFrame, _time){\r
+               function registerAnime( _cssObject, _onComplete, _onEnterFrame, _time){\r
                        var _numFrames = Math.floor( _time / fpms);\r
                        startAnimation( ELM, _cssObject, _onComplete, _onEnterFrame, _numFrames);\r
                }\r
@@ -2343,7 +2339,7 @@ var VisualEffect = ( function(){
                        \r
                }\r
                \r
-               this.anime = resisterAnime;\r
+               this.anime = registerAnime;\r
                this.fadeIn = startFadeIn;\r
                this.fadeOut = startFadeOut;\r
                this.update = update;\r