<!--
// search form object that is going to hijack the pagination tags and add page anchor onto them

YAHOO.pagination = function() {

	// shortcuts
	var $E = YAHOO.util.Event;
	var $D = YAHOO.util.Dom;
	var $ = $D.get;

	return {
		init: function(){

			// media_search_reults_view
			
			// get an array of pagination top links
			var pagination_link_list = $D.getElementsByClassName('pagination_top_link','a');

			// loop through and pass into click event listener
			for(var i = 0; i< pagination_link_list.length;i++){
					$E.on(pagination_link_list[i].id, 'click',this.pagination_form)
				}	
				
			// get an array of pagination top links
			var pagination_link_list = $D.getElementsByClassName('pagination_bottom_link','a');

			// loop through and pass into click event listener
			for(var i = 0; i< pagination_link_list.length;i++){
					$E.on(pagination_link_list[i].id, 'click',this.pagination_form)
				}	
		},
		
		// define clieck event listener
		pagination_form: function (e){
			
			
			// kill normal clicking activities -  all the way to the top
			$E.stopEvent(e);

			// redirect with anchor - add in a pagination / true switch if necc. as this will prevent the search result's counter from incrementing

			// do we already have pagination/true in the string 
			if(this.href.indexOf('pagination/true')==-1){
				
				// check to see if the last character in a URL has is a / or not
				if(this.href.substring(this.href.length - 1,this.href.length)!="/"){
					this.href = this.href + "/";
				}
				
				this.href = this.href + "pagination/true";
			}
			
			if(this.href.indexOf('#search_results_top')==-1){
				
				 this.href =  this.href + "#search_results_top";
				 
			}

			window.location.href = this.href; 
		}
	};
}();

// intialise search form object on page load - run it within the scope of its parent
YAHOO.util.Event.on(window, 'load', YAHOO.pagination.init, YAHOO.pagination, true );
//-->
