var $jq=jQuery;var juice={};var JuiceInsert={};var JuiceProcess={};var JuiceSelectProcess={};var JuicePanel={};(function(){var window=this;function _Juice(){this._debugEnabled=false;this._debugWinId="JuiceDebug";this._debugWinSel="#"+this._debugWinId;this._ready=false;this._panels=[];this._meta=[];this._overlayFunc=null;$jq(document).ready(this._setReady)}_Juice.prototype.version="0.6.1";_Juice.prototype._setReady=function(){this._ready=true};_Juice.prototype.setDebug=function(state){this._debugEnabled=state};_Juice.prototype.overlayFunc=function(v){if(v!=null){this._overlayFunc=v}if(this._overlayFunc==null){try{this._overlayFunc=juiceOverlayDisplay}catch(msg){juice.debugOutln("juiceOverlayDisplay not defined")}}return this._overlayFunc};_Juice.prototype.findMeta=function(id,selector,attribute,filter){this.setMeta(id,this._selectMeta(id,selector,attribute,filter))};_Juice.prototype.setMeta=function(id,arg){var val;if($jq.isFunction(arg)){val=arg(id)}else{val=arg}if(val){this._meta[id]=new Meta(val)}};_Juice.prototype._selectMeta=function(id,selector,attribute,filter){if($jq.isFunction(attribute)){filter=attribute;attribute=null}var i=0;var values=[];$jq(selector).each(function(){var val;if(attribute){val=$jq(this).attr(attribute)}else{if($jq(this).size()>0){val="";var contents=$jq(this).contents();contents.each(function(){if(this.nodeType==3){val+=this.nodeValue}})}}if(jQuery.isFunction(filter)&&val!==undefined){val=filter(val,id)}if(val!==undefined){values[i++]=val}});if(values.length>0){return values}return null};_Juice.prototype.hasMeta=function(id){if(id){var meta=this._getMetaInstance(id);if(meta!=null){return meta.hasMeta()}}else{for(var i in this._meta){if(this._meta[i]!=null){return true}}}return false};_Juice.prototype.getMeta=function(id,index){var meta=this._getMetaInstance(id);if(meta!=null){return meta.get(index)}return null};_Juice.prototype.deleteMeta=function(id){if(this._meta[id]){this._meta[id]=null}};_Juice.prototype.getValues=function(id){return this.getMetaValues(id)};_Juice.prototype.getMetaValues=function(id){var meta=this._getMetaInstance(id);if(meta!=null){return meta.getValues()}return null};_Juice.prototype._getMetaInstance=function(id){return this._meta[id]};_Juice.prototype.debugMeta=function(){for(var i in this._meta){var meta=this._meta[i];if(meta.hasMeta()){if(meta.getLength()>1){juice.debugOutln(i+": ["+meta.getValues().join(",")+"]")}else{juice.debugOutln(i+": "+meta.get())}}else{juice.debugOutln("Meta "+i+": not set")}}};_Juice.prototype.addPanel=function(panel){this._panels[this._panels.length]=panel};_Juice.prototype.hasDebugWin=function(){if($jq(this._debugWinSel).length){return true}return false};_Juice.prototype.debugOutln=function(text){this.debugOut(text+"<br/>")};_Juice.prototype.debugOut=function(text){if(this._debugEnabled){if(!this.hasDebugWin()){this.createDebugWin()}$jq(this._debugWinSel).append(text)}};_Juice.prototype.createDebugWin=function(){this.appendElement("body","div",this._debugWinId,'style="clear: both; z-index: 5000; position: relative; text-align: left; color: #000000; background: #ffffff; font-size: 1.25em;"')};_Juice.prototype.appendElement=function(selector,type,id,attribString){var atts="";if(attribString){atts=" "+attribString+" "}var html="<"+type+' id="'+id+'"'+atts+"></"+type+">";$jq(selector).append(html)};_Juice.prototype.addToPanel=function(sel){for(var i=0;i<this._panels.length;i++){var defPanel=sel.defPanel();var panel=this._panels[i];if((defPanel==null&&!panel.shared())||(defPanel!=null&&panel.getPanelId()!=defPanel)){continue}panel.add(sel)}};_Juice.prototype.enableOnPanel=function(sel,pos){for(var i=0;i<this._panels.length;i++){var defPanel=sel.defPanel();var panel=this._panels[i];if((defPanel==null&&!panel.shared())||(defPanel!=null&&panel.getPanelId()!=defPanel)){continue}panel.enable(sel,pos)}};_Juice.prototype.popup_win=null;_Juice.prototype.launchWinH=600;_Juice.prototype.launchWinW=800;_Juice.prototype.launchWinHieght=function(v){if(v!=null){this.launchWinH=v}return this.launchWinH};_Juice.prototype.launchWinWidth=function(v){if(v!=null){this.launchWinW=v}return this.launchWinW};_Juice.prototype.launchWin=function(uri,type,arg1,arg2){switch(type){case"current":this.launch(uri);break;case"overlay":this.launchOverlayWin(arg1,arg2);break;case"iframe":this.launchIframeWin(uri,arg1);break;case"iframe-overlay":var target=this.launchOverlayWin(arg1,arg2);this.launchIframeWin(uri,target);break;case"new":default:this.launchExternalWin(uri);break}};_Juice.prototype.launch=function(uri){location.href=uri};_Juice.prototype.launchOverlayWin=function(content,hdrContent){var target=null;if(this.overlayFunc()){if(content instanceof JuiceInsert){content=content.container()}target=this.overlayFunc()(content,hdrContent)}return target};_Juice.prototype.launchExternalWin=function(uri){if(this.popup_win&&!this.popup_win.closed){this.popup_win.close()}this.popup_win=window.open(uri,"Juice","width="+this.launchWinW+",height="+this.launchWinH+",toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes");if(window.focus){this.popup_win.focus()}};_Juice.prototype.launchIframeWin=function(uri,insert){var target=insert;if(insert instanceof JuiceInsert){insert.show();target=insert.getInsertObject()}if(target){var frame=document.createElement("iframe");frame.id="juiframe";frame.src=uri;frame.height=target.height();frame.width=target.width();frame.scrolling="auto";target.append(frame)}};_Juice.prototype.runscript=function(id,src){$jq("#"+id).remove();var cont='<script id="'+id+'" src="'+src+'" type="text/javascript"><\/script>';$jq(document).prepend(cont)};_Juice.prototype.onAllLoaded=function(func){this.ready(func)};_Juice.prototype.ready=function(func){var This=this;if(this.isGoogleApiLoaded()&&this.isJsLoaded()){func()}else{setTimeout(function(){This.ready(func)},5)}};function JsLoadFlag(file){this.name=file;this.loaded=false}_Juice.prototype.JsLoadFlags=[];_Juice.prototype.loadJs=function(target,pathPrefix,onLoadEvent){var file=this._absoluteUri(target,pathPrefix);if(this.findJs(file)){if(onLoadEvent){onLoadEvent()}return}this._loadFile(file,"js",onLoadEvent)};_Juice.prototype.loadCss=function(target,pathPrefix){this._loadFile(this._absoluteUri(target,pathPrefix),"css")};_Juice.prototype._loadFile=function(file,type,onLoadEvent){var This=this;var evnt=onLoadEvent;var head=document.getElementsByTagName("head")[0];var ins=null;if(type=="js"){ins=document.createElement("script");ins.type="text/javascript";ins.src=file}else{if(type=="css"){ins=document.createElement("link");ins.type="text/css";ins.rel="stylesheet";ins.href=file}}if(type=="js"){This.JsLoadFlags[this.JsLoadFlags.length]=new JsLoadFlag(file);ins.onreadystatechange=function(){if(ins.readyState=="loaded"||ins.readyState=="complete"){if(evnt){evnt()}This.jsOnLoadEvent(file)}};ins.onload=function(){if(evnt){evnt()}This.jsOnLoadEvent(file)}}head.insertBefore(ins,head.firstChild)};_Juice.prototype._absoluteUri=function(file,pathPrefix){if(this._strBeginsWith(file,"http://")||this._strBeginsWith(file,"https://")){return file}if(this._strBeginsWith(file,"/")){if(!pathPrefix){pathPrefix=""}else{pathPrefix="/"+pathPrefix}return window.location.protocol+"//"+window.location.host+pathPrefix+file}else{if(!pathPrefix){pathPrefix=""}else{pathPrefix=pathPrefix+"/"}var ret=window.location.protocol+"//"+window.location.host;var path=document.location.pathname;if(this._strEndsWith(path,"/")){path=path.substr(0,path.length-1)}var locationBits=path.split("/");for(var i=0;i<locationBits.length-1;i++){ret+=locationBits[i]+"/"}return ret+pathPrefix+file}};_Juice.prototype.findJs=function(file){var fileString=this.urlRoot(file);var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;i++){if(this.urlRoot(scripts[i].getAttribute("src"))==fileString){return true}}return false};_Juice.prototype.urlRoot=function(url){str=new String(url);if(str.indexOf("#")!=-1){str=new String(str.substring(0,str.indexOf("#")))}if(str.indexOf("?")!=-1){str=new String(str.substring(0,str.indexOf("?")))}return str.toString()};_Juice.prototype.jsOnLoadEvent=function(name){var loadFlags=this.JsLoadFlags;for(var i=0;i<loadFlags.length;i++){if(name==loadFlags[i].name){loadFlags[i].loaded=true;break}}};_Juice.prototype.onJsLoaded=function(func){var This=this;if(this.isJsLoaded()){func()}else{setTimeout(function(){This.onJsLoaded(func)},10)}};_Juice.prototype.isJsLoaded=function(){if(this.JsNotLoaded().length){return false}return true};_Juice.prototype.JsNotLoaded=function(){var ret=[];var loadFlags=this.JsLoadFlags;for(var i=0;i<loadFlags.length;i++){if(!loadFlags[i].loaded){ret[ret.length]=loadFlags[i].name}}return ret};_Juice.prototype._googleApiKey="";_Juice.prototype.googleApiKey=function(v){if(v!=null){this._googleApiKey=v}return this._googleApiKey};_Juice.prototype._googleLoadFlag="off";_Juice.prototype.loadGoogle_jsapi=function(apiKey){var key=this._googleApiKey;if(apiKey){key=apiKey}if(key!=""){key="key="+key+"&"}if(this._googleLoadFlag=="off"){this._googleLoadFlag="loading";var google="http://www.google.com/jsapi?"+key+"callback=juice._googleLoaded";juice.loadJs(google)}};_Juice.prototype._googleLoaded=function(){this._googleLoadFlag="loaded"};_Juice.prototype.loadGoogleApi=function(api,ver,args){if(!this.googleApiLoaded(api)){this.gapLoadFlags[this.gapLoadFlags.length]=new JsLoadFlag(api);this._loadGoogleApi(api,ver,args)}};_Juice.prototype._loadGoogleApi=function(api,ver,args){var This=this;this.loadGoogle_jsapi();if(this._googleLoadFlag=="loaded"){this.startLoadGoogleApi(api,ver,args)}else{setTimeout(function(){This._loadGoogleApi(api,ver,args)},20)}};_Juice.prototype.gapLoadFlags=[];_Juice.prototype.startLoadGoogleApi=function(api,ver,args){google.load(api,ver,{callback:function(){juice.gapOnLoadEvent(api)}})};_Juice.prototype.gapOnLoadEvent=function(name){var loadFlags=this.gapLoadFlags;for(var i=0;i<loadFlags.length;i++){if(name==loadFlags[i].name){loadFlags[i].loaded=true;break}}};_Juice.prototype.onGoogleApiLoaded=function(func){var This=this;if(this.isGoogleApiLoaded()){func()}else{setTimeout(function(){This.onGoogleApiLoaded(func)},5)}};_Juice.prototype.isGoogleApiLoaded=function(){if(this.googleApiNotLoaded().length){return false}return true};_Juice.prototype.googleApiNotLoaded=function(){var ret=[];var loadFlags=this.gapLoadFlags;for(var i=0;i<loadFlags.length;i++){if(!loadFlags[i].loaded){ret[ret.length]=loadFlags[i].name}}return ret};_Juice.prototype.googleApiLoaded=function(api){var ret=[];var loadFlags=this.gapLoadFlags;for(var i=0;i<loadFlags.length;i++){if(loadFlags[i].name==api){return true}}return false};_Juice.prototype.nums="0123456789";_Juice.prototype.lc="abcdefghijklmnopqrstuvwxyz";_Juice.prototype.uc="ABCDEFGHIJKLMNOPQRSTUVWXYZ";_Juice.prototype.isVal=function(value,val){if(value==""){return true}for(i=0;i<value.length;i++){if(val.indexOf(value.charAt(i),0)==-1){return false}}return true};_Juice.prototype.isnumser=function(value){return juice.isVal(value,juice.nums)};_Juice.prototype.isLower=function(value){return juice.isVal(value,juice.lc)};_Juice.prototype.isUpper=function(value){return juice.isVal(value,juice.uc)};_Juice.prototype.isAlpha=function(value){return juice.isVal(value,juice.lc+juice.uc)};_Juice.prototype.isAlphanum=function(value){return juice.isVal(value,juice.lc+juice.uc+juice.nums)};_Juice.prototype.stringToAlphnumAray=function(str){var items=[];var count=0;var raw=juice.stringToArray(str,",.:;");for(j=0;j<raw.length;j++){if(juice.isAlphanum(raw[j])){items[count++]=raw[j]}}return items};_Juice.prototype.stringToArray=function(str,extras){var seps=" \t\n\r"+extras;var index;var items=[];var count=0;while(str!=null&&str!=""){index=0;while(index<str.length&&juice.isSepChar(str.charAt(index),seps)){index++}if(index<str.length){var item="";while(index<str.length&&!juice.isSepChar(str.charAt(index),seps)){item+=str.charAt(index);index++}items[count++]=item}str=str.substring(index+1,str.length)}return items};_Juice.prototype.isSepChar=function(ch,chars){var white=" \t\n\r";if(chars!=null||chars!=""){white=chars}return(white.indexOf(ch)!=-1)};_Juice.prototype.toArray=function(data){var items=[];if(!data){return items}else{if($jq.isArray(data)){return data}else{if(typeof data=="string"){items[0]=data}else{if(!data[0]){items[0]=data}else{items=data}}}}return items};_Juice.prototype.updateArray=function(first,second){var ret=first;if(second){for(var i in second){ret[i]=second[i]}}return ret};_Juice.prototype.setCookie=function(name,value,minutes,hours,days,path,domain,secure){var cookie_string=name+"="+escape(value);if(minutes){if(!hours){hours=0}if(!days){days=0}var date=new Date();date.setTime(date.getTime()+((((days*24*60*60)+(hours*60*60)+(minutes*60))*1000)));var expires="; expires="+date.toGMTString();cookie_string+="; expires="+expires.toGMTString()}if(path){cookie_string+="; path="+escape(path)}if(domain){cookie_string+="; domain="+escape(domain)}if(secure){cookie_string+="; secure"}document.cookie=cookie_string};_Juice.prototype.getCookie=function(name){var results=document.cookie.match("(^|;) ?"+name+"=([^;]*)(;|$)");if(results){return(unescape(results[2]))}return null};_Juice.prototype.deleteCookie=function(name){var cookie_date=new Date();cookie_date.setTime(cookie_date.getTime()-1);document.cookie=name+="=; expires="+cookie_date.toGMTString()};_Juice.prototype._strBeginsWith=function(str,target){return(str.match("^"+target)==target)};_Juice.prototype._strEndsWith=function(str,target){return(str.match(target+"$")==target)};window.juice=new _Juice();function JuiceInsert(container,insertPoint,insertType){this._container=container;this._insertPoint=insertPoint;this._insertType=insertType;this.shown=[];this._insertObjects=[];this.inserts=$jq(this._insertPoint).length;for(var i=0;i<this.inserts;i++){this.shown[i]=false;this._insertObjects[i]=null}}JuiceInsert.prototype.container=function(v){if(v!=null){this._container=v}return this._container};JuiceInsert.prototype.insertPoint=function(v){if(v!=null){this._insertPoint=v}return this._insertPoint};JuiceInsert.prototype.insertType=function(v){if(v!=null){this._insertType=v}return this._insertType};JuiceInsert.prototype.insertCount=function(){return this.inserts};JuiceInsert.prototype.insertObjects=function(){return this._insertObjects};JuiceInsert.prototype.showAll=function(){for(var i=0;i<this.inserts;i++){this.show(i)}};JuiceInsert.prototype.show=function(pos){if(!pos){pos=0}var This=this;$jq(this._insertPoint).each(function(i){if(i==pos&&!This.shown[i]){var ins=jQuery(This._container);var target=jQuery(this);This._insertObjects[i]=ins;switch(This._insertType){case"after":target.after(ins);break;case"before":target.before(ins);break;case"prepend":target.prepend(ins);break;case"replace":target.replaceWith(ins);break;case"append":default:target.append(ins);break}This.shown[i]=true}})};JuiceInsert.prototype.getInsertObject=function(pos){if(!pos){pos=0}return this._insertObjects[pos]};JuiceInsert.prototype.remove=function(pos){if(!pos){pos=0}if(this.shown[pos]){this._insertObjects[pos].remove();this._insertObjects[pos]=null;this.shown[pos]=false}};window.JuiceInsert=JuiceInsert;function JuiceProcess(id,initFunc,selectFunc,insert,ju){this._ready=false;if(arguments.length){this.init(id,initFunc,selectFunc,insert,ju)}}JuiceProcess.prototype.initAndStartup=function(id,initFunc,selectFunc,insert,ju){this.init(id,initFunc,selectFunc,insert,ju);this.startup()};JuiceProcess.prototype.init=function(id,initFunc,selectFunc,insert,ju){this._ProcessId=id;this._startFunc=initFunc;this._selectFunc=selectFunc;this._insert=insert;this._juice=ju;this._ready=true};JuiceProcess.prototype.processId=function(v){if(v!=null){this._ProcessId=v}return this._ProcessId};JuiceProcess.prototype.initFunc=function(v){if(v!=null){this._initFunc=v}return this._initFunc};JuiceProcess.prototype.selectFunc=function(v){if(v!=null){this._selectFunc=v}return this._selectFunc};JuiceProcess.prototype.insert=function(v){if(v!=null){this._insert=v}return this._insert};JuiceProcess.prototype.startupWhenReady=function(){if(this.ready()){this.startup()}else{var This=this;setTimeout(function(){This.startupWhenReady()},5)}};JuiceProcess.prototype.startup=function(){var This=this;setTimeout(function(){This._startup()},2)};JuiceProcess.prototype._startup=function(){if(this._startFunc){this._startFunc(this)}else{this.enable()}};JuiceProcess.prototype.ready=function(){return this._ready};_JXSPA=[];JuiceProcess.prototype.callbackArrayPos=-1;JuiceProcess.prototype.jsonCallBackPrefix=function(methodName){var ret="_JXSPA["+this.getCallBackPos()+"]";if(methodName){ret+="."+methodName}return encodeURIComponent(ret)};JuiceProcess.prototype.getCallBackPos=function(){if(this.callbackArrayPos==-1){_JXSPA[_JXSPA.length]=this;for(var i=0;i<_JXSPA.length;i++){if(_JXSPA[i]==this){break}}this.callbackArrayPos=i}return this.callbackArrayPos};JuiceProcess.prototype.showInsert=function(pos){if(this._insert){this._insert.show(pos)}};JuiceProcess.prototype.getInsertObjects=function(){if(this._insert){return this._insert.insertObjects()}return[]};JuiceProcess.prototype.getInsertObject=function(pos){if(this._insert){return this._insert.getInsertObject(pos)}return null};JuiceProcess.prototype.insertCount=function(){if(this._insert){return this._insert.insertCount()}return 0};JuiceProcess.prototype.enable=function(){};window.JuiceProcess=JuiceProcess;function JuiceSelectProcess(id,iconSrc,selText,initFunc,selectFunc,insert,ju,defPanel){this._ready=false;if(arguments.length){this.init(id,iconSrc,selText,initFunc,selectFunc,insert,ju,defPanel)}}JuiceSelectProcess.prototype=new JuiceProcess();JuiceSelectProcess.prototype.constructor=JuiceSelectProcess;JuiceSelectProcess.superclass=JuiceProcess.prototype;JuiceSelectProcess.prototype.init=function(id,iconSrc,selText,initFunc,selectFunc,insert,ju,defPanel){this._iconSrc=iconSrc;this._selText=selText;this._defPanel=defPanel;JuiceSelectProcess.superclass.init.call(this,id,initFunc,selectFunc,insert,ju);this.addToIconWin();this.startup()};JuiceSelectProcess.prototype.iconSrc=function(v){if(v!=null){this._iconSrc=v}return this._iconSrc};JuiceSelectProcess.prototype.selText=function(v){if(v!=null){this._selText=v}return this._selText};JuiceSelectProcess.prototype.defPanel=function(v){if(v!=null){this._defPanel=v}return this._defPanel};JuiceSelectProcess.prototype.addToIconWin=function(){this._juice.addToPanel(this)};JuiceSelectProcess.prototype.enable=function(pos){this._juice.enableOnPanel(this,pos)};JuiceSelectProcess.prototype.getSelectFunction=function(i){if(!i){i=0}var pos=this.getCallBackPos();return(function(){_JXSPA[pos]._selectFunc(i)})};window.JuiceSelectProcess=JuiceSelectProcess;function JuicePanel(insertDiv,panelId,startClass,liveClass,showFunc){this.init(insertDiv,panelId,startClass,liveClass,showFunc)}JuicePanel.prototype.init=function(insertDiv,panelId,startClass,liveClass,showFunc){this._panelId=panelId;this._insertDiv=insertDiv;this._startClass=startClass;this._liveClass=liveClass;this._showFunc=showFunc;this.inserted=false;this.shown=false;this._shared=true};JuicePanel.prototype.getPanelId=function(){return this._panelId};JuicePanel.prototype.startClass=function(v){if(v!=null){this._startClass=v}return this._startClass};JuicePanel.prototype.liveClass=function(v){if(v!=null){this._liveClass=v}return this._liveClass};JuicePanel.prototype.showFunc=function(v){if(v!=null){this._showFunc=v}return this._showFunc};JuicePanel.prototype.shared=function(v){if(v!=null){this._shared=v}return this._shared};JuicePanel.prototype.insert=function(){if(!this.inserted){this._insertDiv.showAll();this.inserted=true}};JuicePanel.prototype.show=function(){if(jQuery.isFunction(this._showFunc)&&!this.shown){this._showFunc();this.shown=true}};JuicePanel.prototype.add=function(sel){this.insert();this.show();var objects=this._insertDiv.insertObjects();for(var i=0;i<objects.length;i++){var id=this.makeId(sel,i);var htm='<img title="'+sel.selText()+'" id="'+id+'" class="'+this.startClass()+'" src="'+sel.iconSrc()+'" />';objects[i].append(htm)}sel.insert(this._insertDiv)};JuicePanel.prototype.enable=function(sel,pos){var func=sel.getSelectFunction(pos);var id=this.makeId(sel,pos);var classes=this.startClass().split(" ");for(var i=0;i<classes.length;i++){$jq("#"+id).removeClass(classes[i])}classes=this.liveClass().split(" ");for(var i=0;i<classes.length;i++){$jq("#"+id).addClass(classes[i])}$jq("#"+id).click(func)};JuicePanel.prototype.makeId=function(sel,pos){if(!pos){pos=0}return this.getPanelId()+"-"+sel.processId()+"-"+pos};window.JuicePanel=JuicePanel;function Meta(arg){this._values=[];if(arguments.length){this.setValues(arg)}}Meta.prototype.setValues=function(val){this._values=juice.toArray(val)};Meta.prototype.get=function(index){return this._values[index==null?0:index]};Meta.prototype.getValues=function(){return this._values};Meta.prototype.getLength=function(){return this._values.length};Meta.prototype.hasMeta=function(){return this._values.length>0}})();function testDebug(data){if(this._debugEnabled){div=document.getElementById("pageFooter");if(div){div.innerHTML+=" "+data}}};
