
	<Script>
			var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
			var act_flag='<?php echo $msg_id ?>';
			act_flag="";
			var var_name='<?php echo $variable_name?>';
			var init_editor_flag=false;
			var command = "";
			function fetch_message()
			{
				eve_id=document.<?php echo $form_name;?>.select_id.value;
				if(eve_id){
					command="<?php echo tep_href_link($submit_pagename,'command=fetch_message_list');?>&" + var_name + "="+eve_id;
					if(act_flag!="" && act_flag!="message_list")
						command+="&msg_id=" + act_flag;
					do_get_command(command);
					act_flag="message_list";
				}
			}

			function fetch_details(eve_id,mid)
			{
			if(document.getElementById('copy_message_load'))
				document.getElementById('copy_message_load').innerHTML='';
				document.getElementById(mid).style.display="";
				if(act_flag!="" && act_flag!="message_list" && act_flag!=mid)
				{
					document.getElementById(act_flag).innerHTML='<?php echo tep_image(DIR_WS_IMAGES . '24-1.gif') ;?>';
					document.getElementById(act_flag).style.display="none";
					document.getElementById(act_flag + "_row").style.display="";
					init_editor_flag=false;
				}
				if(act_flag!=mid)
				{
					command="<?php echo tep_href_link($submit_pagename,'command=fetch_message_details');?>&" + var_name + "="+eve_id + "&msg_id=" + mid;
					do_get_command(command);
					act_flag=mid;
				}
				else 
					hide_message_details();
				
			}
			
			function hide_message_details()
			{
				if(act_flag!="message_list")
				{
					if(document.getElementById(act_flag)){
					document.getElementById(act_flag).innerHTML='<?php echo tep_image(DIR_WS_IMAGES . '24-1.gif') ;?>';
					document.getElementById(act_flag).style.display="none";
					document.getElementById(act_flag + "_row").style.display="";
					init_editor_flag=false;
					act_flag="";
					}
				}
			}
			function do_result(result)
			{ 
			//alert (result);
			var token=result.split('^^^^');
			if(token[0]=='message'){
				switch(token[1]){
					case 'copy_message':
			 			document.getElementById('copy_message_load').innerHTML=token[2];
						break;
					case 'save_message':
						document.getElementById('copy_message_load').innerHTML='';
						document.getElementById('copy_message_load').style.display='none';
						break;
				}
			
			}else{
			
				result_arr=result.split('{}');
				//alert (result_arr);
				if(result_arr[0]=='del_message')
					hide_message_details();
				else if(result_arr[0]!="message_list")
					document.getElementById(act_flag + "_row").style.display="none";
				if(act_flag!="")
					document.getElementById(act_flag).innerHTML=result_arr[1].substr(1);
				if(result_arr[0]=='new_message' && result_arr[1].substr(0,1)!=2)
				{ 
					<?php if($init_editor && HTML_AREA_WYSIWYG_DISABLE=='Enable'){?>
						initEditor('message_text');
					<?php }?>
				}
				init_editor_flag=true;
			 } // else 
			}
			function show_edit()
			{
			
				if(document.getElementById("edit_message"))
					document.getElementById("edit_message").style.display="";
				if(document.getElementById("delete_message"))
					document.getElementById("delete_message").style.display="none";
				
				if(document.getElementById("show_edit"))
					document.getElementById("show_edit").style.visibility="visible";
				if(document.getElementById("show_edit_bottom"))
					document.getElementById("show_edit_bottom").style.display="";
				if(document.getElementById("show_read_only"))
					document.getElementById("show_read_only").style.display="none";
				document.getElementById("show_edit_screen").style.display="";
				//alert(document.getElementById("show_edit_screen").innerHTML);
				if(init_editor_flag)
				{
					<?php if($init_editor && HTML_AREA_WYSIWYG_DISABLE=='Enable'){?>
						initEditor('message_text');
					<?php }?>
					init_editor_flag=false;
				}
			}
			function close_edit()
			{ 
				var tr1=document.getElementById("img_ids");
				var imgsrc;
				var node;
				if(tr1)
				for(var j=0;j<tr1.cells.length;j++){
					td=tr1.cells[j];
					imgsrc='';
					for(var i=0;i<td.childNodes.length;i++){
						node=td.childNodes[i];
						if(node.tagName=='IMG'){
							imgsrc=node.src;
							if(imgsrc==img_src+'template/img_edit_hover.gif')
							   td.childNodes[i].src = img_src+'template/img_edit.gif';
							else if(imgsrc==img_src+'template/img_trash_hover.gif')
							   td.childNodes[i].src = img_src+'template/img_trash.gif';
							break;
						}
					}
				}
				
				if(document.getElementById('edit_message'))
					document.getElementById('edit_message').style.display="none";						
				if(document.getElementById('delete_message'))
					document.getElementById('delete_message').style.display="none";						
				
				if(document.getElementById("show_read_only"))
				{
				if(document.getElementById('show_edit'))
					document.getElementById('show_edit').style.visibility="hidden";						
				if(document.getElementById("show_edit_bottom"))
						document.getElementById("show_edit_bottom").style.display="none";
					document.getElementById("show_read_only").style.display="";
					document.getElementById("show_edit_screen").style.display="none";
				}
				else
					 hide_message_details();
			}
			function do_submit(mode,msg_id,eve_id)
			{ 
			var ifr=document.getElementById('if_message_text');


			<?php if($init_editor && HTML_AREA_WYSIWYG_DISABLE=='Enable'){?>
			document.getElementById('message_text').value=ifr.contentWindow.document.body.innerHTML;
			<?php }?>
				
				if(validateForm())
				{
					command="<?php echo $submit_pagename?>?action=" + mode + "&" + var_name + "="+eve_id + "&id=" + msg_id;
					do_post_command('insert_message',command);
				}
			 }	
				
			function do_delete(msg_id,eve_id,msg_type)
			{
				if(document.getElementById("edit_message"))
					document.getElementById("edit_message").style.display="none";
				if(document.getElementById("delete_message"))
					document.getElementById("delete_message").style.display="";
				if(confirm("<?php echo TEXT_DELETE_CONFIRM;?>"))
				{
					command="<?php echo tep_href_link($submit_pagename,'action=delete_message');?>&" + var_name + "="+eve_id + "&id=" + msg_id + "&msg_type=" + msg_type;
					do_get_command(command);	
				}else{
				if(document.getElementById("edit_message"))
					document.getElementById("edit_message").style.display="none";
				if(document.getElementById("delete_message"))
					document.getElementById("delete_message").style.display="none";
				
				var tr1=document.getElementById("img_ids");
				var imgsrc;
				var node;
				if(tr1)
				for(var j=0;j<tr1.cells.length;j++){
					td=tr1.cells[j];
					imgsrc='';
					for(var i=0;i<td.childNodes.length;i++){
						node=td.childNodes[i];
						if(node.tagName=='IMG'){
							imgsrc=node.src;
							if(imgsrc==img_src+'template/img_edit_hover.gif')
							   td.childNodes[i].src = img_src+'template/img_edit.gif';
							else if(imgsrc==img_src+'template/img_trash_hover.gif')
							   td.childNodes[i].src = img_src+'template/img_trash.gif';
							break;
						}
					}
				}			 
			  }	
			}
			function do_test_send(msg_type,eve_id)
			{
				if(confirm("<?php echo TEXT_TEST_CONFIRM;?>"))
				{
					command="<?php echo tep_href_link($submit_pagename,'action=test_send');?>&" + var_name + "="+eve_id +  "&msg_type=" + msg_type;
					do_get_command(command);		
				}
			}
			function do_change_send(eve_id)
			{
				command="<?php echo tep_href_link($submit_pagename,'action=change_send');?>&" + var_name + "="+eve_id ;
				do_post_command('message_type',command);	
			}
		
			 function do_hover_change(element,eve){ 
				 var span_edit=document.getElementById("edit_message");
				 var span_delete=document.getElementById("delete_message");

				 if(element){		   		    		    
					var img_get_src=element.childNodes[0];
					if(img_get_src){
						if(img_get_src.src==img_src+'template/img_edit.gif') {
							if(span_edit && span_edit.style.display=="" && eve==1 || eve==2){
								img_get_src.src=img_src+'template/img_edit_hover.gif';
							}  		   		 	 			 	 			
						}else if(eve==3 && img_get_src.src==img_src+'template/img_edit_hover.gif' && span_edit  && span_edit.style.display=="none") img_get_src.src=img_src+'template/img_edit.gif';
						if(img_get_src.src==img_src+'template/img_trash.gif') {
							if(span_delete && span_delete.style.display=="" && eve==1 || eve==2){
								img_get_src.src=img_src+'template/img_trash_hover.gif';
							}  		   		 	 			 	 			
						}else if(eve==3 && img_get_src.src==img_src+'template/img_trash_hover.gif' && (span_delete)  && (span_delete.style.display=="none")) img_get_src.src=img_src+'template/img_trash.gif';
				  }
				 }		 
			 }  	

		</Script>
