AjaxRemove={}
AjaxRemove.ConfirmBox=function()
{
   this.div=document.createElement("div");
   this.div.className="AlertBox";
   var title=document.createElement("h3");
   title.appendChild(document.createTextNode("האם אתה בטוח?"));
   var ok=document.createElement("div")
   ok.className="OKButton HoverHidden";
   ok.appendChild(document.createTextNode("כן"));
   var cancel=document.createElement("div")
   cancel.className="CancelButton HoverHidden";
   cancel.appendChild(document.createTextNode("לא"));
   this.div.appendChild(title);
   this.div.appendChild(ok);
   this.div.appendChild(cancel);
   this.ok=ok;
   this.cancel=cancel;
   return this;
}
AjaxRemove.attach=function(anchor)
{
   if (anchor.has_ajaxRemove)
     return;
   anchor.has_ajaxRemove=1;
   anchor.url=anchor.href;
   anchor.href="#";
   anchor.onmouseup=function()
   {
     var confirmBox=AjaxRemove.ConfirmBox();
     confirmBox.ok.row=this.parentNode.parentNode;
     confirmBox.ok.href=this.url;
     confirmBox.ok.root=confirmBox.div
     confirmBox.ok.onclick=function()
     {
       var req=getXMLHttpRequest();                              
       req.open("GET",this.href,true);                                    
       req.onreadystatechange = function()                                    
       {                                    
         if(req.readyState==4)                                    
         {                                    
           if(req.status==200)                                    
           {                                    
             if(req.responseText=="1")
	     {
	       confirmBox.ok.row.parentNode.removeChild(confirmBox.ok.row);
	     }
             else
	     {
	       alert(req.responseText);
	     }
	   }
	 }
       }
       req.send('');
       document.body.removeChild(this.root);
     }     
     confirmBox.cancel.root=confirmBox.div
     confirmBox.cancel.onclick=function()
     {
       document.body.removeChild(this.root);
     }
     document.body.appendChild(confirmBox.div);
     return false;
   }
}
AjaxRemove.init=function()
{
  var reg=new RegExp("ajax_remove");
  for(var i=0;i<document.links.length;++i)
  {   
    lnk=document.links.item(i);
    if (reg.test(lnk.className) && lnk.parentNode.tagName.toLowerCase()=="td")
      AjaxRemove.attach(lnk);
  }
}                       

AjaxRemove.init();

