$(document).ready(function(){
  
  //$('#content_text a').each(function(){
  //  $(this).attr('target','_blank');
  //});
  
  $('#content_text h1').each(function(){
    
    first = "";
    fields = $(this).html().split(" ");
    total = fields.length;
    
    last = fields[(total-1)];
    
    //$total = count($title);
    //$last = $title[($total-1)];
    for (t=0; t<(total-1); t++){
                    first += fields[t] + " ";
    }
    
        
    $(this).html('<span class="title_first">'+first+'</span><span class="title_last">'+last+'</span>');
    
  });
  
  
//  $(".thumb_box img").live("click", function(){
//      
//      id = $(this).attr('val');
//      alert(id);
//      $.ajax({
//	type: "POST",
//	url: "/galleries/show_image/"+id,
//	//data: "name=John&location=Boston",
//	success: function(msg){
//	  $(".gallery_content").html(msg);
//	  
//	}
//    });
  //
  //    
  //});

  jQuery("#carousel").jcarousel({
        scroll: 3,
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });

    
    
    $("#breadcrumbs li:contains('Static Pages')").remove();
	
});

function changeImage(id){
   //id = $(this).attr('val');
     // alert(id);
      $.ajax({
	type: "POST",
	url: "/galleries/show_image/"+id,
	//data: "name=John&location=Boston",
	beforeSend: function(){
	   $(".gallery_content").html("<center><img src='/img/loading.gif' /></center>");
	},
	success: function(msg){
	  $(".gallery_content").html(msg);
	  
	}
    });
  
}

function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
	var go = 0;
	var number = jQuery.jcarousel.intval(jQuery(this).text());
	go = ((number * 3) - 3) + 1;
	carousel.scroll(go);
        return false;
    });
    //
    //jQuery('.jcarousel-scroll select').bind('change', function() {
    //    carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
    //    return false;
    //});

    jQuery('#mycarousel-next').bind('click', function() {	
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};


