/* 
*   Modal Dialog Version 3.0
*   Developed by CJ Amodeo (cjamodeo@gmail.com)
*   Page should be XHTML 1.0 Transitional
*
*   displaySettings - Default display settings
********************************************************************************
*   All function calls should be made using evokeModalDialog.windowOnLoad or after
*   the page is loaded.
********************************************************************************
*   show(id, appendToNodeID, emdDisplaySettings) - Displays the dialog
*       id: ID of obj to display as modal
*       appendToNodeID: -will remove the object and append it to the sepcified node
*       emdDisplaySettings: overrides default display settings
*
*   hide() - Hides the dialog
*
*   refresh() - repositions the dialog
*
*   getCurrentSetting(settingName) - returns the current setting
*   setCurrentSetting(settingName, settingValue) - updates the currently used setting
*
*   windowOnLoad(func) - Attaches an event to be executed with the window onload event
*
*   emdDisplaySettings/evokeModalDialog.displaySettings map variables
*       dialogPosition: string, fixed or absolute, default fixed
*       hideOnClick: boolean, true/false, default true
*       backgroundColor: string, hex color, default #000000
*       opacity: float, 0-1, default 0.6
*       left: integer, default -1 (causes centering)
*       top: integer, default -1 (causes centering)
*       showFunction: function(grayoutDivID, divDialogID), default null, must call showCallback after
*       hideFunction: function(grayoutDivID, divDialogID), default null, must call hideCallback after
*       onHide: function, default null, called at the end of hide()
******************************************************************************************************
*       *** IF JQUERY IS AVAILABLE USE IT! ***
*       useJQuery: bool, default null, will use jQuery to override certain calculations
******************************************************************************************************
*/
var evokeModalDialog=(function(){var l=null;var o=null;var b=0;var m=0;var A="evoModPopDivGrayout";var f=null;var C=window.navigator.userAgent.toLowerCase();var d=(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1];var k=/msie/.test(C);var s=(k&&(parseInt(d)>=6));var r=(k&&(parseInt(d)>=7));var c=0;var t=0;var D={x:-1,y:-1};function g(E){if(l!=null&&l[E]!=undefined&&l[E]!=null){return l[E]}else{return evokeModalDialog.displaySettings[E]}}function n(){return g("useJQuery")}function B(){if(n()){return jQuery("#"+o).outerWidth(true)}else{var E=e(document.getElementById(o),"width");if(isNaN(E)){E=0}return parseInt(E)}}function z(){if(n()){return jQuery("#"+o).outerHeight(true)}else{var E=e(document.getElementById(o),"height");if(isNaN(E)){E=0}return parseInt(E)}}function w(){var E=0;if(n()){E=jQuery(document).width();if(s&&!r){E-=21}}else{if(k){if(s){E=document.documentElement.clientWidth}else{E=document.body.clientWidth}}else{E=window.innerWidth}}return E}function j(){var E=0;if(n()){E=jQuery(document).height()}else{if(k){E=document.body.clientHeight}else{E=window.innerHeight}}return E}function q(){if(D.x>-1){return D.x+i()}else{if(n()){return Math.floor((jQuery(window).width()-B())/2)+i()}else{var E=0;if(k){if(s){E=(document.documentElement.clientWidth-B())/2+i()}else{E=(document.body.clientWidth-B())/2+i()}}else{E=(window.innerWidth-B())/2}if(!k){E-=10}if(E<0){E=0}return E}}}function p(){if(D.y>-1){return D.y+h()}else{if(n()){return Math.floor((jQuery(window).height()-z())/2)+h()}else{var E=0;if(k){if(s){E=((document.documentElement.clientHeight-z())/2)+h()}else{E=((document.body.clientHeight-z())/2)+h()}}else{E=(window.innerHeight-z())/2}if(!k){E-=10}if(E<0){E=0}return E}}}function i(){var E=0;var F=g("dialogPosition");if(F!=null&&F.toLowerCase()=="absolute"){E=document.documentElement.scrollLeft+document.body.scrollLeft}else{if(k){if(s&&!r){E=document.documentElement.scrollLeft}else{if(r){E=0}else{E=document.body.scrollLeft}}}else{E=0}}return E}function h(){var F=0;var E=g("dialogPosition");if(E!=null&&E.toLowerCase()=="absolute"){F=document.documentElement.scrollTop+document.body.scrollTop}else{if(k){if(s&&!r){F=document.documentElement.scrollTop}else{if(r){F=0}else{F=document.body.scrollTop}}}else{F=0}}return F}function e(F,E){if(n){return jQuery(F).css(E)}else{if(!document.getElementById){return}var G=F.style[E];if(!G){if(F.currentStyle){G=F.currentStyle[E]}else{if(document.defaultView){G=document.defaultView.getComputedStyle(F,"").getPropertyValue(E)}}}return G}}function v(){var E=document.getElementById(o);if(E!=null){E.style.left=q()+"px";E.style.top=p()+"px"}f.style.width=w()+"px";f.style.height=j()+"px";f.style.left="0px";f.style.top="0px"}function x(E,F){if(k){window.attachEvent("on"+E,F)}else{window.addEventListener(E,F,false)}}function a(E){var F=document.getElementById(A);if(F.attachEvent){F.attachEvent("onclick",E)}else{F.addEventListener("click",E,false)}}function u(E){var F=document.getElementById(A);if(F.detachEvent){F.detachEvent("onclick",E)}else{F.removeEventListener("click",E,false)}}function y(){}y.displaySettings={dialogPosition:"fixed",hideOnClick:true,backgroundColor:"#000000",opacity:0.6,left:-1,top:-1,showFunction:null,hideFunction:null,onHide:null,useJQuery:null};y.refresh=function(){v()};y.setCurrentSetting=function(E,F){l[E]=F};y.getCurrentSetting=function(E){return g(E)};y.showCallback=function(){};y.hideCallback=function(){document.getElementById(o).style.display="none";f.style.display="none";f.style.width="0px";f.style.height="0px";if(s&&!r){var E=document.getElementsByTagName("select");for(var F=0;F<E.length;F++){E[F].style.visibility="visible"}}};y.show=function(G,J,M){if(o!=null&&o!=G&&document.getElementById(o)){document.getElementById(o).style.display="none"}if(M!=undefined){l=M}else{l=y.displaySettings}D.x=parseInt(g("left"));D.y=parseInt(g("top"));if(J!=undefined){try{var K=document.getElementById(J).getElementById(G);if(K!=null){document.getElementById(J).removeChild(document.getElementById(J).getElementById(G))}}catch(H){}var L=document.getElementById(G);var N=L.parentNode;N.removeChild(L);document.getElementById(J).appendChild(L)}if(s&&!r){c=h();t=i()}if(f==null){f=document.getElementById(A)}f.style.backgroundColor=g("backgroundColor");o=G;var F=document.getElementById(o);F.style.zIndex=99;if(s&&!r){F.style.position="absolute";f.style.position="absolute";if(s&&!r){var E=document.getElementsByTagName("select");for(var I=0;I<E.length;I++){E[I].style.visibility="hidden"}E=F.getElementsByTagName("select");for(var I=0;I<E.length;I++){E[I].style.visibility="visible"}}}else{F.style.position=g("dialogPosition");f.style.position="fixed"}v();if(typeof(l.showFunction)!="undefined"){if(typeof(l.showFunction)=="function"){l.showFunction(A,o)}else{y.initOpacity();f.style.display="inline";F.style.display="inline"}}else{if(typeof(y.displaySettings.showFunction)=="function"){y.displaySettings.showFunction(A,o)}else{y.initOpacity();f.style.display="inline";F.style.display="inline"}}};y.getCurrentOpacity=function(){if(l.opacity!=null){return l.opacity}else{return y.displaySettings.opacity}};y.initOpacity=function(){var E=y.getCurrentOpacity();f.style.opacity=E;if(k){f.filters.alpha.opacity=parseFloat(E).toFixed(2)*100}};y.hide=function(){if(typeof(l.showFunction)!="undefined"){if(typeof(l.showFunction)=="function"){l.hideFunction(A,o)}else{y.hideCallback()}}else{if(typeof(y.displaySettings.showFunction)=="function"){y.displaySettings.hideFunction(A,o)}else{y.hideCallback()}}if(typeof(l.onHide)=="function"){l.onHide()}};y.outsideClick=function(){if(l.hideOnClick!=undefined){if(l.hideOnClick){y.hide()}}else{if(y.displaySettings.hideOnClick){y.hide()}}};y.attachClickEvent=function(E){a(E)};y.detachClickEvent=function(E){u(E)};y.windowOnLoad=function(E){x("load",E)};y.eventLoad=function(){var I="position:fixed;left:0px;top:0px;width:0px;height:0px;display:none;z-index:98;";I+="background-color:"+y.displaySettings.backgroundColor+";";I+="opacity:"+y.displaySettings.opacity+";";I+="filter:alpha(opacity="+(parseFloat(y.displaySettings.opacity).toFixed(2)*100)+");";if(document.createStyleSheet){var G=document.createStyleSheet();G.addRule("#"+A,I)}else{if(C.indexOf("opera")!=-1){var G=document.createElement("style");var K="#"+A+" { "+I+" }";G.innerHTML=K;document.body.appendChild(G)}else{var F=document.getElementsByTagName("head")[0];var G=document.createElement("style");G.type="text/css";G.media="all";F.appendChild(G);var E=0;if(document.styleSheets.length>0){E=document.styleSheets.length-1}G=document.styleSheets[E];var K="#"+A+" { "+I+" }";G.insertRule(K,0)}}var J=document.createElement("div");J.setAttribute("id",A);document.body.appendChild(J);var H=document.getElementById(A);if(H.attachEvent){H.attachEvent("onclick",function(){evokeModalDialog.outsideClick()})}else{H.addEventListener("click",function(){evokeModalDialog.outsideClick()},false)}};y.eventScroll=function(){if(o!=null){if(document.getElementById(o).style.display!="none"){if(s&&!r&&(l.dialogPosition==undefined||l.dialogPosition=="fixed")){document.documentElement.scrollTop=c;document.documentElement.scrollLeft=t}}}};y.eventResize=function(){if(o!=null){if(document.getElementById(o).style.display!="none"){v()}}};y.attachEvents=function(){x("load",y.eventLoad);if(s&&!r){x("scroll",y.eventScroll)}if(n()){jQuery(window).resize(y.eventResize)}else{if(!k){window.captureEvents(Event.RESIZE)}x("resize",y.eventResize)}};return y})();evokeModalDialog.attachEvents();
