Drupal.Views={};Drupal.behaviors.viewsTabs=function(context){$('#views-tabset:not(.views-processed)').addClass('views-processed').each(function(){new Drupal.Views.Tabs($(this),{selectedClass:'active'})});$('a.views-remove-link').addClass('views-processed').click(function(){var id=$(this).attr('id').replace('views-remove-link-','');$('#views-row-'+id).hide();$('#views-removed-'+id).attr('checked',true);return false});$('a.display-remove-link').addClass('display-processed').click(function(){var id=$(this).attr('id').replace('display-remove-link-','');$('#display-row-'+id).hide();$('#display-removed-'+id).attr('checked',true);return false})};Drupal.behaviors.viewsHoverlinks=function(){if($.browser.msie){$("div.view:not(.views-hover-processed)").addClass('views-hover-processed').hover(function(){$('div.views-hide',this).addClass("views-hide-hover");return true},function(){$('div.views-hide',this).removeClass("views-hide-hover");return true});$("div.views-admin-links:not(.views-hover-processed)").addClass('views-hover-processed').hover(function(){$(this).addClass("views-admin-links-hover");return true},function(){$(this).removeClass("views-admin-links-hover");return true})}};Drupal.Views.parseQueryString=function(query){var args={},pos=query.indexOf('?');if(pos!=-1)query=query.substring(pos+1);var pairs=query.split('&');for(var i in pairs)if(typeof(pairs[i])=='string'){var pair=pairs[i].split('=');if(pair[0]!='q'&&pair[1])args[decodeURIComponent(pair[0].replace(/\+/g,' '))]=decodeURIComponent(pair[1].replace(/\+/g,' '))};return args};Drupal.Views.parseViewArgs=function(href,viewPath){var returnObj={},path=Drupal.Views.getPath(href);if(viewPath&&path.substring(0,viewPath.length+1)==viewPath+'/'){var args=decodeURIComponent(path.substring(viewPath.length+1,path.length));returnObj.view_args=args;returnObj.view_path=path};return returnObj};Drupal.Views.pathPortion=function(href){var protocol=window.location.protocol;if(href.substring(0,protocol.length)==protocol)href=href.substring(href.indexOf('/',protocol.length+2));return href};Drupal.Views.getPath=function(href){href=Drupal.Views.pathPortion(href);href=href.substring(Drupal.settings.basePath.length,href.length);if(href.substring(0,3)=='?q=')href=href.substring(3,href.length);var chars=['#','?','&'];for(i in chars)if(href.indexOf(chars[i])>-1)href=href.substr(0,href.indexOf(chars[i]));return href};
Drupal.Views.Ajax=Drupal.Views.Ajax||{};Drupal.Views.Ajax.ajaxViewResponse=function(target,response){if(response.debug)alert(response.debug);var $view=$(target);if(response.status&&response.display){var $newView=$(response.display);$view.replaceWith($newView);$view=$newView;Drupal.attachBehaviors($view.parent())};if(response.messages)$view.find('.views-messages').remove().end().prepend(response.messages)};Drupal.behaviors.ViewsAjaxView=function(){if(Drupal.settings&&Drupal.settings.views&&Drupal.settings.views.ajaxViews){var ajax_path=Drupal.settings.views.ajax_path;if(ajax_path.constructor.toString().indexOf("Array")!=-1)ajax_path=ajax_path[0];$.each(Drupal.settings.views.ajaxViews,function(i,settings){if(settings.view_dom_id){var view='.view-dom-id-'+settings.view_dom_id;if(!$(view).size())view='.view-id-'+settings.view_name+'.view-display-id-'+settings.view_display_id};$('form#views-exposed-form-'+settings.view_name.replace(/_/g,'-')+'-'+settings.view_display_id.replace(/_/g,'-')).filter(':not(.views-processed)').each(function(){$('input[name=q]',this).remove();var form=this;$('input[type=submit], button',this).click(function(){$(this).after('<span class="views-throbbing">&nbsp</span>');form.clk=this});$.each(settings,function(key,setting){$(form).append('<input type="hidden" name="'+key+'" value="'+setting+'"/>')})}).addClass('views-processed').submit(function(){var object=this;$(this).ajaxSubmit({url:ajax_path,type:'GET',success:function(response){if(response.__callbacks){$.each(response.__callbacks,function(i,callback){eval(callback)(view,response)});$('.views-throbbing',object).remove()}},error:function(xhr){Drupal.Views.Ajax.handleErrors(xhr,ajax_path);$('.views-throbbing',object).remove()},dataType:'json'});return false});$(view).filter(':not(.views-processed)').filter(function(){return!$(this).parents('.view').size()}).each(function(){var target=this;$(this).addClass('views-processed').find('ul.pager > li > a, th.views-field a, .attachment .views-summary a').each(function(){var viewData={js:1};$.extend(viewData,Drupal.Views.parseQueryString($(this).attr('href')),Drupal.Views.parseViewArgs($(this).attr('href'),settings.view_base_path),settings);$(this).click(function(){$.extend(viewData,Drupal.Views.parseViewArgs($(this).attr('href'),settings.view_base_path));$(this).addClass('views-throbbing');$.ajax({url:ajax_path,type:'GET',data:viewData,success:function(response){$(this).removeClass('views-throbbing');var offset=$(target).offset(),scrollTarget=target;while($(scrollTarget).scrollTop()==0&&$(scrollTarget).parent())scrollTarget=$(scrollTarget).parent();if(offset.top-10<$(scrollTarget).scrollTop())$(scrollTarget).animate({scrollTop:(offset.top-10)},500);if(response.__callbacks)$.each(response.__callbacks,function(i,callback){eval(callback)(target,response)})},error:function(xhr){$(this).removeClass('views-throbbing');Drupal.Views.Ajax.handleErrors(xhr,ajax_path)},dataType:'json'});return false})})})})}};

