var ec;

$(document).ready(function(){
  $.get("login.html",function(data){
    setTimeout("procContactInsert('"+escape(data)+"')", 400); //sets te time after loading that proContactInsert function is ran
  });
});

function procContactInsert(result){
  var e=document.createElement("div");
  $(e).attr('id','insert-contact').html(unescape(result));
  ec=e;
  $("#toggle-contact").click(function(){

    $("#toggle-contact").toggleClass("active");
	
    if($("#insert-contact").length<1){
      $(ec).css('display','none');
      $("#popdown").prepend(ec);
      $("#insert-contact a.active").click(function(){
        $("#insert-contact").slideToggle("slow",function(){
          $("#insert-contact").remove();
	  $("#toggle-contact").focus();
        });
        return false;
      }).toggleClass("open");
    }

    $("#insert-contact").slideToggle("slow",function(){
      if($("#insert-contact").css("display")=='block') $("#contact a.email").attr('tabindex',-1).focus().attr('tabindex',0);
      else $("#insert-contact").remove();	
    });

    return false;
  })
}


function loginClose() {
  $("#insert-contact").slideToggle("slow", function() {
    $("#insert-contact").remove();
  });

  return false;
}