/**
 * doijs package
 * 
 * @author donna iwan setiawan
 * @version 1.1 
 * copyright - (c) 2007 - 2009 donna iwan setiawan
 * license - GPL version 3 or any later version <http://www.gnu.org/licenses/gpl-3.0.txt>
 */
doi.widget.layers=function(){var b=arguments[0]||false,a=arguments[1]||{},c=false;if(b){return new doi.widget.layer(b,a)}this.render=function(){if(c||b){return false}var e=doi.dom.$("tag:div;title=doi-widget-layer:true");if(!e||(e&&e.length==0)){return false}for(var d=0;d<e.length;d++){(new doi.widget.layer(e[d],a)).render()}c=true}};doi.widget.register(doi.widget.layers);doi.widget.layer=function(){var b=arguments[0]||false,e=null,f=this,a=arguments[1]||{},c="doi-widget-layer",d;return{element:function(){if(arguments[0]&&arguments[0]=="iframe"){return e}return b},hide:function(){if(!this.visible()){return}this.visible(false);var j=arguments[0]||{};var n=arguments[1]||{};var k=this.element();var m=this.element("iframe");var i=k.offsetWidth;var l=k.offsetHeight;if(a.effect&&doi.effect){switch(a.effect){case"blind":case"blindxy":var g=false;doi.effect.blindX([k,m],{to:0,from:i,stop:function(){if(j&&j.hide&&doi.dom.isFunction(j.hide)){if(g){j.hide(n)}g=true}}});doi.effect.blindY([k,m],{to:0,from:l,stop:function(){if(j&&j.hide&&doi.dom.isFunction(j.hide)){if(g){j.hide(n)}g=true}}});return;case"blindx":doi.effect.blindX([k,m],{to:0,from:i,stop:function(){if(j&&j.hide&&doi.dom.isFunction(j.hide)){j.hide(n)}}});return;case"blindy":doi.effect.blindY([k,m],{to:0,from:l,stop:function(){if(j&&j.hide&&doi.dom.isFunction(j.hide)){j.hide(n)}}});return}}doi.dom.style([k,m],{visibility:"hidden",width:"1px",height:"1px",display:"none"});if(j&&j.hide&&doi.dom.isFunction(j.hide)){j.hide(n)}},height:function(){var g=0;if(doi.dom.getStyle(b,"display")!="none"){g=b.offsetHeight}else{doi.dom.style(b,{display:"block"});g=b.scrollHeight;doi.dom.style(b,{display:"none"})}return g},iframe:function(){return this.element("iframe")},moveTo:function(){var g={top:0,left:0};g=doi.dom.merge(g,arguments[0]);var h=this.element();var i=this.iframe();doi.dom.style([h,i],{top:g.top+"px",left:g.left+"px"})},render:function(){if(doi.dom.isElement(b)){var l=doi.dom.parseAttribute(b.title);l.title=l.title||"";a.id=a.id||false;if(doi.dom.isDefined(l.doiWidgetLayer)){if(!l.doiWidgetLayer){return false}c=b.className||a.className||c;d=b.id||a.id;b.setAttribute("title",l.title)}else{c=a.className||c;d=a.id;var o=document.createElement("div");var m=b.parentNode;if(m){m.insertBefore(o,b)}else{doi.dom.write(o)}o.appendChild(b);b=o}}else{c=a.className||c;var o=document.createElement("div");doi.dom.write(o);if(doi.dom.isString(b)){o.innerHTML=b}b=o}a=doi.dom.merge(a,l);d=doi.widget.instance.save(this,d);b.id=d;doi.dom.className(b,c);a.position=a.position||"absolute";var g=a.position;if(a.position=="fixed"){g="absolute";document.body.insertBefore(b,document.body.firstChild)}a.visibility=a.visibility||doi.dom.getStyle(b,"visibility")||"hidden";var n=doi.dom.getStyle(b,"z-index");if(n=="auto"){a.zIndex=a.zIndex||doi.widget.zIndex()}else{a.zIndex=a.zIndex||n||doi.widget.zIndex()}doi.dom.style(b,{display:"block",visibility:a.visibility,position:g,zIndex:a.zIndex,overflow:"hidden"});if(a.effect&&doi.effect&&a.visibility=="hidden"){switch(a.effect){case"blind":case"blindxy":doi.dom.style(b,{width:"1px",height:"1px"});break;case"blindx":doi.dom.style(b,{width:"1px",height:"auto"});break;case"blindy":doi.dom.style(b,{width:"auto",height:"1px"});break;default:doi.dom.style(b,{width:"auto",height:"auto"})}}else{doi.dom.style(b,{width:"auto",height:"auto"})}if(doi.browser.msie&&doi.browser.version<7&&g=="absolute"&&!a.noIframe){var k='<iframe id="'+d+'-iframe" frameborder="0" scrolling="no"></iframe>';var o=document.createElement("div");o.innerHTML=k;e=o.childNodes[0];b.parentNode.insertBefore(e,b);doi.dom.style(e,{position:"absolute",display:"block",visibility:a.visibility,zIndex:a.zIndex-1,width:"1px",height:"1px"})}if(a.visibility!="hidden"){var i=b.scrollWidth;var j=b.scrollHeight;doi.dom.style(e,{width:i+"px",height:j+"px"})}else{doi.dom.style(b,{display:"none"})}return true},resize:function(){if(!this.visible()){return}var j=this.element();var i=this.element("iframe");var m=arguments[0]||{};var h=arguments[1]||{};var p=m.effect||a.effect||"";var l=j.offsetWidth;var o=j.offsetHeight;var k=m.width||j.scrollWidth;var n=m.height||j.scrollHeight;k=doi.dom.parseInt(k);n=doi.dom.parseInt(n);if(p!=""){p="blind"}if(p&&doi.effect){if(k<=l&&doi.dom.isDefined(m.width)&&m.width=="auto"){k="auto"}if(n<=o&&doi.dom.isDefined(m.height)&&m.height=="auto"){n="auto"}switch(p){case"blind":case"blindxy":var g=false;doi.effect.blindX([j,i],{from:l,to:k,stop:function(){if(m&&m.resize&&doi.dom.isFunction(m.resize)){if(g){m.resize(h)}g=true}}});doi.effect.blindY([j,i],{from:o,to:n,stop:function(){if(m&&m.resize&&doi.dom.isFunction(m.resize)){if(g){m.resize(h)}g=true}}});return{width:k,height:n}}}doi.dom.style(j,{width:"auto",height:"auto"});doi.dom.style(i,{width:j.offsetWidth+"px",height:j.offsetHeight+"px"});if(m.resize&&doi.dom.isFunction(m.resize)){m.resize(h)}return{width:k,height:n}},show:function(){if(this.visible()){return}this.visible(true);var o=arguments[0]||{};var j=arguments[1]||{};var m=this.element();var k=this.element("iframe");var s=m.offsetTop;var i=m.offsetLeft;if(doi.dom.isDefined(o.top)){s=o.top}if(doi.dom.isDefined(o.left)){i=o.left}s=doi.dom.parseInt(s);i=doi.dom.parseInt(i);var p=o.zIndex||a.zIndex;var q=0;if(doi.widget.modalBox2&&doi.widget.modalBox2.visible()){q=doi.widget.modalBox2.zIndex()}else{if(doi.widget.modalBox1&&doi.widget.modalBox1.visible()){q=doi.widget.modalBox1.zIndex()}else{if(doi.widget.modalBox&&doi.widget.modalBox.visible()){q=doi.widget.modalBox.zIndex()}}}if(p<q){p=q}doi.dom.style(m,{display:"block",height:"1px"});var r=o.width||m.scrollWidth;r=doi.dom.parseInt(r);var n=o.height||m.scrollHeight;n=doi.dom.parseInt(n);doi.dom.style([m,k],{display:"block",top:s+"px",left:i+"px"});if(a.effect&&doi.effect){switch(a.effect){case"blind":case"blindxy":var g=false;doi.effect.blindX([m,k],{from:0,to:r,stop:function(){if(o&&o.show&&doi.dom.isFunction(o.show)){if(g){o.show(j)}g=true}}});doi.effect.blindY([m,k],{from:0,to:n,stop:function(){if(o&&o.show&&doi.dom.isFunction(o.show)){if(g){o.show(j)}g=true}}});return;case"blindx":doi.dom.style([m,k],{height:n+"px"});doi.effect.blindX([m,k],{from:0,to:r,stop:function(){if(o&&o.show&&doi.dom.isFunction(o.show)){o.show(j)}}});return;case"blindy":doi.dom.style([m,k],{width:r+"px"});doi.effect.blindY([m,k],{from:0,to:n,stop:function(){if(o&&o.show&&doi.dom.isFunction(o.show)){o.show(j)}}});return}}doi.dom.style([m,k],{width:r+"px",height:n+"px",visibility:"visible",zIndex:p});doi.dom.style(k,{zIndex:p-1});if(o&&o.show&&doi.dom.isFunction(o.show)){o.show(j)}},visible:function(){if(doi.dom.isDefined(arguments[0])){if(!!arguments[0]){a.visibility="visible"}else{a.visibility="hidden"}}return(a.visibility!="hidden")},width:function(){var g=0;if(doi.dom.getStyle(b,"display")!="none"){g=b.offsetWidth}else{doi.dom.style(b,{display:"block"});g=b.scrollWidth;doi.dom.style(b,{display:"none"})}return g},zIndex:function(){return a.zIndex}}};