
 function installGallery() {    
			var gallery = $('div.sliderGallery');
			var ul = $('ul', gallery);
	
			var itemsWidth = ul.innerWidth() - gallery.outerWidth();

//alert ("onload ul:"+ul.length+" inner:"+ul.innerWidth()+" gall.outer: "+gallery.outerWidth()+"="+itemsWidth);
					///////////////////////////////////////////////////////////////////
			var itemsWidth = (itemCount*85)-250; // count*85 - 250

//			var e = $('li', gallery);
//	alert("listen to "+e.length+" l i");

		$('li', gallery).click(function() {
      doBadge(this.id);
			return (false);
		});

			$('.slider', gallery).slider({
					min: 0,
					max: itemsWidth,
					handle: '.ui-slider-handle',
					stop: function (event, ui) {
							ul.animate({'left' : ui.value * -1}, 500);
					},
					slide: function (event, ui) {
							ul.css('left', ui.value * -1);
					}
			});
		 $(".btn-left").click(function(){
			 var elValue = $('.slider', gallery).slider('option', 'value');
				 if(elValue > 0) {
						elValue = elValue - 100;
						if(elValue < 0) {
						 elValue = 0;
					}
			 $(".sliderGallery .slider").slider('value', elValue);
					$(".sliderGallery ul").animate({'left' : elValue * -1}, 500);
				 }
		});
		$(".btn-right").click(function(){
			var elValue = $('.slider', gallery).slider('option', 'value');
					 if(elValue < itemsWidth) {
							elValue = elValue + 100; 
							if(elValue > itemsWidth) {
							 elValue = itemsWidth;
						}
						$(".sliderGallery .slider").slider('value', elValue); 
						$(".sliderGallery ul").animate({'left' : elValue * -1}, 500);
					 }
		});
		$("span.end").click(function(){
			var elValue = $('.slider', gallery).slider('option', 'value');
							 elValue = itemsWidth;
						$(".sliderGallery .slider").slider('value', elValue); 
						$(".sliderGallery ul").animate({'left' : elValue * -1}, 500);
		});
		$("span.start").click(function(){
			var elValue = $('.slider', gallery).slider('option', 'value');
							 elValue = 0;
						$(".sliderGallery .slider").slider('value', elValue); 
						$(".sliderGallery ul").animate({'left' : elValue * -1}, 500);
		});
		activeBadge="b_splash";
	}
  
  // show TV badge
	function doBadge (theTitle) {
//     console.log("doBadge:"+theTitle);
    if (activeBadge==undefined) {
      activeBadge='b_splash';
    }
    var h=$('#'+activeBadge).hide();
    
    if (theTitle=="morequotes") {
      theTitle='b_splash';
    }
    activeBadge=theTitle;    
    $('#'+theTitle).show();
	}
	
// switch to a tab, and possibly get an article
  function doTab(thisTitle, theArticle, theLink) {
    if (thisTitle==undefined) {
      thisTitle="Home";
    }

    $('#'+activeTab).removeClass("selected");
    $('#'+thisTitle).addClass("selected");

    $('#t_'+thisTitle).addClass("a_show");
    $('#t_'+activeTab).addClass("t_hide");  //addClass("t_hide");  //removeClass("selected"); 
    $('#t_'+activeTab).removeClass("t_show");
    $('#t_'+thisTitle).removeClass("t_hide");
    var oldTab=activeTab;
    activeTab=thisTitle;

//console.log(activeTab+":"+theLink);
    if (activeTab=="Home" && theLink) {
       $.scrollTo("#"+theLink);
    }
    if (activeTab=="Contact" && theLink) {
       $.scrollTo("#frmRequest");
    }
    
    if (activeTab=="Seminars") {
    //  $('#frmRequest').show(); // display form
    } else {
     // $('#frmRequest').hide(); // hide form      
    }

    if (activeTab=="Articles") {
      $.get("site_nav/get_article.php", { art: theArticle }, function(data){
//        $.scrollTo("#col_promo");
        $("#t_Articles").html(data);
          $('.reconnectbook').click(function() {
            doBadge("reconnect");
            $.scrollTo("#col_promo");
            return false;
          });
      });
    }
    return (false);
  }
