/* Copyright (c) 2007-2008 Kincafe.com. All rights reservered. Contact info@kincafe.com to purchase rights to this software */
var gCurType;var gPopinWins=[];gPopinWins["helpPopin"]={win:null,props:{width:"240px",context:[null,"tl","tr"],fixedcenter:true,constraintoviewport:true,underlay:"none",close:false,visible:true,draggable:false,iframe:true,modal:false}};gPopinWins["__waitPopin"]={win:null,props:{width:"240px",context:[null,"tl","tl"],underlay:"none",close:false,visible:true,draggable:false,iframe:true,modal:false}};gPopinWins["bookSliderPopin"]={win:null,props:{width:"40px",context:[null,"bl","tl"],fixedcenter:true,constraintoviewport:true,underlay:"none",close:false,visible:true,draggable:false,iframe:false,modal:false}};function showPopin(type,body,addlProps,header){var p_a=false;var p_b=false;var win;var props=gPopinWins[type].props;if(addlProps){if(addlProps.x){props.x=addlProps.x;}if(addlProps.y){props.y=addlProps.y;}if(addlProps.contextElement){if(!props.context){props.context=[];}props.context[0]=addlProps.contextElement;}if(addlProps.width){props.width=addlProps.width;}if(addlProps.insidePopin){p_a=true;}}if(!p_a&&!isEmpty(gCurType)){try{hidePopin(gCurType);}catch(ex){;}}if(gPopinWins[type].win==null){win=new YAHOO.widget.Panel(type,props);gPopinWins[type].win=win;p_b=true;}else{win=gPopinWins[type].win;win.cfg.applyConfig(props);}if(body){win.setBody(body);}if(header){closeBtn='<span style="float:right;"><a style="text-decoration:none" href="javascript:hidePopin(\''+type+'\')">'+(type!='album'?'<img src="/images/close.gif" title="Close" alt="x"/>':'<img src="/images/spacer.gif" width=35 height=20 title="Close" alt="x"/>')+'</a></span>';win.setHeader(closeBtn+header);}if(p_b){win.render(document.body);}else{win.render();}win.show();};function hidePopin(type){try{gPopinWins[type].win.hide();if(gPopinWins[type].dependentType){hidePopin(gPopinWins[type].dependentType);}}catch(ex){}};function setPopinBody(type,body){if(gPopinWins[type].win!=null){gPopinWins[type].win.setBody(body);}};function popinClickHandler(){try{var e=YAHOO.util.Event.getEvent();var elem=YAHOO.util.Event.getTarget(e);var p_c=gPopinWins[gCurType].win;while(elem!=null){if(elem.id==p_c.id){return;}if(elem==elem.parentNode){break;}elem=elem.parentNode;}}catch(ex){debug("error occured in popinClickHandler. Ignoring it.");}hidePopin(gCurType);Event.stopObserving(document,'click',popinClickHandler,false);};function showPopinHelp(text,srcElem){showCustomPopin("helpPopin",text,{contextElement:srcElem});};function showWaitMessage(text,btnToCover){showPopin("__waitPopin","<div id='waitPopin'><img style='margin-right:11px;float:left' src='/images/waitPopin.gif'/>"+text+"</div>",{contextElement:btnToCover});};function showCustomPopin(type,body,addlProps){showPopin(type,body,addlProps);try{var e=YAHOO.util.Event.getEvent();if(e){if(e.type=='click'){YAHOO.util.Event.stopPropagation(e);}}}catch(ex){;}if(!(addlProps&&addlProps.insidePopin)){gCurType=type;}Event.observe(document,"click",popinClickHandler,false);};function showModalPopin(type,width,height,contextElem,header,url){if(gPopinWins[type]==null){gPopinWins[type]={win:null,props:{width:width,context:[null,"tl","tl"],zIndex:51,fixedcenter:true,constraintoviewport:true,underlay:"none",close:false,visible:true,draggable:true,iframe:false,modal:true}};}if(url.indexOf("?")>=0){url+="&";}else{url+="?";}url+="dummy="+(new Date()).getTime();var initUrl="/wait.htm";var p_g=true;if(YAHOO.widget.Module.prototype.browser=='safari'){initUrl=url;p_g=false;}showPopin(type,'<iframe name="'+type+'Frm" id="'+type+'Frame" src="'+initUrl+'" width="'+width+'"px" height="'+height+'"px" hspace="0" '+'scrolling="no" frameborder="0" marginwidth="0" marginheight="0" '+'class="dlgWindow" style="padding:0px;overflow:hidden"> '+'</iframe> ',{contextElement:contextElem},((header!=null&&header.length>0)?"&gt;&gt; "+header:' '));if(p_g){$(type+"Frame").src=url;}};gPopinWins["dropdown"]={win:null,props:{context:[null,"tl","bl"],zIndex:52,fixedcenter:false,constraintoviewport:false,underlay:"none",close:false,visible:true,draggable:false,iframe:true,modal:false}};Dropdown=function(id,options,selectedIndex,targetFld,selectListener,parentPopinType,bMenuStyle,p_f){this.id=id;this.options=options;this.selectListener=selectListener;this.targetFld=targetFld;this.p_a=false;if(parentPopinType&&parentPopinType!=null){this.p_a=true;YAHOO.util.Event.addListener(gPopinWins[parentPopinType].win,"beforeHide",new function(){hidePopin('dropdown');},this,true);gPopinWins[parentPopinType].dependentType='dropdown';}var elem=$(this.id);if(!bMenuStyle){elem.className+=" dropdown";}if(!bMenuStyle){if(isEmpty(elem.innerHTML)&&options!=null&&options.length>0){elem.innerHTML=options[selectedIndex]["text"];}YAHOO.util.Event.addListener(elem,"click",this.clickListener,this,true);YAHOO.util.Event.addListener(elem,"mouseover",this.mouseOverListener,this,true);YAHOO.util.Event.addListener(elem,"mouseout",this.mouseOutListener,this,true);}else{YAHOO.util.Event.addListener(p_f,"click",this.clickListener,this,true);}if(this.targetFld!=null&&selectedIndex>=0){$(this.targetFld).value=options[selectedIndex]["value"];}};Dropdown.prototype.clickListener=function(){var p_e=(new Date()).getTime();var elem=$(this.id);var body="<div id='"+this.id+"_ddoc' class='dropdownOptionsC'><ul>";for(var i=0;i<this.options.length;i++){body+="<li><a id='"+this.id+"_"+i+"_"+p_e+"' + href='javascript:navigate()'>"+this.options[i]["text"]+"</a></li>";}body+="</ul></div>";showCustomPopin("dropdown",body,{width:elem.offsetWidth,contextElement:elem,insidePopin:this.p_a});for(var i=0;i<this.options.length;i++){YAHOO.util.Event.addListener($(this.id+"_"+i+"_"+p_e),"click",this.itemClickListener,{dropdown:this,selectedIndex:i});}};Dropdown.prototype.itemClickListener=function(e,params){var p_d=params["dropdown"];var selectedIndex=params["selectedIndex"];$(p_d.id).innerHTML=p_d.options[selectedIndex]["text"];if(p_d.targetFld!=null){$(p_d.targetFld).value=p_d.options[selectedIndex]["value"];}hidePopin("dropdown");p_d.selectListener.call($(p_d.id),selectedIndex,p_d.options[selectedIndex]["value"]);};Dropdown.prototype.mouseOverListener=function(){var elem=$(this.id);if(elem.className.indexOf("Focus")!=elem.className.length-5){elem.className+="Focus";}};Dropdown.prototype.mouseOutListener=function(){var elem=$(this.id);if(elem.className.indexOf("Focus")==elem.className.length-5){elem.className=elem.className.substr(0,elem.className.length-5);}};var gAskQData=null;function askQuestion(question,buttons,callbackFnName,extData){gAskQData=extData;var type="question";if(gPopinWins[type]==null){gPopinWins[type]={win:null,props:{zIndex:51,fixedcenter:true,constraintoviewport:true,underlay:"none",close:false,visible:true,draggable:true,iframe:false,modal:true}};}var html='<div style="padding:1px;border:1px solid silver"><div id="'+type+'Popin" style="text-align:center;padding:10px 20px;background-color:#f8f8f8;"><p style="font-weight:bold;">'+question+'</p><p>';for(var i=0;i<buttons.length;i++){html+='<input style="margin:5px 10px;" type="button" name="'+buttons[i][0]+'" onclick="hidePopin(\''+type+'\');'+callbackFnName+'(\''+buttons[i][0]+'\', gAskQData)" value="'+buttons[i][1]+'"/>';}html+='</div></div>';showPopin(type,html,{});} 