/* jsfunctions.js */

var defaultSearch = "" ;

$(function() { 
  $('#gallery a').lightBox({fixedNavigation:true}); 
  $('#small_gallery a').lightBox( {fixedNavigation: false});
  $('#page_gallery a').lightBox( {fixedNavigation: true});
  $('#thumb_gallery a').lightBox( {fixedNavigation: true});
});

$(document).ready( function() {
  $("div#pagelinks ul.bulletlist").corner({
    tl: { radius: 15 },
    tr: { radius: 15 },
    bl: { radius: 15 },
    br: { radius: 15 },
    antiAlias: true,
    autoPad: false
  }) ;
    
  $("div#sidebar div.section").corner({
    tl: { radius: 0 },
    tr: { radius: 0 },
    bl: { radius: 15 },
    br: { radius: 15 },
    antiAlias: true,
    autoPad: false
  }) ;
    
  $("a#donation, ul#m_links a").click(function() {
    window.open(this.href) ;
    return false ;
  });
    
  $("a.show_more").click(function() {
    // see if we're just clicking on this one again
    var c = $(this).parent().next() ;
    if ($(c).is(":visible")) {
      // just hide it
      $(c).slideUp("fast") ;
    } else {
      // hide all of them
      $("p.post_content:visible").slideUp("fast") ;
      $(c).slideDown("slow") ;
    }
    return false ;
  }); 
    
  $("img#search").click(function() {
    var k = $("#searchkey").val() ;
    window.location.href = "/search.php?searchkey=" + k + "&searchtype=all" ;
    return false ;
  });  
  
  $("img#search").hover(
    function() { // mouseover
      $(this).css("cursor", "pointer") ;
    }, 
    function() { // mouseout
      $(this).css("cursor", "auto") ;
    }   
  );
  
  $("#searchkey").focus(function() {
    if ($(this).val() == "Site Search" || $(this).val() == "Recherche sur le site"  ) {
      defaultSearch = $(this).val() ;
      $(this).val('') ;
    }
  });
    
  $("#searchkey").blur(function() {
    if ($(this).val() == '') {
      $(this).val(defaultSearch) ;
    }
  });
    
  // set a stripe pattern on the tables
  $("table.zebra tr:nth-child(even)").addClass("stripe");

  // enable edit-in-place plugin for input boxes
  $("dd.editable span[rel='input']").editInPlace({
    url: "/members/profile.php", 
    params: "ajax=yes",
	show_buttons: true
  });
  
  // enable edit-in-place plugin
  $("span#receive_email").editInPlace({
    url: "/members/profile.php", 
    params: "ajax=yes",
    field_type: "select" , 
	select_options: "Yes, No"
  });
});
  
function doQuickLink(s) {
  var url = s.options[s.selectedIndex].value ;
  if (url != "") {
    window.location.href = url ;
  }
}
