/**
 * 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.modalbox=function(){var w,b=arguments[0]||{},l,d,s,e,q=true,m=30,i,o=this,k,r,a=750,c=300,h=0,n=false,f=false,g=false,t=[],p=false;b.className=b.className||"doi-widget-modalbox";b.id=doi.widget.instance.save(this,b.id);b.zIndex=b.zIndex||0;function x(){l=document.createElement("div");l.id=b.id;doi.dom.className(l,b.className);w=document.createElement("div");w.id=b.id+"-bar";doi.dom.className(w,b.className+"-bar");var y=document.createElement("a");y.setAttribute("href","#");y.innerHTML="Close";y.id=b.id+"-close";doi.event.add(y,"click",function(){o.hide();return false});var A=document.createElement("span");var D=document.createElement("a");D.setAttribute("href","#");D.innerHTML="Back";doi.event.add(D,"click",function(){o.back();return false});A.id=b.id+"-back";A.innerHTML=" | ";A.insertBefore(D,A.firstChild);w.appendChild(A);if(doi.debug()){var C=document.createElement("span");var z=document.createElement("a");z.setAttribute("href","#");z.innerHTML="View Source";doi.event.add(z,"click",function(){var E=o.element("content").innerHTML;o.show({url:E.htmlentities(),type:"html"});return false});C.id=b.id+"-source";C.innerHTML=" | ";C.insertBefore(z,C.firstChild);w.appendChild(C)}w.appendChild(y);l.appendChild(w);s=document.createElement("div");s.innerHTML="&nbsp;";s.id=b.id+"-loader";doi.dom.className(s,b.className+"-loader");l.appendChild(s);e=document.createElement("div");e.id=b.id+"-content";doi.dom.className(e,b.className+"-content");l.appendChild(e);doi.dom.style(e,{visibility:"hidden",display:"none"});if(!b.zIndex){i=new doi.widget.overlay({animated:false})}else{i=new doi.widget.overlay({animated:false,zIndex:b.zIndex})}i.render();b.zIndex=i.zIndex()+2;d=new doi.widget.layer(l,{className:b.className+"-frame",position:"fixed",zIndex:b.zIndex,noIframe:true,effect:"blindy",visibility:"hidden"});d.render();doi.dom.style([d.element(),d.element("iframe")],{top:"-500px",height:"1px"});var B=false;doi.event.add(window,"scroll",function(){if(o.visible()){var E=doi.dom.dimension.bodyScroll().scrollTop;window.clearTimeout(B);B=window.setTimeout(function(){doi.effect.moveY([o.frame().element(),o.frame().iframe()],{from:o.frame().element().offsetTop,to:E})},500)}})}function j(y){r=window.setTimeout(function(){var B=o.element("content");doi.dom.style(B,{visibility:"visible",display:"block"});if(y.type=="url"){if(p){doi.ajax.abort(p)}var A=new doi.dom.request(y.url);A.append("_modalbox","1");y.url=A.toString();var D=y.method||"GET";p=doi.ajax.request(D,y.url,{success:function(E){B.innerHTML=E.responseText;doi.dom.execScript(B);doi.widget.render({attribute:{zIndex:o.overlay().zIndex()+100}});o.hide("loader")},failure:function(E){alert("Could not load page!");o.hide("loader")},data:y.data})}else{if(y.type=="image"){var z=new Image();B.innerHTML="";var C=document.createElement("div");doi.dom.style(C,{textAlign:"center"});C.appendChild(z);B.appendChild(C);z.onload=function(){var E=this.width;if(this.width>o.overlay().width()){E=o.overlay().width()-100}var G=doi.dom.dimension.client();var F=Math.floor(this.height/this.width*E);if(F>G.height){F=G.height-100;E=Math.floor(this.width/this.height*F)}doi.dom.style(this,{width:E+"px",height:F+"px"});o.hide("loader")};z.src=y.url}else{if(y.type=="element"&&doi.dom.isElement(y.url)){g=y.url;B.innerHTML="";B.appendChild(y.url);y.display=doi.dom.getStyle(y.url,"display");y.visibility=doi.dom.getStyle(y.url,"visibility");doi.dom.style(y.url,{display:"block",visibility:"visible"});o.hide("loader")}else{if(y.type=="html"){B.innerHTML=y.url;doi.dom.execScript(B);doi.widget.render({attribute:{zIndex:o.overlay().zIndex()+100}});o.hide("loader")}}}}},a)}function v(z){var y=o.element("loader");if(o.visible("loader")){var A=y.offsetHeight;if(A>m){m=A}}else{o.show("loader")}j(z)}function u(){var A=doi.dom.dimension.client();var z=o.frame().width();var y=Math.ceil((A.width-z)/2);if(o.frame().element().offsetTop<=0){var B=doi.dom.dimension.bodyScroll().scrollTop;doi.dom.style([o.frame().element(),o.frame().iframe()],{left:y+"px",top:B+"px"})}else{doi.dom.style([o.frame().element(),o.frame().iframe()],{left:y+"px"})}}this.back=function(){if(!o.visible()||t.length<=1){return false}t.pop();var y=t.length-1;if(t[y]){o.show(t[y],true)}if(y<=0){doi.dom.style(o.element("back"),{visibility:"hidden"})}return true};this.element=function(){var y=false;switch(arguments[0]){case"bar":y=w;break;case"loader":y=s;break;case"content":y=e;break;case"back":y=doi.dom.$(b.id+"-back");break;case"overlay":y=i.element();break;case"frame":y=d.element();break;default:y=l}return y};this.frame=function(){return d};this.hide=function(){if(arguments[0]=="loader"){var y=o.element("loader");if(o.visible("loader")||y.doi_blindv_timer){window.clearTimeout(r);r=false;doi.effect.blindY(y,{from:y.offsetHeight,to:"0",stop:function(){o.resize();o.visible("loader",false)}})}return}o.frame().hide({hide:function(){doi.dom.style(o.element(),{width:h+"px"});doi.dom.style([o.frame().element(),o.frame().element("iframe")],{visibility:"hidden",display:"block",top:"-500px",height:"1px",width:h+"px"});o.overlay().hide({hide:function(){window.clearInterval(k);k=false;window.clearTimeout(r);r=false;var A=o.element("content");if(f.type=="element"&&doi.dom.isElement(g)){document.body.appendChild(g);doi.dom.style(g,{display:f.display,visibility:f.visibility});g=false}A.innerHTML="";doi.dom.style(A,{height:"auto",visibility:"hidden",display:"none"});doi.dom.style(o.element("loader"),{height:m+"px",display:"block"});o.visible("loader",false);o.visible(false);f=false;var z=t[0];if(z&&z.hide&&doi.dom.isFunction(z.hide)){z.hide()}t=[];doi.ajax.abort(p)}})}})};this.overlay=function(){return i};this.resize=function(){var R=o.element("bar");var Q=o.element("content");var O=o.element("frame");var L=o.element("loader");var T=Q.scrollTop;doi.dom.style(Q,{width:"auto",height:"auto",position:"absolute",overflow:"auto"});var E=O.offsetHeight;var D=R.offsetHeight+L.offsetHeight+Q.offsetHeight;var I=doi.dom.dimension.client().height;var A=false;if(D>I){D=I-20;A=true}var H=O.offsetWidth;var G=Q.offsetWidth;var C=doi.dom.dimension.client().width-100;if(G<h){G=h}if(G>C){G=C;A=true}if(A){var J=doi.dom.parseInt(doi.dom.getStyle(Q,"padding-top"));var y=doi.dom.parseInt(doi.dom.getStyle(Q,"padding-bottom"));var P=doi.dom.parseInt(doi.dom.getStyle(Q,"border-top-width"));var B=doi.dom.parseInt(doi.dom.getStyle(Q,"border-bottom-width"));var M=O.scrollHeight-D+J+y+P+B;doi.dom.style(Q,{height:Q.offsetHeight-M+"px"})}Q.scrollTop=T;doi.dom.style(Q,{position:"relative"});if(doi.browser.msie){var N=doi.dom.parseInt(doi.dom.getStyle(Q,"padding-left"));var K=doi.dom.parseInt(doi.dom.getStyle(Q,"padding-right"));var z=doi.dom.parseInt(doi.dom.getStyle(Q,"border-left-width"));var S=doi.dom.parseInt(doi.dom.getStyle(Q,"border-right-width"));var F=Q.offsetWidth-(N+K+z+S);doi.dom.style(Q,{width:F+"px"})}doi.dom.style(o.element(),{width:G+"px"});o.frame().resize({width:G,height:D})};this.show=function(){var B=arguments[0]||{};if(h==0){var z=doi.dom.parseInt(doi.dom.getStyle(l,"width"));if(z>c){h=z}else{h=c}}if(doi.dom.isString(B)){if(B=="loader"){if(!o.visible("loader")){o.visible("loader",true);var y=o.element("loader");doi.effect.blindY(y,{from:"0",to:m,stop:function(){o.resize()}})}return}var C=B;B={};B.url=C;B.type="url";if(/\.(jpg|jpeg|bmp|gif|png|svg)$/i.test(C)){B.type="image"}}else{if(doi.dom.isElement(B)){var C=B;B={};B.url=C;B.type="element"}else{if(B.url){if(doi.dom.isElement(B.url)){B.type="element"}else{if(!B.type){if(/\.(jpg|jpeg|bmp|gif|png|svg)$/i.test(B.url)){B.type="image"}else{B.type="url"}}}}}}B.type=B.type||"html";B.url=B.url||"Nothing to be loaded.";B.data=B.data||{};f=B;var A=arguments[1]||false;if(!A){t.push(f)}if(t.length>1){doi.dom.style(o.element("back"),{visibility:"visible"})}else{doi.dom.style(o.element("back"),{visibility:"hidden"})}if(!o.visible()){o.element("content").innerHTML="";doi.dom.style([d.element(),d.element("iframe")],{top:"-500px",height:"1px",width:h+"px"});o.visible(true);if(B.width){doi.dom.style([o.element("content"),o.frame().element(),o.frame().element("iframe")],{width:B.width+"px"})}else{B.width=h}o.overlay().show({show:function(){o.frame().show({show:v},B);o.visible("loader",true)},click:function(){o.hide({});doi.event.fire(document,"click")}});k=window.setInterval(u,1)}else{B.width=B.width||h;v(B)}return};this.visible=function(){if(doi.dom.isDefined(arguments[0])){if(arguments[0]=="loader"){if(doi.dom.isDefined(arguments[1])){q=!!(arguments[1])}return q}n=!!(arguments[0])}return n};this.zIndex=function(){return b.zIndex};doi.event.add(doi,"load",x)};doi.widget.modalBox=new doi.widget.modalbox({zIndex:99999});doi.widget.modalBox1=new doi.widget.modalbox({zIndex:999999});doi.widget.modalBox2=new doi.widget.modalbox({zIndex:9999999});