YAHOO.namespace("protoscript");YAHOO.protoscript.UI=function(){var panel=null;return{save:function(name,value,exp_y,exp_m,exp_d,path,domain,secure){var cookie_string=name+"="+escape(value);if(exp_y){var expires=new Date(exp_y,exp_m,exp_d);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;},load:function(cookieName){var results=document.cookie.match(cookieName+'=(.*?)(;|$)');if(results)
return(unescape(results[1]));else
return null;},showUI:function(){this.panel.show();},createUI:function(){var priorSelectorVal=this.load("protoscript_selectorval");var priorScriptVal=this.load("protoscript_scriptval");this.panel=new YAHOO.widget.ResizePanel('prototype-ui',{fixedcenter:true,close:true,draggable:true,underlay:'shadow',model:false,width:'400px',visible:true,iframe:true});var innerHTML='
'+'
'+''+''+''+'
'+'
'+'
'+''+''+'
'+'
'+'
'+'
';this.panel.center=this.centerPanelY;this.panel.setHeader("Test Protoscript");this.panel.setBody(innerHTML);this.panel.setFooter("");this.panel.render(document.body);this.panel.body.style.height=400+"px";this.panel.show();var yuv=YAHOO.util.Event;var yud=YAHOO.util.Dom;yud.get('the-query-field').value=priorSelectorVal||"";yud.get('the-script-field').value=priorScriptVal||"";var me=this;yuv.addListener('execute-script-button','click',function(){var selectorVal=yud.get('the-query-field').value;var protoscriptVal=yud.get('the-script-field').value;if(selectorVal.length>0&&protoscriptVal.length>0){protoscriptVal=protoscriptVal.replace(/\s*((\S+\s*)*)/,"$1");if(protoscriptVal.substr(0,1)!='{'){protoscriptVal='{'+protoscriptVal+'}';}
me.save("protoscript_selectorval",selectorVal);me.save("protoscript_scriptval",protoscriptVal);var psConfig;eval('psConfig='+protoscriptVal);$proto(selectorVal,psConfig);}});yuv.addListener('find-elems','click',function(){var selectorVal=yud.get('the-query-field').value;if(selectorVal.length>0){selectorVal=selectorVal.replace(/\s*((\S+\s*)*)/,"$1");$proto(selectorVal,{Fade:{opacity:{to:0.5},duration:0.1,onComplete:{Fade:{opacity:{to:1.0},duration:0.1},SetStyle:{borderLeftWidth:'0px',borderLeftStyle:'none',borderTopWidth:'0px',borderTopStyle:'none',borderRightWidth:'0px',borderRightStyle:'none',borderBottomWidth:'0px',borderBottomStyle:'none'}}},SetStyle:{borderLeftWidth:'1px',borderLeftStyle:'solid',borderLeftColor:'red',borderTopWidth:'1px',borderTopStyle:'solid',borderTopColor:'red',borderRightWidth:'1px',borderRightStyle:'solid',borderRightColor:'red',borderBottomWidth:'1px',borderBottomStyle:'solid',borderBottomColor:'red'}});}});},centerPanelY:function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var pageRight=viewPortWidth+scrollX-50;var gobblerRight=YAHOO.util.Dom.getX(this.element)+elementWidth+scrollX;if(gobblerRight>pageRight){var gobblerLeft=(viewPortWidth-elementWidth)+scrollX-50;this.element.style.left=parseInt(gobblerLeft,10)+"px";}
if(elementHeight<=viewPortHeight){var top=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.element.style.top=parseInt(top,10)+"px";}else{this.element.style.top=scrollY+"px";}
this.syncPosition();this.cfg.refireEvent("iframe");},};}();