/**** Add application wide javascripts below this point  ******/
$(document).ready(function() {
  $("#companies_block .list .image_0").eq(0).attr("src", $(".image_0").attr("rel"));
  $("#companies_block .list .image_1").eq(0).attr("src", $(".image_1").attr("rel"));
});




secondary_backgrounds = []; //global one for all background images...
primary_backgrounds = [];
event_cost = 0;
//background swapping on home page
function home_page_backgrounds(backgrounds, prefix, size){
  if(typeof(backgrounds) != undefined && backgrounds.length){
    for(var div_id in backgrounds){
      if(!size) jQuery('#'+prefix+div_id).css('background', "url('"+backgrounds[div_id]+"') no-repeat center center");
      else jQuery('#'+prefix+div_id).css('background', "url('/show_image/"+backgrounds[div_id]+"/"+size+".jpg') no-repeat center center");
    }
  }
}

/** GOOGLE MAP **/
function googlemap(){
  if(jQuery('#googlemap').length && GBrowserIsCompatible() ){
    var g_map = new google.maps.Map2(document.getElementById('googlemap'));
    g_map.enableScrollWheelZoom();
		g_map.setUIToDefault();
		var local_search = new google.search.LocalSearch();
		local_search.setSearchCompleteCallback(null, function(){		  
		  if(local_search.results[0]){
		    var resultLat = local_search.results[0].lat, resultLng = local_search.results[0].lng;
		    var latLng = new GLatLng(resultLat, resultLng);
        g_map.setCenter(latLng, 15);
        var gicon = new GIcon(G_DEFAULT_ICON);
	      var marker = new GMarker(latLng, {icon:gicon, title:jQuery('h1').text()});		      
	      GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(jQuery('#event_page .location .copy').html());
        });
        g_map.addOverlay(marker);
		  }
		});
		local_search.execute(jQuery('address.postcode').html()+', UK');
  }
}


/** DIALOG **/
function email_friend_dialog(){
  jQuery('#email_a_friend').dialog({autoOpen:false,modal:true});
  jQuery('.send_to_friend').click(function(){
    jQuery('#email_a_friend').dialog('open');
    jQuery('#email_a_friend').dialog('option', 'title', 'Send to a Friend');
    jQuery('#email_a_friend form').show();
    email_friend_ajax_send();
    return false;
  });
}
function email_friend_ajax_send(){
  jQuery('#email_a_friend form').submit(function(){
    var form_fields = jQuery('#email_a_friend form').serialize();
    jQuery.ajax({
      type:jQuery('#email_a_friend form').attr('method'),
		  url:jQuery('#email_a_friend form').attr('action') + '.ajax',
  		data: form_fields,
  		success: function(response){
  			jQuery('#email_a_friend form').html(response);
  		},
  		error:function(response){
  		  jQuery('#email_a_friend form').html(response);
  		}
    });
    return false;
  });
}

function login_warning(){
  jQuery('a[href=#login_warning]').addClass('login_dialog');
  var introcopy = '<img src="/images/forms/traffic-cone.gif" alt="warning" class="left"/><p>In order to access this exclusive content, you must be an IiE Registered User. Enter your username and password now.</p>';
  var noaccess = '<p>You do not have access to this piece of content.</p>';
  if(jQuery('#iie_login form').length){
    var login_form = '<form id="iie_login_form_modal" method="post" action="">'+jQuery('#iie_login form').html()+'</form>';
    jQuery('#login_required_dialog').html(introcopy+login_form);
  }else jQuery('#login_required_dialog').html(noaccess);
  jQuery('#login_required_dialog').dialog({autoOpen:false,modal:true, title:'Attention'});
  jQuery('a.login_dialog').click(function(){
    jQuery('#login_required_dialog').dialog('open');
    return false;
  });
}


/**** EVENT FORM ****/
function show_hide_delegates(val){
  if(val == 0) jQuery('.delegate_form').hide();
  else{
    jQuery('.delegate_form').each(function(){
      var num = parseInt(jQuery(this).attr('id').replace("delegate_", ""));
      if(num >= val) jQuery(this).hide().find('input').attr('disabled', true);
      else jQuery(this).show().find('input').removeAttr('disabled');
    });
  }
  var new_cost = ((val+1)*event_cost).toFixed(2);
  jQuery('#total_cost span em').html(new_cost);
}
function event_form(){
  if(!jQuery('#main_registrar_register_lead_contact').is(":checked")) jQuery('.delegate').hide().find('input').attr('disabled', true);
  else show_hide_delegates(parseInt(jQuery('#main_registrar_delegates').val()));

  if(jQuery('#main_registrar_register_lead_contact_table').is(":checked")) jQuery('#total_cost span em').html(event_table_cost);

  jQuery('#main_registrar_register_lead_contact').click(function(){ 
    jQuery('#delegates_intro').show(); 
    show_hide_delegates(parseInt(jQuery('#main_registrar_delegates').val()));
  });
  jQuery('#main_registrar_register_as_individual').click(function(){
    jQuery('.delegate').hide().find('input').attr('disabled', true);
    jQuery('#total_cost span em').html(event_cost);
  });
	jQuery('#main_registrar_register_lead_contact_table').click(function(){
    jQuery('.delegate').hide().find('input').attr('disabled', true);
    jQuery('#total_cost span em').html(event_table_cost);
  });
  
  jQuery('#main_registrar_delegates').change(function(){ show_hide_delegates(parseInt(jQuery(this).val())); });
}

/** ajax calendar links **/
function ajax_calendar(){
  jQuery('.cal_options .previous a, .cal_options .next a').click(function(){
    jQuery('#calendar_block').fadeTo('fast', 0.6);
    var clicked = this.href.substring(this.href.indexOf('?'));
    jQuery.ajax({
      type:'post',
      url:'/calendar_list.ajax'+clicked,
      success:function(response){
        jQuery('#calendar_block').replaceWith(response);
        ajax_calendar();
      },
      error:function(){ajax_calendar();}
    });
    return false;
  });
}

/**** ****/
jQuery(document).ready(function(){
  if(jQuery('#primary_featured_articles').length){
    jQuery('#primary_featured_articles').switcher({item:'.primary_feature', pagination:'#paginated_features', auto_rotate:false, rotate_time:15000, swap_container_class:true,speed:0});
    home_page_backgrounds(primary_backgrounds, 'primary_feature_', false);
  }
  if(jQuery('div.secondary_feature').length) home_page_backgrounds(secondary_backgrounds, 'secondary_feature_', false);
  if(jQuery('#secondary_images').length && jQuery('#secondary_images img').length > 1) jQuery('#secondary_images').switcher({item:'.image_holder', auto_rotate:true, rotate_time:5000, speed:"slow"});
  googlemap();
  
  if(jQuery('#news_archive').length) jQuery('#news_archive').slidingtree();
  if(jQuery('#email_a_friend_form').length){
    jQuery('#email_a_friend_form').hide();
    email_friend_dialog();
  }
  if(jQuery('.flickr a.gallery').length) jQuery('.flickr a.gallery').lightBox();
  if(jQuery('#secondary_images a.gallery').length) jQuery('#secondary_images a.gallery').lightBox();  
  login_warning();
  if(jQuery('#register_form').length) event_form();
  if(jQuery('#calendar_block').length) ajax_calendar();
});



var block_items;
var current_block=0;
/***** Companies Block Rotator ************/
$(document).ready(function() {
    block_items = $("#companies_block .list img").hide().filter(":eq(0)").show().add("#companies_block .list img").size();
    if(block_items > 1) setInterval(auto_block,4000);
});

function auto_block() {
    $("#companies_block .list img:eq("+current_block+")").fadeOut("slow",function(){
      $(this).hide();
      current_block = ++current_block%block_items;
      ahead_block = current_block+1;
      $("#companies_block .list img:eq("+ahead_block+")").attr("src", $("#companies_block .list img:eq("+ahead_block+")").attr("rel"));
      $("#companies_block .list img:eq("+current_block+")").fadeIn("slow");
    });
}
(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'/images/lightbox/ico-loading.gif',imageBtnPrev:'/images/lightbox/btn-prev.gif',imageBtnNext:'/images/lightbox/btn-next.gif',imageBtnClose:'/images/lightbox/btn-close.gif',imageBlank:'/images/lightbox/blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}
function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}
_set_image_to_view();}
function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}
function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}
$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}
if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}
function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}
if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}
_enable_keyboard_navigation();}
function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}
function _disable_keyboard_navigation(){$(document).unbind();}
function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}
key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}
if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}
if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}
function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}
if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}
function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}
while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);/**
  Switcher Plugin
  - swaps between 'item' passed in using fade effect
**/
(function($) {

	$.fn.slidingtree=function(options){
		return this.each(function(){			
			if(this._st) return;
			else this._st = plugin_counter;
			var params = $.extend(true, {}, $.fn.slidingtree.defaults, options);
			H[plugin_counter] = {container:this, params:params, items:[]};
			$.slidingtree.setup(plugin_counter);
			plugin_counter ++;

		});
	};
	
	//the default config vars
	$.fn.slidingtree.defaults = { after_function:false, 
	                              active_class:'active', 
	                              end_hide_check_level:"auto", 
	                              node:'li', 
	                              branch:'ul', 
	                              click_trigger:'a', 
	                              speed:'slow'
	                              };
	//the over riden stuff
	$.slidingtree = {
		hash:{}, //the hash used to store all the configs & targets
		/**
     * - loop over everything and give it the right level
     * - hide all but the default level
		 */
		setup:function(index){
		  if(H[index].params.end_hide_check_level == "auto") H[index].params.end_hide_check_level= $.slidingtree.find_depth(index, H[index].container, 0);
		  $.slidingtree.traverse(index,H[index].container, 0, H[index].params.end_hide_check_level);
		  $.slidingtree.triggers(index);
	  },
	  /**
	   * find the depth of the tree and returns the total overall depth -1 (so the leafs at the end are never manipulated by this code)
	   */
	  find_depth:function(index, branch, level){
      H[index].params.end_hide_check_level = level;
      jQ(branch).children(H[index].params.node).each(function(){        
	      jQ(this).children(H[index].params.branch).each(function(){
	        return $.slidingtree.find_depth(index,this,level+1);
	      });	        
	    });
	    return H[index].params.end_hide_check_level -1;
	  },
	  /**
	   * - Loop over the nodes (li) of the branch (ul) passed in
	   * - add node class & level counter on to each leaf thats above the level threshold 
	   *    - the level threshold is used so the end leafs at the lowest level in the tree are never hidden - ie the links to the page
	   * - if the first a it finds does not have a 'active_class' param on it then that branch is hidden 
	   * - if any of this branches(ul) nodes(li) has branchs(ul) then call this function again passing in new level 
	   */
	  traverse:function(index, branch, level, end_level){	
	    jQ(branch).children(H[index].params.node).each(function(){
	      if(!jQ(this).hasClass('node') && level <= H[index].params.end_hide_check_level) jQ(this).addClass('node').addClass('node-'+level);
	      
        if(!jQ(this).find("a:first").hasClass(H[index].params.active_class) && level <= end_level) jQ(this).children(H[index].params.branch).slideUp(H[index].params.speed);
        else jQ(this).children(H[index].params.branch).slideDown(H[index].params.speed);
        jQ(this).find("a:first").attr('rel',level); 
        
	      jQ(this).children(H[index].params.branch).each(function(){
	        return $.slidingtree.traverse(index,this, level+1, end_level);
	      });	        
	    });
	    return;
	  },
	  hide_and_show:function(index){
	    
	  },
	  triggers:function(index){
	    jQ(H[index].container).find(H[index].params.click_trigger).click(function(){
	      // this is a base level item, no sliding, just return true so the page link is followed
        if(!jQ(this).parent().hasClass('node')) return true; 
        else{             
          //find the top node in this tree;
          var current_level = jQ(this).attr('rel'), 
              current_node = jQ(this).parent();                    
          //remove all active classes                 
          jQ(H[index].container).find('.'+H[index].params.active_class).removeClass(H[index].params.active_class);
          //find the right nodes to add active class onto -- so everything above where clicked
          for(var i = current_level; i>=0; i--){
            jQ(current_node).children('a:first').addClass('active');
            if(jQ(current_node).parent().parent().hasClass('node')) current_node = jQ(current_node).parent().parent();
          }
          $.slidingtree.traverse(index,H[index].container, 0, H[index].params.end_hide_check_level+1); //plus one on this so id hides end nodes
        }
      
	      return false;
	    });
	    
	  } 
	  
	};
	var H=$.slidingtree.hash,	jQ = jQuery; ie6=$.browser.msie&&($.browser.version == "6.0"), plugin_counter=0;
})(jQuery);
/**
  Switcher Plugin
  - swaps between 'item' passed in using fade effect
**/
(function($) {

	$.fn.switcher=function(options){
		return this.each(function(){			
			if(this._sw) return; //if already a switcher return
			else this._sw = plugin_counter; //otherwise add the index
      var params = $.extend(true, {}, $.fn.switcher.defaults, options);
			H[plugin_counter] = {container:this, params:params,item_switch_countdown:false, items:[],active:false};
			$.switcher.setup(plugin_counter);
      $.switcher.setup_rotate(plugin_counter);
			if(H[plugin_counter].params.pagination) $.switcher.pagination_trigger(plugin_counter);			
			plugin_counter ++;
		});
	};
	
	//the default config vars
	$.fn.switcher.defaults = {after_function:false, auto_rotate:false, rotate_time:6000, item:'.item', pagination:false, pagination_active_class:'active' ,speed:"slow", swap_container_class:false};
	//the over riden stuff
	$.switcher = {
		hash:{}, //the hash used to store all the configs & targets
		/*
		 loop over all items in the container and add new class and also push them to the internal array - this 
		 is then used for rotate / pagination etc
		*/
		setup:function(index){
		  var counter = 0;
      jQ(H[index].container).find(H[index].params.item).each(function(){
        H[index].items.push(this);
        jQ(this).addClass('switcher').addClass('switcher_'+counter);
        if(counter>0) jQ(this).hide();
        counter++;        
      });
      H[index].active = 0;
	  },
	  setup_rotate:function(index){
	    if(H[index].params.auto_rotate && H[index].params.rotate_time){	      
	      H[index].item_switch_countdown = setTimeout("$.switcher.rotate("+index+")", H[index].params.rotate_time);
      }
	  },
	  rotate:function(index){
	    var outbound = 0;
      if(!H[index].active) H[index].active = outbound = 0;
      else outbound = H[index].active;      
      var inbound=outbound +1;     
      if(inbound > H[index].items.length-1) inbound = 0; //so doesnt rotate beyond limits!
      $.switcher.hide_show(index,outbound, inbound);
      $.switcher.setup_rotate(index);       
	  },
	  hide_show:function(index,outbound,inbound){
	    jQ(H[index].items[outbound]).fadeOut(H[index].params.speed, function(){	      
        jQ(H[index].items[inbound]).fadeIn(H[index].params.speed, function(){
          if(H[index].params.after_function) H[index].params.after_function();
        });
        if(H[index].params.swap_container_class){
          var class_name = jQ(H[index].items[inbound]).find("h2 a").attr('rel');
          jQ(H[index].container).attr('class', class_name);
        }        
        if(H[index].params.pagination){
          var target_href = '#'+jQ(H[index].items[inbound]).attr('id');
          jQ(H[index].container).find('.'+H[index].params.pagination_active_class).removeClass(H[index].params.pagination_active_class);
          jQ(H[index].container).find('a[href='+target_href+']').parent().addClass(H[index].params.pagination_active_class);
        }
        if(typeof(H[index].item_switch_countdown) != "undefined") clearTimeout(H[index].item_switch_countdown);
        $.switcher.setup_rotate(index);       
      });
      H[index].active = inbound;
	  },
	  pagination_trigger:function(index){
	    var search_for = '#'+H[index].container.id+' '+H[index].params.pagination+' a';
	    jQ(search_for).hover(function(){
	      //clear timers
	      if(typeof(H[index].item_switch_countdown) != "undefined") clearTimeout(H[index].item_switch_countdown);
	      var match_to = this.rel.replace('#', ''), inbound = 0;
        for(var i in H[index].items){
          if(jQ(H[index].items[i]).attr('id') == match_to) inbound = i;
        }
	      $.switcher.hide_show(index, H[index].active, inbound);
	      $.switcher.setup_rotate(index);
	      return false;
	    },function(){
				if(typeof(H[index].item_switch_countdown) != "undefined") clearTimeout(H[index].item_switch_countdown);
				return false;
			});
			jQ(search_for).click(function(){return false;});
	  }
	};
	var H=$.switcher.hash,	jQ = jQuery; ie6=$.browser.msie&&($.browser.version == "6.0"), plugin_counter=0;
})(jQuery);
