// All source files have their checksums specified. Any change made to the source files will result in automatic lock of the application and will make it impossible to access data.


function zmien1przycisk()
{
  document.getElementById("zmieniaczstylu").innerHTML = '<div class="change-template" onclick="templates.toggle();zmien2przycisk();"><a onfocus="this.blur();" href="javascript:templates.toggle();"></a></div>';             
};
function zmien2przycisk()
{
  document.getElementById("zmieniaczstylu").innerHTML = '<div class="cancel-change" onclick="templates.toggle();zmien1przycisk();"><a onfocus="this.blur();" href="javascript:templates.toggle();"></a></div>';             
};
function zmien3przycisk()
{
  document.getElementById("stylzmiany").style = 'cancel-change';             
//    document.getElementById("stylzmiany").style.background = 'url(../images/cancel_change.gif)';             
};

function zmien4przycisk()
{
// alert(document.getElementById("zmieniaczs").style.background);
 if ( document.getElementById("zmieniaczs").style.background == 'transparent url(../images/cancel_change.gif) repeat scroll 0% 0%' || document.getElementById("zmieniaczs").style.background=='url(../images/cancel_change.gif)')
    {
    document.getElementById("zmieniaczs").style.background='url(../images/change-design.gif)';	
	$("#templates").slideUp();	
    }
else
   {
    document.getElementById("zmieniaczs").style.background='url(../images/cancel_change.gif)';
	$("#templates").slideDown();	
   };
};

function CloseEditor(ne)
   {

		if (document.mymemory.opened_editor.value == 'H') {
			CancelHeader();
		};
		if (document.mymemory.opened_editor.value == 'I') {
			CancelIntro();
		};
		if (document.mymemory.opened_editor.value == 'A') {
			CancelAbout();
		};
		if (document.mymemory.opened_editor.value == 'A1') {
			CancelArticle(1);
		};
		if (document.mymemory.opened_editor.value == 'A2') {
			CancelArticle(2);
		};
		if (document.mymemory.opened_editor.value == 'A3') {
			CancelArticle(3);
		};
		if (document.mymemory.opened_editor.value == 'C') {
			CancelContact();
		};
		if (document.mymemory.opened_editor.value == 'R') {
			CancelCopyright();
		};
   };
function CloseEditor2()
   {
   document.mymemory2.warning1.value = '';
   
   if (document.mymemory.header_status.value=='O') {SaveHeader(); };
   if (document.mymemory.intro_status.value=='O') {SaveIntro(); };
   if (document.mymemory.article1_status.value=='O') {SaveArticle(1); };   	
   if (document.mymemory.article2_status.value=='O') {SaveArticle(2); };
   if (document.mymemory.article3_status.value=='O') {SaveArticle(3); };
   if (document.mymemory.about_status.value=='O') {SaveAbout(); };   
   if (document.mymemory.contact_status.value=='O') {SaveContact(); };            
   if (document.mymemory.copyright_status.value=='O') {SaveCopyright(); };   
   };

function CloseEditor3()
   {
   if (document.mymemory.header_status.value=='O') {CancelHeader(); };
   if (document.mymemory.intro_status.value=='O') {CancelIntro(); };
   if (document.mymemory.article1_status.value=='O') {CancelArticle(1); };   	
   if (document.mymemory.article2_status.value=='O') {CancelArticle(2); };
   if (document.mymemory.article3_status.value=='O') {CancelArticle(3); };
   if (document.mymemory.about_status.value=='O') {CancelAbout(); };   
   if (document.mymemory.contact_status.value=='O') {CancelContact(); };            
   if (document.mymemory.copyright_status.value=='O') {CancelCopyright(); };   
   };


//-----    obsluga naglowka   ----------------------------------------------------------------------------------
function EditHeader()
   {    
   if (document.mymemory2.warning1.value != '') {
   	if (!confirm(document.mymemory2.warning1.value)) 
   		return;
   };
   CloseEditor2();	
   document.mymemory.opened_editor.value="H";
   advAJAX.post
      ({
       url: "includes/edit-header.php",
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
	   header_note: document.mymemory.m_header_note.value,
       header_h1: document.mymemory.m_header_h1.value,
	   header_date: document.mymemory.m_header_date.value,
	   header_welcome: document.mymemory.m_header_welcome.value,			  			  			  
	   header_img: document.mymemory.m_header_img.value,
	   id_newsletter: document.mymemory.id_newsletter.value,
	   b_header: document.mymemory.b_header.value,
       template_name: document.mymemory.template_name.value,
	   m_status: document.mymemory.m_status.value,
       onError : function(obj) { alert("Error: " + obj.status); },	   
	   onInitialization: function(obj) { 
		  document.getElementById("header-loader").style.display = 'block';	    
	      prompter("T","opening header...");
		   },
	   onSuccess : function(obj) 
	      { 		  
		  if (document.mymemory.m_status.value=='S')
		     {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";
			 };
		  document.getElementById("header-section").innerHTML = obj.responseText;             
		  },
	   onFinalization : function(obj)
	      {
		  prompter("T","i'm ready :)");	 
		  document.mymemory.m_status.value='';
		  if (document.editor.temp_id_newsletter)
		     {
		     document.mymemory.id_newsletter.value=document.editor.temp_id_newsletter.value;
			 };
             updatelist(document.mymemory.myemail.value);			 				 
	      document.mymemory.header_status.value='O';
          if (document.mymemory.opened_editor.value!="H")
		     {
			 CancelHeader();	
			 };			 
		  document.getElementById("header-loader").style.display = 'none';	    			 
		  }	  
      });
   };                  
function CancelHeader()
	{       
   	if (document.mymemory.opened_editor.value=='H')
      	{
	  	document.mymemory.opened_editor.value='';	
	  	};
   	id_newsletter=document.mymemory.id_newsletter.value;
   	advAJAX.post
    	({
	   	url: "includes/trigger-header.php",
	   	id_newsletter: document.mymemory.id_newsletter.value,
       	ac: "cancel",			  
       	timeout : 1000,
       	retryCount: 5,
       	retryDelay: 1000,
       	onError : function(obj) { alert("Error: " + obj.status); },
	   	onInitialization: function(obj) { 
  		document.getElementById("header-loader").style.display = 'block';	    			 
	    prompter("T", "canceling header..."); },
       	onSuccess : function(obj) 
	    	{ 
//			if (document.mymemory.m_header_note.value=="Y" || document.mymemory.m_header_note.value=="true" || document.mymemory.m_header_note.value=="on") 
//				{
//				document.getElementById("header_note").style.display='block';
//				}
//			else		
//				{
//				document.getElementById("header_note").style.display='none';
//				};			  
		  	document.getElementById("message").innerHTML = "header canceled";		  
		  	document.getElementById("header-section").innerHTML = obj.responseText;   
			if (document.getElementById("header_h1"))
	          	document.getElementById("header_h1").innerHTML = document.mymemory.m_header_h1.value;
			if (document.getElementById("header_date"))
	          	document.getElementById("header_date").innerHTML = document.mymemory.m_header_date.value;          
			if (document.getElementById("header_welcome"))
          		document.getElementById("header_welcome").innerHTML = document.mymemory.m_header_welcome.value;          
		  	if (document.images["header_img"])
		    	{
			 	afteruploadshow(document.mymemory.m_header_img.value,"header_img");  	 
			 	};
		  	},
		onFinalization : function(obj)
	    	{
		  	document.mymemory.header_status.value='C';
		  	prompter("T", "i'm ready :)");		  
		  	document.getElementById("header-loader").style.display = 'none';	    			 		  
		  	}		  
		});                  
   };
function SaveHeader()
   {  
   if (document.mymemory.opened_editor.value=='H')
      {
      document.mymemory.opened_editor.value='';	
	  };
if (document.editor.e_header_h1)	  
   document.mymemory.m_header_h1.value=document.editor.e_header_h1.value;
if (document.editor.e_header_welcome)
   document.mymemory.m_header_welcome.value=document.editor.e_header_welcome.value;
if (document.editor.e_header_date)
   document.mymemory.m_header_date.value=document.editor.e_header_date.value;
if (document.editor.e_header_note)
   document.mymemory.m_header_note.value=document.editor.e_header_note.checked;

   if (document.editor.e_header_img)
      { document.mymemory.m_header_img.value=document.editor.e_header_img.value; };  
   advAJAX.post
      ({
	   url: "includes/trigger-header.php",
       header_h1: document.mymemory.m_header_h1.value,
	   header_date: document.mymemory.m_header_date.value,
	   header_welcome: document.mymemory.m_header_welcome.value,			  			  			  
	   header_img: document.mymemory.m_header_img.value,
	   header_note: document.mymemory.m_header_note.value,	   
	   id_newsletter: document.mymemory.id_newsletter.value,
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { 
	      		  document.getElementById("header-loader").style.display = 'block';	    			 
		prompter("T", "saving header ...."); 		
		},
       onSuccess : function(obj) 
	      { 		  
		  document.getElementById("header-section").innerHTML = obj.responseText;                  		  
		  },
	   onFinalization : function(obj)
	      {

			if (document.mymemory.m_header_img.value!='' && document.mymemory.m_contact_www2.value!='')
				{
				if (document.getElementById("header_imgl")) {
					zostawiam = $("#header_imgl").html();
					$("#header_imgl").replaceWith(zostawiam);
				};	
			    $("#header_imgs").wrapInner($("<a id='header_imgl' href='http://"+document.mymemory.m_contact_www2.value+"'></a>"));	
				}
			else
				{
				zostawiam=$("#header_imgl").html();
  				$("#header_imgl").replaceWith(zostawiam);	
				};
		  	
			
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.header_status.value='C';
		  document.getElementById("header-loader").style.display = 'none';	    			 		  
		  }		  		  
      });                  
   }
// ----------------------------------------------------------------------------------------------------------------------------------
function EditIntro()
   {     	
      if (document.mymemory2.warning1.value != '') {
   	if (!confirm(document.mymemory2.warning1.value)) 
   		return;
   };
	
   CloseEditor2();	
   document.mymemory.opened_editor.value="I";
   advAJAX.post
      ({
       url: "includes/edit-intro.php",
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       intro_h1: document.mymemory.m_intro_h1.value,
	   intro_text: document.mymemory.m_intro_text.value,
	   intro_img: document.mymemory.m_intro_img.value,			  			  			  			  
	   intro_rmore: document.mymemory.m_intro_rmore.value,			  			  			  			  	   
	   id_newsletter: document.mymemory.id_newsletter.value,	   
	   b_intro: document.mymemory.b_intro.value,
	   m_status: document.mymemory.m_status.value,	   
       template_name: document.mymemory.template_name.value,	   
	   onInitialization: function(obj) { 
		  document.getElementById("intro-loader").style.display = 'block';	    
	      prompter("T", "opening intro editor ..."); 
		  },
	   onSuccess : function(obj) 
	      { 
		  document.getElementById("intro-section").innerHTML = obj.responseText;                  		  
		  if (document.mymemory.m_status.value=='S')
		     {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";			 	

			 };
		  },
	   onFinalization : function(obj)
	      {
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.m_status.value='';
		  if (document.editor.temp_id_newsletter)
		     {
		     document.mymemory.id_newsletter.value=document.editor.temp_id_newsletter.value;
			 };
             updatelist(document.mymemory.myemail.value);			 				 
		  document.mymemory.intro_status.value='O';		  
          if (document.mymemory.opened_editor.value!="I")
		     {
			 CancelIntro();	
			 };
		  document.getElementById("intro-loader").style.display = 'none';	    			 
		  }	  
      });
   };                  
function CancelIntro()
   {  
   if (document.mymemory.opened_editor.value=='I')
      {
      document.mymemory.opened_editor.value='';	
	  };
   id_newsletter=document.mymemory.id_newsletter.value;
   advAJAX.post
      ({
	   url: "includes/trigger-intro.php",
	   id_newsletter: document.mymemory.id_newsletter.value,
       ac: "cancel",			  
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) {
  	    document.getElementById("intro-loader").style.display = 'block';	    
	    prompter("T", "intro canceling..."); 
		},	   
       onSuccess : function(obj) 
	      { 		  
		  document.getElementById("intro-section").innerHTML = obj.responseText;             
          document.getElementById("intro_h1").innerHTML = document.mymemory.m_intro_h1.value;

		  text=document.mymemory.m_intro_text.value;
		  text2=text.replace(/\r\n|\r|\n/g, '<br \/>');
          document.getElementById("intro_text").innerHTML = text2;		           

		  if (document.links["intro_rmore"].href)
          document.links["intro_rmore"].href=document.mymemory.m_intro_rmore.value; 
          if (document.images["intro_img"])
             {
 			 afteruploadshow(document.mymemory.m_intro_img.value,"intro_img");  	  
	         };
		  },
	   onFinalization : function(obj)
	      {
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.intro_status.value='C';
		  document.getElementById("intro-loader").style.display = 'none';	    
		  }		  
      });                  
   }
function SaveIntro()
   {  
   if (document.mymemory.opened_editor.value=='I')
      {
      document.mymemory.opened_editor.value='';	
	  };   
   document.mymemory.m_intro_h1.value=document.editor.e_intro_h1.value;
   document.mymemory.m_intro_text.value=document.editor.e_intro_text.value;
   document.mymemory.m_intro_rmore.value=document.editor.e_intro_rmore.value;
   if (document.editor.e_intro_img) 
      { 
      document.mymemory.m_intro_img.value=document.editor.e_intro_img.value; 
      };
   advAJAX.post
      ({
	   url: "includes/trigger-intro.php",
	   intro_h1: document.editor.e_intro_h1.value,
	   intro_text: document.editor.e_intro_text.value,
	   intro_rmore: document.editor.e_intro_rmore.value,			  
  	   intro_img: document.mymemory.m_intro_img.value,			  			  			  			  
	   id_newsletter: document.mymemory.id_newsletter.value,
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
      onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { 
   	    document.getElementById("intro-loader").style.display = 'block';	    
		prompter("T", "intro saving ...."); },
      onSuccess : function(obj) 
		 { 
		 document.getElementById("intro-section").innerHTML = obj.responseText;                  		  
	     },
	   onFinalization : function(obj)
	      {
		  document.mymemory.intro_status.value='C';
		  prompter("T", "i'm ready :)");		  
  	    document.getElementById("intro-loader").style.display = 'none';	    
		  }		  		 		 
      });                  
   };		
// ----------------------------------------------------------------------------------------------------------------------------
function EditArticle(nart)
   {  
   if (document.mymemory2.warning1.value != '') {
   	if (!confirm(document.mymemory2.warning1.value)) 
   		return;
   };
   
   CloseEditor2();	
   document.mymemory.opened_editor.value="A"+nart;   
   costam=nart;  
   if (costam==1)
      {
      advAJAX.post
         ({
          url: "includes/edit-article.php",
          article_title: document.mymemory.m_article1_title.value,
	      article_subtitle: document.mymemory.m_article1_subtitle.value,
	      article_img: document.mymemory.m_article1_img.value,			  			  			  			  
	      article_rmore: document.mymemory.m_article1_rmore.value,			  			  			  			  	   
	      article_text: document.mymemory.m_article1_text.value,			  			  			  			  	   	   
	      id_newsletter: document.mymemory.id_newsletter.value,	   
	      b_article: document.mymemory.b_article1.value,
	      m_status: document.mymemory.m_status.value,		  
          template_name: document.mymemory.template_name.value,
       	  timeout : 1000,
       	  retryCount: 5,
       	  retryDelay: 1000,		  	   
          nr_article: costam,
	      onInitialization: function(obj){ 
   	  	    document.getElementById("article1-loader").style.display = 'block';	    
			 prompter("T", "opening article 1 editor ....");
			 },
	      onSuccess : function(obj) 
	         { 
		     document.getElementById("article01-section").innerHTML = obj.responseText;                  		  
   		     if (document.mymemory.m_status.value=='S')
		        {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";					

			    };
		     },
	   	onFinalization : function(obj)
	      {
		  document.mymemory.m_status.value='';
		  if (document.editor.temp_id_newsletter)
		     {
		     document.mymemory.id_newsletter.value=document.editor.temp_id_newsletter.value;
			 };
             updatelist(document.mymemory.myemail.value);			 				 
		  prompter("T", "i'm ready");		  	
		  document.mymemory.article1_status.value='O';			 
   	  	    document.getElementById("article1-loader").style.display = 'none';	    			 		  
          if (document.mymemory.opened_editor.value!="A1")
		     {
			 CancelArticle(1);	
			 };
		  }	  			 
         });
      };         	                    
   if (costam==2)
      {
      advAJAX.post
         ({
          url: "includes/edit-article.php",
          article_title: document.mymemory.m_article2_title.value,
	      article_subtitle: document.mymemory.m_article2_subtitle.value,
	      article_img: document.mymemory.m_article2_img.value,			  			  			  			  
	      article_rmore: document.mymemory.m_article2_rmore.value,			  			  			  			  	   
	      article_text: document.mymemory.m_article2_text.value,			  			  			  			  	   	   
	      id_newsletter: document.mymemory.id_newsletter.value,	   
	      b_article: document.mymemory.b_article2.value,
	      m_status: document.mymemory.m_status.value,		  
          template_name: document.mymemory.template_name.value,	   
          nr_article: costam,
	      timeout : 1000,
    	  retryCount: 5,
       	  retryDelay: 1000,		  
	      onInitialization: function(obj){ 
		   document.getElementById("article2-loader").style.display = 'block';	    
		   prompter("T", "opening article 2 editor ....");  },
	      onSuccess : function(obj) 
	         { 
		     document.getElementById("article02-section").innerHTML = obj.responseText;                  		  
		     },
	   	onFinalization : function(obj)
	      {
		  document.mymemory.m_status.value='';
		  if (document.editor.temp_id_newsletter)
		     {
		     document.mymemory.id_newsletter.value=document.editor.temp_id_newsletter.value;
             if (document.mymemory.m_status.value=='S')
		        {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";					
                updatelist(document.mymemory.myemail.value);			 	
			    };

			 };		  	
		  prompter("T", "i'm ready");		  	
		  document.mymemory.article2_status.value='O';			 
   	  	    document.getElementById("article2-loader").style.display = 'none';	    			 		  
          if (document.mymemory.opened_editor.value!="A2")
		     {
			 CancelArticle(2);	
			 };
		  }	  
			 
         });
      };         	                    

   if (costam==3)
      {
      advAJAX.post
         ({
          url: "includes/edit-article.php",
          article_title: document.mymemory.m_article3_title.value,
	      article_subtitle: document.mymemory.m_article3_subtitle.value,
	      article_img: document.mymemory.m_article3_img.value,			  			  			  			  
	      article_rmore: document.mymemory.m_article3_rmore.value,			  			  			  			  	   
	      article_text: document.mymemory.m_article3_text.value,			  			  			  			  	   	   
	      id_newsletter: document.mymemory.id_newsletter.value,	   
	      b_article: document.mymemory.b_article3.value,		  
          template_name: document.mymemory.template_name.value,
	      timeout : 1000,
    	  retryCount: 5,
       	  retryDelay: 1000,		  	   
          nr_article: costam,
	      m_status: document.mymemory.m_status.value,
		  onInitialization: function(obj)
	         {
   	  	    document.getElementById("article3-loader").style.display = 'block';	    
		     prompter("T", "opening article 3 editor ....");             		    
		     },
	      onSuccess : function(obj) 
	         { 
		     document.getElementById("article03-section").innerHTML = obj.responseText;
		  if (document.mymemory.m_status.value=='S')
		     {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";			 	
             updatelist(document.mymemory.myemail.value);			 	
			 };
			                   		  
		     },
	   	onFinalization : function(obj)
	      {
		  document.mymemory.m_status.value='';
		  if (document.editor.temp_id_newsletter)
		     {
		     document.mymemory.id_newsletter.value=document.editor.temp_id_newsletter.value;
			 };		  	
		  prompter("T", "i'm ready");		  	
		  document.mymemory.article3_status.value='O';			 
   	  	    document.getElementById("article3-loader").style.display = 'none';	    			 		  
          if (document.mymemory.opened_editor.value!="A3")
		     {
			 CancelArticle(3);	
			 };		  	     		  
		  }	  			 
         });
      };         	                    
   };
function CancelArticle(nart)
   {     
   if (document.mymemory.opened_editor.value=='A'+nart)
      {
      document.mymemory.opened_editor.value='';	
	  };   
   id_newsletter=document.mymemory.id_newsletter.value;
   advAJAX.post
      ({
	   url: "includes/trigger-article.php",
	   id_newsletter: document.mymemory.id_newsletter.value,
	   nr_article: nart,
       ac: "cancel",			  
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization : function(obj)
	      {
		  prompter("T", "canceling article "+nart+" ...");		  		
		  },	  
       onSuccess : function(obj) 
	      { 
          if (nart==1)  
             {
  		     document.getElementById("article01-section").innerHTML = obj.responseText;             
             document.getElementById("article1_title").innerHTML = document.mymemory.m_article1_title.value;
			 if (document.getElementById("article1_subtitle"))
             document.getElementById("article1_subtitle").innerHTML = document.mymemory.m_article1_subtitle.value;          

		  text=document.mymemory.m_article1_text.value;
		  text2=text.replace(/\r\n|\r|\n/g, '<br \/>');
          document.getElementById("article1_text").innerHTML = text2;		           
			 if (document.links["article1_rmore"])	
             document.links["article1_rmore"].href=document.mymemory.m_article1_rmore.value; 
 			 afteruploadshow(document.mymemory.m_article1_img.value,"article1_img"); 
	         }
          if (nart==2)  
             {
  		     document.getElementById("article02-section").innerHTML = obj.responseText;             
             document.getElementById("article2_title").innerHTML = document.mymemory.m_article2_title.value;
			 if (document.getElementById("article2_subtitle"))
             document.getElementById("article2_subtitle").innerHTML = document.mymemory.m_article2_subtitle.value;          
          

		  text=document.mymemory.m_article2_text.value;
		  text2=text.replace(/\r\n|\r|\n/g, '<br \/>');
          document.getElementById("article2_text").innerHTML = text2;		           

			 if (document.links["article2_rmore"])	
             document.links["article2_rmore"].href=document.mymemory.m_article2_rmore.value;
			 afteruploadshow(document.mymemory.m_article2_img.value,"article2_img"); 
	         }
          if (nart==3)  
             {
  		     document.getElementById("article03-section").innerHTML = obj.responseText;             
             document.getElementById("article3_title").innerHTML = document.mymemory.m_article3_title.value;
			 if (document.getElementById("article3_subtitle"))
             document.getElementById("article3_subtitle").innerHTML = document.mymemory.m_article3_subtitle.value;          

		  text=document.mymemory.m_article3_text.value;
		  text2=text.replace(/\r\n|\r|\n/g, '<br \/>');
          document.getElementById("article3_text").innerHTML = text2;		           

			 if (document.links["article3_rmore"])	          
             document.links["article3_rmore"].href=document.mymemory.m_article3_rmore.value; 
			 afteruploadshow(document.mymemory.m_article3_img.value,"article3_img"); 
	         }
		  },
       onFinalization : function(obj)
	      {
		  prompter("T", "i'm ready");		  	
          if (nart==1)  { 
		   document.mymemory.article1_status.value='C';
    	    document.getElementById("article1-loader").style.display = 'none';	    
		   };
          if (nart==2)  { 
		   document.mymemory.article2_status.value='C';
		     	    document.getElementById("article2-loader").style.display = 'none';	    
		   };
          if (nart==3)  { 
		   document.mymemory.article3_status.value='C';
  	    document.getElementById("article3-loader").style.display = 'none';	    
		   };		  		  
		  }		  		  
      });                  
   };
function SaveArticle(nart)
   {
   if (document.mymemory.opened_editor.value=='A'+nart)
      {
      document.mymemory.opened_editor.value='';	
	  };   
   if (nart==1)
      {  
      document.mymemory.m_article1_title.value=document.editor.e_article_title.value;
	  if (document.editor.e_article_subtitle)
         document.mymemory.m_article1_subtitle.value=document.editor.e_article_subtitle.value;
      document.mymemory.m_article1_text.value=document.editor.e_article_text.value;
	  if (document.editor.e_article_img)
      	document.mymemory.m_article1_img.value=document.editor.e_article_img.value;   
      document.mymemory.m_article1_rmore.value=document.editor.e_article_rmore.value;      
      };
   if (nart==2)
      {  
      document.mymemory.m_article2_title.value=document.editor.e_article_title.value;
	  if (document.editor.e_article_subtitle)
      	document.mymemory.m_article2_subtitle.value=document.editor.e_article_subtitle.value;
      document.mymemory.m_article2_text.value=document.editor.e_article_text.value;
	  if (document.editor.e_article_img)
      	document.mymemory.m_article2_img.value=document.editor.e_article_img.value;   
      document.mymemory.m_article2_rmore.value=document.editor.e_article_rmore.value;      
      };
   if (nart==3)
      {  
      document.mymemory.m_article3_title.value=document.editor.e_article_title.value;
	  if (document.editor.e_article_subtitle)
      	document.mymemory.m_article3_subtitle.value=document.editor.e_article_subtitle.value;
      document.mymemory.m_article3_text.value=document.editor.e_article_text.value;
	  if (document.editor.e_article_img)
	      document.mymemory.m_article3_img.value=document.editor.e_article_img.value;   
      document.mymemory.m_article3_rmore.value=document.editor.e_article_rmore.value;      
      };

       tarticle_title= document.editor.e_article_title.value;
	  if (document.editor.e_article_subtitle)	   
	   tarticle_subtitle = document.editor.e_article_subtitle.value;
	   else
	    tarticle_subtitle='';
	   tarticle_text = document.editor.e_article_text.value;  	
	  if (document.editor.e_article_img)	   	   		  			  
	   tarticle_img = document.editor.e_article_img.value;		  			  			  			  
	  else
	   tarticle_img=''; 
	   tarticle_rmore = document.editor.e_article_rmore.value;

   advAJAX.post
      ({
	   url: "includes/trigger-article.php",
       article_title: document.editor.e_article_title.value,
	   article_subtitle: tarticle_subtitle,
	   article_text: document.editor.e_article_text.value,			  			  			  
	   article_img: tarticle_img,			  			  			  			  
	   article_rmore: document.editor.e_article_rmore.value,			  			  			  			  	   
	   nr_article: nart,
	   id_newsletter: document.mymemory.id_newsletter.value,
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj)
	      {
		  prompter("T", "saving article "+nart+" ...");             		    
		  },
       onSuccess : function(obj) 
	      { 
	      if (nart==1)  
	         {
		     document.getElementById("article01-section").innerHTML = obj.responseText;
		     document.mymemory.article1_status.value='C';			              
		     };
	      if (nart==2)  
	         {
		     document.getElementById("article02-section").innerHTML = obj.responseText;             
		     document.mymemory.article2_status.value='C';
		     };
	      if (nart==3)  
	         {
		     document.getElementById("article03-section").innerHTML = obj.responseText;
		     document.mymemory.article3_status.value='C';			              
		     };
		  },
	   onFinalization : function(obj)
	      {
		  prompter("T", "i'm ready :)");		  
	      if (nart==1)  
	         {	
	  	    document.getElementById("article1-loader").style.display = 'none';	    
			if (document.mymemory.m_article1_img.value!='' && document.mymemory.m_article1_rmore.value!='')
				{
				if (document.getElementById("article1_imgl")) {
					zostawiam = $("#article1_imgl").html();
					$("#article1_imgl").replaceWith(zostawiam);
				};	
			    $("#article1_imgs").wrapInner($("<a id='article1_imgl' href='"+document.mymemory.m_article1_rmore.value+"'></a>"));	
				}
			else
				{
				zostawiam=$("#article1_imgl").html();
  				$("#article1_imgl").replaceWith(zostawiam);	
				};
             };
	      if (nart==2)  
	         {	
	  	    document.getElementById("article2-loader").style.display = 'none';	    
			if (document.mymemory.m_article2_img.value!='' && document.mymemory.m_article2_rmore.value!='')
				{
				if (document.getElementById("article2_imgl")) {
					zostawiam = $("#article2_imgl").html();
					$("#article2_imgl").replaceWith(zostawiam);
				};	
			    $("#article2_imgs").wrapInner($("<a id='article2_imgl' href='"+document.mymemory.m_article2_rmore.value+"'></a>"));	
				}
			else
				{
				zostawiam=$("#article2_imgl").html();
  				$("#article2_imgl").replaceWith(zostawiam);	
				};
             };
	      if (nart==3)  
	         {	
	  	     document.getElementById("article3-loader").style.display = 'none';	    
			if (document.mymemory.m_article3_img.value!='' && document.mymemory.m_article3_rmore.value!='')
				{
				if (document.getElementById("article3_imgl")) {
					zostawiam = $("#article3_imgl").html();
					$("#article3_imgl").replaceWith(zostawiam);
				};	
			    $("#article3_imgs").wrapInner($("<a id='article3_imgl' href='"+document.mymemory.m_article3_rmore.value+"'></a>"));	
				}
			else
				{
				zostawiam=$("#article3_imgl").html();
  				$("#article3_imgl").replaceWith(zostawiam);	
				};
			 
             };

		  }		  		 		 
      });                  
   }
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function EditCopyright()
   {  
      if (document.mymemory2.warning1.value != '') {
   	if (!confirm(document.mymemory2.warning1.value)) 
   		return;
   };

   CloseEditor2();	
   document.mymemory.opened_editor.value="R";   
   advAJAX.post
      ({
       url: "includes/edit-copyright.php",
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,	   
       copyright: document.mymemory.m_copyright.value,
       toddle_logo: document.mymemory.m_toddle_logo.value,			  			  			  			  	   	   
	   id_newsletter: document.mymemory.id_newsletter.value,
       template_name: document.mymemory.template_name.value,
	   m_status: document.mymemory.m_status.value,	   
	   onInitialization: function(obj) { prompter("T", "opening copyrights ...."); },
	   onSuccess : function(obj) 
	      { 
		  document.getElementById("copy-section").innerHTML = obj.responseText;                  		  
		  if (document.mymemory.m_status.value=='S')
		     {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";
			 	
             updatelist(document.mymemory.myemail.value);			 	
			 };
		  },
	   onFinalization : function(obj)
	      {
		  document.mymemory.m_status.value='';
		  if (document.editor.temp_id_newsletter)
		     {
		     document.mymemory.id_newsletter.value=document.editor.temp_id_newsletter.value;
			 };		  	
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.copyright_status.value='O';			 
          if (document.mymemory.opened_editor.value!="R")
		     {
			 CancelCopyright();	
			 };		  	     		  
		  }	  		  
      });                  
   };
function CancelCopyright()
   {
   if (document.mymemory.opened_editor.value=='R')
      {
      document.mymemory.opened_editor.value='';	
	  };   	
   id_newsletter=document.mymemory.id_newsletter.value;
   advAJAX.post
      ({
	   url: "includes/trigger-copyright.php",
	   id_newsletter: document.mymemory.id_newsletter.value,
       ac: "cancel",			  
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { prompter("T", "copyrights canceling..."); },
       onSuccess : function(obj) 
	      { 
		  document.getElementById("copy-section").innerHTML = obj.responseText;             
          document.getElementById("copy").innerHTML = document.mymemory.m_copyright.value;
//          document.getElementById("about_text").innerHTML = document.mymemory.m_about_text.value;          
		  },
	   onFinalization : function(obj)
	      {
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.copyright_status.value='C';
		  }		  		  
      });                  
   }

function SaveCopyright()
   {  
   if (document.mymemory.opened_editor.value=='R')
      {
      document.mymemory.opened_editor.value='';	
	  };      
   document.mymemory.m_copyright.value=document.editor.e_copy.value;
   document.mymemory.m_toddle_logo.value=document.editor.e_toddle_logo.value;
   advAJAX.post
      ({
	   url: "includes/trigger-copyright.php",
       copyright: document.editor.e_copy.value,
       toddle_logo: document.editor.e_toddle_logo.value,
	   id_newsletter: document.mymemory.id_newsletter.value,
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { prompter("T", "saving copyrights ...."); },
       onSuccess : function(obj) 
	      { 
		  document.getElementById("copy-section").innerHTML = obj.responseText;                  		  
		  },
	   onFinalization : function(obj)
	      {
		  document.mymemory.copyright_status.value='C';		  	
		  prompter("T", "i'm ready :)");		  
		  }		  		 		 		  
      });                  
   }


function EditAbout()
   {  
      if (document.mymemory2.warning1.value != '') {
   	if (!confirm(document.mymemory2.warning1.value)) 
   		return;
   };

   CloseEditor2();	
   document.mymemory.opened_editor.value="A";   
   advAJAX.post
      ({
       url: "includes/edit-about.php",
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,	   
       about_title: document.mymemory.m_about_title.value,
       about_text: document.mymemory.m_about_text.value,			  			  			  			  	   	   
	   id_newsletter: document.mymemory.id_newsletter.value,
       template_name: document.mymemory.template_name.value,
	   m_status: document.mymemory.m_status.value,	   
	   onInitialization: function(obj) { prompter("T", "opening about ...."); },
	   onSuccess : function(obj) 
	      { 
		  document.getElementById("about-section").innerHTML = obj.responseText;                  		  
		  if (document.mymemory.m_status.value=='S')
		     {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";
			 	
             updatelist(document.mymemory.myemail.value);			 	
			 };
		  },
	   onFinalization : function(obj)
	      {
		  document.mymemory.m_status.value='';
		  if (document.editor.temp_id_newsletter)
		     {
		     document.mymemory.id_newsletter.value=document.editor.temp_id_newsletter.value;
			 };		  	
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.about_status.value='O';			 
          if (document.mymemory.opened_editor.value!="A")
		     {
			 CancelAbout();	
			 };		  	     		  
		  }	  		  
      });                  
   };
function CancelAbout()
   {
   if (document.mymemory.opened_editor.value=='A')
      {
      document.mymemory.opened_editor.value='';	
	  };   	
   id_newsletter=document.mymemory.id_newsletter.value;
   advAJAX.post
      ({
	   url: "includes/trigger-about.php",
	   id_newsletter: document.mymemory.id_newsletter.value,
       ac: "cancel",			  
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { prompter("T", "about canceling..."); },
       onSuccess : function(obj) 
	      { 
		  document.getElementById("about-section").innerHTML = obj.responseText;             
          document.getElementById("about_title").innerHTML = document.mymemory.m_about_title.value;

		  text=document.mymemory.m_about_text.value;
		  text2=text.replace(/\r\n|\r|\n/g, '<br \/>');
          document.getElementById("about_text").innerHTML = text2;		           
		  
		  
		  },
	   onFinalization : function(obj)
	      {
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.about_status.value='C';
		  }		  		  
      });                  
   }
function SaveAbout()
   {  
   if (document.mymemory.opened_editor.value=='A')
      {
      document.mymemory.opened_editor.value='';	
	  };      
   document.mymemory.m_about_title.value=document.editor.e_about_title.value;
   document.mymemory.m_about_text.value=document.editor.e_about_text.value;
   advAJAX.post
      ({
	   url: "includes/trigger-about.php",
       about_title: document.editor.e_about_title.value,
       about_text: document.editor.e_about_text.value,
	   id_newsletter: document.mymemory.id_newsletter.value,
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { prompter("T", "saving about ...."); },
       onSuccess : function(obj) 
	      { 
		  document.getElementById("about-section").innerHTML = obj.responseText;                  		  
		  },
	   onFinalization : function(obj)
	      {
		  document.mymemory.about_status.value='C';		  	
		  prompter("T", "i'm ready :)");		  
		  }		  		 		 		  
      });                  
   }
// ----------------------------------------------------------------------------------------------------------------------------------
function EditContact()
   {  
   if (document.mymemory2.warning1.value != '') {
   	if (!confirm(document.mymemory2.warning1.value)) 
   		return;
   };
   
   CloseEditor2();	
   document.mymemory.opened_editor.value="C";   
   advAJAX.post
      ({
       url: "includes/edit-contact.php",
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,	   
       contact_addr2: document.mymemory.m_contact_addr2.value,
       contact_name2: document.mymemory.m_contact_name2.value,
       contact_phone2: document.mymemory.m_contact_phone2.value,
       contact_fax2: document.mymemory.m_contact_fax2.value,
       contact_email2: document.mymemory.m_contact_email2.value,
       contact_mobile2: document.mymemory.m_contact_mobile2.value,
       contact_im2: document.mymemory.m_contact_im2.value,
       contact_www2: document.mymemory.m_contact_www2.value,	   
	   id_newsletter: document.mymemory.id_newsletter.value,
       template_name: document.mymemory.template_name.value,
	   m_status: document.mymemory.m_status.value,	   
	   onInitialization: function(obj) { prompter("T", "opening contact ...."); },
	   onSuccess : function(obj) 
	      { 
		  document.getElementById("address-section").innerHTML = obj.responseText;
           if (document.mymemory.m_status.value=='S')
		     {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";
			 				 };

		  },
	   	onFinalization : function(obj)
	      {
		  document.mymemory.m_status.value='';
		  if (document.editor.temp_id_newsletter)
		     {
		     document.mymemory.id_newsletter.value=document.editor.temp_id_newsletter.value;
			 };	
             updatelist(document.mymemory.myemail.value);			 	
			 	  	
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.contact_status.value='O';			 
          if (document.mymemory.opened_editor.value!="C")
		     {
			 CancelContact();	
			 };		  	     		  
		  }	  		  
      });                  
   };
function CancelContact()
   {       
   if (document.mymemory.opened_editor.value=='C')
      {
      document.mymemory.opened_editor.value='';	
	  };      
   id_newsletter=document.mymemory.id_newsletter.value;
   advAJAX.post
      ({
	   url: "includes/trigger-contact.php",
	   id_newsletter: document.mymemory.id_newsletter.value,
       ac: "cancel",			  
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { prompter("T", "canceling contact ...."); },
       onSuccess : function(obj) 
	      { 
		  text=document.mymemory.m_contact_addr2.value;
		  text2=text.replace(/\r\n|\r|\n/g, '<br \/>');
          document.getElementById("adr").innerHTML = text2;		           
		  document.getElementById("address-section").innerHTML = obj.responseText;             
          document.getElementById("fn").innerHTML = document.mymemory.m_contact_name2.value;
          document.getElementById("tel").innerHTML = document.mymemory.m_contact_phone2.value;
          document.getElementById("fax").innerHTML = document.mymemory.m_contact_fax2.value;
          document.getElementById("email").innerHTML = document.mymemory.m_contact_email2.value;
          document.getElementById("im").innerHTML = document.mymemory.m_contact_im2.value;
          document.getElementById("url").innerHTML = document.mymemory.m_contact_www2.value;

		  },
	   onFinalization : function(obj)
	      {
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.contact_status.value='C';
		  }		  		  		  
      });                  
   }
function CancelContactold()
   {       
   if (document.mymemory.opened_editor.value=='C')
      {
      document.mymemory.opened_editor.value='';	
	  };      
   id_newsletter=document.mymemory.id_newsletter.value;
   advAJAX.post
      ({
	   url: "includes/trigger-contact.php",
	   id_newsletter: document.mymemory.id_newsletter.value,
       ac: "cancel",			  
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { prompter("T", "canceling contact ...."); },
       onSuccess : function(obj) 
	      { 
		  text=document.mymemory.m_contact_addr2.value;
		  text2=text.replace(/\r\n|\r|\n/g, '<br \/>');
          document.getElementById("contact_addr2").innerHTML = text2;		           

		  document.getElementById("address-section").innerHTML = obj.responseText;             

          document.getElementById("contact_name2").innerHTML = document.mymemory.m_contact_name2.value;
          document.getElementById("contact_phone").innerHTML = document.mymemory.m_contact_phone2.value;
          document.getElementById("contact_fax2").innerHTML = document.mymemory.m_contact_fax2.value;
          document.getElementById("contact_email2").innerHTML = document.mymemory.m_contact_email2.value;
          document.getElementById("contact_mobile2").innerHTML = document.mymemory.m_contact_phone2.value;
          document.getElementById("contact_im2").innerHTML = document.mymemory.m_contact_im2.value;
          document.getElementById("contact_www2").innerHTML = document.mymemory.m_contact_www2.value;

		  },
	   onFinalization : function(obj)
	      {
		  prompter("T", "i'm ready :)");		  	
		  document.mymemory.contact_status.value='C';
		  }		  		  		  
      });                  
   }

function SaveContact_old()
   {  
   if (document.mymemory.opened_editor.value=='C') { document.mymemory.opened_editor.value=''; };      
   document.mymemory.m_contact_addr2.value=document.editor.e_contact_addr2.value;
   if (document.mymemory.e_contact_name2) { document.mymemory.m_contact_name2.value=document.editor.e_contact_name2.value; };
   document.mymemory.m_contact_phone2.value=document.editor.e_contact_phone2.value;
   document.mymemory.m_contact_email2.value=document.editor.e_contact_email2.value;
   document.mymemory.m_contact_mobile2.value=document.editor.e_contact_mobile2.value;
   document.mymemory.m_contact_fax2.value=document.editor.e_contact_fax2.value;
   document.mymemory.m_contact_im2.value=document.editor.e_contact_im2.value;
   document.mymemory.m_contact_www2.value=document.editor.e_contact_www2.value;   
   advAJAX.post
      ({
	   url: "includes/trigger-contact.php",
       contact_addr2: document.editor.e_contact_addr2.value,
       contact_name2: document.editor.e_contact_name2.value,
       contact_phone2: document.editor.e_contact_phone2.value,
       contact_fax2: document.editor.e_contact_fax2.value,
       contact_email2: document.editor.e_contact_email2.value,
       contact_mobile2: document.editor.e_contact_mobile2.value,
       contact_im2: document.editor.e_contact_im2.value,
       contact_www2: document.editor.e_contact_www2.value,	   
	   id_newsletter: document.mymemory.id_newsletter.value,
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { prompter("T", "saving contact ...."); },
       onSuccess : function(obj) 
	      { 
		  document.getElementById("address-section").innerHTML = obj.responseText;                  		  
		  },
	   onFinalization : function(obj)
	      {
		  document.mymemory.contact_status.value='C';		  	
		  prompter("T", "i'm ready :)");		  
		  }		  		 		 		  		  
      });                  
   };


function SaveContact()
   {  
   if (document.mymemory.opened_editor.value=='C') 
   		{ document.mymemory.opened_editor.value=''; };      
   document.mymemory.m_contact_addr2.value=document.editor.e_adr.value;
   document.mymemory.m_contact_name2.value=document.editor.e_fn.value;
   document.mymemory.m_contact_phone2.value=document.editor.e_tel.value;
   document.mymemory.m_contact_email2.value=document.editor.e_email.value;
   document.mymemory.m_contact_fax2.value=document.editor.e_fax.value;
   document.mymemory.m_contact_im2.value=document.editor.e_im.value;
   document.mymemory.m_contact_www2.value=document.editor.e_url.value;
   advAJAX.post
      ({
	   url: "includes/trigger-contact.php",
       contact_addr2: document.editor.e_adr.value,
       contact_name2: document.editor.e_fn.value,
       contact_phone2: document.editor.e_tel.value,
       contact_fax2: document.editor.e_fax.value,
       contact_email2: document.editor.e_email.value,
       contact_im2: document.editor.e_im.value,
       contact_www2: document.editor.e_url.value,	   
	   id_newsletter: document.mymemory.id_newsletter.value,
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) { prompter("T", "saving contact ...."); },
       onSuccess : function(obj) 
	      { 
		  document.getElementById("address-section").innerHTML = obj.responseText;                  		  
		  },
	   onFinalization : function(obj)
	      {
			if (document.mymemory.m_header_img.value!='' && document.mymemory.m_contact_www2.value!='')
				{
				if (document.getElementById("header_imgl")) {
					zostawiam = $("#header_imgl").html();
					$("#header_imgl").replaceWith(zostawiam);
				};	
			    $("#header_imgs").wrapInner($("<a id='header_imgl' href='http://"+document.mymemory.m_contact_www2.value+"'></a>"));	
				}
			else
				{
				zostawiam=$("#header_imgl").html();
  				$("#header_imgl").replaceWith(zostawiam);	
				};


		  document.mymemory.contact_status.value='C';		  	
		  prompter("T", "i'm ready :)");		  
		  }		  		 		 		  		  
      });                  
   };

// ----------------------------------------------------------------------------------------------------------------------------------
// "type and see" dla pol tekstowych
function edit1(pole)
   {
   var tresc = document.forms['editor'].elements["e_"+pole].value;      
   tresc = tresc.replace(/\r\n|\r|\n/g, '<br \/>'); 
   document.getElementById(pole).innerHTML = tresc;
   };
function editc(pole)
   {
   var tresc = document.forms['editor'].elements["e_"+pole].value;      
   tresc = tresc.replace(/\r\n|\r|\n/g, '<br \/>'); 
   document.getElementById(pole).innerHTML = tresc;
   };



function edit11(pole,nr_article)
   {
   var tresc = document.forms['editor'].elements["e_"+pole].value;      
   tresc = tresc.replace(/\r\n|\r|\n/g, '<br \/>');
  //// TU JEST PROBLEM Z NAZWA POLA !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11  
   if (nr_article==1)
      {
      if (pole=="article_title")
         document.getElementById("article1_title").innerHTML = tresc;
      if (pole=="article_subtitle")
         document.getElementById("article1_subtitle").innerHTML = tresc;
      if (pole=="article_text")
         document.getElementById("article1_text").innerHTML = tresc;
      };
   if (nr_article==2)
      {
      if (pole=="article_title")
         document.getElementById("article2_title").innerHTML = tresc;
      if (pole=="article_subtitle")
         document.getElementById("article2_subtitle").innerHTML = tresc;
      if (pole=="article_text")
         document.getElementById("article2_text").innerHTML = tresc;
      };
   if (nr_article==3)
      {
      if (pole=="article_title")
         document.getElementById("article3_title").innerHTML = tresc;
      if (pole=="article_subtitle")
         document.getElementById("article3_subtitle").innerHTML = tresc;
      if (pole=="article_text")
         document.getElementById("article3_text").innerHTML = tresc;
      };
   };



// laduj obrazek do preview i zapisz w ukrytej zmiennej naglowka	
function afteruploadshow(plik,area_img)
   {
     if (area_img=="header_img")
        {
        var imgsize = document.mymemory.b_header.value;
        };
     if (area_img=="intro_img")
        {
        var imgsize = document.mymemory.b_intro.value;
        };
     if (area_img=="article1_img")
        {
        var imgsize = document.mymemory.b_article1.value;
        };
     if (area_img=="article2_img")
        {
        var imgsize = document.mymemory.b_article2.value;
        };
     if (area_img=="article3_img")
        {
        var imgsize = document.mymemory.b_article3.value;
        };


    ssiz=imgsize.indexOf("(")+1;
    esiz=imgsize.indexOf(")");
    lsiz=esiz-ssiz;
    siz=imgsize.substr(ssiz,lsiz);
       
   id_newsletter=document.mymemory.id_newsletter.value;		  			  			  			  
   if (plik!='')
      {
      document.images[area_img].style.display="block"; 	             
      document.images[area_img].src="show_thumb.php?id_newsletter="+id_newsletter+"&file="+plik+"&width="+siz+"&t="+document.mymemory.template_name.value; 
    }
    else
       {
//     if (area_img=="article1_img" || area_img=="article2_img" || area_img=="article3_img")
//        {
//        area_img="article_img";
//        };

      if (document.images[area_img])
      document.images[area_img].src="images/1.gif";	   	 	     
		};

     if (area_img=="article1_img" || area_img=="article2_img" || area_img=="article3_img")
        {
        area_img="article_img";
        };
   if (document.forms['editor'])
      {		
	     if (document.forms['editor'].elements["e_"+area_img])
      {document.forms['editor'].elements["e_"+area_img].value=plik;};
      };
   };

// ukryj 		
function closeit(id)
   {
   document.getElementById(id).style.display='none';	
   }		
		



//-------------- zmien templata -------------------------------------------------------------------------------------------
function change_style(template_name)
   {
zmien4przycisk();
   CloseEditor2();
      var head = document.getElementsByTagName('head')[0];
      var link = document.getElementById("presenttemplate");

        head.removeChild(link);

	lasttpl="#"+document.mymemory.template_name.value;
	$(lasttpl).removeClass("current");


   document.mymemory.template_name.value=template_name;
   newtpl="#"+template_name;
	$(newtpl).addClass("current");

   mycss = document.createElement("link");
   mycss.id="presenttemplate";
   mycss.type="text/css";
   mycss.rel="stylesheet";
   mycss.title="preview";   
   mycss.href= "templates/"+template_name+"/css/"+template_name+".css";
   document.getElementsByTagName("head")[0].appendChild(mycss);

	$("#templates").slideUp("slow");

   advAJAX.post
      ({
       url: "tpl_analize2.php",
       id_newsletter: document.mymemory.id_newsletter.value,	   
	   ntemplate_name: template_name,
	   m_status: document.mymemory.m_status.value,
	   ac: "back",
       timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,	   
       onInitialization : function(obj)
          {
 		  document.getElementById("right-column").display = "none";                                       
 		  document.getElementById("right-column").innerHTML = "";                           
 		  document.getElementById("right-column").innerHTML = "<img src=../images/ajax-loader.gif />";               
 		  document.getElementById("right-column").display = "block";                                        		  
		  },
	   onSuccess : function(obj) 
	      { 
          back1=obj.responseText;               
          var back2 = new Array(2);
		  back2 = back1.split(",");
	      document.mymemory.b_header.value = back2[0];
	      document.mymemory.b_intro.value = back2[1];	      
	      document.mymemory.b_article1.value = back2[2];	      
	      document.mymemory.b_article2.value = back2[3];	      
	      document.mymemory.b_article3.value = back2[4];	
		  document.mymemory.id_newsletter.value = back2[5];     
		  },
	   onFinalization : function(obj)
	      {
		  if (document.mymemory.b_intro.value=='' || document.mymemory.b_intro.value==' ' || document.mymemory.b_intro.value=='  ' || document.mymemory.b_intro.value=='   ' || document.mymemory.b_intro.value=='    ')
		  	{
	  	  	document.getElementById("intro-section").style.display = "none";                                       	
			}
		  else
		  	{
	  	  	document.getElementById("intro-section").style.display = "block";                                       					
			};

		  if (document.mymemory.b_header.value=='' || document.mymemory.b_header.value==' ' || document.mymemory.b_header.value=='  ' || document.mymemory.b_header.value=='   ' || document.mymemory.b_header.value=='    ')
		  	{
	  	  	document.getElementById("header-section").style.display = "none";                                       	
			}
		  else
		  	{
	  	  	document.getElementById("header-section").style.display = "block";                                       					
			};
		  if (document.mymemory.b_article2.value=='' || document.mymemory.b_article2.value==' ' || document.mymemory.b_article2.value=='  ' || document.mymemory.b_article2.value=='   ' || document.mymemory.b_article2.value=='    ')
		  	{
	  	  	document.getElementById("article02-section").style.display = "none";                                       	
			}
		  else
		  	{
	  	  	document.getElementById("article02-section").style.display = "block";                                       					
			};

		  if (document.mymemory.b_article1.value=='' || document.mymemory.b_article1.value==' ' || document.mymemory.b_article1.value=='  ' || document.mymemory.b_article1.value=='   ' || document.mymemory.b_article1.value=='    ')
		  	{
	  	  	document.getElementById("article01-section").style.display = "none";                                       	
			}
		  else
		  	{
	  	  	document.getElementById("article01-section").style.display = "block";                                       					
			};
		  if (document.mymemory.b_article3.value=='' || document.mymemory.b_article3.value==' ' || document.mymemory.b_article3.value=='  ' || document.mymemory.b_article3.value=='   ' || document.mymemory.b_article3.value=='    ')
		  	{
	  	  	document.getElementById("article03-section").style.display = "none";                                       	
			}
		  else
		  	{
	  	  	document.getElementById("article03-section").style.display = "block";                                       					
			};


			
		  advAJAX.post
      		({
       		url: "includes/aboutcredits.php",
	        email: document.mymemory.myemail.value,			
	  	    ntemplate_name: template_name,
		   id_newsletter: document.mymemory.id_newsletter.value,						
	   		onSuccess : function(obj) 
	      		{ 
				},
	   		onFinalization : function(obj) 
	      		{ 
				document.getElementById("aboutcredits").innerHTML = obj.responseText;                  		  
				}
			});
			
			
				
  advAJAX.post
      ({
       url: "tpl_preview_r.php",
       header_h1: document.mymemory.m_header_h1.value,
	   header_date: document.mymemory.m_header_date.value,
	   header_welcome: document.mymemory.m_header_welcome.value,			  			  			  
	   header_img: document.mymemory.m_header_img.value,			  			  			  			  
       intro_h1: document.mymemory.m_intro_h1.value,
	   intro_text: document.mymemory.m_intro_text.value,
	   intro_img: document.mymemory.m_intro_img.value,			  			  			  			  
	   intro_rmore: document.mymemory.m_intro_rmore.value,			 	    			  			  			  	   
	   article1_title : document.mymemory.m_article1_title.value,
	   article1_subtitle: document.mymemory.m_article1_subtitle.value,
	   article1_text : document.mymemory.m_article1_text.value,
	   article1_img        : document.mymemory.m_article1_img.value,                
	   article1_rmore       : document.mymemory.m_article1_rmore.value,
	   article2_title      : document.mymemory.m_article2_title.value,
	   article2_subtitle   : document.mymemory.m_article2_subtitle.value,
	   article2_text       : document.mymemory.m_article2_text.value,
	   article2_img        : document.mymemory.m_article2_img.value,                
	   article2_rmore       : document.mymemory.m_article2_rmore.value,
	   article3_title      : document.mymemory.m_article3_title.value,
	   article3_subtitle   : document.mymemory.m_article3_subtitle.value,
	   article3_text       : document.mymemory.m_article3_text.value,
	   article3_img        : document.mymemory.m_article3_img.value,                
	   article3_rmore       : document.mymemory.m_article3_rmore.value,
       contact_addr2: document.mymemory.m_contact_addr2.value,
       contact_name2: document.mymemory.m_contact_name2.value,
       contact_phone2: document.mymemory.m_contact_phone2.value,
       contact_fax2: document.mymemory.m_contact_fax2.value,
       contact_email2: document.mymemory.m_contact_email2.value,
       contact_mobile2: document.mymemory.m_contact_mobile2.value,
       contact_im2: document.mymemory.m_contact_im2.value,
       contact_url: document.mymemory.m_contact_www2.value,
       about_title: document.mymemory.m_about_title.value,
       about_text: document.mymemory.m_about_text.value,			  			  			  			  	   	   
       copyright: document.mymemory.m_copyright.value,
       toddle_logo: document.mymemory.m_toddle_logo.value,			  			  			  			  	   	   
       id_newsletter: document.mymemory.id_newsletter.value,
       b_header: document.mymemory.b_header.value,
       b_intro: document.mymemory.b_intro.value,       
	   myemail: document.mymemory.myemail.value,
       b_article1: document.mymemory.b_article1.value,       
       b_article2: document.mymemory.b_article2.value,       
       b_article3: document.mymemory.b_article3.value,       	          
	   ntemplate_name: template_name,
       timeout : 1800,
       retryCount: 8,
       retryDelay: 800,	   
	   onSuccess : function(obj) 
	      { 
		  document.getElementById("right-column").innerHTML = obj.responseText;             
           if (document.mymemory.m_status.value=='S')
		     {
			 document.getElementById("advanced-options").style.display="none";
			 document.mymemory.m_status.value="";					

             updatelist(document.mymemory.myemail.value);			 	
			 };

		  },
	   		onFinalization: function(obj){
				jq_preview();
//				if (document.mymemory.myemail.value == "tomasz@walkowiak.name") {
					showmsgs(document.mymemory.myemail.value, template_name, document.mymemory.myuserid.value);
//				};
			}		  
      });                  
		    
		  }  
      });                  
   }
function trick1()
 {
	      $("#sent2-newsletter").show(); 		  	       
//		  document.getElementById("sent-newsletter").innerHTML = "<img src=images/newsletter-sent.gif />";             		    
 };
function SendNewsletter()
	{
	CloseEditor2();
	advAJAX.post
		({
		url: "email.php",
		id_newsletter: document.mymemory.id_newsletter.value,
		template_name: document.mymemory.template_name.value,
		b_header: document.mymemory.b_header.value,	   
		b_intro: document.mymemory.b_intro.value,	   
		b_article1 : document.mymemory.b_article1.value,	   
		b_article2 : document.mymemory.b_article2.value,
		b_article3 : document.mymemory.b_article3.value,
		timeout : 6000,
		retryCount: 5,
		retryDelay: 1000,
		onInitialization: function(obj)
			{
			//	      $("#aboutcredits").hide("fast"); 		  
			document.getElementById("aboutcredits").style.display= "none";             		    
			document.getElementById("sent2-newsletter").style.display= "block";     
//			$("#sent2-newsletter").show("fast"); 		  	       	   
			var so = new SWFObject("http://www.toddle.com/flashvideo/pigeon_flying.swf","sending","350","60","9","#FFFFFF");
			so.write("sent2-newsletter");		
			//		document.getElementById("sent2-newsletter").innerHTML= "<img id='animek' src='images/newsletter-sent.gif' />";     
			//		 document.images["animek"].src = "images/newsletter-sent.gif";
			//		 setTimeout('document.images["animek"].src = "images/newsletter-sent.gif"',3000);
			},
		onSuccess : function(obj) 
			{ 
			document.mymemory.m_status.value="S";
			},
		onFinalization : function(obj) 
			{

			$("#sent2-newsletter").hide(); 		  	       	      								

			document.getElementById("sent-newsletter").innerHTML = obj.responseText;                  		  	      	       
//			$("#aboutcredits").show(); 			

			advAJAX.post
				({
				url: "includes/aboutcredits.php",
				ntemplate_name: document.mymemory.template_name.value,
				email: document.mymemory.myemail.value,			
				id_newsletter: document.mymemory.id_newsletter.value,			
				onSuccess : function(obj) 
					{ 
					},
				onFinalization : function(obj) 
					{ 
					document.getElementById("advanced-options").style.display="block";
					$("#aboutcredits").show(); 			
					document.getElementById("aboutcredits").innerHTML = obj.responseText;                  		  

					advAJAX.post
						({
						url: "includes/advanced.php",
						ntemplate_name: document.mymemory.template_name.value,
						email: document.mymemory.myemail.value,			
						onSuccess : function(obj) 
							{ 
							$("#advanced-options-details").empty(); 		  	       	      
							},
						onFinalization : function(obj) 
							{ 
							document.getElementById("advanced-options-details").innerHTML = obj.responseText;   
							h2ideadvanced();               		  
							document.getElementById("sent2-newsletter").innerHTML= "";     
							}
						});
					}
				});			
			prompter("T","check your email ! :), im ready :)");                  		  
			}
		});                  	  
	};
   

function pausecomp(millis)
{

var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 
   
function addEvent( obj, type, fn ) { 
  if ( obj.attachEvent ) { 
    obj['e'+type+fn] = fn; 
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );} 
    obj.attachEvent( 'on'+type, obj[type+fn] ); 
  } else 
    obj.addEventListener( type, fn, false ); 
} 
function removeEvent( obj, type, fn ) { 
  if ( obj.detachEvent ) { 
    obj.detachEvent( 'on'+type, obj[type+fn] ); 
    obj[type+fn] = null; 
  } else 
    obj.removeEventListener( type, fn, false ); 
}    

function prompter(itype,icontent)
   {
   if (itype=="T")
      {   
//      document.getElementById("message").innerHTML = icontent;
	  };   	
   };   
function emptycontrol(pole)
   {
   if (document.getElementById(pole).value=="type your newsletter title") 
   		{ 
		document.getElementById(pole).value = ''; 
		};	
   };
   
function contenthint(pole)
   {
   alert("content hint");
   }

function h2ideadvanced()
   {
   document.getElementById("advanced-options-header").innerHTML = '<a onclick="s2howadvanced()">Show advanced sending options</a>';	
   document.getElementById("advanced-options-details").style.display = 'none';   
   };
function s2howadvanced()
   {
   document.getElementById("advanced-options-header").innerHTML='<a onclick="h2ideadvanced()">Hide advanced sending options</a>';	
   document.getElementById("advanced-options-details").style.display='block';   
   };



function updatelist(useremail)
   {
   advAJAX.post
      ({
       url: "update_list.php",
	   id_newsletter: document.mymemory.id_newsletter.value,
  	   uemail : useremail,
	   timeout : 1000,
       retryCount: 5,
       retryDelay: 1000,
	   onInitialization: function(obj)
	      {
		  document.getElementById("sent-newsletter").innerHTML = "<span>Send your newsletter</span><img src=images/ajax-loader.gif />";             		    
		  },
	   onSuccess : function(obj) 
	      { 
		  document.getElementById("sent-newsletter").innerHTML = obj.responseText;                  		  
		  }
      });
		  advAJAX.post
      		({
       		url: "includes/aboutcredits.php",
	        ntemplate_name: document.mymemory.template_name.value,
			email: document.mymemory.myemail.value,			
		   	id_newsletter: document.mymemory.id_newsletter.value,			
	   		onSuccess : function(obj) 
	      		{ 
				},
	   		onFinalization : function(obj) 
	      		{ 
				if (document.mymemory.m_status.value=="S")
			 		document.getElementById("advanced-options").style.display="block";
				else	
			 		document.getElementById("advanced-options").style.display="none";					
				document.getElementById("aboutcredits").innerHTML = obj.responseText;                  		  
				}
			});
   		                    	  
   };
   
  function EditingRMore(what) 
  	{
		newlink=document.editor.e_article_rmore.value;
		if (newlink.substr(0,7)!='http://' && newlink.length>7)
		   {
		   document.editor.e_article_rmore.value="http://"+newlink;
		   };
		if (document.links[what])  
		document.links[what].href=document.editor.e_article_rmore.value;
		if (document.editor.e_article_rmore.value!='')
			{
			document.getElementById(what).style.display='block';
			}
		else
			{
			document.getElementById(what).style.display='none';				
			};	
	};

  function edit2(what) 
  	{
		newlink=document.editor.e_intro_rmore.value;
		if (newlink.substr(0,7)!='http://' && newlink.length>7)
		   {
		   document.editor.e_intro_rmore.value="http://"+newlink;
		   };
		if (document.links["intro_rmore"] && document.editor.e_intro_rmore)
  		   document.links["intro_rmore"].href=document.editor.e_intro_rmore.value; 
		if (document.editor.e_intro_rmore.value!='')
			{
			document.getElementById(what).style.display='block';
			}
		else
			{
			document.getElementById(what).style.display='none';				
			};	
	} 
	
	
function setheadernote()
	{
	if (document.editor.e_header_note.checked) 
		{
		document.getElementById("header_note").style.display='block';
		}
	else		
		{
		document.getElementById("header_note").style.display='none';
		};	
	}
	
function finding()
   {
   advAJAX.post
      ({
	   url: "searching.php",
       what: document.finder.findit.value,			  
       timeout : 100,
       retryCount: 2,
       retryDelay: 100,
       onError : function(obj) { alert("Error: " + obj.status); },
	   onInitialization: function(obj) 
	   		{
		  document.getElementById("searchresults").innerHTML = "searching ....";             
			},
       onSuccess : function(obj) 
	      { 
		  document.getElementById("searchresults").innerHTML = "done ....";             		  
		  },
	   onFinalization : function(obj)
	      {
		  document.getElementById("searchresults").innerHTML = obj.responseText;             
		  }		  		  
      });                  
   }
	
function jq_finding()
   {
   $.ajax({
   		type: "POST",
		url: "searching.php",
		data: "what="+document.finder.findit.value,
		cache: false,
		success: function(html) {
			$("#latest").hide();						
			$("#found").show();			
			$("#searchresults").empty();
			$("#searchresults").append(html);
		}
   });                  
   }
function jq_finding2(evt)
   {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode == 13) {
   	
   $.ajax({
   		type: "POST",
		url: "searching.php",
		data: "what="+document.finder.findit.value,
		cache: false,
		success: function(html) {
			$("#latest").hide();						
			$("#found").show();			
			$("#searchresults").empty();
			$("#searchresults").append(html);
		}
   });         
   return false;         
   }
   return true;
   };
   
function jq_preview()   	
	{
	if (document.mymemory.m_article1_img.value!='' && document.mymemory.m_article1_rmore.value!='')
		{
		$("#article1_imgs").wrapInner($("<a id='article1_imgl' href='"+document.mymemory.m_article1_rmore.value+"'></a>"));	
		};
	if (document.mymemory.m_article2_img.value!='' && document.mymemory.m_article2_rmore.value!='')
		{
		$("#article2_imgs").wrapInner($("<a id='article2_imgl' href='"+document.mymemory.m_article2_rmore.value+"'></a>"));	
		};
	if (document.mymemory.m_article3_img.value!='' && document.mymemory.m_article3_rmore.value!='')
		{
		$("#article3_imgs").wrapInner($("<a id='article3_imgl' href='"+document.mymemory.m_article3_rmore.value+"'></a>"));	
		};		
	if (document.mymemory.m_header_img.value!='' && document.mymemory.m_contact_www2.value!='')
		{
		$("#header_imgs").wrapInner($("<a id='header_imgl' href='http://"+document.mymemory.m_contact_www2.value+"'></a>"));	
		};		
	if (document.mymemory.m_header_note.value=='Y' || document.mymemory.m_header_note.value=='on' || document.mymemory.m_header_note.value=='true')
		{
		$("#header_note").show();	
		};		


	};
function f2uploaded(nr,ufile) {
	document.getElementById("status1").innerHTML= '<p style="display: block; background: url(http://www.toddle.com/show_thumb.php?id_newsletter='+nr+'&file='+ufile+'&width=64&t=chocolate) no-repeat 10px 20px; padding: 20px 10px 0 80px; font-size: 11px; color: #121212;"></p>';
	};
	
	
function bugreport1()
   {
   		$.ajax({
		type: "POST",
		url: "includes/bugreport.php",
		data: "email="+document.mymemory.myemail.value+"&newsletter="+document.mymemory.id_newsletter.value+"&template="+document.mymemory.template_name.value+"&urgent=" + document.bugreport.urgent.value+"&did="+document.bugreport.did.value+"&expected="+document.bugreport.expected.value+"&happened="+document.bugreport.happened.value,
		cache: false,
		success: function(html){
				$('#report-bug-form').hide();
				document.getElementById('report-sent').innerHTML=html;	
		}
	});

   };	


function readmsg3(email,template)
   {
   		$.ajax({
		type: "POST",
		url: "includes/readmsg3.php",
		data: "email="+email+"&template="+template+"&userid="+document.mymemory.myuserid.value,
		cache: false,
		success: function(html){
				$('#msg3').fadeOut();
		}
	});

   };	


function readmsg0(email)
   {
   		$.ajax({
		type: "POST",
		url: "includes/readmsg0.php",
		data: "email="+email,
		cache: false,
		success: function(html){
				$('#message0').fadeOut();
		}
	});

   };	

function showmsgs(email,template,userid)
   {
	$.ajax({
		type: "POST",
		url: "messages.php",
		data: "email="+email+"&template="+template+"&action=read&userid="+userid,
		cache: false,
		success: function(html){
				document.getElementById('messages').innerHTML=html;				
		}
	});
   };	

   
