$(document).ready(function() {
 
/*
 $(".test").click(function(e) {
   alert ('a');
   $('#depts2 option').each(function(i) {  
     //alert(i);
     $(this).attr("selected", "selected");  
     //alert($(this).val());
     });
   $('form #kish').submit();
   e.preventDefault();
   })
*/ 
 
 // in submit handle in the search form the moving from one to another
   $('.cmxform').submit(function() {
     $('#research2 option').each(function(i) {  
       //alert(i);
       $(this).attr("selected", "selected");  
       //alert($(this).val());
       });

     $('#depts2 option').each(function(i) {  
       $(this).attr("selected", "selected");  
       });
     }); 

  $(".narrow").change(function() {
  var selected = parseInt($(this).val());

  
  var lines = "";
  for (var i = 1; i <= selected; ++i) {
    //alert("show");
    $('#placeholder'+i).show();
    }
  selected++;
  for (var i = selected; i<=5; ++i) {
    //alert("hide");
    $('#placeholder'+i).hide();

    //lines = lines+i;
   /* 
    lines+="<p><label>Upload Image_"+i+": </label><input type=\"file\" name=\"image\" class=\"wide\" /></p> <p><label>Caption:</label> "+
  "<script type='text/javascript'>" +
  "var oFCKeditor = new FCKeditor( 'caption_"+i+"' ) ;"+
  "oFCKeditor.ToolbarSet = 'Basic' ;   "+
  "oFCKeditor.Width        = 550;"+
  "oFCKeditor.Height       = 175;"+
  "oFCKeditor.Config[\"CustomConfigurationsPath\"]       = \"/Biology/open_day_2010/site_config.js\" ;"+
  "oFCKeditor.Value        = '"+i+"' ;"+
  "oFCKeditor.Create() ;"+
   "<"+"/script></p>";
  alert(lines);
   */

    }
  //$("#placeholder1").appendTo(lines);
  });
  $("#newmemberbutton").click(function() {
    $("#newmembercounter").val(parseInt($("#newmembercounter").val())+1)
    //alert($("#newmembercounter").val());
    str = 'Last Name: <input type="text" name="lname_'+$("#newmembercounter").val()+'" value="" class="clearField" /><br>First Name: <input type="text" name="fname_'+$("#newmembercounter").val()+'" value="" class="clearField" /><br>\n';

    $("#newmember").append(str);
  });

  $("#newpubbutton").click(function() {
    $("#newpubcounter").val(parseInt($("#newpubcounter").val())+1)
    //alert($("#newpubcounter").val());
    str = '<p>If you add a publication, please enter it in the following format:<br> author (yr) title. journal volume, pages</p>Publication Information:<br><input type="text" name="pubname_'+$("#newpubcounter").val()+'" value="" class="wide" maxlength="750" /></p>\n<p>Because there are legal issues with linking to publications, please give the link to the publication from PubMed.<br>If the publication is in press, please do not give a link.<br>Publication Link:<br><input type="text" name="doi_'+$("#newpubcounter").val()+'" value=""  class="wide" maxlength="750" /></p>';
    $("#newpub").append(str);
  });

});


