function convertEntities(b){var d,a;d=function(c){if(/&[^;]+;/.test(c)){var f=document.createElement("div");f.innerHTML=c;return!f.firstChild?c:f.firstChild.nodeValue}return c};if(typeof b==="string"){return d(b)}else{if(typeof b==="object"){for(a in b){if(typeof b[a]==="string"){b[a]=d(b[a])}}}}return b};;var $j=jQuery.noConflict();var bwbpsActiveGallery=0;var displayedGalleries="";var bwbpsUploadStatus=false;var bwbpsSelectedImages;var bwbpsStopResizing=false;var bwbpsAllImport=0;$j.fn.tagName=function(){return this.get(0).tagName;}$j(document).ready(function(){$j('.bwbps_uploadform').submit(function(){$j('#bwbps_message').html('');bwbpsAjaxLoadImage(this);return false;});$j(".init_radio").attr("checked","checked");if($j('#bwbps_gen_settingsform').val()=='1'){bwbpsAddPSSettingsMassUpdateActions();}$j('.bwbps-post-cat-form').attr('multiple','multiple');});function bwbpsSaveFavorite(image_id,fav_nonce){var _data={};_data['action']='favoriteimage';_data['image_id']=image_id;_data['_wpnonce']=fav_nonce;try{$j('#ps_savemsg').show();}catch(err){}if(jQuery(".bwbps-fav-"+image_id).hasClass('bwbps-fav-0')){jQuery(".bwbps-fav-"+image_id).removeClass('bwbps-fav-0');jQuery(".bwbps-fav-"+image_id).addClass('bwbps-fav-1');}else{jQuery(".bwbps-fav-"+image_id).removeClass('bwbps-fav-1');jQuery(".bwbps-fav-"+image_id).addClass('bwbps-fav-0');}$j.ajax({type:'POST',url:bwbpsAjaxRateImage,data:_data,dataType:'json',success:function(data){bwbpsFavoriteSuccess(data,image_id);}});return false;}function bwbpsFavoriteSuccess(data,image_id){if(data==-1){alert('Security failed: nonce.');return;}if(data.status==1){if(jQuery(".bwbps-fav-"+image_id).hasClass('bwbps-fav-0')){jQuery(".bwbps-fav-"+image_id).removeClass('bwbps-fav-0');jQuery(".bwbps-fav-"+image_id).addClass('bwbps-fav-1');}}else{if(jQuery(".bwbps-fav-"+image_id).hasClass('bwbps-fav-1')){jQuery(".bwbps-fav-"+image_id).removeClass('bwbps-fav-1');jQuery(".bwbps-fav-"+image_id).addClass('bwbps-fav-0');}}}function bwbpsUserDeleteImage(image_id){var _data={};if(!confirm('Do you wish to permanently delete this image?')){return;}_data['action']='userdeletewithpost';_data['image_id']=image_id;_data['_ajax_nonce']=bwbps_upload_nonce;try{$j('#ps_savemsg').show();}catch(err){}jQuery(".bwbps_delbtn_"+image_id).after("<span style='color: red; font-size: .8em;' class='bwbps_deleting_"+image_id+"'>deleting...</span>");jQuery(".bwbps_delbtn_"+image_id).remove();$j.ajax({type:'POST',url:bwbpsAjaxUserURL,data:_data,dataType:'json',success:function(data){bwbpsUserDeleteImageSuccess(data,image_id);}});return false;}function bwbpsUserDeleteImageSuccess(data,image_id){if(data==-1){alert('Security failed: nonce.');return;}if(data.status==1){jQuery(".bwbps_deleting_"+image_id).html('deleted');}else{jQuery(".bwbps_deleting_"+image_id).html('<a href="javascript: void(0);" onclick="alert(\'Cannot delete approved images\'); return false;" title="Cannot delete approved images">unable to delete</a>');}}function bwbpsAjaxLoadImage(myForm){var form_pfx=myForm.id;form_pfx=form_pfx.replace("bwbps_uploadform","");$j('#'+form_pfx+'bwbps_imgcaption').val($j('#'+form_pfx+'bwbps_imgcaptionInput').val());$j('#'+form_pfx+'bwbps_result').html('');$j('#'+form_pfx+'bwbps_message').html('');$j('#'+form_pfx+'bwbps_previewpost').html('');$j("#"+form_pfx+"bwbps_loading").show();var options={beforeSubmit:function(){if(!bwbpsVerifyUploadRequest(form_pfx)){$j("#"+form_pfx+"bwbps_loading").hide();return false;}else{return true;}},success:function(data,statusText){bwbpsUploadSuccess(data,statusText,form_pfx);},failure:function(){alert('failed');$j("#"+form_pfx+"bwbps_loading").hide();bwbpsUploadStatus=false;},url:bwbpsAjaxUpload,iframe:true,dataType:'json'};$j(myForm).ajaxSubmit(options);return false;}$j(window).bind("load",psSetGalleryHts);function psSetGalleryHts(){if(displayedGalleries=='')return;var ps=displayedGalleries.split('|');var i=0;var icnt=ps.length;for(i=0;i<icnt;i++){if(ps[i]!=""){bwbps_equalHeight($j(".psgal_"+ps[i]));}}}function bwbpsVerifyUploadRequest(form_pfx){if(!bwbpsVerifyFileFilled(form_pfx)){$j('#'+form_pfx+'bwbps_message').html('<b>VALIDATION ERROR: Please select a file.</b>');$j('#'+form_pfx+'bwbps_submitBtn').removeAttr('disabled');$j('#'+form_pfx+'bwbps_imgcaptionInput').removeAttr('disabled');return false;}if(!bwbpsVerifyRequiredFields(form_pfx)){return false;}$j('#'+form_pfx+'bwbps_submitBtn').attr('disabled','disabled');$j('#'+form_pfx+'bwbps_imgcaptionInput').attr('disabled','disabled');$j('#'+form_pfx+'bwbps_result').html('');return true;}function bwbpsVerifyRequiredFields(form_pfx){var bFilled=true;var icnt=0;jQuery(".ps_required_"+form_pfx).each(function(index){if(!jQuery(this).val()){icnt++;jQuery(this).addClass('bwbps_red_bkg');bFilled=false;}else{jQuery(this).removeClass('bwbps_red_bkg');}});if(!bFilled){alert("There are "+icnt+" incomplete required fields.");}return bFilled;}function bwbpsVerifyFileFilled(form_pfx){if($j('#'+form_pfx+'bwbps_allownoimg').val()==1){return true;}var filetype=$j('#'+form_pfx+'bwbps_uploadform :input:radio[name=bwbps_filetype]:checked').val();var bFilled=false;switch(Number(filetype)){case 0:bFilled=$j('#'+form_pfx+'bwbps_uploadfile').val();break;case 1:bFilled=$j('#'+form_pfx+'bwbps_uploadurl').val();if(bFilled){$j('#'+form_pfx+'bwbps_uploadfile').val("");}break;case 2:bFilled=$j('#'+form_pfx+'bwbps_uploaddl').val();if(bFilled){$j('#'+form_pfx+'bwbps_uploadfile').val("");}break;case 3:bFilled=$j('#'+form_pfx+'bwbps_uploadyt').val();break;case 4:bFilled=$j('#'+form_pfx+'bwbps_uploadvid').val();break;case 5:bFilled=$j('#'+form_pfx+'bwbps_uploadfile2').val();break;case 6:bFilled=$j('#'+form_pfx+'bwbps_uploadurl2').val();if(bFilled){$j('#'+form_pfx+'bwbps_uploadfile2').val("");}break;default:bFilled=true;break;}if(bFilled){return true;}else{return false;}}function bwbpsUploadSuccess(data,statusText,form_pfx){$j("#"+form_pfx+"bwbps_loading").hide();if(bwbpsAlternateUploadFunction(data,statusText,form_pfx)){return false;}$j('#'+form_pfx+'bwbps_submitBtn').removeAttr('disabled');$j('#'+form_pfx+'bwbps_imgcaptionInput').removeAttr('disabled');bwbpsUploadStatus=true;if(statusText=='success'){if(data==-1){alert('security failure: nonce');$j('#'+form_pfx+'bwbps_message').html("<span class='error'>Upload failed due to invalid authorization.  Please reload this page and try again.</span>");if(data.special_msg){$j('#'+form_pfx+'bwbps_message').append("<p>"+unescape(data.special_msg)+"</p>");}return false;}if(data.succeed=='false'){$j('#'+form_pfx+'bwbps_message').html(data.message);if(data.special_msg){$j('#'+form_pfx+'bwbps_message').append("<p id='bwbps_special_msg'>"+unescape(data.special_msg)+"</p>");}return false;}if(data.db_saved>0){if(data.thumb_fullurl){$j('#'+form_pfx+'bwbps_result').html('<img src="'+data.thumb_fullurl+'" />');}else{$j('#'+form_pfx+'bwbps_result').html('<img src="'+bwbpsThumbsURL+data.img+'" />');}if(data.message==undefined){data.message="";}else{data.message="<br/>"+data.message;}$j('#'+form_pfx+'bwbps_message').html('<b>Upload successful!</b>'+data.message);$j('.bwbps_reset').val('');var adderdiv;if($j('#bwbps_stdgal_'+data.gallery_id).length==0){adderdiv=$j('<div></div>');adderdiv.attr('id','bwbps_galcont_'+data.gallery_id).attr('class','');$j('<h2></h2>').html('Added Images').appendTo(adderdiv);var bbtbl=$j('<table></table>');var bbtr=$j('<tr></tr>');bbtr.appendTo(bbtbl);var bbtd=$j('<td></td>');bbtd.appendTo(bbtr);var newImgUL=$j('<ul></ul>').attr('class','bwbps_gallery bwbps_custom_add').attr('id','bwbps_stdgal_'+data.gallery_id);newImgUL.appendTo(bbtd);bbtbl.appendTo(adderdiv);adderdiv.insertAfter('#bwbpsInsertBox_'+data.gallery_id);}var li=$j('<li></li>').attr('class','ps_newimage psgal_'+data.gallery_id).appendTo('#bwbps_stdgal_'+data.gallery_id);if(data.li_width>0){li.css('width',data.li_width+'%');}else{li.css('margin','15px');}if(Number(data.thumb_height)){var thumb_ht=Number(data.thumb_height)+15;}if(thumb_ht=='NaN'||thumb_ht<16){thumb_ht=125;}if($j('#bwbps_stdgal_'+data.gallery_id).hasClass('bwbps_custom_add')){li.css('height',thumb_ht+"px");}var imgdiv;if($j.browser.msie){imgdiv=$j('<div></div>').css('width',data.thumb_width);}else{imgdiv=$j('<div></div>').css('width',data.thumb_width).css('margin','auto');}var ahref;if(data.thumb_fullurl){ahref=$j('<a></a>').attr('href',data.image_fullurl).attr('rel',data.imgrel);$j('<img src="'+data.thumb_fullurl+'" />').appendTo(ahref);}else{ahref=$j('<a></a>').attr('href',bwbpsImagesURL+data.img).attr('rel',data.imgrel);$j('<img src="'+bwbpsThumbsURL+data.img+'" />').appendTo(ahref);}if(data.show_imgcaption>0){$j('<br />').appendTo(ahref);$j('<span>'+data.image_caption+'</span>').attr('class','bwbps_caption').appendTo(ahref);}ahref.appendTo(imgdiv);imgdiv.appendTo(li);bwbps_equalHeight($j('.psgal_'+data.gallery_id));li.append('&nbsp;');if(data.special_msg){var pv="";if(data.preview_id){pv="<a href='/?p="+data.preview_id+"&preview=true' target='_blank'>Preview</a>";}$j('#'+form_pfx+'bwbps_previewpost').append("<p>"+pv+unescape(data.special_msg)+"</p>");}}else{$j('#'+form_pfx+'bwbps_message').html("Image not saved: "+data.error);if(data.special_msg){$j('#'+form_pfx+'bwbps_message').append("<p>"+unescape(data.special_msg)+"</p>");}}}else{$j('#'+form_pfx+'bwbps_message').html('Unknown error!');}}function bwbpsShowPhotoUpload(gal_id,post_id,form_pfx){if(form_pfx==null){form_pfx="";}bwbpsActiveGallery=gal_id;$j('#'+form_pfx+'bwbps_galleryid').val(gal_id);$j('#'+form_pfx+'bwbps_post_id').val(post_id);$j('#'+form_pfx+"bwbps_submitBtn").removeAttr('disabled');}function bwbpsShowPhotoUploadNoThickbox(gal_id,post_id,form_pfx){bwbpsActiveGallery=gal_id;if(!form_pfx){form_pfx="";}$j('#'+form_pfx+'bwbps_galleryid').val(gal_id);$j('#'+form_pfx+'bwbps_post_id').val(post_id);$j('#'+form_pfx+'bwbps-formcont').hide();$j('#'+form_pfx+'bwbps-formcont').appendTo('#bwbpsFormSpace_'+gal_id);$j('#bwbpsFormSpace_'+gal_id).show();$j('#'+form_pfx+'bwbps-formcont').show('slow');$j('#'+form_pfx+"bwbps_submitBtn").removeAttr('disabled');}function bwbpsHideUploadForm(gal_id,form_pfx){if(!gal_id){gal_id="";}if(form_pfx==null){form_pfx="";}$j('#'+form_pfx+'bwbps-formcont').hide('slow');$j('#bwbpsFormSpace_'+gal_id).hide('slow');}function bwbpsSwitchUploadField(field_id,select_iteration,form_pfx){if(select_iteration==null){select_iteration="";}if(form_pfx==null){form_pfx="";}$j("."+form_pfx+"bwbps_uploadspans"+select_iteration).hide();$j("#"+field_id).fadeIn("slow");}function bwbpsToggleFormAlwaysVisible(){if($j("#bwbps_use_thickbox").attr('checked')){$j("#bwbps_formviz").fadeOut('slow');}else{$j("#bwbps_formviz").fadeIn('slow');}}function bwbps_equalHeight(group){tallest=0;group.each(function(){thisHeight=$j(this).height();if(thisHeight>tallest){tallest=thisHeight;}});group.height(tallest);}function bwbpsToggleDivHeight(ele_id,tog_ht){if($j("#"+ele_id).css('height')==tog_ht){$j("#"+ele_id).css('height','auto');}else{$j("#"+ele_id).css('height',tog_ht);}}function bwbpsToggleCheckboxes(chkbox_class,chk_val){$j('input:checkbox.'+chkbox_class).attr('checked',chk_val);}function bwbpsModerateImage(action,image_id,post_id){var imgid=parseInt(''+image_id);var myaction=false;var actiontext="";var postid=parseInt(''+post_id);var img_id_text=" (image id: "+imgid+")";var sendMsg=jQuery("#ps_mod_send_msg").attr('checked')?1:0;var modMsg='';var modSubject='';var confirmOn=true;switch(action){case'publishpost':myaction=action;actiontext="publish post: "+postid;break;case'remove':myaction=action;actiontext="remove this image from gallery (leaves Media Library images in tact) ";break;case'bury':myaction='delete';actiontext="delete this image (Note: will only 'remove' if more than one record uses image. Will delete images from Media Gallery if 'delete' is used. Use 'remove' to leave Media Gallery images in tact.) ";if(sendMsg&&!confirm('Is Rejection Moderation Message correct?\n\n '+jQuery("#ps_mod_reject_msg").val())){return;}else{if(sendMsg){modMsg=jQuery("#ps_mod_reject_msg").val();modSubject=jQuery("#ps_mod_msg_subject").val();}}break;case'approve':myaction=action;actiontext="approve this image ";if(sendMsg&&!confirm('Is Approve Moderation Message correct?\n\n '+jQuery("#ps_mod_approve_msg").val())){return;}else{if(sendMsg){modMsg=jQuery("#ps_mod_approve_msg").val();modSubject=jQuery("#ps_mod_msg_subject").val();}}break;case'review':myaction=action;actiontext="mark this image as reviewed ";if(sendMsg&&!confirm('Is Approve Moderation Message correct?\n\n '+jQuery("#ps_mod_approve_msg").val())){return;}else{if(sendMsg){modMsg=jQuery("#ps_mod_approve_msg").val();modSubject=jQuery("#ps_mod_msg_subject").val();}}break;case'savecaption':myaction=action;actiontext="save image data ";break;case'saveall':myaction='savecaption';actiontext="save image data ";confirmOn=false;break;}if(!myaction){alert('Invalid action.');return false;}if(confirmOn){if(!confirm('Do you want to '+actiontext+img_id_text+')?')){return false;}}var _moderate_nonce=$j("#_moderate_nonce").val();var image_caption='';var image_url="";var image_tags="";var meta_data="";var file_url="";var image_seq="";var image_geolat=0;var image_geolong=0;var image_post_id=0;if(myaction=='savecaption'){image_caption=$j('#imgcaption_'+imgid).val();image_url=$j('#imgurl_'+imgid).val();image_seq=$j('#imgseq_'+imgid).val();image_tags=$j('#imgtags_'+imgid).val();image_geolat=$j('#geolat_'+imgid).val();image_geolong=$j('#geolong_'+imgid).val();meta_data=$j('#imgmeta_'+imgid).val();file_url=$j('#fileurl_'+imgid).val();image_post_id=$j('#image_post_id_'+imgid).val();}try{$j('#ps_savemsg').show();}catch(err){}$j.ajax({type:'POST',url:bwbpsAjaxURL,data:{'action':myaction,'image_id':imgid,'_ajax_nonce':_moderate_nonce,'image_caption':image_caption,'image_url':image_url,'image_geolat':image_geolat,'image_geolong':image_geolong,'image_tags':image_tags,'meta_data':meta_data,'file_url':file_url,'seq':image_seq,'post_id':postid,'image_post_id':image_post_id,'mod_msg':modMsg,'send_msg':sendMsg,'mod_subject':modSubject},dataType:'json',success:function(data){bwbpsModerateSuccess(data,imgid);}});return false;}function bwbpsModerateSuccess(data,imgid){jQuery('.bwbps_save_flds_'+imgid).attr('src',bwbpsPhotoSmashURL+'images/disk.png');try{$j('#ps_savemsg').hide();}catch(err){}if(data==-1){alert('Failed due to security: invalid nonce');$j('#psmod_'+imgid).html("fail: security");return false;}if(data.status=='false'||data.status==0){$j('#psmod_'+imgid).html("update: fail");return false;}else{switch(data.action){case'published':$j('#psimg_pubpost'+imgid).html('published');$j('#psimg_pubpost'+imgid).addClass('ps-moderate');break;default:$j('#psmod_'+imgid).html('');$j('#psmodmsg_'+imgid).html(data.action);if(data.deleted=='deleted'){$j('#psimage_'+imgid).html('');}$j('#psimg_'+imgid).removeClass('ps-moderate');break;}return false;}}jQuery.fn.bwbpsFade=function(settings){var o=(settings&&settings.constructor==String)?{start:settings}:settings||{};var d=jQuery.bwbpsFade.defaults;var i=o['interval']||d['interval'];var a=o['attr']||d['attr'];var ts={'linear':function(s,e,t,c){return parseInt(s+(c/t)*(e-s));},'sinusoidal':function(s,e,t,c){return parseInt(s+Math.sin(((c/t)*90)*(Math.PI/180))*(e-s));},'exponential':function(s,e,t,c){return parseInt(s+(Math.pow(c/t,2))*(e-s));}};var t=(o['iterator']&&o['iterator'].constructor==Function)?o['iterator']:ts[o['iterator']]||ts[d['iterator']]||ts['linear'];if(d['iterator']&&d['iterator'].constructor==Function)t=d['iterator'];return this.each(function(){if(!this.highlighting)this.highlighting={};var e=(this.highlighting[a])?this.highlighting[a].end:jQuery.bwbpsFade.getBaseValue(this,a)||[255,255,255];var c=jQuery.bwbpsFade.getRGB(o['start']||o['colour']||o['color']||d['start']||[255,255,128]);var s=jQuery.speed(o['speed']||d['speed']);var r=o['final']||(this.highlighting[a]&&this.highlighting[a].orig)?this.highlighting[a].orig:jQuery.curCSS(this,a);if(o['end']||d['end'])r=jQuery.bwbpsFade.asRGBString(e=jQuery.bwbpsFade.getRGB(o['end']||d['end']));if(typeof o['final']!='undefined')r=o['final'];if(this.highlighting[a]&&this.highlighting[a].timer)window.clearInterval(this.highlighting[a].timer);this.highlighting[a]={steps:((s.duration)/i),interval:i,currentStep:0,start:c,end:e,orig:r,attr:a};jQuery.bwbpsFade(this,a,o['complete'],t);});};jQuery.bwbpsFade=function(e,a,o,t){e.highlighting[a].timer=window.setInterval(function(){var newR=t(e.highlighting[a].start[0],e.highlighting[a].end[0],e.highlighting[a].steps,e.highlighting[a].currentStep);var newG=t(e.highlighting[a].start[1],e.highlighting[a].end[1],e.highlighting[a].steps,e.highlighting[a].currentStep);var newB=t(e.highlighting[a].start[2],e.highlighting[a].end[2],e.highlighting[a].steps,e.highlighting[a].currentStep);jQuery(e).css(a,jQuery.bwbpsFade.asRGBString([newR,newG,newB]));if(e.highlighting[a].currentStep++>=e.highlighting[a].steps){jQuery(e).css(a,e.highlighting[a].orig||'');window.clearInterval(e.highlighting[a].timer);e.highlighting[a]=null;if(o&&o.constructor==Function)o.call(e);}},e.highlighting[a].interval);};jQuery.bwbpsFade.defaults={start:[255,255,128],interval:50,speed:400,attr:'backgroundColor'};jQuery.bwbpsFade.getRGB=function(c,d){var result;if(c&&c.constructor==Array&&c.length==3)return c;if(result=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];else if(result=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];else if(result=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt("0x"+result[1]),parseInt("0x"+result[2]),parseInt("0x"+result[3])];else if(result=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt("0x"+result[1]+result[1]),parseInt("0x"+result[2]+result[2]),parseInt("0x"+result[3]+result[3])];elsereturn jQuery.bwbpsFade.checkColorName(c)||d||null;};jQuery.bwbpsFade.asRGBString=function(a){return"rgb("+a.join(",")+")";};jQuery.bwbpsFade.getBaseValue=function(e,a,b){var s,t;b=b||false;t=a=a||jQuery.bwbpsFade.defaults['attr'];do{s=jQuery(e).css(t||'backgroundColor');if((s!=''&&s!='transparent')||(e.tagName.toLowerCase()=="body")||(!b&&e.highlighting&&e.highlighting[a]&&e.highlighting[a].end))break;t=false;}while(e=e.parentNode);if(!b&&e.highlighting&&e.highlighting[a]&&e.highlighting[a].end)s=e.highlighting[a].end;if(s==undefined||s==''||s=='transparent')s=[255,255,255];return jQuery.bwbpsFade.getRGB(s);};jQuery.bwbpsFade.checkColorName=function(c){if(!c)return null;switch(c.replace(/^\s*|\s*$/g,'').toLowerCase()){case'aqua':return[0,255,255];case'black':return[0,0,0];case'blue':return[0,0,255];case'fuchsia':return[255,0,255];case'gray':return[128,128,128];case'green':return[0,128,0];case'lime':return[0,255,0];case'maroon':return[128,0,0];case'navy':return[0,0,128];case'olive':return[128,128,0];case'purple':return[128,0,128];case'red':return[255,0,0];case'silver':return[192,192,192];case'teal':return[0,128,128];case'white':return[255,255,255];case'yellow':return[255,255,0];}};;jQuery.fn.psvoting=function(url,options){if(url==null){return;}url=bwbpsAjaxRateImage+"?action=voteimage&"+url;var settings={url:url,increment:1,maxvalue:5,curvalue:0,uponly:0,rating_cnt:0};if(options){jQuery.extend(settings,options);};var container=jQuery(this);var startitle="";jQuery.extend(container,{url:settings.url});var innerbox=jQuery('<div></div>');container.empty().append(innerbox);var votetotal;var votinglinks;var voteinfo;if(!settings.rating_position){innerbox.addClass("bwbps-vote-data");var allowrate=settings.allow_rating?'bwbps-star':'bwbps-star bwbps-norate';votetotal=jQuery('<div class="bwbps-vote-total">'+settings.curvalue+'</div>');voteinfo=jQuery('<div class="bwbps-vote-info" style="display:none;"># votes: '+settings.rating_cnt+'</div>');innerbox.append(votetotal);votinglinks=jQuery('<div class="bwbps-vote-links"></div>');innerbox.append(votinglinks);}else{votetotal=jQuery('<span class="bwbps-vote-total">['+settings.curvalue+']</span>');voteinfo=jQuery('<div class="bwbps-vote-info"># votes: '+settings.rating_cnt+'</div>');votinglinks=jQuery('<span></span>');innerbox.append(votinglinks);innerbox.append(votetotal);}innerbox.append(voteinfo);var voteupbutton;if(!settings.uponly){voteupbutton='<img src="'+bwbpsPhotoSmashURL+'images/thumb_up.png" alt="vote up" />';}else{voteupbutton='Vote';}var upvote=jQuery('<a href="#up" title="Vote up"></a>').html(voteupbutton);upvote.click(function(){votetotal.empty();votetotal.addClass("bwbps-vote-small");votetotal.html('saving...');jQuery.post(container.url,{"rating":1},function(data){votetotal.addClass("bwbps-vote-small");votetotal.empty().html(data);});return false;});votinglinks.append(upvote);if(!settings.uponly){votinglinks.append("&nbsp;");var downvote=jQuery('<a href="#up" title="Vote down"><img src="'+bwbpsPhotoSmashURL+'images/thumb_down.png" alt="vote down" /></a>');downvote.click(function(){votetotal.empty();votetotal.addClass("bwbps-vote-small");votetotal.html('saving...');jQuery.post(container.url,{"rating":-1},function(data){votetotal.addClass("bwbps-vote-small");votetotal.empty().html(data);});return false;});votinglinks.append(downvote);}if(!settings.rating_position){container.mouseover(function(){container.addClass('bwbps-voting-hover').end();container.removeClass('bwbps-voting-bkg').end();voteinfo.show();}).mouseout(function(){container.addClass('bwbps-voting-bkg').end();container.removeClass('bwbps-voting-hover').end();voteinfo.hide();});}}jQuery.fn.psrating=function(url,options){if(url==null)return;url=bwbpsAjaxRateImage+"?action=rateimage&"+url;var settings={url:url,increment:1,curvalue:0};if(options){jQuery.extend(settings,options);};jQuery.extend(settings,{cancel:(settings.maxvalue>1)?true:false});var container=jQuery(this);var startitle="";jQuery.extend(container,{averageRating:settings.curvalue,url:settings.url});settings.increment=(settings.increment<.75)?.5:1;var innerbox=$j('<div class="bwbps-rating"></div>');var allowrate=settings.allow_rating?'bwbps-star':'bwbps-star bwbps-norate';container.empty().append(innerbox);var s=0;for(var i=0;i<=settings.maxvalue;i++){if(i==0){if(settings.cancel==true){var div='';innerbox.empty().append(div);}}else{startitle=settings.allow_rating?"Give it "+i+"/"+settings.maxvalue:"Login required to rate.";var $div=$j('<div class="'+allowrate+'"></div>').append('<a href="#'+i+'" title="'+startitle+'">'+i+'</a>').appendTo(innerbox);if(settings.increment==.5){if(s%2){$div.addClass('bwbps-star-left');}else{$div.addClass('bwbps-star-right');}}}i=i-1+settings.increment;s++;}if(!settings.rating_position){innerbox.addClass(' bwbps-rating-container');var infobox=$j('<div class="bwbps-rating-infobox">'+settings.avg_rating+' ('+settings.rating_cnt+' votes)</div>').appendTo(innerbox).css('display','none').addClass('bwbps-rating-info');var infoclear=$j('<a></a>').click(function(){container.css('display','none');}).appendTo(infobox).attr('title','hide rating');infoclear.append($j('<img>').attr('src',bwbpsPhotoSmashURL+"css/images/cancel-12.png").addClass('bwbps-rating-clearimg'));innerbox.mouseover(function(){innerbox.addClass('bwbps-rating-hover').end();infobox.show();}).mouseout(function(){var relatedTarget=event.relatedTarget?event.relatedTarget:event.toElement;innerbox.removeClass('bwbps-rating-hover').end();infobox.hide();});}else{var infobox=$j('<p>'+settings.avg_rating+' ('+settings.rating_cnt+' votes)</p>').css('clear','both').appendTo(innerbox);}var stars=jQuery(innerbox).children('.bwbps-star');var cancel=jQuery(innerbox).children('.cancel');if(settings.allow_rating){stars.mouseover(function(){event.drain();event.fill(this);}).mouseout(function(){event.drain();event.reset();}).focus(function(){event.drain();event.fill(this);}).blur(function(){event.drain();event.reset();});stars.click(function(){if(settings.cancel==true){settings.curvalue=(stars.index(this)*settings.increment)+settings.increment;jQuery.post(container.url,{"rating":jQuery(this).children('a')[0].href.split('#')[1]},function(data){infobox.empty().html(data).append(infoclear);});return false;}else if(settings.maxvalue==1){settings.curvalue=(settings.curvalue==0)?1:0;$j(this).toggleClass('bwbps-on');jQuery.post(container.url,{"rating":jQuery(this).children('a')[0].href.split('#')[1]});return false;}return true;});}else{stars.click(function(){alert('Login is required to rate.');});}if(cancel){cancel.mouseover(function(){event.drain();jQuery(this).addClass('on');}).mouseout(function(){event.reset();jQuery(this).removeClass('on');}).focus(function(){event.drain();jQuery(this).addClass('on');}).blur(function(){event.reset();jQuery(this).removeClass('on');});cancel.click(function(){event.drain();settings.curvalue=0;jQuery.post(container.url,{"rating":jQuery(this).children('a')[0].href.split('#')[1]});return false;});}var event={fill:function(el){var index=stars.index(el)+1;stars.children('a').css('width','100%').end().slice(0,index).addClass('bwbps-hover').end();},drain:function(){stars.filter('.bwbps-on').removeClass('bwbps-on').end().filter('.bwbps-hover').removeClass('bwbps-hover').end();},reset:function(){stars.slice(0,settings.curvalue/settings.increment).addClass('bwbps-on').end();}};event.reset();return(this);};function bwbpsToggleRatings(gal_id){if(gal_id){$j('.bwbps-rating-gal-'+gal_id).toggle();}};function sack(file){this.xmlhttp=null;this.resetData=function(){this.method="POST";this.queryStringSeparator="?";this.argumentSeparator="&";this.URLString="";this.encodeURIString=true;this.execute=false;this.element=null;this.elementObj=null;this.requestFile=file;this.vars=new Object();this.responseStatus=new Array(2)};this.resetFunctions=function(){this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onError=function(){};this.onFail=function(){}};this.reset=function(){this.resetFunctions();this.resetData()};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e1){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e2){this.xmlhttp=null}}if(!this.xmlhttp){if(typeof XMLHttpRequest!="undefined"){this.xmlhttp=new XMLHttpRequest()}else{this.failed=true}}};this.setVar=function(name,value){this.vars[name]=Array(value,false)};this.encVar=function(name,value,returnvars){if(true==returnvars){return Array(encodeURIComponent(name),encodeURIComponent(value))}else{this.vars[encodeURIComponent(name)]=Array(encodeURIComponent(value),true)}};this.processURLString=function(string,encode){encoded=encodeURIComponent(this.argumentSeparator);regexp=new RegExp(this.argumentSeparator+"|"+encoded);varArray=string.split(regexp);for(i=0;i<varArray.length;i++){urlVars=varArray[i].split("=");if(true==encode){this.encVar(urlVars[0],urlVars[1])}else{this.setVar(urlVars[0],urlVars[1])}}};this.createURLString=function(urlstring){if(this.encodeURIString&&this.URLString.length){this.processURLString(this.URLString,true)}if(urlstring){if(this.URLString.length){this.URLString+=this.argumentSeparator+urlstring}else{this.URLString=urlstring}}this.setVar("rndval",new Date().getTime());urlstringtemp=new Array();for(key in this.vars){if(false==this.vars[key][1]&&true==this.encodeURIString){encoded=this.encVar(key,this.vars[key][0],true);delete this.vars[key];this.vars[encoded[0]]=Array(encoded[1],true);key=encoded[0]}urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0]}if(urlstring){this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator)}else{this.URLString+=urlstringtemp.join(this.argumentSeparator)}};this.runResponse=function(){eval(this.response)};this.runAJAX=function(urlstring){if(this.failed){this.onFail()}else{this.createURLString(urlstring);if(this.element){this.elementObj=document.getElementById(this.element)}if(this.xmlhttp){var self=this;if(this.method=="GET"){totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString;this.xmlhttp.open(this.method,totalurlstring,true)}else{this.xmlhttp.open(this.method,this.requestFile,true);try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(e){}}this.xmlhttp.onreadystatechange=function(){switch(self.xmlhttp.readyState){case 1:self.onLoading();break;case 2:self.onLoaded();break;case 3:self.onInteractive();break;case 4:self.response=self.xmlhttp.responseText;self.responseXML=self.xmlhttp.responseXML;self.responseStatus[0]=self.xmlhttp.status;self.responseStatus[1]=self.xmlhttp.statusText;if(self.execute){self.runResponse()}if(self.elementObj){elemNodeName=self.elementObj.nodeName;elemNodeName.toLowerCase();if(elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"){self.elementObj.value=self.response}else{self.elementObj.innerHTML=self.response}}if(self.responseStatus[0]=="200"){self.onCompletion()}else{self.onError()}self.URLString="";break}};this.xmlhttp.send(this.URLString)}}};this.reset();this.createAJAX()};
