jQuery.extend({ImpromptuDefaults:{prefix:'jqi',buttons:{Ok:true},loaded:function(){},submit:function(){return true;},callback:function(){},opacity:0.6,zIndex:3000,overlayspeed:'slow',promptspeed:'fast',show:'show',focus:0,useiframe:false},SetImpromptuDefaults:function(o){jQuery.ImpromptuDefaults=jQuery.extend({},jQuery.ImpromptuDefaults,o);},prompt:function(m,o){o=jQuery.extend({},jQuery.ImpromptuDefaults,o);var ie6=(jQuery.browser.msie&&jQuery.browser.version<7);var b=jQuery(document.body);var w=jQuery(window);var msgbox='<div class="'+o.prefix+'box" id="'+o.prefix+'box">';if(o.useiframe&&((jQuery.browser.msie&&jQuery('object, applet').length>0)||ie6))
msgbox+='<iframe src="javascript:;" class="'+o.prefix+'fade" id="'+o.prefix+'fade"></iframe>';else{if(ie6)$('select').css('visibility','hidden');msgbox+='<div class="'+o.prefix+'fade" id="'+o.prefix+'fade"></div>';}
msgbox+='<div class="'+o.prefix+'" id="'+o.prefix+'"><div class="'+o.prefix+'container"><div class="'+o.prefix+'message">'+m+'</div><div class="'+o.prefix+'buttons" id="'+o.prefix+'buttons">';jQuery.each(o.buttons,function(k,v){msgbox+='<button name="'+o.prefix+'button'+k+'" id="'+o.prefix+'button'+k+'" value="'+v+'">'+k+'</button>'});msgbox+='</div></div></div></div>';var jqib=b.append(msgbox).children('#'+o.prefix+'box');var jqi=jqib.children('#'+o.prefix);var jqif=jqib.children('#'+o.prefix+'fade');var getWindowScrollOffset=function(){return(document.documentElement.scrollTop||document.body.scrollTop)+'px';};var getWindowSize=function(){var size={width:window.innerWidth||(window.document.documentElement.clientWidth||window.document.body.clientWidth),height:window.innerHeight||(window.document.documentElement.clientHeight||window.document.body.clientHeight)};return size;};var ie6scroll=function(){jqib.css({top:getWindowScrollOffset()});};var flashPrompt=function(){var i=0;jqib.addClass(o.prefix+'warning');var intervalid=setInterval(function(){jqib.toggleClass(o.prefix+'warning');if(i++>1){clearInterval(intervalid);jqib.removeClass(o.prefix+'warning');}},100);};var escapeKeyClosePrompt=function(e){var kC=(window.event)?event.keyCode:e.keyCode;var Esc=(window.event)?27:e.DOM_VK_ESCAPE;if(kC==Esc)removePrompt();};var positionPrompt=function(){var wsize=getWindowSize();jqib.css({position:(ie6)?"absolute":"fixed",height:wsize.height,width:"100%",top:(ie6)?getWindowScrollOffset():0,left:0,right:0,bottom:0});jqif.css({position:"absolute",height:wsize.height,width:"100%",top:0,left:0,right:0,bottom:0});jqi.css({position:"absolute",top:"100px",left:"50%",marginLeft:((((jqi.css("paddingLeft").split("px")[0]*1)+jqi.width())/2)*-1)});};var stylePrompt=function(){jqif.css({zIndex:o.zIndex,display:"none",opacity:o.opacity});jqi.css({zIndex:o.zIndex+1,display:"none"});}
var removePrompt=function(callCallback,clicked,msg){jqi.remove();if(ie6)b.unbind('scroll',ie6scroll);w.unbind('resize',positionPrompt);jqif.fadeOut(o.overlayspeed,function(){jqif.unbind('click',flashPrompt);jqif.remove();if(callCallback)o.callback(clicked,msg);jqib.unbind('keypress',escapeKeyClosePrompt);jqib.remove();if(ie6&&!o.useiframe)$('select').css('visibility','visible');});}
positionPrompt();stylePrompt();jQuery('#'+o.prefix+'buttons').children('button').click(function(){var msg=jqi.children('.'+o.prefix+'container').children('.'+o.prefix+'message');var clicked=o.buttons[jQuery(this).text()];if(o.submit(clicked,msg))
removePrompt(true,clicked,msg);});if(ie6)w.scroll(ie6scroll);jqif.click(flashPrompt);w.resize(positionPrompt);jqib.keypress(escapeKeyClosePrompt);jqi.find('.'+o.prefix+'close').click(removePrompt);jqif.fadeIn(o.overlayspeed);jqi[o.show](o.promptspeed,o.loaded);jqi.find('#'+o.prefix+'buttons button:eq('+o.focus+')').focus();return jqib;}});function checkLengthForText(c,t,b,n){thecount=document.getElementById(c);thetext=document.getElementById(t);thebutton=document.getElementById(b);thenum=n;var available_characters=thenum-thetext.value.length;thecount.value=available_characters;if(available_characters<0){thebutton.disabled=true;thecount.style.color="#EB3F1D";thetext.style.color="#AA412C";}
else{thebutton.disabled=false;thetext.style.color="#222";thecount.style.color="#9C9686";}}
function checkLengthForTitle(objId){obj=document.getElementById(objId);var available_characters=50-obj.value.length;if(available_characters<0){obj.className="editready editable too-much";obj.value=obj.value.substring(0,50);}
else{obj.className="editready editable";}}
function whyFlagCallBackForm(v,m){var item_id=m.children('#item_id').val();var myReason=m.children('#reason').val();var myFormId='flag'+item_id;var myReasonId='reason_flag'+item_id;if(v=='true'){document.getElementById(myReasonId).value=myReason;document.getElementById(myFormId).submit();return true;}
else{return false;}}
function why_flag(owner,item_id,filename){var txt="<p>Reason for flagging (optional):</p><br /> \
           <input type=\"text\" id=\"reason\" name=\"myname\" value=\"\" /></p><br/> \
		   <p>"+owner+" will be notified their item was flagged<br />(But don’t worry, flagging is anonymous, so "+owner+" won’t know who flagged this.)</p> \
           <input type=\"hidden\" id=\"item_id\" value=\""+item_id+"\"";var answer=$.prompt(txt,{show:'fadeIn',promptspeed:'fast',overlayspeed:'fast',callback:whyFlagCallBackForm,buttons:{Flag:'true',Cancel:'false'}});}
function whyBanCallBackForm(v,m){var item_id=m.children('#item_id').val();var myReason=m.children('#reason').val();var myFormId='ban'+item_id;var myReasonId='reason_ban'+item_id;if(v=='true'){document.getElementById(myReasonId).value=myReason;document.getElementById(myFormId).submit();return true;}
else{return false;}}
function why_ban(owner,item_id,filename){var txt="Reason for banning (optional): <br /> \
           <input type=\"text\" id=\"reason\" name=\"myname\" value=\"\" /> \
		   <p>(Don’t worry, banning is anonymous, so "+owner+" won’t know who banned this.)</p> \
           <input type=\"hidden\" id=\"item_id\" value=\""+item_id+"\"";var answer=$.prompt(txt,{show:'fadeIn',promptspeed:'fast',overlayspeed:'fast',callback:whyBanCallBackForm,buttons:{Ban:'true',Cancel:'false'}});}
(function($){$.fn.jqm=function(o){var p={overlay:50,overlayClass:'jqmOverlay',closeClass:'jqmClose',trigger:'.jqModal',ajax:F,ajaxText:'',target:F,modal:F,toTop:F,onShow:F,onHide:F,onLoad:F};return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};if(p.trigger)$(this).jqmAddTrigger(p.trigger);});};$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};$.fn.jqmShow=function(t){return this.each(function(){$.jqm.open(this._jqm,t);});};$.fn.jqmHide=function(t){return this.each(function(){$.jqm.close(this._jqm,t)});};$.jqm={hash:{},open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index'))),z=(z>0)?z:3000,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);if(c.modal){if(!A[0])L('bind');A.push(s);}
else if(c.overlay>0)h.w.jqmAddClose(o);else o=F;h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in{Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}
if(c.ajax){var r=c.target||h.w,u=c.ajax,r=(typeof r=='string')?$(r,h.w):$(r),u=(u.substr(0,1)=='@')?$(t).attr(u.substring(1)):u;r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
else if(cc)h.w.jqmAddClose($(cc,h.w));if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);(c.onShow)?c.onShow(h):h.w.show();e(h);return F;},close:function(s){var h=H[s];if(!h.a)return F;h.a=F;if(A[0]){A.pop();if(!A[0])L('unbind');}
if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();}return F;},params:{}};var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version=="6.0"),F=false,i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i);f(h);},f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return!r;},hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function(){if(!this[c]){this[c]=[];$(this).click(function(){for(var i in{jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};})(jQuery);var IEPNGFix=window.IEPNGFix||{};IEPNGFix.tileBG=function(elm,pngSrc,ready){var data=this.data[elm.uniqueID],elmW=Math.max(elm.clientWidth,elm.scrollWidth),elmH=Math.max(elm.clientHeight,elm.scrollHeight),bgX=elm.currentStyle.backgroundPositionX,bgY=elm.currentStyle.backgroundPositionY,bgR=elm.currentStyle.backgroundRepeat;if(!data.tiles){data.tiles={elm:elm,src:'',cache:[],img:new Image(),old:{}};}
var tiles=data.tiles,pngW=tiles.img.width,pngH=tiles.img.height;if(pngSrc){if(!ready&&pngSrc!=tiles.src){tiles.img.onload=function(){this.onload=null;IEPNGFix.tileBG(elm,pngSrc,1);};return tiles.img.src=pngSrc;}}else{if(tiles.src)ready=1;pngW=pngH=0;}
tiles.src=pngSrc;if(!ready&&elmW==tiles.old.w&&elmH==tiles.old.h&&bgX==tiles.old.x&&bgY==tiles.old.y&&bgR==tiles.old.r){return;}
var pos={top:'0%',left:'0%',center:'50%',bottom:'100%',right:'100%'},x,y,pc;x=pos[bgX]||bgX;y=pos[bgY]||bgY;if(pc=x.match(/(\d+)%/)){x=Math.round((elmW-pngW)*(parseInt(pc[1])/100));}
if(pc=y.match(/(\d+)%/)){y=Math.round((elmH-pngH)*(parseInt(pc[1])/100));}
x=parseInt(x);y=parseInt(y);var repeatX={'repeat':1,'repeat-x':1}[bgR],repeatY={'repeat':1,'repeat-y':1}[bgR];if(repeatX){x%=pngW;if(x>0)x-=pngW;}
if(repeatY){y%=pngH;if(y>0)y-=pngH;}
this.hook.enabled=0;if(!({relative:1,absolute:1}[elm.currentStyle.position])){elm.style.position='relative';}
var count=0,xPos,maxX=repeatX?elmW:x+0.1,yPos,maxY=repeatY?elmH:y+0.1,d,s,isNew;if(pngW&&pngH){for(xPos=x;xPos<maxX;xPos+=pngW){for(yPos=y;yPos<maxY;yPos+=pngH){isNew=0;if(!tiles.cache[count]){tiles.cache[count]=document.createElement('div');isNew=1;}
var clipR=(xPos+pngW>elmW?elmW-xPos:pngW),clipB=(yPos+pngH>elmH?elmH-yPos:pngH);d=tiles.cache[count];s=d.style;s.behavior='none';s.left=xPos+'px';s.top=yPos+'px';s.width=clipR+'px';s.height=clipB+'px';s.clip='rect('+
(yPos<0?0-yPos:0)+'px,'+
clipR+'px,'+
clipB+'px,'+
(xPos<0?0-xPos:0)+'px)';s.display='block';if(isNew){s.position='absolute';s.zIndex=-999;if(elm.firstChild){elm.insertBefore(d,elm.firstChild);}else{elm.appendChild(d);}}
this.fix(d,pngSrc,0);count++;}}}
while(count<tiles.cache.length){this.fix(tiles.cache[count],'',0);tiles.cache[count++].style.display='none';}
this.hook.enabled=1;tiles.old={w:elmW,h:elmH,x:bgX,y:bgY,r:bgR};};IEPNGFix.update=function(){for(var i in IEPNGFix.data){var t=IEPNGFix.data[i].tiles;if(t&&t.elm&&t.src){IEPNGFix.tileBG(t.elm,t.src);}}};IEPNGFix.update.timer=0;if(window.attachEvent&&!window.opera){window.attachEvent('onresize',function(){clearTimeout(IEPNGFix.update.timer);IEPNGFix.update.timer=setTimeout(IEPNGFix.update,100);});}
function swapClass(objId, newClass) {obj= document.getElementById(objId);obj.className= newClass;}