PR={init:function(){var body_id=$("body").attr("id");switch(body_id){case"list-clips":PR.clips.init();break;case"edit-article":PR.editArticle.init();break;case"upload-browser":PR.uploader.init();break;case"media-browser":PR.mediaBrowser.init();break;case"list-posts":PR.posts.init();break;case"list-users":PR.users.init();break;case"list-feeds":PR.feeds.init();break;case"frontend-homepage":PR.home.init();break;case"article":PR.article.init();break;case"subscribe":PR.subscribe.init();break;case"frontend-faq":PR.faq.init();break;case"frontend-image":PR.image.init();break;}
if(body_id.indexOf('frontend')===0){PR.search.init();}},setConsole:function(){if(!window.console){window.console=function(){};window.console.log=function(message){};}},getHashValue:function(index){var url=document.location.hash;if(url.length===0){return false;}
var values=url.split("#/")[1];var value=values.split("/")[index];if(value!==undefined){return value;}
else{return false;}},setHash:function(hash){document.location.hash=hash;}};jQuery(document).ready(function(){PR.setConsole();PR.init();});
PR.article={init:function(){this.bindEvents();this.recalculateFileSizeTotal();},bindEvents:function(){$(".boxDownload a").click(this.toggleDownloadOverlay);$(".popupClose a").click(this.toggleDownloadOverlay);$(".fieldCheckRadio").click(this.recalculateFileSizeTotal);$("#downloadSubmit").click(this.downloadPressPack);},OVERLAY_STATE:false,toggleDownloadOverlay:function(){if(!PR.article.OVERLAY_STATE){$(".popupWrap").show();PR.article.OVERLAY_STATE=true;}
else{$(".popupWrap").hide();PR.article.OVERLAY_STATE=false;}},recalculateFileSizeTotal:function(){var values=$("#download_presspack_form").serialize();$("#file_size_total").html('<img src="/media/admin/images/loader.gif"/>');$.post("/presspack/size/"+PR.article.getArticleID()+"/",values,function(data){$("#file_size_total").html(data);});},downloadPressPack:function(){var values=$("#download_presspack_form").serialize();$.download("/presspack/download/"+PR.article.getArticleID()+"/",values,"POST");return false;},getArticleID:function(){return $("body").attr("rel");}};
jQuery.download=function(url,data,method){if(url&&data){data=typeof data=='string'?data:jQuery.param(data);var inputs='';jQuery.each(data.split('&'),function(){var pair=this.split('=');inputs+='<input type="hidden" name="'+pair[0]+'" value="'+pair[1]+'" />';});jQuery('<form action="'+url+'" method="'+(method||'post')+'">'+inputs+'</form>').appendTo('body').submit().remove();}};