$(document).ready(function() {
  //Toggle accordion
  $(".accordion dt").click(function() {
    $(this)
      .next("dd").slideToggle("fast").end()
      .find(".ui-icon")
        .toggleClass("ui-icon-triangle-1-s")
        .toggleClass("ui-icon-triangle-1-e");
    return false;
  });

  //Bind dialogs
  $("#contact, #share").each(function() {
    $(this).dialog({
      autoOpen: false,
      width: 600,
      height: 430,
      resizable: false,
      title: $(this).find("h2:first").remove().text()
    });
  });

  //Open Dialog
  $(".openContact").click(function() {
    $("#contact").dialog("open");
    $(".ui-dialog").appendTo("#Form1");
    var title = $(this).parents("dd:first").prev().text();
    $("#txt_Subject").val("Applying for " + title);
    return false;
  });
  //move modals inside the form
  $(".openShare").click(function() {
    $("#share").dialog("open");
    $(".ui-dialog").appendTo("#Form1");
    var content = $(this).parent().siblings().html();
    $("#txt_BodyToFriend").val("Check out this exciting career opportunity from Auctiva at <a href='http://jobs.auctiva.com'>jobs.auctiva.com</a> :<br /><br />" + content);
    return false;
  });
});
