function clearText(field){
   if (field.defaultValue == field.value) field.value = '';
   
}
function putBack(field){
  if (field.value=='') field.value = field.defaultValue; 
}

$(document).ready(function() {

  $('.fancy').fancyZoom({scaleImg: true, closeOnClick: true});

  current_img = 1;

  $(".img_nav_link").bind("click", function(){
    //alert( $("#right_image_tag").attr("src") );

    // get replacement source file
    img = "/assets/uploads/images/page_item/" + $(this).attr("name");
    imgLarge = "/assets/uploads/images/page_item_large/" + $(this).attr("name2");
    
    if( $(this).attr("name2") ){
      $( '#fancy_anchor' ).attr( 'href', '#image1' );
      $( '#fancy_anchor' ).removeClass("move_off")
    } else {
      $( '#fancy_anchor' ).addClass("move_off")
    }

    
    $('#image_to_change').attr( "src", imgLarge );
    
    caption = $(this).attr("caption");
    // remove all img_selected classes of all links
    $( ".img_nav_link" ).removeClass("img_selected");
    $( ".index_"+current_img ).addClass("img_unselected");

    // set the current selected navigation number ( with a square )
    $(this).addClass("img_selected");
    $(this).removeClass("img_unselected");

    // replace the image (by rewriting the "src" attribute
    $("#right_image_tag").attr("src", img );
    
    $(".image_caption .text").html(caption);

    current_img = $(this).attr("index");
    
  });

});

