
function addFormField() {
	var id = document.getElementById("id").value;
	$("#divTxt").append("<p id='row" + id + "'><label for='txt"+id+"' class='hide error'>Format error in address</label><input type='text' class='text required email' size='20' name='aliases[]' id='txt" + id + "'>&nbsp;&nbsp<a href='#' onClick='removeFormField(\"#row" + id + "\"); return false;'><img src='./images/cross.png' /></a></p>");
	
	id = (id - 1) + 2;
	document.getElementById("id").value = id;
}

function removeFormField(id) {
	$(id).remove();
}
$(document).ready(function(){

   $(".closePanel").hide();
 /*  
   $(".editForm").toggle(function(){
       $("#modify").slideDown("slow");
   },function(){
       $("#modify").slideUp("slow");
   
   });
*/
  $(".editReg").click(function(){
    if('#modify:hidden'){
      $('#modify').slideDown("slow");
	  $('.openPanel').hide();
	  $(".closePanel").fadeIn("slow");
	}
	 $("#modify").load('try.php',{'user': $(this).attr("id"),'type':'reg'});
  });
 
  $('.openPanel').click(function(){
     $("#modify").slideDown("slow");
     $(".openPanel").hide();
	 $(".closePanel").fadeIn("slow");
	
  });
  
   $('.closePanel').click(function(){
     $("#modify").slideUp("slow");
     $(".closePanel").hide();
	 $(".openPanel").fadeIn("slow");
  });
   
   $(".editAlias").click(function(){
    if('#modify:hidden'){
      $('#modify').slideDown("slow");
	  $('.openPanel').hide();
	  $(".closePanel").fadeIn("slow");
	  
	}
	 $("#modify").load('try.php',{'aliasname': $(this).attr("id"),'type':'alias'});
  });
  
/*	  */
  $('a[rel]').click(function(){
      
   }).ajaxStart(function(){
       $("#myOverlay").fadeIn();  
   }).ajaxStop(function(){
       $("#myOverlay").fadeOut();
	   
   });
  
  $('body').click(function(event) {
     if ($(event.target).is('#rem')) {
      
	  var $curr = $(event.target);
	  var $ptag = $(event.target).attr("class");
      $curr = $curr.prev();
      $curr.remove();
	  $("p."+$ptag).remove();
	  $(event.target).remove();
    }
	if($(event.target).is('a.clearForm')){
		$("#modify").load('try.php',{'type':'clear'});
	
	}
	if($(event.target).is("#submitUser")){
		 $("#addUserForm2").validate({
		  });
	}
	if($(event.target).is("#submitAlias")){
		 $("#addAliasForm").validate({
		 });
	}
	if($(event.target).is('#fancy_close')){
		location.reload(); 
	
	}
   });
  
     $("a.overlay").fancybox({
		 
			'frameWidth':680,
			'frameHeight':570,
			
			});
    
	 $("a.test").fancybox({
		 
			'frameWidth':250,
			'frameHeight':225
			});
	 
   $("#addUserForm").validate({
	
	});
	
   $("#addAliasForm").validate({
	
   });
   $("#addAliasForm2").validate({
	
   });
   $("#editForm").validate({
	
	});
     $(".Users tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
   $(".Users tr:even").addClass("alt");

});


      

	  




