function TWizy(name)
{
  this.Name=name;
  this.Div=$("[id='"+name+"']");
  


  this.InitalizeParse();
}

TWizy.prototype.InitalizeParse=function()
{
  this.Div.find("h1").after(function(){return '<p class="h1">'+this.innerHTML+'</p>';}).remove();  
  this.Div.find("h2").after(function(){return '<p class="h2">'+this.innerHTML+'</p>';}).remove();  
}

TWizy.prototype.Activate=function()
{
  this.Div[0].contentEditable=true;
  this.Div.css("outline",Redactor.WizyWindow_Outline);
  this.Div.focus(function(){Redactor.ActivWizy=this.id;});
  this.Div.keyup(function(){Redactor.onChange();});
  this.Div.mouseover(function(){$(this).css("outline",Redactor.WizyWindow_OutlineActive);});
  this.Div.mouseout(function(){$(this).css("outline",Redactor.WizyWindow_Outline);});
  this.onChange();
}

TWizy.prototype.Deactivate=function()
{
  this.Div[0].contentEditable=false;
  this.Div.find('p').unbind();
  this.Div.unbind();
}

TWizy.prototype.onChange=function()
{
  //alert('1');
  this.Div.find("span.Apple-style-span").after(function(){return this.innerHTML;}).remove();
  
  
  this.Div.find("p").css('backgroundImage' , '');
  this.Div.find("p").mouseover(function(){$(this).css('backgroundImage' , 'url(/pic/module/redact/p.over.png)');});
  this.Div.find("p").mouseout(function(){$(this).css('backgroundImage' , '');});
  
  this.Div.find("img").css('cursor','pointer');
  this.Div.find("img").mouseover(function(){$(this).css('outline','2px groove #f2cb80');});
  this.Div.find("img").mouseout(function(){$(this).css('outline','none');});
  
  this.Div.find("div").mouseover(function(){$(this).css('outline','2px groove #f2cb80');});
  this.Div.find("div").mouseout(function(){$(this).css('outline','none');});
}

TWizy.prototype.FormatBlock=function(t1,t2,t2class)
{//alert('1');
  //this.Div.find("p").remove();
  if(t2class!=''){
  this.Div.find(t1).after(function(){return '<'+t2+' class="'+t2class+'">'+this.innerHTML+'</'+t2+'>';}).remove();
  }else{
  this.Div.find(t1).after(function(){return '<'+t2+'>'+this.innerHTML+'</'+t2+'>';}).remove();
  }
  this.Div.find("font").after(function(){return this.innerHTML;}).remove();
  this.onChange();
  $('#save')[0].disabled=false;
}
