includes/clientside/static/ajax.js
changeset 1227 bdac73ed481e
parent 1226 de56132c008d
child 1246 330f4de4c937
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
     2  * AJAX applets
     2  * AJAX applets
     3  */
     3  */
     4  
     4  
     5 window.ajaxReset = function()
     5 window.ajaxReset = function()
     6 {
     6 {
     7   // IE <6 pseudo-compatibility
     7 	// IE <6 pseudo-compatibility
     8   if ( KILL_SWITCH )
     8 	if ( KILL_SWITCH )
     9     return true;
     9 		return true;
    10   var ns_id = strToPageID(physical_title);
    10 	var ns_id = strToPageID(physical_title);
    11   if ( ns_id[1] == 'Special' || ns_id[1] == 'Admin' )
    11 	if ( ns_id[1] == 'Special' || ns_id[1] == 'Admin' )
    12     return false;
    12 		return false;
    13   enableUnload();
    13 	enableUnload();
    14   setAjaxLoading();
    14 	setAjaxLoading();
    15   var redir = ( disable_redirect ) ? '&redirect=no' : '';
    15 	var redir = ( disable_redirect ) ? '&redirect=no' : '';
    16   ajaxGet(append_sid(scriptPath + '/ajax.php?title=' + physical_title +'&_mode=getpage&noheaders' + redir), function(ajax) {
    16 	ajaxGet(append_sid(scriptPath + '/ajax.php?title=' + physical_title +'&_mode=getpage&noheaders' + redir), function(ajax) {
    17     // Allow for 404 here, it's generated by the "page not found" error message
    17 		// Allow for 404 here, it's generated by the "page not found" error message
    18     // (even with noheaders specified, probably should be fixed)
    18 		// (even with noheaders specified, probably should be fixed)
    19     if ( ajax.readyState == 4 && ( ajax.status == 200 || ajax.status == 404 ) ) {
    19 		if ( ajax.readyState == 4 && ( ajax.status == 200 || ajax.status == 404 ) ) {
    20       unsetAjaxLoading();
    20 			unsetAjaxLoading();
    21       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
    21 			document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
    22       selectButtonMajor('article');
    22 			selectButtonMajor('article');
    23       unselectAllButtonsMinor();
    23 			unselectAllButtonsMinor();
    24       // if we're on a userpage, call the onload function to rebuild the tabs
    24 			// if we're on a userpage, call the onload function to rebuild the tabs
    25       if ( typeof(userpage_onload) == 'function' )
    25 			if ( typeof(userpage_onload) == 'function' )
    26       {
    26 			{
    27         window.userpage_blocks = [];
    27 				window.userpage_blocks = [];
    28         userpage_onload();
    28 				userpage_onload();
    29       }
    29 			}
    30     }
    30 		}
    31   });
    31 	});
    32 }
    32 }
    33 
    33 
    34 // Miscellaneous AJAX applets
    34 // Miscellaneous AJAX applets
    35 
    35 
    36 window.ajaxProtect = function(existing_level)
    36 window.ajaxProtect = function(existing_level)
    37 {
    37 {
    38   // IE <6 pseudo-compatibility
    38 	// IE <6 pseudo-compatibility
    39   if ( KILL_SWITCH )
    39 	if ( KILL_SWITCH )
    40     return true;
    40 		return true;
    41   
    41 	
    42   // touch this variable to allow it to be used in child functions
    42 	// touch this variable to allow it to be used in child functions
    43   void(existing_level);
    43 	void(existing_level);
    44   
    44 	
    45   // require re-auth
    45 	// require re-auth
    46   if ( auth_level <= USER_LEVEL_MEMBER )
    46 	if ( auth_level <= USER_LEVEL_MEMBER )
    47   {
    47 	{
    48     load_component(['login', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'crypto', 'messagebox']);
    48 		load_component(['login', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'crypto', 'messagebox']);
    49     ajaxDynamicReauth(function(key)
    49 		ajaxDynamicReauth(function(key)
    50       {
    50 			{
    51         ajaxProtect(existing_level);
    51 				ajaxProtect(existing_level);
    52       }, user_level);
    52 			}, user_level);
    53     
    53 		
    54     return false;
    54 		return false;
    55   }
    55 	}
    56   
    56 	
    57   load_component(['messagebox', 'jquery', 'jquery-ui', 'l10n', 'fadefilter', 'flyin']);
    57 	load_component(['messagebox', 'jquery', 'jquery-ui', 'l10n', 'fadefilter', 'flyin']);
    58   
    58 	
    59   // preload language
    59 	// preload language
    60   $lang.get('meta_meta');
    60 	$lang.get('meta_meta');
    61   
    61 	
    62   var mp = miniPrompt(function(parent)
    62 	var mp = miniPrompt(function(parent)
    63     {
    63 		{
    64       var icon_full = gen_sprite_html(cdnPath + '/images/protect-icons.png', 22, 22, 0, 0);
    64 			var icon_full = gen_sprite_html(cdnPath + '/images/protect-icons.png', 22, 22, 0, 0);
    65       var icon_semi = gen_sprite_html(cdnPath + '/images/protect-icons.png', 22, 22, 22, 0);
    65 			var icon_semi = gen_sprite_html(cdnPath + '/images/protect-icons.png', 22, 22, 22, 0);
    66       var icon_none = gen_sprite_html(cdnPath + '/images/protect-icons.png', 22, 22, 44, 0);
    66 			var icon_none = gen_sprite_html(cdnPath + '/images/protect-icons.png', 22, 22, 44, 0);
    67       
    67 			
    68       $(parent).append('<h3>' + $lang.get('onpage_protect_heading') + '</h3>');
    68 			$(parent).append('<h3>' + $lang.get('onpage_protect_heading') + '</h3>');
    69       $(parent).append('<p>' + $lang.get('onpage_protect_msg_select_level') + '</p>');
    69 			$(parent).append('<p>' + $lang.get('onpage_protect_msg_select_level') + '</p>');
    70       
    70 			
    71       $(parent).append('<div class="protectlevel"><label><input type="radio" id="protect_level_1" name="protect_level" /> ' + icon_full + ' ' + $lang.get('onpage_protect_btn_full') + '</label></div>');
    71 			$(parent).append('<div class="protectlevel"><label><input type="radio" id="protect_level_1" name="protect_level" /> ' + icon_full + ' ' + $lang.get('onpage_protect_btn_full') + '</label></div>');
    72       $(parent).append('<div class="protectlevel_hint" id="protect_level_1_hint">' + $lang.get('onpage_protect_btn_full_hint') + '</div>');
    72 			$(parent).append('<div class="protectlevel_hint" id="protect_level_1_hint">' + $lang.get('onpage_protect_btn_full_hint') + '</div>');
    73       $(parent).append('<div class="protectlevel"><label><input type="radio" id="protect_level_2" name="protect_level" /> ' + icon_semi + ' ' + $lang.get('onpage_protect_btn_semi') + '</label></div>');
    73 			$(parent).append('<div class="protectlevel"><label><input type="radio" id="protect_level_2" name="protect_level" /> ' + icon_semi + ' ' + $lang.get('onpage_protect_btn_semi') + '</label></div>');
    74       $(parent).append('<div class="protectlevel_hint" id="protect_level_2_hint">' + $lang.get('onpage_protect_btn_semi_hint') + '</div>');
    74 			$(parent).append('<div class="protectlevel_hint" id="protect_level_2_hint">' + $lang.get('onpage_protect_btn_semi_hint') + '</div>');
    75       $(parent).append('<div class="protectlevel"><label><input type="radio" id="protect_level_0" name="protect_level" /> ' + icon_none + ' ' + $lang.get('onpage_protect_btn_none') + '</label></div>');
    75 			$(parent).append('<div class="protectlevel"><label><input type="radio" id="protect_level_0" name="protect_level" /> ' + icon_none + ' ' + $lang.get('onpage_protect_btn_none') + '</label></div>');
    76       $(parent).append('<div class="protectlevel_hint" id="protect_level_0_hint">' + $lang.get('onpage_protect_btn_none_hint') + '</div>');
    76 			$(parent).append('<div class="protectlevel_hint" id="protect_level_0_hint">' + $lang.get('onpage_protect_btn_none_hint') + '</div>');
    77       
    77 			
    78       $(parent).append('<table class="protectreason"><tr><td valign="top">' + $lang.get('onpage_protect_lbl_reason') + '</td><td><input id="protect_reason" size="30" type="text" /><br /><small>' + $lang.get('onpage_protect_lbl_reason_hint') + '</small></td></tr></table>');
    78 			$(parent).append('<table class="protectreason"><tr><td valign="top">' + $lang.get('onpage_protect_lbl_reason') + '</td><td><input id="protect_reason" size="30" type="text" /><br /><small>' + $lang.get('onpage_protect_lbl_reason_hint') + '</small></td></tr></table>');
    79       
    79 			
    80       $(parent).append('<p class="buttons"><a class="submitbutton abutton abutton_green" style="font-weight: bold;" href="#" onclick="ajaxProtectSubmit(this); return false;">' + $lang.get('onpage_protect_btn_submit') + '</a> <a class="submitbutton abutton" href="#" onclick="miniPromptDestroy(this); return false;">' + $lang.get('etc_cancel') + '</a></p>');
    80 			$(parent).append('<p class="buttons"><a class="submitbutton abutton abutton_green" style="font-weight: bold;" href="#" onclick="ajaxProtectSubmit(this); return false;">' + $lang.get('onpage_protect_btn_submit') + '</a> <a class="submitbutton abutton" href="#" onclick="miniPromptDestroy(this); return false;">' + $lang.get('etc_cancel') + '</a></p>');
    81       
    81 			
    82       $('.protectlevel', parent).css('line-height', '22px');
    82 			$('.protectlevel', parent).css('line-height', '22px');
    83       $('h3', parent).css('text-align', 'center');
    83 			$('h3', parent).css('text-align', 'center');
    84       $('.protectlevel_hint', parent)
    84 			$('.protectlevel_hint', parent)
    85         .css('font-size', 'smaller')
    85 				.css('font-size', 'smaller')
    86         .css('margin-left', '52px')
    86 				.css('margin-left', '52px')
    87         .hide();
    87 				.hide();
    88       $('p.buttons', parent).css('margin-top', '15px').css('text-align', 'center');
    88 			$('p.buttons', parent).css('margin-top', '15px').css('text-align', 'center');
    89       
    89 			
    90       if ( typeof(existing_level) == 'number' )
    90 			if ( typeof(existing_level) == 'number' )
    91       {
    91 			{
    92         $('#protect_level_' + existing_level, parent).attr('checked', 'checked');
    92 				$('#protect_level_' + existing_level, parent).attr('checked', 'checked');
    93         $('#protect_level_' + existing_level + '_hint', parent).show();
    93 				$('#protect_level_' + existing_level + '_hint', parent).show();
    94         $('#protect_level_' + existing_level, parent).parent().append(' <small><span style="color: #050; background-color: #eee; padding: 0 4px;">' + $lang.get('onpage_protect_lbl_current') + '</span></small>');
    94 				$('#protect_level_' + existing_level, parent).parent().append(' <small><span style="color: #050; background-color: #eee; padding: 0 4px;">' + $lang.get('onpage_protect_lbl_current') + '</span></small>');
    95       }
    95 			}
    96       
    96 			
    97       $('input:radio', parent).click(function()
    97 			$('input:radio', parent).click(function()
    98         {
    98 				{
    99           var mp = miniPromptGetParent(this);
    99 					var mp = miniPromptGetParent(this);
   100           $('.protectlevel_hint:visible', mp).hide('blind', 150);
   100 					$('.protectlevel_hint:visible', mp).hide('blind', 150);
   101           $('#' + this.id + '_hint').show('blind', 150);
   101 					$('#' + this.id + '_hint').show('blind', 150);
   102           $('#protect_reason').focus();
   102 					$('#protect_reason').focus();
   103         });
   103 				});
   104       $('input:text', parent).keyup(function(e)
   104 			$('input:text', parent).keyup(function(e)
   105         {
   105 				{
   106           if ( e.keyCode == 13 )
   106 					if ( e.keyCode == 13 )
   107             ajaxProtectSubmit(this);
   107 						ajaxProtectSubmit(this);
   108         });
   108 				});
   109     });
   109 		});
   110 }
   110 }
   111 
   111 
   112 window.ajaxProtectSubmit = function(el)
   112 window.ajaxProtectSubmit = function(el)
   113 {
   113 {
   114   var mp = miniPromptGetParent(el);
   114 	var mp = miniPromptGetParent(el);
   115   
   115 	
   116   var reason = trim($('#protect_reason', mp).attr('value'));
   116 	var reason = trim($('#protect_reason', mp).attr('value'));
   117   if ( reason == '' )
   117 	if ( reason == '' )
   118   {
   118 	{
   119     var oldbg = $('#protect_reason').css('background-color');
   119 		var oldbg = $('#protect_reason').css('background-color');
   120     if ( jQuery.fx.off )
   120 		if ( jQuery.fx.off )
   121     {
   121 		{
   122       $('#protect_reason').css('background-color', '#a00');
   122 			$('#protect_reason').css('background-color', '#a00');
   123       setTimeout(function()
   123 			setTimeout(function()
   124         {
   124 				{
   125           $('#protect_reason').css('background-color', oldbg);
   125 					$('#protect_reason').css('background-color', oldbg);
   126         }, 1000);
   126 				}, 1000);
   127     }
   127 		}
   128     else
   128 		else
   129     {
   129 		{
   130       $('#protect_reason').css('background-color', '#a00').animate({ backgroundColor: oldbg }, 1000);
   130 			$('#protect_reason').css('background-color', '#a00').animate({ backgroundColor: oldbg }, 1000);
   131     }
   131 		}
   132     return false;
   132 		return false;
   133   }
   133 	}
   134   
   134 	
   135   var level = 0;
   135 	var level = 0;
   136   if ( $('#protect_level_1', mp).attr('checked') )
   136 	if ( $('#protect_level_1', mp).attr('checked') )
   137     level = 1;
   137 		level = 1;
   138   if ( $('#protect_level_2', mp).attr('checked') )
   138 	if ( $('#protect_level_2', mp).attr('checked') )
   139     level = 2;
   139 		level = 2;
   140   
   140 	
   141   var whitey = whiteOutMiniPrompt(mp);
   141 	var whitey = whiteOutMiniPrompt(mp);
   142   $.post(stdAjaxPrefix + '&_mode=protect', { level: level, reason: reason }, function(response, statustext)
   142 	$.post(stdAjaxPrefix + '&_mode=protect', { level: level, reason: reason }, function(response, statustext)
   143     {
   143 		{
   144       if ( response.success )
   144 			if ( response.success )
   145       {
   145 			{
   146         whiteOutReportSuccess(whitey);
   146 				whiteOutReportSuccess(whitey);
   147         // update protect button
   147 				// update protect button
   148         var btn = $('#tb_ajax_protect_btn').get(0);
   148 				var btn = $('#tb_ajax_protect_btn').get(0);
   149         btn.level = level;
   149 				btn.level = level;
   150         btn.setAttribute('onclick', null);
   150 				btn.setAttribute('onclick', null);
   151         btn.onclick = null;
   151 				btn.onclick = null;
   152         $(btn).click(function()
   152 				$(btn).click(function()
   153           {
   153 					{
   154             ajaxProtect(this.level);
   154 						ajaxProtect(this.level);
   155             return false;
   155 						return false;
   156           });
   156 					});
   157         var status = '';
   157 				var status = '';
   158         switch(level)
   158 				switch(level)
   159         {
   159 				{
   160           case 1: status = $lang.get('onpage_btn_protect_on'); break;
   160 					case 1: status = $lang.get('onpage_btn_protect_on'); break;
   161           case 0: status = $lang.get('onpage_btn_protect_off'); break;
   161 					case 0: status = $lang.get('onpage_btn_protect_off'); break;
   162           case 2: status = $lang.get('onpage_btn_protect_semi'); break;
   162 					case 2: status = $lang.get('onpage_btn_protect_semi'); break;
   163         }
   163 				}
   164         $('#tb_ajax_protect_status').text(status);
   164 				$('#tb_ajax_protect_status').text(status);
   165       }
   165 			}
   166       else
   166 			else
   167       {
   167 			{
   168         whiteOutReportFailure(whitey);
   168 				whiteOutReportFailure(whitey);
   169         alert($lang.get('page_err_' + response.error));
   169 				alert($lang.get('page_err_' + response.error));
   170       }
   170 			}
   171     }, 'json');
   171 		}, 'json');
   172 }
   172 }
   173 
   173 
   174 window.ajaxRename = function()
   174 window.ajaxRename = function()
   175 {
   175 {
   176   // IE <6 pseudo-compatibility
   176 	// IE <6 pseudo-compatibility
   177   if ( KILL_SWITCH )
   177 	if ( KILL_SWITCH )
   178     return true;
   178 		return true;
   179   
   179 	
   180   // updated - 1.1.4 to use miniPrompt
   180 	// updated - 1.1.4 to use miniPrompt
   181   load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
   181 	load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
   182   miniPrompt(ajaxRenameConstructDialog);
   182 	miniPrompt(ajaxRenameConstructDialog);
   183 }
   183 }
   184 
   184 
   185 var ajaxRenameConstructDialog = function(div)
   185 var ajaxRenameConstructDialog = function(div)
   186 {
   186 {
   187   // title
   187 	// title
   188   var heading = document.createElement('h3');
   188 	var heading = document.createElement('h3');
   189   heading.appendChild(document.createTextNode($lang.get('ajax_rename_prompt_short')));
   189 	heading.appendChild(document.createTextNode($lang.get('ajax_rename_prompt_short')));
   190   div.appendChild(heading);
   190 	div.appendChild(heading);
   191   
   191 	
   192   // form
   192 	// form
   193   var form = document.createElement('form');
   193 	var form = document.createElement('form');
   194   form.action = 'javascript:void(0);';
   194 	form.action = 'javascript:void(0);';
   195   
   195 	
   196   // box
   196 	// box
   197   var box = document.createElement('input');
   197 	var box = document.createElement('input');
   198   box.size = '43';
   198 	box.size = '43';
   199   box.style.width = '100%';
   199 	box.style.width = '100%';
   200   form.appendChild(box);
   200 	form.appendChild(box);
   201   div.appendChild(form);
   201 	div.appendChild(form);
   202   
   202 	
   203   // notice
   203 	// notice
   204   var notice = document.createElement('small');
   204 	var notice = document.createElement('small');
   205   notice.appendChild(document.createTextNode($lang.get('ajax_rename_notice')));
   205 	notice.appendChild(document.createTextNode($lang.get('ajax_rename_notice')));
   206   div.appendChild(notice);
   206 	div.appendChild(notice);
   207   
   207 	
   208   // button area
   208 	// button area
   209   var btndiv = document.createElement('div');
   209 	var btndiv = document.createElement('div');
   210   btndiv.className = 'mp-buttons';
   210 	btndiv.className = 'mp-buttons';
   211   
   211 	
   212   // buttons
   212 	// buttons
   213   var btn_submit = document.createElement('a');
   213 	var btn_submit = document.createElement('a');
   214   btn_submit.href = '#';
   214 	btn_submit.href = '#';
   215   btn_submit.appendChild(document.createTextNode($lang.get('etc_go')));
   215 	btn_submit.appendChild(document.createTextNode($lang.get('etc_go')));
   216   btn_submit.className = 'abutton abutton_green';
   216 	btn_submit.className = 'abutton abutton_green';
   217   
   217 	
   218   var btn_cancel = document.createElement('a');
   218 	var btn_cancel = document.createElement('a');
   219   btn_cancel.href = '#';
   219 	btn_cancel.href = '#';
   220   btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel')));
   220 	btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel')));
   221   btn_cancel.className = 'abutton';
   221 	btn_cancel.className = 'abutton';
   222   
   222 	
   223   btndiv.appendChild(btn_submit);
   223 	btndiv.appendChild(btn_submit);
   224   btndiv.appendChild(document.createTextNode(' | '));
   224 	btndiv.appendChild(document.createTextNode(' | '));
   225   btndiv.appendChild(btn_cancel);
   225 	btndiv.appendChild(btn_cancel);
   226   div.appendChild(btndiv);
   226 	div.appendChild(btndiv);
   227   
   227 	
   228   // events
   228 	// events
   229   btn_submit.onclick = function()
   229 	btn_submit.onclick = function()
   230   {
   230 	{
   231     ajaxRenameSubmit(this);
   231 		ajaxRenameSubmit(this);
   232     return false;
   232 		return false;
   233   }
   233 	}
   234   btn_cancel.onclick = function()
   234 	btn_cancel.onclick = function()
   235   {
   235 	{
   236     miniPromptDestroy(this);
   236 		miniPromptDestroy(this);
   237     return false;
   237 		return false;
   238   }
   238 	}
   239   form.onsubmit = function()
   239 	form.onsubmit = function()
   240   {
   240 	{
   241     ajaxRenameSubmit(this);
   241 		ajaxRenameSubmit(this);
   242     return false;
   242 		return false;
   243   }
   243 	}
   244   
   244 	
   245   setTimeout(function()
   245 	setTimeout(function()
   246     {
   246 		{
   247       box.focus();
   247 			box.focus();
   248     }, ( aclDisableTransitionFX ? 200 : 750 ));
   248 		}, ( aclDisableTransitionFX ? 200 : 750 ));
   249 }
   249 }
   250 
   250 
   251 window.ajaxRenameSubmit = function(obj)
   251 window.ajaxRenameSubmit = function(obj)
   252 {
   252 {
   253   var box = miniPromptGetParent(obj);
   253 	var box = miniPromptGetParent(obj);
   254   if ( !box )
   254 	if ( !box )
   255     return false;
   255 		return false;
   256   
   256 	
   257   var input = box.getElementsByTagName('input')[0];
   257 	var input = box.getElementsByTagName('input')[0];
   258   if ( !input )
   258 	if ( !input )
   259     return false;
   259 		return false;
   260     
   260 		
   261   var newname = input.value;
   261 	var newname = input.value;
   262   newname = trim(newname);
   262 	newname = trim(newname);
   263   
   263 	
   264   if ( newname.length < 1 )
   264 	if ( newname.length < 1 )
   265   {
   265 	{
   266     alert($lang.get('ajax_rename_too_short'));
   266 		alert($lang.get('ajax_rename_too_short'));
   267     return false;
   267 		return false;
   268   }
   268 	}
   269   
   269 	
   270   if ( !newname )
   270 	if ( !newname )
   271   {
   271 	{
   272     return false;
   272 		return false;
   273   }
   273 	}
   274   
   274 	
   275   var innerBox = getElementsByClassName(box, 'div', 'mp-body')[0];
   275 	var innerBox = getElementsByClassName(box, 'div', 'mp-body')[0];
   276   var whiteout = whiteOutElement(innerBox);
   276 	var whiteout = whiteOutElement(innerBox);
   277   whiteout.style.width = ( $dynano(whiteout).Width() - 78 ) + 'px';
   277 	whiteout.style.width = ( $dynano(whiteout).Width() - 78 ) + 'px';
   278   whiteout.style.left = ( $dynano(whiteout).Left() + 44 ) + 'px';
   278 	whiteout.style.left = ( $dynano(whiteout).Left() + 44 ) + 'px';
   279   
   279 	
   280   ajaxPost(stdAjaxPrefix + '&_mode=rename', 'newtitle=' + ajaxEscape(newname), function(ajax)
   280 	ajaxPost(stdAjaxPrefix + '&_mode=rename', 'newtitle=' + ajaxEscape(newname), function(ajax)
   281     {
   281 		{
   282       if ( ajax.readyState == 4 && ajax.status == 200 )
   282 			if ( ajax.readyState == 4 && ajax.status == 200 )
   283       {
   283 			{
   284         whiteout.parentNode.removeChild(whiteout);
   284 				whiteout.parentNode.removeChild(whiteout);
   285         var response = String(ajax.responseText);
   285 				var response = String(ajax.responseText);
   286         if ( !check_json_response(response) )
   286 				if ( !check_json_response(response) )
   287         {
   287 				{
   288           handle_invalid_json(response);
   288 					handle_invalid_json(response);
   289           return false;
   289 					return false;
   290         }
   290 				}
   291         response = parseJSON(response);
   291 				response = parseJSON(response);
   292         if ( response.success )
   292 				if ( response.success )
   293         {
   293 				{
   294           miniPromptDestroy(box, true);
   294 					miniPromptDestroy(box, true);
   295           ajaxRenameDoClientTransform(newname);
   295 					ajaxRenameDoClientTransform(newname);
   296           new MessageBox( MB_OK|MB_ICONINFORMATION, $lang.get('ajax_rename_success_title'), $lang.get('ajax_rename_success_body', { page_name_new: newname }) );
   296 					new MessageBox( MB_OK|MB_ICONINFORMATION, $lang.get('ajax_rename_success_title'), $lang.get('ajax_rename_success_body', { page_name_new: newname }) );
   297           mb_previously_had_darkener = false;
   297 					mb_previously_had_darkener = false;
   298         }
   298 				}
   299         else
   299 				else
   300         {
   300 				{
   301           var errmsg = $lang.get('page_err_' + response.error);
   301 					var errmsg = $lang.get('page_err_' + response.error);
   302           alert(errmsg);
   302 					alert(errmsg);
   303         }
   303 				}
   304       }
   304 			}
   305     }, true);
   305 		}, true);
   306 }
   306 }
   307 
   307 
   308 window.ajaxRenameDoClientTransform = function(newname)
   308 window.ajaxRenameDoClientTransform = function(newname)
   309 {
   309 {
   310   var obj = document.getElementById('h2PageName');
   310 	var obj = document.getElementById('h2PageName');
   311   if ( obj )
   311 	if ( obj )
   312   {
   312 	{
   313     obj.firstChild.nodeValue = newname;
   313 		obj.firstChild.nodeValue = newname;
   314   }
   314 	}
   315   document.title = newname;
   315 	document.title = newname;
   316 }
   316 }
   317 
   317 
   318 window.ajaxDeletePage = function()
   318 window.ajaxDeletePage = function()
   319 {
   319 {
   320   // IE <6 pseudo-compatibility
   320 	// IE <6 pseudo-compatibility
   321   if ( KILL_SWITCH )
   321 	if ( KILL_SWITCH )
   322     return true;
   322 		return true;
   323   
   323 	
   324   // require re-auth
   324 	// require re-auth
   325   if ( auth_level <= USER_LEVEL_MEMBER )
   325 	if ( auth_level <= USER_LEVEL_MEMBER )
   326   {
   326 	{
   327     load_component(['login', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'crypto', 'messagebox']);
   327 		load_component(['login', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'crypto', 'messagebox']);
   328     ajaxDynamicReauth(function(key)
   328 		ajaxDynamicReauth(function(key)
   329       {
   329 			{
   330         ajaxDeletePage();
   330 				ajaxDeletePage();
   331       }, user_level);
   331 			}, user_level);
   332     
   332 		
   333     return false;
   333 		return false;
   334   }
   334 	}
   335   
   335 	
   336   load_component(['l10n', 'messagebox', 'jquery', 'jquery-ui', 'fadefilter', 'flyin']);
   336 	load_component(['l10n', 'messagebox', 'jquery', 'jquery-ui', 'fadefilter', 'flyin']);
   337   
   337 	
   338   // stage 1: prompt for reason and confirmation
   338 	// stage 1: prompt for reason and confirmation
   339   miniPrompt(function(parent)
   339 	miniPrompt(function(parent)
   340     {
   340 		{
   341       // heading/title
   341 			// heading/title
   342       var h3 = document.createElement('h3');
   342 			var h3 = document.createElement('h3');
   343       h3.appendChild(document.createTextNode($lang.get('ajax_delete_header')));
   343 			h3.appendChild(document.createTextNode($lang.get('ajax_delete_header')));
   344       parent.appendChild(h3);
   344 			parent.appendChild(h3);
   345       
   345 			
   346       // "please enter your reason"
   346 			// "please enter your reason"
   347       var p1 = document.createElement('p');
   347 			var p1 = document.createElement('p');
   348       p1.appendChild(document.createTextNode($lang.get('ajax_delete_prompt_reason')));
   348 			p1.appendChild(document.createTextNode($lang.get('ajax_delete_prompt_reason')));
   349       parent.appendChild(p1);
   349 			parent.appendChild(p1);
   350       
   350 			
   351       // textbox + label thereof
   351 			// textbox + label thereof
   352       var p2 = document.createElement('p');
   352 			var p2 = document.createElement('p');
   353       var tb = document.createElement('input');
   353 			var tb = document.createElement('input');
   354       var dl = document.createElement('label');
   354 			var dl = document.createElement('label');
   355       
   355 			
   356       tb.type = 'text';
   356 			tb.type = 'text';
   357       tb.size = '30';
   357 			tb.size = '30';
   358       tb.onkeyup = function(e)
   358 			tb.onkeyup = function(e)
   359       {
   359 			{
   360         if ( e )
   360 				if ( e )
   361         if ( e.keyCode )
   361 				if ( e.keyCode )
   362         if ( e.keyCode == 13 )
   362 				if ( e.keyCode == 13 )
   363         {
   363 				{
   364           if ( ajaxDeletePageSubmit(this) )
   364 					if ( ajaxDeletePageSubmit(this) )
   365           {
   365 					{
   366             miniPromptDestroy(this);
   366 						miniPromptDestroy(this);
   367           }
   367 					}
   368         }
   368 				}
   369         else if ( e.keyCode == 27 )
   369 				else if ( e.keyCode == 27 )
   370         {
   370 				{
   371           miniPromptDestroy(this);
   371 					miniPromptDestroy(this);
   372         }
   372 				}
   373       }
   373 			}
   374       
   374 			
   375       dl.appendChild(document.createTextNode($lang.get('ajax_delete_lbl_reason') + ' '));
   375 			dl.appendChild(document.createTextNode($lang.get('ajax_delete_lbl_reason') + ' '));
   376       dl.appendChild(tb);
   376 			dl.appendChild(tb);
   377       p2.appendChild(dl);
   377 			p2.appendChild(dl);
   378       parent.appendChild(p2);
   378 			parent.appendChild(p2);
   379       
   379 			
   380       // notice underneath
   380 			// notice underneath
   381       var p3 = document.createElement('p');
   381 			var p3 = document.createElement('p');
   382       p3.style.fontSize = 'smaller';
   382 			p3.style.fontSize = 'smaller';
   383       p3.appendChild(document.createTextNode($lang.get('ajax_delete_msg_confirm')));
   383 			p3.appendChild(document.createTextNode($lang.get('ajax_delete_msg_confirm')));
   384       parent.appendChild(p3);
   384 			parent.appendChild(p3);
   385       
   385 			
   386       // confirmation + submit/cancel (structure)
   386 			// confirmation + submit/cancel (structure)
   387       var divleft  = document.createElement('div');
   387 			var divleft  = document.createElement('div');
   388       var divright = document.createElement('div');
   388 			var divright = document.createElement('div');
   389       var divclear = document.createElement('div');
   389 			var divclear = document.createElement('div');
   390       
   390 			
   391       divleft.style.cssFloat = 'left';
   391 			divleft.style.cssFloat = 'left';
   392       divleft.style.styleFloat = 'left';
   392 			divleft.style.styleFloat = 'left';
   393       
   393 			
   394       divright.style.cssFloat = 'right';
   394 			divright.style.cssFloat = 'right';
   395       divright.style.styleFloat = 'right';
   395 			divright.style.styleFloat = 'right';
   396       
   396 			
   397       divclear.style.clear = 'both';
   397 			divclear.style.clear = 'both';
   398       
   398 			
   399       parent.appendChild(divleft);
   399 			parent.appendChild(divleft);
   400       parent.appendChild(divright);
   400 			parent.appendChild(divright);
   401       parent.appendChild(divclear);
   401 			parent.appendChild(divclear);
   402       
   402 			
   403       // confirmation + submit/cancel (controls)
   403 			// confirmation + submit/cancel (controls)
   404       var cb = document.createElement('input');
   404 			var cb = document.createElement('input');
   405       var cl = document.createElement('label');
   405 			var cl = document.createElement('label');
   406       
   406 			
   407       cb.type = 'checkbox';
   407 			cb.type = 'checkbox';
   408       cb.checked = false;
   408 			cb.checked = false;
   409       
   409 			
   410       // a bit of a hack here, doesn't seem to work in fx3
   410 			// a bit of a hack here, doesn't seem to work in fx3
   411       cb.onblur = function(e)
   411 			cb.onblur = function(e)
   412       {
   412 			{
   413         var parent = this.parentNode.parentNode.parentNode;
   413 				var parent = this.parentNode.parentNode.parentNode;
   414         var submitter = parent.getElementsByTagName('a')[0];
   414 				var submitter = parent.getElementsByTagName('a')[0];
   415         if ( submitter )
   415 				if ( submitter )
   416           submitter.focus();
   416 					submitter.focus();
   417       }
   417 			}
   418       
   418 			
   419       cl.appendChild(cb);
   419 			cl.appendChild(cb);
   420       cl.appendChild(document.createTextNode(' ' + $lang.get('ajax_delete_lbl_confirm')));
   420 			cl.appendChild(document.createTextNode(' ' + $lang.get('ajax_delete_lbl_confirm')));
   421       divleft.appendChild(cl);
   421 			divleft.appendChild(cl);
   422       
   422 			
   423       var btn_submit = document.createElement('a');
   423 			var btn_submit = document.createElement('a');
   424       btn_submit.className = 'abutton abutton_red';
   424 			btn_submit.className = 'abutton abutton_red';
   425       btn_submit.href = '#';
   425 			btn_submit.href = '#';
   426       btn_submit.appendChild(document.createTextNode($lang.get('ajax_delete_btn_delete')));
   426 			btn_submit.appendChild(document.createTextNode($lang.get('ajax_delete_btn_delete')));
   427       btn_submit.onclick = function()
   427 			btn_submit.onclick = function()
   428       {
   428 			{
   429         if ( ajaxDeletePageSubmit(this) )
   429 				if ( ajaxDeletePageSubmit(this) )
   430         {
   430 				{
   431           miniPromptDestroy(this);
   431 					miniPromptDestroy(this);
   432         }
   432 				}
   433         return false;
   433 				return false;
   434       }
   434 			}
   435       
   435 			
   436       var btn_cancel = document.createElement('a');
   436 			var btn_cancel = document.createElement('a');
   437       btn_cancel.className = 'abutton';
   437 			btn_cancel.className = 'abutton';
   438       btn_cancel.href = '#';
   438 			btn_cancel.href = '#';
   439       btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel')));
   439 			btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel')));
   440       btn_cancel.onclick = function()
   440 			btn_cancel.onclick = function()
   441       {
   441 			{
   442         miniPromptDestroy(this);
   442 				miniPromptDestroy(this);
   443         return false;
   443 				return false;
   444       }
   444 			}
   445       
   445 			
   446       divright.appendChild(btn_submit);
   446 			divright.appendChild(btn_submit);
   447       divright.appendChild(document.createTextNode(' '));
   447 			divright.appendChild(document.createTextNode(' '));
   448       divright.appendChild(btn_cancel);
   448 			divright.appendChild(btn_cancel);
   449       
   449 			
   450       var timeout = ( aclDisableTransitionFX ) ? 10 : 1000;
   450 			var timeout = ( aclDisableTransitionFX ) ? 10 : 1000;
   451       setTimeout(function()
   451 			setTimeout(function()
   452         {
   452 				{
   453           tb.focus();
   453 					tb.focus();
   454         }, timeout);
   454 				}, timeout);
   455     });
   455 		});
   456 }
   456 }
   457 
   457 
   458 window.ajaxDeletePageSubmit = function(prompt_obj)
   458 window.ajaxDeletePageSubmit = function(prompt_obj)
   459 {
   459 {
   460   prompt_obj = miniPromptGetParent(prompt_obj).childNodes[1];
   460 	prompt_obj = miniPromptGetParent(prompt_obj).childNodes[1];
   461   var inputs = prompt_obj.getElementsByTagName('input');
   461 	var inputs = prompt_obj.getElementsByTagName('input');
   462   var reason = inputs[0];
   462 	var reason = inputs[0];
   463   var confirm = inputs[1];
   463 	var confirm = inputs[1];
   464   
   464 	
   465   if ( trim(reason.value) == '' )
   465 	if ( trim(reason.value) == '' )
   466   {
   466 	{
   467     // flash the background of the reason entry
   467 		// flash the background of the reason entry
   468     $(reason.parentNode).effect("highlight", {}, 1000);
   468 		$(reason.parentNode).effect("highlight", {}, 1000);
   469     return false;
   469 		return false;
   470   }
   470 	}
   471   
   471 	
   472   if ( !confirm.checked )
   472 	if ( !confirm.checked )
   473   {
   473 	{
   474     // flash the background of the confirm checkbox
   474 		// flash the background of the confirm checkbox
   475     $(confirm.parentNode).effect("highlight", {}, 1000);
   475 		$(confirm.parentNode).effect("highlight", {}, 1000);
   476     return false;
   476 		return false;
   477   }
   477 	}
   478   
   478 	
   479   prompt_obj.innerHTML = '<img alt="loading" style="display: block; margin: 0 auto;" src="' + cdnPath + '/images/loading-big.gif" />';
   479 	prompt_obj.innerHTML = '<img alt="loading" style="display: block; margin: 0 auto;" src="' + cdnPath + '/images/loading-big.gif" />';
   480   
   480 	
   481   // tenemos la confirmación y la razón - borre la página.
   481 	// tenemos la confirmación y la razón - borre la página.
   482   setAjaxLoading();
   482 	setAjaxLoading();
   483   ajaxPost(stdAjaxPrefix + '&_mode=deletepage', 'reason=' + ajaxEscape(trim(reason.value)), function(ajax)
   483 	ajaxPost(stdAjaxPrefix + '&_mode=deletepage', 'reason=' + ajaxEscape(trim(reason.value)), function(ajax)
   484     {
   484 		{
   485       if ( ajax.readyState == 4 && ajax.status == 200 )
   485 			if ( ajax.readyState == 4 && ajax.status == 200 )
   486       {
   486 			{
   487         unsetAjaxLoading();
   487 				unsetAjaxLoading();
   488         
   488 				
   489         // show the response in the same prompt window
   489 				// show the response in the same prompt window
   490         prompt_obj.style.textAlign = 'center';
   490 				prompt_obj.style.textAlign = 'center';
   491         prompt_obj.innerHTML = '';
   491 				prompt_obj.innerHTML = '';
   492         
   492 				
   493         var p1 = document.createElement('div');
   493 				var p1 = document.createElement('div');
   494         p1.style.marginBottom = '15px';
   494 				p1.style.marginBottom = '15px';
   495         p1.appendChild(document.createTextNode(ajax.responseText));
   495 				p1.appendChild(document.createTextNode(ajax.responseText));
   496         prompt_obj.appendChild(p1);
   496 				prompt_obj.appendChild(p1);
   497         
   497 				
   498         var p2 = document.createElement('p');
   498 				var p2 = document.createElement('p');
   499         var a = document.createElement('a');
   499 				var a = document.createElement('a');
   500         a.className = 'abutton';
   500 				a.className = 'abutton';
   501         a.href = '#';
   501 				a.href = '#';
   502         a.appendChild(document.createTextNode($lang.get('etc_close')));
   502 				a.appendChild(document.createTextNode($lang.get('etc_close')));
   503         a.onclick = function()
   503 				a.onclick = function()
   504         {
   504 				{
   505           miniPromptDestroy(this);
   505 					miniPromptDestroy(this);
   506           window.location.reload();
   506 					window.location.reload();
   507           return false;
   507 					return false;
   508         }
   508 				}
   509         p2.appendChild(a);
   509 				p2.appendChild(a);
   510         prompt_obj.appendChild(a);
   510 				prompt_obj.appendChild(a);
   511         
   511 				
   512         a.focus();
   512 				a.focus();
   513       }
   513 			}
   514     });
   514 		});
   515   
   515 	
   516   return true;
   516 	return true;
   517 }
   517 }
   518 
   518 
   519 window.ajaxDelVote = function()
   519 window.ajaxDelVote = function()
   520 {
   520 {
   521   load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
   521 	load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
   522   
   522 	
   523   // IE <6 pseudo-compatibility
   523 	// IE <6 pseudo-compatibility
   524   if ( KILL_SWITCH )
   524 	if ( KILL_SWITCH )
   525     return true;
   525 		return true;
   526   miniPromptMessage({
   526 	miniPromptMessage({
   527       title: $lang.get('ajax_delvote_confirm_title'),
   527 			title: $lang.get('ajax_delvote_confirm_title'),
   528       message: $lang.get('ajax_delvote_confirm_body'),
   528 			message: $lang.get('ajax_delvote_confirm_body'),
   529       buttons: [
   529 			buttons: [
   530         {
   530 				{
   531           text: $lang.get('ajax_delvote_btn_submit'),
   531 					text: $lang.get('ajax_delvote_btn_submit'),
   532           color: 'red',
   532 					color: 'red',
   533           style: {
   533 					style: {
   534             fontWeight: 'bold'
   534 						fontWeight: 'bold'
   535           },
   535 					},
   536           onclick: function(e)
   536 					onclick: function(e)
   537           {
   537 					{
   538             miniPromptDestroy(this);
   538 						miniPromptDestroy(this);
   539             setAjaxLoading();
   539 						setAjaxLoading();
   540             ajaxGet(stdAjaxPrefix+'&_mode=delvote', function(ajax) {
   540 						ajaxGet(stdAjaxPrefix+'&_mode=delvote', function(ajax) {
   541               if ( ajax.readyState == 4 && ajax.status == 200 ) {
   541 							if ( ajax.readyState == 4 && ajax.status == 200 ) {
   542                 unsetAjaxLoading();
   542 								unsetAjaxLoading();
   543                 alert(ajax.responseText);
   543 								alert(ajax.responseText);
   544               }
   544 							}
   545             }, true);
   545 						}, true);
   546           }
   546 					}
   547         },
   547 				},
   548         {
   548 				{
   549           text: $lang.get('etc_cancel'),
   549 					text: $lang.get('etc_cancel'),
   550           onclick: function(e)
   550 					onclick: function(e)
   551           {
   551 					{
   552             miniPromptDestroy(this);
   552 						miniPromptDestroy(this);
   553           }
   553 					}
   554         }
   554 				}
   555       ]
   555 			]
   556     });
   556 		});
   557 }
   557 }
   558 
   558 
   559 window.ajaxResetDelVotes = function()
   559 window.ajaxResetDelVotes = function()
   560 {
   560 {
   561   load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
   561 	load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
   562   
   562 	
   563   // IE <6 pseudo-compatibility
   563 	// IE <6 pseudo-compatibility
   564   if ( KILL_SWITCH )
   564 	if ( KILL_SWITCH )
   565     return true;
   565 		return true;
   566   miniPromptMessage({
   566 	miniPromptMessage({
   567       title: $lang.get('ajax_delvote_reset_confirm_title'),
   567 			title: $lang.get('ajax_delvote_reset_confirm_title'),
   568       message: $lang.get('ajax_delvote_reset_confirm_body'),
   568 			message: $lang.get('ajax_delvote_reset_confirm_body'),
   569       buttons: [
   569 			buttons: [
   570         {
   570 				{
   571           text: $lang.get('ajax_delvote_reset_btn_submit'),
   571 					text: $lang.get('ajax_delvote_reset_btn_submit'),
   572           color: 'red',
   572 					color: 'red',
   573           style: {
   573 					style: {
   574             fontWeight: 'bold'
   574 						fontWeight: 'bold'
   575           },
   575 					},
   576           onclick: function(e)
   576 					onclick: function(e)
   577           {
   577 					{
   578             var box = miniPromptGetParent(this);
   578 						var box = miniPromptGetParent(this);
   579             var whitey = whiteOutMiniPrompt(box);
   579 						var whitey = whiteOutMiniPrompt(box);
   580             ajaxGet(stdAjaxPrefix+'&_mode=resetdelvotes', function(ajax) {
   580 						ajaxGet(stdAjaxPrefix+'&_mode=resetdelvotes', function(ajax) {
   581               if ( ajax.readyState == 4 && ajax.status == 200 ) {
   581 							if ( ajax.readyState == 4 && ajax.status == 200 ) {
   582                 whiteOutReportSuccess(whitey);
   582 								whiteOutReportSuccess(whitey);
   583                 
   583 								
   584                 item = document.getElementById('mdgDeleteVoteNoticeBox');
   584 								item = document.getElementById('mdgDeleteVoteNoticeBox');
   585                 if(item)
   585 								if(item)
   586                 {
   586 								{
   587                   opacity('mdgDeleteVoteNoticeBox', 100, 0, 1000);
   587 									opacity('mdgDeleteVoteNoticeBox', 100, 0, 1000);
   588                   setTimeout("document.getElementById('mdgDeleteVoteNoticeBox').style.display = 'none';", 1000);
   588 									setTimeout("document.getElementById('mdgDeleteVoteNoticeBox').style.display = 'none';", 1000);
   589                 }
   589 								}
   590               }
   590 							}
   591             }, true);
   591 						}, true);
   592           }
   592 					}
   593         },
   593 				},
   594         {
   594 				{
   595           text: $lang.get('etc_cancel'),
   595 					text: $lang.get('etc_cancel'),
   596           onclick: function(e)
   596 					onclick: function(e)
   597           {
   597 					{
   598             miniPromptDestroy(this);
   598 						miniPromptDestroy(this);
   599           }
   599 					}
   600         }
   600 				}
   601       ]
   601 			]
   602     });
   602 		});
   603 }
   603 }
   604 
   604 
   605 // Editing/saving category information
   605 // Editing/saving category information
   606 // This was not easy to write, I hope enjoy it, and dang I swear I'm gonna
   606 // This was not easy to write, I hope enjoy it, and dang I swear I'm gonna
   607 // find someone to work on just the Javascript part of Enano...
   607 // find someone to work on just the Javascript part of Enano...
   608 
   608 
   609 window.ajaxCatEdit = function()
   609 window.ajaxCatEdit = function()
   610 {
   610 {
   611   // IE <6 pseudo-compatibility
   611 	// IE <6 pseudo-compatibility
   612   if ( KILL_SWITCH )
   612 	if ( KILL_SWITCH )
   613     return true;
   613 		return true;
   614   setAjaxLoading();
   614 	setAjaxLoading();
   615   ajaxGet(stdAjaxPrefix+'&_mode=catedit', function(ajax) {
   615 	ajaxGet(stdAjaxPrefix+'&_mode=catedit', function(ajax) {
   616     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   616 		if ( ajax.readyState == 4 && ajax.status == 200 ) {
   617       unsetAjaxLoading();
   617 			unsetAjaxLoading();
   618       edit_open = false;
   618 			edit_open = false;
   619       eval(ajax.responseText);
   619 			eval(ajax.responseText);
   620     }
   620 		}
   621   });
   621 	});
   622 }
   622 }
   623 
   623 
   624 window.ajaxCatSave = function()
   624 window.ajaxCatSave = function()
   625 {
   625 {
   626   // IE <6 pseudo-compatibility
   626 	// IE <6 pseudo-compatibility
   627   if ( KILL_SWITCH )
   627 	if ( KILL_SWITCH )
   628     return true;
   628 		return true;
   629   if(!catlist)
   629 	if(!catlist)
   630   {
   630 	{
   631     alert('Var catlist has no properties');
   631 		alert('Var catlist has no properties');
   632     return;
   632 		return;
   633   }
   633 	}
   634   query='';
   634 	query='';
   635   for(i=0;i<catlist.length;i++)
   635 	for(i=0;i<catlist.length;i++)
   636   {
   636 	{
   637     var s = ( document.forms.mdgCatForm['mdgCat_' + catlist[i]]['checked'] ) ? true : false;
   637 		var s = ( document.forms.mdgCatForm['mdgCat_' + catlist[i]]['checked'] ) ? true : false;
   638     if(s) query = query + '&' + catlist[i] + '=true';
   638 		if(s) query = query + '&' + catlist[i] + '=true';
   639   }
   639 	}
   640   setAjaxLoading();
   640 	setAjaxLoading();
   641   query = query.substring(1, query.length);
   641 	query = query.substring(1, query.length);
   642   ajaxPost(stdAjaxPrefix+'&_mode=catsave', query, function(ajax) {
   642 	ajaxPost(stdAjaxPrefix+'&_mode=catsave', query, function(ajax) {
   643     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   643 		if ( ajax.readyState == 4 && ajax.status == 200 ) {
   644       unsetAjaxLoading();
   644 			unsetAjaxLoading();
   645       edit_open = false;
   645 			edit_open = false;
   646       if(ajax.responseText != 'GOOD') alert(ajax.responseText);
   646 			if(ajax.responseText != 'GOOD') alert(ajax.responseText);
   647       ajaxReset();
   647 			ajaxReset();
   648     }
   648 		}
   649   });
   649 	});
   650 }
   650 }
   651 
   651 
   652 // History stuff
   652 // History stuff
   653 
   653 
   654 window.ajaxHistory = function()
   654 window.ajaxHistory = function()
   655 {
   655 {
   656   // IE <6 pseudo-compatibility
   656 	// IE <6 pseudo-compatibility
   657   if ( KILL_SWITCH )
   657 	if ( KILL_SWITCH )
   658     return true;
   658 		return true;
   659   setAjaxLoading();
   659 	setAjaxLoading();
   660   ajaxGet(stdAjaxPrefix+'&_mode=histlist', function(ajax) {
   660 	ajaxGet(stdAjaxPrefix+'&_mode=histlist', function(ajax) {
   661     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   661 		if ( ajax.readyState == 4 && ajax.status == 200 ) {
   662       unsetAjaxLoading();
   662 			unsetAjaxLoading();
   663       edit_open = false;
   663 			edit_open = false;
   664       selectButtonMajor('article');
   664 			selectButtonMajor('article');
   665       selectButtonMinor('history');
   665 			selectButtonMinor('history');
   666       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   666 			document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   667       buildDiffList();
   667 			buildDiffList();
   668     }
   668 		}
   669   });
   669 	});
   670 }
   670 }
   671 
   671 
   672 window.ajaxHistView = function(oldid, ttl) {
   672 window.ajaxHistView = function(oldid, ttl) {
   673   // IE <6 pseudo-compatibility
   673 	// IE <6 pseudo-compatibility
   674   if ( KILL_SWITCH )
   674 	if ( KILL_SWITCH )
   675     return true;
   675 		return true;
   676   if(!ttl) ttl=title;
   676 	if(!ttl) ttl=title;
   677   setAjaxLoading();
   677 	setAjaxLoading();
   678   ajaxGet(append_sid(scriptPath+'/ajax.php?title='+ttl+'&_mode=getpage&oldid='+oldid), function(ajax) {
   678 	ajaxGet(append_sid(scriptPath+'/ajax.php?title='+ttl+'&_mode=getpage&oldid='+oldid), function(ajax) {
   679     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   679 		if ( ajax.readyState == 4 && ajax.status == 200 ) {
   680       unsetAjaxLoading();
   680 			unsetAjaxLoading();
   681       edit_open = false;
   681 			edit_open = false;
   682       document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   682 			document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   683     }
   683 		}
   684   });
   684 	});
   685 }
   685 }
   686 
   686 
   687 window.ajaxRollback = function(id) {
   687 window.ajaxRollback = function(id) {
   688   // IE <6 pseudo-compatibility
   688 	// IE <6 pseudo-compatibility
   689   if ( KILL_SWITCH )
   689 	if ( KILL_SWITCH )
   690     return true;
   690 		return true;
   691   setAjaxLoading();
   691 	setAjaxLoading();
   692   ajaxGet(stdAjaxPrefix+'&_mode=rollback&id='+id, function(ajax) {
   692 	ajaxGet(stdAjaxPrefix+'&_mode=rollback&id='+id, function(ajax) {
   693     if ( ajax.readyState == 4 && ajax.status == 200 ) {
   693 		if ( ajax.readyState == 4 && ajax.status == 200 ) {
   694       unsetAjaxLoading();
   694 			unsetAjaxLoading();
   695       
   695 			
   696       var response = String(ajax.responseText + '');
   696 			var response = String(ajax.responseText + '');
   697       if ( !check_json_response(response) )
   697 			if ( !check_json_response(response) )
   698       {
   698 			{
   699         handle_invalid_json(response);
   699 				handle_invalid_json(response);
   700         return false;
   700 				return false;
   701       }
   701 			}
   702       
   702 			
   703       response = parseJSON(response);
   703 			response = parseJSON(response);
   704       if ( response.success )
   704 			if ( response.success )
   705       {
   705 			{
   706         alert( $lang.get('page_msg_rb_success_' + response.action, { dateline: response.dateline }) )
   706 				alert( $lang.get('page_msg_rb_success_' + response.action, { dateline: response.dateline }) )
   707       }
   707 			}
   708       else
   708 			else
   709       {
   709 			{
   710         if ( response.action )
   710 				if ( response.action )
   711         {
   711 				{
   712           alert( $lang.get('page_err_' + response.error, { action: response.action }) );
   712 					alert( $lang.get('page_err_' + response.error, { action: response.action }) );
   713         }
   713 				}
   714         else
   714 				else
   715         {
   715 				{
   716           alert( $lang.get('page_err_' + response.error) );
   716 					alert( $lang.get('page_err_' + response.error) );
   717         }
   717 				}
   718       }
   718 			}
   719     }
   719 		}
   720   });
   720 	});
   721 }
   721 }
   722 
   722 
   723 window.ajaxClearLogs = function()
   723 window.ajaxClearLogs = function()
   724 {
   724 {
   725   // IE <6 pseudo-compatibility
   725 	// IE <6 pseudo-compatibility
   726   if ( KILL_SWITCH )
   726 	if ( KILL_SWITCH )
   727     return true;
   727 		return true;
   728   
   728 	
   729   // require re-auth
   729 	// require re-auth
   730   if ( auth_level <= USER_LEVEL_MEMBER )
   730 	if ( auth_level <= USER_LEVEL_MEMBER )
   731   {
   731 	{
   732     load_component(['login', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'crypto', 'messagebox']);
   732 		load_component(['login', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'crypto', 'messagebox']);
   733     ajaxDynamicReauth(function(key)
   733 		ajaxDynamicReauth(function(key)
   734       {
   734 			{
   735         ajaxClearLogs();
   735 				ajaxClearLogs();
   736       }, user_level);
   736 			}, user_level);
   737     
   737 		
   738     return false;
   738 		return false;
   739   }
   739 	}
   740   
   740 	
   741   load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
   741 	load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
   742   
   742 	
   743   miniPromptMessage({
   743 	miniPromptMessage({
   744       title: $lang.get('ajax_clearlogs_confirm_title'),
   744 			title: $lang.get('ajax_clearlogs_confirm_title'),
   745       message: $lang.get('ajax_clearlogs_confirm_body'),
   745 			message: $lang.get('ajax_clearlogs_confirm_body'),
   746       buttons: [
   746 			buttons: [
   747         {
   747 				{
   748           text: $lang.get('ajax_clearlogs_btn_submit'),
   748 					text: $lang.get('ajax_clearlogs_btn_submit'),
   749           color: 'red',
   749 					color: 'red',
   750           style: {
   750 					style: {
   751             fontWeight: 'bold'
   751 						fontWeight: 'bold'
   752           },
   752 					},
   753           onclick: function(e)
   753 					onclick: function(e)
   754           {
   754 					{
   755             miniPromptDestroy(this);
   755 						miniPromptDestroy(this);
   756             setAjaxLoading();
   756 						setAjaxLoading();
   757             ajaxGet(stdAjaxPrefix+'&_mode=flushlogs', function(ajax) {
   757 						ajaxGet(stdAjaxPrefix+'&_mode=flushlogs', function(ajax) {
   758               if ( ajax.readyState == 4 && ajax.status == 200 ) {
   758 							if ( ajax.readyState == 4 && ajax.status == 200 ) {
   759                 unsetAjaxLoading();
   759 								unsetAjaxLoading();
   760                 alert(ajax.responseText);
   760 								alert(ajax.responseText);
   761                 window.location.reload();
   761 								window.location.reload();
   762               }
   762 							}
   763             });
   763 						});
   764           }
   764 					}
   765         },
   765 				},
   766         {
   766 				{
   767           text: $lang.get('etc_cancel'),
   767 					text: $lang.get('etc_cancel'),
   768           onclick: function(e)
   768 					onclick: function(e)
   769           {
   769 					{
   770             miniPromptDestroy(this);
   770 						miniPromptDestroy(this);
   771           }
   771 					}
   772         }
   772 				}
   773       ]
   773 			]
   774     });
   774 		});
   775 }
   775 }
   776 
   776 
   777 window.buildDiffList = function()
   777 window.buildDiffList = function()
   778 {
   778 {
   779   arrDiff1Buttons = getElementsByClassName(document, 'input', 'clsDiff1Radio');
   779 	arrDiff1Buttons = getElementsByClassName(document, 'input', 'clsDiff1Radio');
   780   arrDiff2Buttons = getElementsByClassName(document, 'input', 'clsDiff2Radio');
   780 	arrDiff2Buttons = getElementsByClassName(document, 'input', 'clsDiff2Radio');
   781   var len = arrDiff1Buttons.length;
   781 	var len = arrDiff1Buttons.length;
   782   if ( len < 1 )
   782 	if ( len < 1 )
   783     return false;
   783 		return false;
   784   timelist = new Array();
   784 	timelist = new Array();
   785   for ( var i = 0; i < len; i++ )
   785 	for ( var i = 0; i < len; i++ )
   786   {
   786 	{
   787     timelist.push( arrDiff2Buttons[i].id.substr(6) );
   787 		timelist.push( arrDiff2Buttons[i].id.substr(6) );
   788   }
   788 	}
   789   timelist.push( arrDiff1Buttons[len-1].id.substr(6) );
   789 	timelist.push( arrDiff1Buttons[len-1].id.substr(6) );
   790   delete(timelist.toJSONString);
   790 	delete(timelist.toJSONString);
   791   for ( var i = 1; i < timelist.length-1; i++ )
   791 	for ( var i = 1; i < timelist.length-1; i++ )
   792   {
   792 	{
   793     if ( i >= timelist.length ) break;
   793 		if ( i >= timelist.length ) break;
   794     arrDiff2Buttons[i].style.display = 'none';
   794 		arrDiff2Buttons[i].style.display = 'none';
   795   }
   795 	}
   796 }
   796 }
   797 
   797 
   798 window.selectDiff1Button = function(obj)
   798 window.selectDiff1Button = function(obj)
   799 {
   799 {
   800   var this_time = obj.id.substr(6);
   800 	var this_time = obj.id.substr(6);
   801   var index = parseInt(in_array(this_time, timelist));
   801 	var index = parseInt(in_array(this_time, timelist));
   802   for ( var i = 0; i < timelist.length - 1; i++ )
   802 	for ( var i = 0; i < timelist.length - 1; i++ )
   803   {
   803 	{
   804     if ( i < timelist.length - 1 )
   804 		if ( i < timelist.length - 1 )
   805     {
   805 		{
   806       var state = ( i < index ) ? 'inline' : 'none';
   806 			var state = ( i < index ) ? 'inline' : 'none';
   807       var id = 'diff2_' + timelist[i];
   807 			var id = 'diff2_' + timelist[i];
   808       document.getElementById(id).style.display = state;
   808 			document.getElementById(id).style.display = state;
   809       
   809 			
   810       // alert("Debug:\nIndex: "+index+"\nState: "+state+"\ni: "+i);
   810 			// alert("Debug:\nIndex: "+index+"\nState: "+state+"\ni: "+i);
   811     }
   811 		}
   812   }
   812 	}
   813 }
   813 }
   814 
   814 
   815 window.selectDiff2Button = function(obj)
   815 window.selectDiff2Button = function(obj)
   816 {
   816 {
   817   var this_time = obj.id.substr(6);
   817 	var this_time = obj.id.substr(6);
   818   var index = parseInt(in_array(this_time, timelist));
   818 	var index = parseInt(in_array(this_time, timelist));
   819   for ( var i = 1; i < timelist.length; i++ )
   819 	for ( var i = 1; i < timelist.length; i++ )
   820   {
   820 	{
   821     if ( i < timelist.length - 1 )
   821 		if ( i < timelist.length - 1 )
   822     {
   822 		{
   823       var state = ( i > index ) ? 'inline' : 'none';
   823 			var state = ( i > index ) ? 'inline' : 'none';
   824       var id = 'diff1_' + timelist[i];
   824 			var id = 'diff1_' + timelist[i];
   825       document.getElementById(id).style.display = state;
   825 			document.getElementById(id).style.display = state;
   826       
   826 			
   827       // alert("Debug:\nIndex: "+index+"\nState: "+state+"\ni: "+i);
   827 			// alert("Debug:\nIndex: "+index+"\nState: "+state+"\ni: "+i);
   828     }
   828 		}
   829   }
   829 	}
   830 }
   830 }
   831 
   831 
   832 window.ajaxHistDiff = function()
   832 window.ajaxHistDiff = function()
   833 {
   833 {
   834   // IE <6 pseudo-compatibility
   834 	// IE <6 pseudo-compatibility
   835   if ( KILL_SWITCH )
   835 	if ( KILL_SWITCH )
   836     return true;
   836 		return true;
   837   var id1=false;
   837 	var id1=false;
   838   var id2=false;
   838 	var id2=false;
   839   for ( i = 0; i < arrDiff1Buttons.length; i++ )
   839 	for ( i = 0; i < arrDiff1Buttons.length; i++ )
   840   {
   840 	{
   841     k = i + '';
   841 		k = i + '';
   842     kpp = i + 1;
   842 		kpp = i + 1;
   843     kpp = kpp + '';
   843 		kpp = kpp + '';
   844     if(arrDiff1Buttons[k].checked) id1 = arrDiff1Buttons[k].id.substr(6);
   844 		if(arrDiff1Buttons[k].checked) id1 = arrDiff1Buttons[k].id.substr(6);
   845     if(arrDiff2Buttons[k].checked) id2 = arrDiff2Buttons[k].id.substr(6);
   845 		if(arrDiff2Buttons[k].checked) id2 = arrDiff2Buttons[k].id.substr(6);
   846   }
   846 	}
   847   if(!id1 || !id2) { alert('BUG: Couldn\'t get checked radiobutton state'); return; }
   847 	if(!id1 || !id2) { alert('BUG: Couldn\'t get checked radiobutton state'); return; }
   848   setAjaxLoading();
   848 	setAjaxLoading();
   849   ajaxGet(stdAjaxPrefix+'&_mode=pagediff&diff1='+id1+'&diff2='+id2, function(ajax)
   849 	ajaxGet(stdAjaxPrefix+'&_mode=pagediff&diff1='+id1+'&diff2='+id2, function(ajax)
   850     {
   850 		{
   851       if ( ajax.readyState == 4 && ajax.status == 200 )
   851 			if ( ajax.readyState == 4 && ajax.status == 200 )
   852       {
   852 			{
   853         unsetAjaxLoading();
   853 				unsetAjaxLoading();
   854         document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   854 				document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText;
   855       }
   855 			}
   856     });
   856 		});
   857 }
   857 }
   858 
   858 
   859 // Change the user's preferred style/theme
   859 // Change the user's preferred style/theme
   860 
   860 
   861 window.ajaxChangeStyle = function()
   861 window.ajaxChangeStyle = function()
   862 {
   862 {
   863   // IE <6 pseudo-compatibility
   863 	// IE <6 pseudo-compatibility
   864   if ( KILL_SWITCH )
   864 	if ( KILL_SWITCH )
   865     return true;
   865 		return true;
   866   load_component(['l10n', 'fadefilter', 'jquery', 'jquery-ui']);
   866 	load_component(['l10n', 'fadefilter', 'jquery', 'jquery-ui']);
   867   
   867 	
   868   // force string fetch
   868 	// force string fetch
   869   $lang.get('etc_cancel');
   869 	$lang.get('etc_cancel');
   870   
   870 	
   871   // preload some images
   871 	// preload some images
   872   var i1 = new Image();
   872 	var i1 = new Image();
   873   i1.src = cdnPath + '/images/loading-big.gif';
   873 	i1.src = cdnPath + '/images/loading-big.gif';
   874   var i2 = new Image();
   874 	var i2 = new Image();
   875   i2.src = cdnPath + '/images/check-large.png';
   875 	i2.src = cdnPath + '/images/check-large.png';
   876   
   876 	
   877   darken(true, 70, 'theme-selector-shade');
   877 	darken(true, 70, 'theme-selector-shade');
   878   
   878 	
   879   $('body').append('<div id="theme-selector-wrapper"><div id="theme-selector-body"><div id="theme-selector-inner"><div class="theme-selector-spinner"></div></div></div></div>');
   879 	$('body').append('<div id="theme-selector-wrapper"><div id="theme-selector-body"><div id="theme-selector-inner"><div class="theme-selector-spinner"></div></div></div></div>');
   880   $('#theme-selector-wrapper')
   880 	$('#theme-selector-wrapper')
   881     .css('top', String(getScrollOffset()) + 'px')
   881 		.css('top', String(getScrollOffset()) + 'px')
   882     .css('left', 0)
   882 		.css('left', 0)
   883     .css('z-index', String( getHighestZ() + 20 ));
   883 		.css('z-index', String( getHighestZ() + 20 ));
   884   
   884 	
   885   $.get(stdAjaxPrefix + '&_mode=theme_list', {}, function(data, status)
   885 	$.get(stdAjaxPrefix + '&_mode=theme_list', {}, function(data, status)
   886     {
   886 		{
   887       $('#theme-selector-inner .theme-selector-spinner').fadeOut(650);
   887 			$('#theme-selector-inner .theme-selector-spinner').fadeOut(650);
   888       $('#theme-selector-body').animate({ width: 728 }, 600, function()
   888 			$('#theme-selector-body').animate({ width: 728 }, 600, function()
   889         {
   889 				{
   890           // avoiding jQuery's fade functions because they insist on toggling display as well
   890 					// avoiding jQuery's fade functions because they insist on toggling display as well
   891           if ( !aclDisableTransitionFX )
   891 					if ( !aclDisableTransitionFX )
   892             changeOpac(0, 'theme-selector-inner');
   892 						changeOpac(0, 'theme-selector-inner');
   893           $('#theme-selector-inner').html('<h3></h3>');
   893 					$('#theme-selector-inner').html('<h3></h3>');
   894           $('#theme-selector-inner > h3').text($lang.get('ajax_thmsel_lbl_choosetheme'));
   894 					$('#theme-selector-inner > h3').text($lang.get('ajax_thmsel_lbl_choosetheme'));
   895           $('#theme-selector-inner').append('<ul></ul>');
   895 					$('#theme-selector-inner').append('<ul></ul>');
   896           for ( var i = 0; i < data.length; i++ )
   896 					for ( var i = 0; i < data.length; i++ )
   897           {
   897 					{
   898             var bgi = data[i].have_thumb ? cdnPath + '/themes/' + data[i].theme_id + '/preview.png' : cdnPath + '/images/themepreview.png';
   898 						var bgi = data[i].have_thumb ? cdnPath + '/themes/' + data[i].theme_id + '/preview.png' : cdnPath + '/images/themepreview.png';
   899             var maxheight = getHeight() - 325;
   899 						var maxheight = getHeight() - 325;
   900             $('#theme-selector-inner > ul')
   900 						$('#theme-selector-inner > ul')
   901               .css('clip', 'rect(0px, auto, auto, 0px)')
   901 							.css('clip', 'rect(0px, auto, auto, 0px)')
   902               .css('overflow', 'auto')
   902 							.css('overflow', 'auto')
   903               .css('max-height', maxheight)
   903 							.css('max-height', maxheight)
   904               .append('<li id="theme_' + i + '"><a href="#"><span></span></a></li>');
   904 							.append('<li id="theme_' + i + '"><a href="#"><span></span></a></li>');
   905             $('#theme-selector-inner li#theme_' + i + ' > a')
   905 						$('#theme-selector-inner li#theme_' + i + ' > a')
   906               .css('background-image', 'url(' + bgi + ')')
   906 							.css('background-image', 'url(' + bgi + ')')
   907               .attr('enano:theme_id', data[i].theme_id);
   907 							.attr('enano:theme_id', data[i].theme_id);
   908             $('#theme-selector-inner li#theme_' + i + ' > a > span')
   908 						$('#theme-selector-inner li#theme_' + i + ' > a > span')
   909               .text(data[i].theme_name);
   909 							.text(data[i].theme_name);
   910           }
   910 					}
   911           $('#theme-selector-inner').append('<span class="menuclear"></span>');
   911 					$('#theme-selector-inner').append('<span class="menuclear"></span>');
   912           $('#theme-selector-inner').append('<div style="padding-top: 40px;"><a class="abutton abutton_green" style="font-size: larger;" href="#" onclick="ajaxChangeStyleClose(); return false;">' + $lang.get('etc_cancel') + '</a></div>');
   912 					$('#theme-selector-inner').append('<div style="padding-top: 40px;"><a class="abutton abutton_green" style="font-size: larger;" href="#" onclick="ajaxChangeStyleClose(); return false;">' + $lang.get('etc_cancel') + '</a></div>');
   913           
   913 					
   914           $('#theme-selector-body').animate({ height: $('#theme-selector-inner').height() + 30 }, 600, function()
   914 					$('#theme-selector-body').animate({ height: $('#theme-selector-inner').height() + 30 }, 600, function()
   915             {
   915 						{
   916               if ( !aclDisableTransitionFX )
   916 							if ( !aclDisableTransitionFX )
   917                 opacity('theme-selector-inner', 0, 100, 750);
   917 								opacity('theme-selector-inner', 0, 100, 750);
   918             });
   918 						});
   919           
   919 					
   920           $('#theme-selector-inner li a').click(function()
   920 					$('#theme-selector-inner li a').click(function()
   921             {
   921 						{
   922               var theme_id = $(this).attr('enano:theme_id');
   922 							var theme_id = $(this).attr('enano:theme_id');
   923               $('span', this).html('&nbsp;').addClass('loading').fadeTo('fast', 0.6)
   923 							$('span', this).html('&nbsp;').addClass('loading').fadeTo('fast', 0.6)
   924               $.get(stdAjaxPrefix + '&_mode=get_styles', { theme_id: theme_id }, function(data, status)
   924 							$.get(stdAjaxPrefix + '&_mode=get_styles', { theme_id: theme_id }, function(data, status)
   925                 {
   925 								{
   926                   if ( data.length > 1 )
   926 									if ( data.length > 1 )
   927                   {
   927 									{
   928                     $('#theme-selector-inner').css('height', $('#theme-selector-inner').height()).fadeOut(600, function()
   928 										$('#theme-selector-inner').css('height', $('#theme-selector-inner').height()).fadeOut(600, function()
   929                     {
   929 										{
   930                       var div = document.createElement('div');
   930 											var div = document.createElement('div');
   931                       if ( !aclDisableTransitionFX )
   931 											if ( !aclDisableTransitionFX )
   932                         domObjChangeOpac(0, div);
   932 												domObjChangeOpac(0, div);
   933                       
   933 											
   934                       $(div).attr('id', 'theme-selector-style-list').append('<h3></h3>');
   934 											$(div).attr('id', 'theme-selector-style-list').append('<h3></h3>');
   935                       $('h3', div).text($lang.get('ajax_thmsel_lbl_choosestyle'));
   935 											$('h3', div).text($lang.get('ajax_thmsel_lbl_choosestyle'));
   936                       
   936 											
   937                       for ( var i = 0; i < data.length; i++ )
   937 											for ( var i = 0; i < data.length; i++ )
   938                       {
   938 											{
   939                         $(div).append('<a class="abutton block stylebtn" id="stylebtn_' + i + '" enano:style_id="' + data[i] + '">' + themeid_to_title(data[i]) + '</a>');
   939 												$(div).append('<a class="abutton block stylebtn" id="stylebtn_' + i + '" enano:style_id="' + data[i] + '">' + themeid_to_title(data[i]) + '</a>');
   940                       }
   940 											}
   941                       
   941 											
   942                       $(div).append('<div style="padding-top: 40px;"><a class="abutton abutton_green" style="font-size: larger;" href="#" onclick="ajaxChangeStyleClose(); return false;">' + $lang.get('etc_cancel') + '</a></div>');
   942 											$(div).append('<div style="padding-top: 40px;"><a class="abutton abutton_green" style="font-size: larger;" href="#" onclick="ajaxChangeStyleClose(); return false;">' + $lang.get('etc_cancel') + '</a></div>');
   943                       
   943 											
   944                       if ( !aclDisableTransitionFX )
   944 											if ( !aclDisableTransitionFX )
   945                         changeOpac(0, 'theme-selector-style-list');
   945 												changeOpac(0, 'theme-selector-style-list');
   946                       $(this).html(div).show();
   946 											$(this).html(div).show();
   947                       
   947 											
   948                       $('#theme-selector-body').animate({width: 300, height: $('#theme-selector-style-list').height() + 30}, 300, function()
   948 											$('#theme-selector-body').animate({width: 300, height: $('#theme-selector-style-list').height() + 30}, 300, function()
   949                         {
   949 												{
   950                           if ( !aclDisableTransitionFX )
   950 													if ( !aclDisableTransitionFX )
   951                             opacity('theme-selector-style-list', 0, 100, 500);
   951 														opacity('theme-selector-style-list', 0, 100, 500);
   952                         });
   952 												});
   953                       
   953 											
   954                       $('.stylebtn').click(function()
   954 											$('.stylebtn').click(function()
   955                         {
   955 												{
   956                           ajaxChangeThemeSetLoading();
   956 													ajaxChangeThemeSetLoading();
   957                           $.post(stdAjaxPrefix + '&_mode=change_theme', { theme_id: theme_id, style_id: $(this).attr('enano:style_id') }, function(data, status)
   957 													$.post(stdAjaxPrefix + '&_mode=change_theme', { theme_id: theme_id, style_id: $(this).attr('enano:style_id') }, function(data, status)
   958                             {
   958 														{
   959                               if ( data.error )
   959 															if ( data.error )
   960                               {
   960 															{
   961                                 alert(data.error);
   961 																alert(data.error);
   962                                 ajaxChangeStyleClose();
   962 																ajaxChangeStyleClose();
   963                                 return false;
   963 																return false;
   964                               }
   964 															}
   965                               ajaxChangeThemeShowSuccess();
   965 															ajaxChangeThemeShowSuccess();
   966                             }, 2000);
   966 														}, 2000);
   967                           
   967 													
   968                           return false;
   968 													return false;
   969                         });
   969 												});
   970                     });
   970 										});
   971                   }
   971 									}
   972                   else
   972 									else
   973                   {
   973 									{
   974                     if ( !data[0] )
   974 										if ( !data[0] )
   975                     {
   975 										{
   976                       alert('Didn\'t find any CSS files. :-/');
   976 											alert('Didn\'t find any CSS files. :-/');
   977                       ajaxChangeStyleClose();
   977 											ajaxChangeStyleClose();
   978                     }
   978 										}
   979                     
   979 										
   980                     $.post(stdAjaxPrefix + '&_mode=change_theme', { theme_id: theme_id, style_id: data[0] }, function(data, status)
   980 										$.post(stdAjaxPrefix + '&_mode=change_theme', { theme_id: theme_id, style_id: data[0] }, function(data, status)
   981                       {
   981 											{
   982                         if ( data.error )
   982 												if ( data.error )
   983                         {
   983 												{
   984                           alert(data.error);
   984 													alert(data.error);
   985                           ajaxChangeStyleClose();
   985 													ajaxChangeStyleClose();
   986                           return false;
   986 													return false;
   987                         }
   987 												}
   988                         ajaxChangeThemeShowSuccess();
   988 												ajaxChangeThemeShowSuccess();
   989                       }, 'json');
   989 											}, 'json');
   990                   }
   990 									}
   991                 }, 'json');
   991 								}, 'json');
   992               return false;
   992 							return false;
   993             }); // click function
   993 						}); // click function
   994         }); // animate
   994 				}); // animate
   995     }, 'json'); // get
   995 		}, 'json'); // get
   996 }
   996 }
   997 
   997 
   998 window.ajaxChangeThemeSetLoading = function()
   998 window.ajaxChangeThemeSetLoading = function()
   999 {
   999 {
  1000   $('#theme-selector-body').animate({width: 130, height: 130});
  1000 	$('#theme-selector-body').animate({width: 130, height: 130});
  1001   $('#theme-selector-inner').empty().html('<div class="theme-selector-spinner"></div>');
  1001 	$('#theme-selector-inner').empty().html('<div class="theme-selector-spinner"></div>');
  1002 }
  1002 }
  1003 
  1003 
  1004 window.ajaxChangeThemeShowSuccess = function()
  1004 window.ajaxChangeThemeShowSuccess = function()
  1005 {
  1005 {
  1006   if ( aclDisableTransitionFX )
  1006 	if ( aclDisableTransitionFX )
  1007   {
  1007 	{
  1008     $('#theme-selector-inner').empty();
  1008 		$('#theme-selector-inner').empty();
  1009   }
  1009 	}
  1010   else
  1010 	else
  1011   {
  1011 	{
  1012     setTimeout(function()
  1012 		setTimeout(function()
  1013       {
  1013 			{
  1014         $('#theme-selector-inner').empty();
  1014 				$('#theme-selector-inner').empty();
  1015       }, 10);
  1015 			}, 10);
  1016   }
  1016 	}
  1017   
  1017 	
  1018   $('#theme-selector-body').animate({width: 400, height: 300 }, 600, function()
  1018 	$('#theme-selector-body').animate({width: 400, height: 300 }, 600, function()
  1019       {
  1019 			{
  1020         $('#theme-selector-inner').append('<img src="' + cdnPath + '/images/check-large.png" alt=" " style="display: block; margin: 15px auto;" />');
  1020 				$('#theme-selector-inner').append('<img src="' + cdnPath + '/images/check-large.png" alt=" " style="display: block; margin: 15px auto;" />');
  1021         $('#theme-selector-inner').append('<h3>' + $lang.get('ajax_thmsel_msg_success') + '</h3>');
  1021 				$('#theme-selector-inner').append('<h3>' + $lang.get('ajax_thmsel_msg_success') + '</h3>');
  1022         $('#theme-selector-inner').append('<div style="padding-top: 20px;"><a class="abutton abutton_green" style="font-size: larger;" href="#" onclick="window.location.reload(); return false;">' + $lang.get('ajax_thmsel_btn_reload') + '</a></div>');
  1022 				$('#theme-selector-inner').append('<div style="padding-top: 20px;"><a class="abutton abutton_green" style="font-size: larger;" href="#" onclick="window.location.reload(); return false;">' + $lang.get('ajax_thmsel_btn_reload') + '</a></div>');
  1023         $('#theme-selector-inner').append('<div style="padding-top: 25px;"><a href="#" style="font-size: smaller;" onclick="ajaxChangeStyleClose(); return false;">' + $lang.get('ajax_thmsel_btn_close') + '</a><br /><small>' + $lang.get('ajax_thmsel_btn_close_hint') + '</small></div>');
  1023 				$('#theme-selector-inner').append('<div style="padding-top: 25px;"><a href="#" style="font-size: smaller;" onclick="ajaxChangeStyleClose(); return false;">' + $lang.get('ajax_thmsel_btn_close') + '</a><br /><small>' + $lang.get('ajax_thmsel_btn_close_hint') + '</small></div>');
  1024         $('#theme-selector-inner').fadeIn();
  1024 				$('#theme-selector-inner').fadeIn();
  1025       });
  1025 			});
  1026 }
  1026 }
  1027 
  1027 
  1028 window.ajaxChangeStyleClose = function()
  1028 window.ajaxChangeStyleClose = function()
  1029 {
  1029 {
  1030   setTimeout(function()
  1030 	setTimeout(function()
  1031     {
  1031 		{
  1032       enlighten(false, 'theme-selector-shade');
  1032 			enlighten(false, 'theme-selector-shade');
  1033       $('#theme-selector-wrapper').fadeOut(500, function()
  1033 			$('#theme-selector-wrapper').fadeOut(500, function()
  1034         {
  1034 				{
  1035           $(this).remove();
  1035 					$(this).remove();
  1036         });
  1036 				});
  1037     }, ( aclDisableTransitionFX ? 0 : 300));
  1037 		}, ( aclDisableTransitionFX ? 0 : 300));
  1038   if ( !aclDisableTransitionFX )
  1038 	if ( !aclDisableTransitionFX )
  1039     opacity('theme-selector-inner', 100, 0, 250);
  1039 		opacity('theme-selector-inner', 100, 0, 250);
  1040 }
  1040 }
  1041 
  1041 
  1042 function themeid_to_title(id)
  1042 function themeid_to_title(id)
  1043 {
  1043 {
  1044   if ( typeof(id) != 'string' )
  1044 	if ( typeof(id) != 'string' )
  1045     return false;
  1045 		return false;
  1046   id = id.substr(0, 1).toUpperCase() + id.substr(1);
  1046 	id = id.substr(0, 1).toUpperCase() + id.substr(1);
  1047   id = id.replace(/_/g, ' ');
  1047 	id = id.replace(/_/g, ' ');
  1048   id = id.replace(/-/g, ' ');
  1048 	id = id.replace(/-/g, ' ');
  1049   return id;
  1049 	return id;
  1050 }
  1050 }
  1051 
  1051 
  1052 window.ajaxSetPassword = function()
  1052 window.ajaxSetPassword = function()
  1053 {
  1053 {
  1054   // IE <6 pseudo-compatibility
  1054 	// IE <6 pseudo-compatibility
  1055   if ( KILL_SWITCH )
  1055 	if ( KILL_SWITCH )
  1056     return true;
  1056 		return true;
  1057   load_component('crypto');
  1057 	load_component('crypto');
  1058   pass = hex_sha1(document.getElementById('mdgPassSetField').value);
  1058 	pass = hex_sha1(document.getElementById('mdgPassSetField').value);
  1059   setAjaxLoading();
  1059 	setAjaxLoading();
  1060   ajaxPost(stdAjaxPrefix+'&_mode=setpass', 'password='+pass, function(ajax)
  1060 	ajaxPost(stdAjaxPrefix+'&_mode=setpass', 'password='+pass, function(ajax)
  1061     {
  1061 		{
  1062       unsetAjaxLoading();
  1062 			unsetAjaxLoading();
  1063       if ( ajax.readyState == 4 && ajax.status == 200 )
  1063 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1064       {
  1064 			{
  1065         alert(ajax.responseText);
  1065 				alert(ajax.responseText);
  1066       }
  1066 			}
  1067     }, true);
  1067 		}, true);
  1068 }
  1068 }
  1069 
  1069 
  1070 window.ajaxDisableEmbeddedPHP = function()
  1070 window.ajaxDisableEmbeddedPHP = function()
  1071 {
  1071 {
  1072   // IE <6 pseudo-compatibility
  1072 	// IE <6 pseudo-compatibility
  1073   if ( KILL_SWITCH )
  1073 	if ( KILL_SWITCH )
  1074     return true;
  1074 		return true;
  1075   if ( !confirm($lang.get('ajax_killphp_confirm')) )
  1075 	if ( !confirm($lang.get('ajax_killphp_confirm')) )
  1076     return false;
  1076 		return false;
  1077   var $killdiv = $dynano('php_killer');
  1077 	var $killdiv = $dynano('php_killer');
  1078   if ( !$killdiv.object )
  1078 	if ( !$killdiv.object )
  1079   {
  1079 	{
  1080     alert('Can\'t get kill div object');
  1080 		alert('Can\'t get kill div object');
  1081     return false;
  1081 		return false;
  1082   }
  1082 	}
  1083   $killdiv.object.innerHTML = '<img alt="Loading..." src="' + scriptPath + '/images/loading-big.gif" /><br />Making request...';
  1083 	$killdiv.object.innerHTML = '<img alt="Loading..." src="' + scriptPath + '/images/loading-big.gif" /><br />Making request...';
  1084   var url = makeUrlNS('Admin', 'Home', 'src=ajax');
  1084 	var url = makeUrlNS('Admin', 'Home', 'src=ajax');
  1085   ajaxPost(url, 'act=kill_php', function(ajax) {
  1085 	ajaxPost(url, 'act=kill_php', function(ajax) {
  1086       if ( ajax.readyState == 4 && ajax.status == 200 )
  1086 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1087       {
  1087 			{
  1088         if ( ajax.responseText == '1' )
  1088 				if ( ajax.responseText == '1' )
  1089         {
  1089 				{
  1090           var $killdiv = $dynano('php_killer');
  1090 					var $killdiv = $dynano('php_killer');
  1091           //$killdiv.object.innerHTML = '<img alt="Success" src="' + scriptPath + '/images/error.png" /><br />Embedded PHP in pages has been disabled.';
  1091 					//$killdiv.object.innerHTML = '<img alt="Success" src="' + scriptPath + '/images/error.png" /><br />Embedded PHP in pages has been disabled.';
  1092           $killdiv.object.parentNode.removeChild($killdiv.object);
  1092 					$killdiv.object.parentNode.removeChild($killdiv.object);
  1093           var newdiv = document.createElement('div');
  1093 					var newdiv = document.createElement('div');
  1094           // newdiv.style = $killdiv.object.style;
  1094 					// newdiv.style = $killdiv.object.style;
  1095           newdiv.className = $killdiv.object.className;
  1095 					newdiv.className = $killdiv.object.className;
  1096           newdiv.innerHTML = '<img alt="Success" src="' + scriptPath + '/images/error.png" /><br />' + $lang.get('ajax_killphp_success');
  1096 					newdiv.innerHTML = '<img alt="Success" src="' + scriptPath + '/images/error.png" /><br />' + $lang.get('ajax_killphp_success');
  1097           $killdiv.object.parentNode.appendChild(newdiv);
  1097 					$killdiv.object.parentNode.appendChild(newdiv);
  1098           $killdiv.object.parentNode.removeChild($killdiv.object);
  1098 					$killdiv.object.parentNode.removeChild($killdiv.object);
  1099         }
  1099 				}
  1100         else
  1100 				else
  1101         {
  1101 				{
  1102           var $killdiv = $dynano('php_killer');
  1102 					var $killdiv = $dynano('php_killer');
  1103           $killdiv.object.innerHTML = ajax.responseText;
  1103 					$killdiv.object.innerHTML = ajax.responseText;
  1104         }
  1104 				}
  1105       }
  1105 			}
  1106     });
  1106 		});
  1107 }
  1107 }
  1108 
  1108 
  1109 var catHTMLBuf = false;
  1109 var catHTMLBuf = false;
  1110 
  1110 
  1111 window.ajaxCatToTag = function()
  1111 window.ajaxCatToTag = function()
  1112 {
  1112 {
  1113   if ( KILL_SWITCH )
  1113 	if ( KILL_SWITCH )
  1114     return false;
  1114 		return false;
  1115   setAjaxLoading();
  1115 	setAjaxLoading();
  1116   ajaxGet(stdAjaxPrefix + '&_mode=get_tags', function(ajax)
  1116 	ajaxGet(stdAjaxPrefix + '&_mode=get_tags', function(ajax)
  1117     {
  1117 		{
  1118       if ( ajax.readyState == 4 && ajax.status == 200 )
  1118 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1119       {
  1119 			{
  1120         unsetAjaxLoading();
  1120 				unsetAjaxLoading();
  1121         var resptext = String(ajax.responseText + ' ');
  1121 				var resptext = String(ajax.responseText + ' ');
  1122         resptext = resptext.substr(0, resptext.length-1);
  1122 				resptext = resptext.substr(0, resptext.length-1);
  1123         if ( resptext.substr(0, 1) != '{' )
  1123 				if ( resptext.substr(0, 1) != '{' )
  1124         {
  1124 				{
  1125           handle_invalid_json(resptext);
  1125 					handle_invalid_json(resptext);
  1126           return false;
  1126 					return false;
  1127         }
  1127 				}
  1128         var json = parseJSON(resptext);
  1128 				var json = parseJSON(resptext);
  1129         var catbox = document.getElementById('mdgCatBox');
  1129 				var catbox = document.getElementById('mdgCatBox');
  1130         if ( !catbox )
  1130 				if ( !catbox )
  1131           return false;
  1131 					return false;
  1132         var linkbox = catbox.parentNode.firstChild.firstChild.nextSibling;
  1132 				var linkbox = catbox.parentNode.firstChild.firstChild.nextSibling;
  1133         linkbox.firstChild.nodeValue = $lang.get('catedit_catbox_link_showcategorization');
  1133 				linkbox.firstChild.nodeValue = $lang.get('catedit_catbox_link_showcategorization');
  1134         linkbox.onclick = function() { ajaxTagToCat(); return false; };
  1134 				linkbox.onclick = function() { ajaxTagToCat(); return false; };
  1135         catHTMLBuf = catbox.innerHTML;
  1135 				catHTMLBuf = catbox.innerHTML;
  1136         catbox.innerHTML = '';
  1136 				catbox.innerHTML = '';
  1137         catbox.appendChild(document.createTextNode($lang.get('tags_lbl_page_tags')+' '));
  1137 				catbox.appendChild(document.createTextNode($lang.get('tags_lbl_page_tags')+' '));
  1138         if ( json.tags.length < 1 )
  1138 				if ( json.tags.length < 1 )
  1139         {
  1139 				{
  1140           catbox.appendChild(document.createTextNode($lang.get('tags_lbl_no_tags')));
  1140 					catbox.appendChild(document.createTextNode($lang.get('tags_lbl_no_tags')));
  1141         }
  1141 				}
  1142         for ( var i = 0; i < json.tags.length; i++ )
  1142 				for ( var i = 0; i < json.tags.length; i++ )
  1143         {
  1143 				{
  1144           catbox.appendChild(document.createTextNode(json.tags[i].name));
  1144 					catbox.appendChild(document.createTextNode(json.tags[i].name));
  1145           if ( json.tags[i].can_del )
  1145 					if ( json.tags[i].can_del )
  1146           {
  1146 					{
  1147             catbox.appendChild(document.createTextNode(' '));
  1147 						catbox.appendChild(document.createTextNode(' '));
  1148             var a = document.createElement('a');
  1148 						var a = document.createElement('a');
  1149             a.appendChild(document.createTextNode('[X]'));
  1149 						a.appendChild(document.createTextNode('[X]'));
  1150             a.href = '#';
  1150 						a.href = '#';
  1151             a._js_tag_id = json.tags[i].id;
  1151 						a._js_tag_id = json.tags[i].id;
  1152             a.onclick = function() { ajaxDeleteTag(this, this._js_tag_id); return false; }
  1152 						a.onclick = function() { ajaxDeleteTag(this, this._js_tag_id); return false; }
  1153             catbox.appendChild(a);
  1153 						catbox.appendChild(a);
  1154           }
  1154 					}
  1155           if ( ( i + 1 ) < json.tags.length )
  1155 					if ( ( i + 1 ) < json.tags.length )
  1156             catbox.appendChild(document.createTextNode(', '));
  1156 						catbox.appendChild(document.createTextNode(', '));
  1157         }
  1157 				}
  1158         if ( json.can_add )
  1158 				if ( json.can_add )
  1159         {
  1159 				{
  1160           catbox.appendChild(document.createTextNode(' '));
  1160 					catbox.appendChild(document.createTextNode(' '));
  1161           var addlink = document.createElement('a');
  1161 					var addlink = document.createElement('a');
  1162           addlink.href = '#';
  1162 					addlink.href = '#';
  1163           addlink.onclick = function() { try { ajaxAddTagStage1(); } catch(e) { }; return false; };
  1163 					addlink.onclick = function() { try { ajaxAddTagStage1(); } catch(e) { }; return false; };
  1164           addlink.appendChild(document.createTextNode($lang.get('tags_btn_add_tag')));
  1164 					addlink.appendChild(document.createTextNode($lang.get('tags_btn_add_tag')));
  1165           catbox.appendChild(addlink);
  1165 					catbox.appendChild(addlink);
  1166         }
  1166 				}
  1167       }
  1167 			}
  1168     });
  1168 		});
  1169 }
  1169 }
  1170 
  1170 
  1171 var addtag_open = false;
  1171 var addtag_open = false;
  1172 
  1172 
  1173 window.ajaxAddTagStage1 = function()
  1173 window.ajaxAddTagStage1 = function()
  1174 {
  1174 {
  1175   if ( addtag_open )
  1175 	if ( addtag_open )
  1176     return false;
  1176 		return false;
  1177   var catbox = document.getElementById('mdgCatBox');
  1177 	var catbox = document.getElementById('mdgCatBox');
  1178   var adddiv = document.createElement('div');
  1178 	var adddiv = document.createElement('div');
  1179   var text = document.createElement('input');
  1179 	var text = document.createElement('input');
  1180   var addlink = document.createElement('a');
  1180 	var addlink = document.createElement('a');
  1181   addlink.href = '#';
  1181 	addlink.href = '#';
  1182   addlink.onclick = function() { ajaxAddTagStage2(this.parentNode.firstChild.nextSibling.value, this.parentNode); return false; };
  1182 	addlink.onclick = function() { ajaxAddTagStage2(this.parentNode.firstChild.nextSibling.value, this.parentNode); return false; };
  1183   addlink.appendChild(document.createTextNode($lang.get('tags_btn_add')));
  1183 	addlink.appendChild(document.createTextNode($lang.get('tags_btn_add')));
  1184   text.type = 'text';
  1184 	text.type = 'text';
  1185   text.size = '15';
  1185 	text.size = '15';
  1186   text.onkeyup = function(e)
  1186 	text.onkeyup = function(e)
  1187   {
  1187 	{
  1188     if ( e.keyCode == 13 )
  1188 		if ( e.keyCode == 13 )
  1189     {
  1189 		{
  1190       ajaxAddTagStage2(this.value, this.parentNode);
  1190 			ajaxAddTagStage2(this.value, this.parentNode);
  1191     }
  1191 		}
  1192   }
  1192 	}
  1193   
  1193 	
  1194   adddiv.style.margin = '5px 0 0 0';
  1194 	adddiv.style.margin = '5px 0 0 0';
  1195   adddiv.appendChild(document.createTextNode($lang.get('tags_lbl_add_tag')+' '));
  1195 	adddiv.appendChild(document.createTextNode($lang.get('tags_lbl_add_tag')+' '));
  1196   adddiv.appendChild(text);
  1196 	adddiv.appendChild(text);
  1197   adddiv.appendChild(document.createTextNode(' '));
  1197 	adddiv.appendChild(document.createTextNode(' '));
  1198   adddiv.appendChild(addlink);
  1198 	adddiv.appendChild(addlink);
  1199   catbox.appendChild(adddiv);
  1199 	catbox.appendChild(adddiv);
  1200   addtag_open = true;
  1200 	addtag_open = true;
  1201 }
  1201 }
  1202 
  1202 
  1203 var addtag_nukeme = false;
  1203 var addtag_nukeme = false;
  1204 
  1204 
  1205 window.ajaxAddTagStage2 = function(tag, nukeme)
  1205 window.ajaxAddTagStage2 = function(tag, nukeme)
  1206 {
  1206 {
  1207   if ( !addtag_open )
  1207 	if ( !addtag_open )
  1208     return false;
  1208 		return false;
  1209   if ( addtag_nukeme )
  1209 	if ( addtag_nukeme )
  1210     return false;
  1210 		return false;
  1211   addtag_nukeme = nukeme;
  1211 	addtag_nukeme = nukeme;
  1212   tag = ajaxEscape(tag);
  1212 	tag = ajaxEscape(tag);
  1213   setAjaxLoading();
  1213 	setAjaxLoading();
  1214   ajaxPost(stdAjaxPrefix + '&_mode=addtag', 'tag=' + tag, function(ajax)
  1214 	ajaxPost(stdAjaxPrefix + '&_mode=addtag', 'tag=' + tag, function(ajax)
  1215     {
  1215 		{
  1216       if ( ajax.readyState == 4 && ajax.status == 200 )
  1216 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1217       {
  1217 			{
  1218         unsetAjaxLoading();
  1218 				unsetAjaxLoading();
  1219         var nukeme = addtag_nukeme;
  1219 				var nukeme = addtag_nukeme;
  1220         addtag_nukeme = false;
  1220 				addtag_nukeme = false;
  1221         var resptext = String(ajax.responseText + ' ');
  1221 				var resptext = String(ajax.responseText + ' ');
  1222         resptext = resptext.substr(0, resptext.length-1);
  1222 				resptext = resptext.substr(0, resptext.length-1);
  1223         if ( resptext.substr(0, 1) != '{' )
  1223 				if ( resptext.substr(0, 1) != '{' )
  1224         {
  1224 				{
  1225           handle_invalid_json(resptext);
  1225 					handle_invalid_json(resptext);
  1226           return false;
  1226 					return false;
  1227         }
  1227 				}
  1228         var json = parseJSON(resptext);
  1228 				var json = parseJSON(resptext);
  1229         var parent = nukeme.parentNode;
  1229 				var parent = nukeme.parentNode;
  1230         parent.removeChild(nukeme);
  1230 				parent.removeChild(nukeme);
  1231         addtag_open = false;
  1231 				addtag_open = false;
  1232         if ( json.success )
  1232 				if ( json.success )
  1233         {
  1233 				{
  1234           var node = parent.childNodes[1];
  1234 					var node = parent.childNodes[1];
  1235           var insertafter = false;
  1235 					var insertafter = false;
  1236           var nukeafter = false;
  1236 					var nukeafter = false;
  1237           if ( node.nodeValue == $lang.get('tags_lbl_no_tags') )
  1237 					if ( node.nodeValue == $lang.get('tags_lbl_no_tags') )
  1238           {
  1238 					{
  1239             nukeafter = true;
  1239 						nukeafter = true;
  1240           }
  1240 					}
  1241           insertafter = parent.childNodes[ parent.childNodes.length - 3 ];
  1241 					insertafter = parent.childNodes[ parent.childNodes.length - 3 ];
  1242           // these need to be inserted in reverse order
  1242 					// these need to be inserted in reverse order
  1243           if ( json.can_del )
  1243 					if ( json.can_del )
  1244           {
  1244 					{
  1245             var a = document.createElement('a');
  1245 						var a = document.createElement('a');
  1246             a.appendChild(document.createTextNode('[X]'));
  1246 						a.appendChild(document.createTextNode('[X]'));
  1247             a.href = '#';
  1247 						a.href = '#';
  1248             a._js_tag_id = json.tag_id;
  1248 						a._js_tag_id = json.tag_id;
  1249             a.onclick = function() { ajaxDeleteTag(this, this._js_tag_id); return false; }
  1249 						a.onclick = function() { ajaxDeleteTag(this, this._js_tag_id); return false; }
  1250             insertAfter(parent, a, insertafter);
  1250 						insertAfter(parent, a, insertafter);
  1251             insertAfter(parent, document.createTextNode(' '), insertafter);
  1251 						insertAfter(parent, document.createTextNode(' '), insertafter);
  1252           }
  1252 					}
  1253           insertAfter(parent, document.createTextNode(json.tag), insertafter);
  1253 					insertAfter(parent, document.createTextNode(json.tag), insertafter);
  1254           if ( !nukeafter )
  1254 					if ( !nukeafter )
  1255           {
  1255 					{
  1256             insertAfter(parent, document.createTextNode(', '), insertafter);
  1256 						insertAfter(parent, document.createTextNode(', '), insertafter);
  1257           }
  1257 					}
  1258           if ( nukeafter )
  1258 					if ( nukeafter )
  1259           {
  1259 					{
  1260             parent.removeChild(insertafter);
  1260 						parent.removeChild(insertafter);
  1261           }
  1261 					}
  1262         }
  1262 				}
  1263         else
  1263 				else
  1264         {
  1264 				{
  1265           alert(json.error);
  1265 					alert(json.error);
  1266         }
  1266 				}
  1267       }
  1267 			}
  1268     });
  1268 		});
  1269 }
  1269 }
  1270 
  1270 
  1271 window.ajaxDeleteTag = function(parentobj, tag_id)
  1271 window.ajaxDeleteTag = function(parentobj, tag_id)
  1272 {
  1272 {
  1273   var arrDelete = [ parentobj, parentobj.previousSibling, parentobj.previousSibling.previousSibling ];
  1273 	var arrDelete = [ parentobj, parentobj.previousSibling, parentobj.previousSibling.previousSibling ];
  1274   var parent = parentobj.parentNode;
  1274 	var parent = parentobj.parentNode;
  1275   var writeNoTags = false;
  1275 	var writeNoTags = false;
  1276   if ( parentobj.previousSibling.previousSibling.previousSibling.nodeValue == ', ' )
  1276 	if ( parentobj.previousSibling.previousSibling.previousSibling.nodeValue == ', ' )
  1277     arrDelete.push(parentobj.previousSibling.previousSibling.previousSibling);
  1277 		arrDelete.push(parentobj.previousSibling.previousSibling.previousSibling);
  1278   else if ( parentobj.previousSibling.previousSibling.previousSibling.nodeValue == $lang.get('tags_lbl_page_tags') + ' ' )
  1278 	else if ( parentobj.previousSibling.previousSibling.previousSibling.nodeValue == $lang.get('tags_lbl_page_tags') + ' ' )
  1279     arrDelete.push(parentobj.nextSibling);
  1279 		arrDelete.push(parentobj.nextSibling);
  1280   
  1280 	
  1281   if ( parentobj.previousSibling.previousSibling.previousSibling.nodeValue == $lang.get('tags_lbl_page_tags') + ' ' &&
  1281 	if ( parentobj.previousSibling.previousSibling.previousSibling.nodeValue == $lang.get('tags_lbl_page_tags') + ' ' &&
  1282        parentobj.nextSibling.nextSibling.firstChild )
  1282  			parentobj.nextSibling.nextSibling.firstChild )
  1283     if ( parentobj.nextSibling.nextSibling.firstChild.nodeValue == $lang.get('tags_btn_add_tag'))
  1283 		if ( parentobj.nextSibling.nextSibling.firstChild.nodeValue == $lang.get('tags_btn_add_tag'))
  1284       writeNoTags = true;
  1284 			writeNoTags = true;
  1285     
  1285 		
  1286   ajaxPost(stdAjaxPrefix + '&_mode=deltag', 'tag_id=' + String(tag_id), function(ajax)
  1286 	ajaxPost(stdAjaxPrefix + '&_mode=deltag', 'tag_id=' + String(tag_id), function(ajax)
  1287     {
  1287 		{
  1288       if ( ajax.readyState == 4 && ajax.status == 200 )
  1288 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1289       {
  1289 			{
  1290         if ( ajax.responseText == 'success' )
  1290 				if ( ajax.responseText == 'success' )
  1291         {
  1291 				{
  1292           for ( var i = 0; i < arrDelete.length; i++ )
  1292 					for ( var i = 0; i < arrDelete.length; i++ )
  1293           {
  1293 					{
  1294             try
  1294 						try
  1295             {
  1295 						{
  1296               parent.removeChild(arrDelete[i]);
  1296 							parent.removeChild(arrDelete[i]);
  1297             } catch(e) {}
  1297 						} catch(e) {}
  1298           }
  1298 					}
  1299           if ( writeNoTags )
  1299 					if ( writeNoTags )
  1300           {
  1300 					{
  1301             var node1 = document.createTextNode($lang.get('tags_lbl_no_tags'));
  1301 						var node1 = document.createTextNode($lang.get('tags_lbl_no_tags'));
  1302             var node2 = document.createTextNode(' ');
  1302 						var node2 = document.createTextNode(' ');
  1303             insertAfter(parent, node1, parent.firstChild);
  1303 						insertAfter(parent, node1, parent.firstChild);
  1304             insertAfter(parent, node2, node1);
  1304 						insertAfter(parent, node2, node1);
  1305           }
  1305 					}
  1306         }
  1306 				}
  1307         else
  1307 				else
  1308         {
  1308 				{
  1309           alert(ajax.responseText);
  1309 					alert(ajax.responseText);
  1310         }
  1310 				}
  1311       }
  1311 			}
  1312     });
  1312 		});
  1313 }
  1313 }
  1314 
  1314 
  1315 window.ajaxTagToCat = function()
  1315 window.ajaxTagToCat = function()
  1316 {
  1316 {
  1317   if ( !catHTMLBuf )
  1317 	if ( !catHTMLBuf )
  1318     return false;
  1318 		return false;
  1319   var catbox = document.getElementById('mdgCatBox');
  1319 	var catbox = document.getElementById('mdgCatBox');
  1320   if ( !catbox )
  1320 	if ( !catbox )
  1321     return false;
  1321 		return false;
  1322   addtag_open = false;
  1322 	addtag_open = false;
  1323   var linkbox = catbox.parentNode.firstChild.firstChild.nextSibling;
  1323 	var linkbox = catbox.parentNode.firstChild.firstChild.nextSibling;
  1324   linkbox.firstChild.nodeValue = $lang.get('tags_catbox_link');
  1324 	linkbox.firstChild.nodeValue = $lang.get('tags_catbox_link');
  1325   linkbox.onclick = function() { ajaxCatToTag(); return false; };
  1325 	linkbox.onclick = function() { ajaxCatToTag(); return false; };
  1326   catbox.innerHTML = catHTMLBuf;
  1326 	catbox.innerHTML = catHTMLBuf;
  1327   catHTMLBuf = false;
  1327 	catHTMLBuf = false;
  1328 }
  1328 }
  1329 
  1329 
  1330 var keepalive_interval = false;
  1330 var keepalive_interval = false;
  1331 
  1331 
  1332 window.ajaxPingServer = function()
  1332 window.ajaxPingServer = function()
  1333 {
  1333 {
  1334   ajaxGet(stdAjaxPrefix + '&_mode=ping', function(ajax)
  1334 	ajaxGet(stdAjaxPrefix + '&_mode=ping', function(ajax)
  1335     {
  1335 		{
  1336     });
  1336 		});
  1337 }
  1337 }
  1338 
  1338 
  1339 window.ajaxToggleKeepalive = function()
  1339 window.ajaxToggleKeepalive = function()
  1340 {
  1340 {
  1341   if ( readCookie('admin_keepalive') == '1' )
  1341 	if ( readCookie('admin_keepalive') == '1' )
  1342   {
  1342 	{
  1343     createCookie('admin_keepalive', '0', 3650);
  1343 		createCookie('admin_keepalive', '0', 3650);
  1344     if ( keepalive_interval )
  1344 		if ( keepalive_interval )
  1345       clearInterval(keepalive_interval);
  1345 			clearInterval(keepalive_interval);
  1346     var span = document.getElementById('keepalivestat');
  1346 		var span = document.getElementById('keepalivestat');
  1347     span.firstChild.nodeValue = $lang.get('adm_btn_keepalive_off');
  1347 		span.firstChild.nodeValue = $lang.get('adm_btn_keepalive_off');
  1348   }
  1348 	}
  1349   else
  1349 	else
  1350   {
  1350 	{
  1351     createCookie('admin_keepalive', '1', 3650);
  1351 		createCookie('admin_keepalive', '1', 3650);
  1352     if ( !keepalive_interval )
  1352 		if ( !keepalive_interval )
  1353       keepalive_interval = setInterval('ajaxPingServer();', 600000);
  1353 			keepalive_interval = setInterval('ajaxPingServer();', 600000);
  1354     var span = document.getElementById('keepalivestat');
  1354 		var span = document.getElementById('keepalivestat');
  1355     span.firstChild.nodeValue = $lang.get('adm_btn_keepalive_on');
  1355 		span.firstChild.nodeValue = $lang.get('adm_btn_keepalive_on');
  1356     ajaxPingServer();
  1356 		ajaxPingServer();
  1357   }
  1357 	}
  1358 }
  1358 }
  1359 
  1359 
  1360 var keepalive_onload = function()
  1360 var keepalive_onload = function()
  1361 {
  1361 {
  1362   if ( readCookie('admin_keepalive') == '1' )
  1362 	if ( readCookie('admin_keepalive') == '1' )
  1363   {
  1363 	{
  1364     if ( !keepalive_interval )
  1364 		if ( !keepalive_interval )
  1365       keepalive_interval = setInterval('ajaxPingServer();', 600000);
  1365 			keepalive_interval = setInterval('ajaxPingServer();', 600000);
  1366     var span = document.getElementById('keepalivestat');
  1366 		var span = document.getElementById('keepalivestat');
  1367     span.firstChild.nodeValue = $lang.get('adm_btn_keepalive_on');
  1367 		span.firstChild.nodeValue = $lang.get('adm_btn_keepalive_on');
  1368   }
  1368 	}
  1369   else
  1369 	else
  1370   {
  1370 	{
  1371     if ( keepalive_interval )
  1371 		if ( keepalive_interval )
  1372       clearInterval(keepalive_interval);
  1372 			clearInterval(keepalive_interval);
  1373     var span = document.getElementById('keepalivestat');
  1373 		var span = document.getElementById('keepalivestat');
  1374     span.firstChild.nodeValue = $lang.get('adm_btn_keepalive_off');
  1374 		span.firstChild.nodeValue = $lang.get('adm_btn_keepalive_off');
  1375   }
  1375 	}
  1376 };
  1376 };
  1377 
  1377 
  1378 window.aboutKeepAlive = function()
  1378 window.aboutKeepAlive = function()
  1379 {
  1379 {
  1380   load_component(['messagebox', 'flyin', 'fadefilter']);
  1380 	load_component(['messagebox', 'flyin', 'fadefilter']);
  1381   new MessageBox(MB_OK|MB_ICONINFORMATION, $lang.get('user_keepalive_info_title'), $lang.get('user_keepalive_info_body'));
  1381 	new MessageBox(MB_OK|MB_ICONINFORMATION, $lang.get('user_keepalive_info_title'), $lang.get('user_keepalive_info_body'));
  1382 }
  1382 }
  1383 
  1383 
  1384 window.ajaxUpdateCheck = function(targetelement)
  1384 window.ajaxUpdateCheck = function(targetelement)
  1385 {
  1385 {
  1386   if ( !document.getElementById(targetelement) )
  1386 	if ( !document.getElementById(targetelement) )
  1387   {
  1387 	{
  1388     return false;
  1388 		return false;
  1389   }
  1389 	}
  1390   var target = document.getElementById(targetelement);
  1390 	var target = document.getElementById(targetelement);
  1391   target.innerHTML = '';
  1391 	target.innerHTML = '';
  1392   var img = document.createElement('img');
  1392 	var img = document.createElement('img');
  1393   img.src = cdnPath + '/images/loading.gif';
  1393 	img.src = cdnPath + '/images/loading.gif';
  1394   img.alt = 'Loading...';
  1394 	img.alt = 'Loading...';
  1395   target.appendChild(img);
  1395 	target.appendChild(img);
  1396   ajaxGet(makeUrlNS('Admin', 'Home/updates.xml'), function(ajax)
  1396 	ajaxGet(makeUrlNS('Admin', 'Home/updates.xml'), function(ajax)
  1397     {
  1397 		{
  1398       if ( ajax.readyState == 4 && ajax.status == 200 )
  1398 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1399       {
  1399 			{
  1400         var releases = new Array();
  1400 				var releases = new Array();
  1401         var update_available = false;
  1401 				var update_available = false;
  1402         if ( ajax.responseXML == null )
  1402 				if ( ajax.responseXML == null )
  1403         {
  1403 				{
  1404           alert("Error fetching updates list:\n" + ajax.responseText);
  1404 					alert("Error fetching updates list:\n" + ajax.responseText);
  1405           return false;
  1405 					return false;
  1406         }
  1406 				}
  1407         if ( ajax.responseXML.firstChild.tagName == 'enano' )
  1407 				if ( ajax.responseXML.firstChild.tagName == 'enano' )
  1408         {
  1408 				{
  1409           var enanotag = ajax.responseXML.firstChild;
  1409 					var enanotag = ajax.responseXML.firstChild;
  1410           for ( var i = 0; i < enanotag.childNodes.length; i++ )
  1410 					for ( var i = 0; i < enanotag.childNodes.length; i++ )
  1411           {
  1411 					{
  1412             if ( enanotag.childNodes[i].tagName == 'error' )
  1412 						if ( enanotag.childNodes[i].tagName == 'error' )
  1413             {
  1413 						{
  1414               alert(enanotag.childNodes[i].firstChild.nodeValue);
  1414 							alert(enanotag.childNodes[i].firstChild.nodeValue);
  1415             }
  1415 						}
  1416             else if ( enanotag.childNodes[i].tagName == 'latest' )
  1416 						else if ( enanotag.childNodes[i].tagName == 'latest' )
  1417             {
  1417 						{
  1418               // got <latest>
  1418 							// got <latest>
  1419               var latesttag = enanotag.childNodes[i];
  1419 							var latesttag = enanotag.childNodes[i];
  1420               for ( var j = 0; j < latesttag.childNodes.length; j++ )
  1420 							for ( var j = 0; j < latesttag.childNodes.length; j++ )
  1421               {
  1421 							{
  1422                 var node = latesttag.childNodes[j];
  1422 								var node = latesttag.childNodes[j];
  1423                 if ( node.tagName == 'release' )
  1423 								if ( node.tagName == 'release' )
  1424                 {
  1424 								{
  1425                   var releasedata = new Object();
  1425 									var releasedata = new Object();
  1426                   for ( var k = 0; k < node.attributes.length; k++ )
  1426 									for ( var k = 0; k < node.attributes.length; k++ )
  1427                   {
  1427 									{
  1428                     releasedata[node.attributes[k].nodeName] = node.attributes[k].nodeValue;
  1428 										releasedata[node.attributes[k].nodeName] = node.attributes[k].nodeValue;
  1429                   }
  1429 									}
  1430                   releases.push(releasedata);
  1430 									releases.push(releasedata);
  1431                 }
  1431 								}
  1432                 else if ( node.tagName == 'haveupdates' )
  1432 								else if ( node.tagName == 'haveupdates' )
  1433                 {
  1433 								{
  1434                   update_available = true;
  1434 									update_available = true;
  1435                 }
  1435 								}
  1436               }
  1436 							}
  1437               break;
  1437 							break;
  1438             }
  1438 						}
  1439           }
  1439 					}
  1440         }
  1440 				}
  1441         else
  1441 				else
  1442         {
  1442 				{
  1443           return false;
  1443 					return false;
  1444         }
  1444 				}
  1445         var thediv = document.getElementById(targetelement);
  1445 				var thediv = document.getElementById(targetelement);
  1446         thediv.innerHTML = '';
  1446 				thediv.innerHTML = '';
  1447         if ( !thediv )
  1447 				if ( !thediv )
  1448         {
  1448 				{
  1449           return false;
  1449 					return false;
  1450         }
  1450 				}
  1451         if ( releases.length > 0 )
  1451 				if ( releases.length > 0 )
  1452         {
  1452 				{
  1453           thediv.className = 'tblholder';
  1453 					thediv.className = 'tblholder';
  1454           // FIXME: l10n
  1454 					// FIXME: l10n
  1455           if ( update_available )
  1455 					if ( update_available )
  1456           {
  1456 					{
  1457             var infobox = document.createElement('div');
  1457 						var infobox = document.createElement('div');
  1458             infobox.className = 'info-box-mini';
  1458 						infobox.className = 'info-box-mini';
  1459             infobox.appendChild(document.createTextNode('An update for Enano is available. The newest release is highlighted below.'));
  1459 						infobox.appendChild(document.createTextNode('An update for Enano is available. The newest release is highlighted below.'));
  1460             infobox.style.borderWidth = '0';
  1460 						infobox.style.borderWidth = '0';
  1461             infobox.style.margin = '0 0 0 0';
  1461 						infobox.style.margin = '0 0 0 0';
  1462             thediv.appendChild(infobox);
  1462 						thediv.appendChild(infobox);
  1463           }
  1463 					}
  1464           else
  1464 					else
  1465           {
  1465 					{
  1466             var infobox = document.createElement('div');
  1466 						var infobox = document.createElement('div');
  1467             infobox.className = 'info-box-mini';
  1467 						infobox.className = 'info-box-mini';
  1468             infobox.appendChild(document.createTextNode('No new updates are available. The latest available releases are shown below.'));
  1468 						infobox.appendChild(document.createTextNode('No new updates are available. The latest available releases are shown below.'));
  1469             infobox.style.borderWidth = '0';
  1469 						infobox.style.borderWidth = '0';
  1470             infobox.style.margin = '0 0 0 0';
  1470 						infobox.style.margin = '0 0 0 0';
  1471             thediv.appendChild(infobox);
  1471 						thediv.appendChild(infobox);
  1472           }
  1472 					}
  1473           var table = document.createElement('table');
  1473 					var table = document.createElement('table');
  1474           table.setAttribute('border', '0');
  1474 					table.setAttribute('border', '0');
  1475           table.setAttribute('cellspacing', '1');
  1475 					table.setAttribute('cellspacing', '1');
  1476           table.setAttribute('cellpadding', '4');
  1476 					table.setAttribute('cellpadding', '4');
  1477           
  1477 					
  1478           var tr = document.createElement('tr');
  1478 					var tr = document.createElement('tr');
  1479           
  1479 					
  1480           var td1 = document.createElement('th');
  1480 					var td1 = document.createElement('th');
  1481           var td2 = document.createElement('th');
  1481 					var td2 = document.createElement('th');
  1482           var td3 = document.createElement('th');
  1482 					var td3 = document.createElement('th');
  1483           var td4 = document.createElement('th');
  1483 					var td4 = document.createElement('th');
  1484           
  1484 					
  1485           // FIXME: l10n
  1485 					// FIXME: l10n
  1486           td1.appendChild( document.createTextNode('Release type') );
  1486 					td1.appendChild( document.createTextNode('Release type') );
  1487           td2.appendChild( document.createTextNode('Version') );
  1487 					td2.appendChild( document.createTextNode('Version') );
  1488           td3.appendChild( document.createTextNode('Code name') );
  1488 					td3.appendChild( document.createTextNode('Code name') );
  1489           td4.appendChild( document.createTextNode('Release notes') );
  1489 					td4.appendChild( document.createTextNode('Release notes') );
  1490           
  1490 					
  1491           tr.appendChild(td1);
  1491 					tr.appendChild(td1);
  1492           tr.appendChild(td2);
  1492 					tr.appendChild(td2);
  1493           tr.appendChild(td3);
  1493 					tr.appendChild(td3);
  1494           tr.appendChild(td4);
  1494 					tr.appendChild(td4);
  1495             
  1495 						
  1496           table.appendChild(tr);
  1496 					table.appendChild(tr);
  1497           
  1497 					
  1498           var cls = 'row2';
  1498 					var cls = 'row2';
  1499           
  1499 					
  1500           var j = 0;
  1500 					var j = 0;
  1501           for ( var i in releases )
  1501 					for ( var i in releases )
  1502           {
  1502 					{
  1503             j++;
  1503 						j++;
  1504             if ( j > 5 )
  1504 						if ( j > 5 )
  1505               break;
  1505 							break;
  1506             if ( update_available && j == 1 )
  1506 						if ( update_available && j == 1 )
  1507               cls = 'row1_green';
  1507 							cls = 'row1_green';
  1508             else
  1508 						else
  1509               cls = ( cls == 'row1' ) ? 'row2' : 'row1';
  1509 							cls = ( cls == 'row1' ) ? 'row2' : 'row1';
  1510             var release = releases[i];
  1510 						var release = releases[i];
  1511             var tr = document.createElement('tr');
  1511 						var tr = document.createElement('tr');
  1512             
  1512 						
  1513             var td1 = document.createElement('td');
  1513 						var td1 = document.createElement('td');
  1514             var td2 = document.createElement('td');
  1514 						var td2 = document.createElement('td');
  1515             var td3 = document.createElement('td');
  1515 						var td3 = document.createElement('td');
  1516             var td4 = document.createElement('td');
  1516 						var td4 = document.createElement('td');
  1517             
  1517 						
  1518             td1.className = cls;
  1518 						td1.className = cls;
  1519             td2.className = cls;
  1519 						td2.className = cls;
  1520             td3.className = cls;
  1520 						td3.className = cls;
  1521             td4.className = cls;
  1521 						td4.className = cls;
  1522             
  1522 						
  1523             if ( release.tag )
  1523 						if ( release.tag )
  1524               td1.appendChild( document.createTextNode(release.tag) );
  1524 							td1.appendChild( document.createTextNode(release.tag) );
  1525             
  1525 						
  1526             if ( release.version )
  1526 						if ( release.version )
  1527               td2.appendChild( document.createTextNode(release.version) );
  1527 							td2.appendChild( document.createTextNode(release.version) );
  1528             
  1528 						
  1529             if ( release.codename )
  1529 						if ( release.codename )
  1530               td3.appendChild( document.createTextNode(release.codename) );
  1530 							td3.appendChild( document.createTextNode(release.codename) );
  1531             
  1531 						
  1532             if ( release.relnotes )
  1532 						if ( release.relnotes )
  1533             {
  1533 						{
  1534               var a = document.createElement('a');
  1534 							var a = document.createElement('a');
  1535               a.href = release.relnotes;
  1535 							a.href = release.relnotes;
  1536               a.appendChild(document.createTextNode('View'));
  1536 							a.appendChild(document.createTextNode('View'));
  1537               td4.appendChild( a );
  1537 							td4.appendChild( a );
  1538             }
  1538 						}
  1539             
  1539 						
  1540             tr.appendChild(td1);
  1540 						tr.appendChild(td1);
  1541             tr.appendChild(td2);
  1541 						tr.appendChild(td2);
  1542             tr.appendChild(td3);
  1542 						tr.appendChild(td3);
  1543             tr.appendChild(td4);
  1543 						tr.appendChild(td4);
  1544             
  1544 						
  1545             table.appendChild(tr);
  1545 						table.appendChild(tr);
  1546           }
  1546 					}
  1547           thediv.appendChild(table);
  1547 					thediv.appendChild(table);
  1548         }
  1548 				}
  1549         else
  1549 				else
  1550         {
  1550 				{
  1551           thediv.appendChild(document.createTextNode('No releases available.'));
  1551 					thediv.appendChild(document.createTextNode('No releases available.'));
  1552         }
  1552 				}
  1553       }
  1553 			}
  1554     });
  1554 		});
  1555 }
  1555 }
  1556 
  1556 
  1557 window.ajaxPluginAction = function(action, plugin_filename, btnobj, send_confirm)
  1557 window.ajaxPluginAction = function(action, plugin_filename, btnobj, send_confirm)
  1558 {
  1558 {
  1559   // if installing, uninstalling, or re-importing, confirm
  1559 	// if installing, uninstalling, or re-importing, confirm
  1560   if ( action == 'install' || action == 'uninstall' || action == 'reimport' )
  1560 	if ( action == 'install' || action == 'uninstall' || action == 'reimport' )
  1561   {
  1561 	{
  1562     var prompt = miniPrompt(function(div)
  1562 		var prompt = miniPrompt(function(div)
  1563       {
  1563 			{
  1564         var txtholder = document.createElement('div');
  1564 				var txtholder = document.createElement('div');
  1565         txtholder.style.textAlign = 'center';
  1565 				txtholder.style.textAlign = 'center';
  1566         txtholder.appendChild(document.createTextNode($lang.get('acppl_msg_confirm_' + action)));
  1566 				txtholder.appendChild(document.createTextNode($lang.get('acppl_msg_confirm_' + action)));
  1567         txtholder.appendChild(document.createElement('br'));
  1567 				txtholder.appendChild(document.createElement('br'));
  1568         txtholder.appendChild(document.createElement('br'));
  1568 				txtholder.appendChild(document.createElement('br'));
  1569         
  1569 				
  1570         // create buttons
  1570 				// create buttons
  1571         var btn_go = document.createElement('a');
  1571 				var btn_go = document.createElement('a');
  1572         btn_go.className = 'abutton abutton_red';
  1572 				btn_go.className = 'abutton abutton_red';
  1573         btn_go.href = '#';
  1573 				btn_go.href = '#';
  1574         btn_go._action = action;
  1574 				btn_go._action = action;
  1575         btn_go._filename = plugin_filename;
  1575 				btn_go._filename = plugin_filename;
  1576         btn_go._button = btnobj;
  1576 				btn_go._button = btnobj;
  1577         btn_go.appendChild(document.createTextNode($lang.get('acppl_btn_' + action)));
  1577 				btn_go.appendChild(document.createTextNode($lang.get('acppl_btn_' + action)));
  1578         btn_go.style.fontWeight = 'bold';
  1578 				btn_go.style.fontWeight = 'bold';
  1579         txtholder.appendChild(btn_go);
  1579 				txtholder.appendChild(btn_go);
  1580         
  1580 				
  1581         // space
  1581 				// space
  1582         txtholder.appendChild(document.createTextNode(' '));
  1582 				txtholder.appendChild(document.createTextNode(' '));
  1583         
  1583 				
  1584         // cancel
  1584 				// cancel
  1585         var btn_cancel = document.createElement('a');
  1585 				var btn_cancel = document.createElement('a');
  1586         btn_cancel.className = 'abutton abutton_blue';
  1586 				btn_cancel.className = 'abutton abutton_blue';
  1587         btn_cancel.href = '#';
  1587 				btn_cancel.href = '#';
  1588         btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel')));
  1588 				btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel')));
  1589         
  1589 				
  1590         txtholder.appendChild(btn_cancel);
  1590 				txtholder.appendChild(btn_cancel);
  1591         div.appendChild(txtholder);
  1591 				div.appendChild(txtholder);
  1592         
  1592 				
  1593         btn_go.onclick = function()
  1593 				btn_go.onclick = function()
  1594         {
  1594 				{
  1595           ajaxPluginAction(this._action + '_confirm', this._filename, this._button);
  1595 					ajaxPluginAction(this._action + '_confirm', this._filename, this._button);
  1596           miniPromptDestroy(this);
  1596 					miniPromptDestroy(this);
  1597           return false;
  1597 					return false;
  1598         };
  1598 				};
  1599         btn_cancel.onclick = function()
  1599 				btn_cancel.onclick = function()
  1600         {
  1600 				{
  1601           miniPromptDestroy(this);
  1601 					miniPromptDestroy(this);
  1602           return false;
  1602 					return false;
  1603         };
  1603 				};
  1604       });
  1604 			});
  1605     return true;
  1605 		return true;
  1606   }
  1606 	}
  1607   action = action.replace(/_confirm$/, '');
  1607 	action = action.replace(/_confirm$/, '');
  1608   // white-out the plugin info box
  1608 	// white-out the plugin info box
  1609   if ( btnobj )
  1609 	if ( btnobj )
  1610   {
  1610 	{
  1611     var td = btnobj.parentNode.parentNode.parentNode.parentNode;
  1611 		var td = btnobj.parentNode.parentNode.parentNode.parentNode;
  1612     var blackbox = whiteOutElement(td);
  1612 		var blackbox = whiteOutElement(td);
  1613   }
  1613 	}
  1614   var request = {
  1614 	var request = {
  1615       mode: action,
  1615 			mode: action,
  1616       plugin: plugin_filename
  1616 			plugin: plugin_filename
  1617     };
  1617 		};
  1618   if ( send_confirm )
  1618 	if ( send_confirm )
  1619   {
  1619 	{
  1620     request.install_confirmed = true;
  1620 		request.install_confirmed = true;
  1621   }
  1621 	}
  1622   request = toJSONString(request);
  1622 	request = toJSONString(request);
  1623   ajaxPost(makeUrlNS('Admin', 'PluginManager/action.json'), 'r=' + ajaxEscape(request), function(ajax)
  1623 	ajaxPost(makeUrlNS('Admin', 'PluginManager/action.json'), 'r=' + ajaxEscape(request), function(ajax)
  1624     {
  1624 		{
  1625       if ( ajax.readyState == 4 && ajax.status == 200 )
  1625 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1626       {
  1626 			{
  1627         var response = String(ajax.responseText + '');
  1627 				var response = String(ajax.responseText + '');
  1628         if ( !check_json_response(response) )
  1628 				if ( !check_json_response(response) )
  1629         {
  1629 				{
  1630           handle_invalid_json(response);
  1630 					handle_invalid_json(response);
  1631           return false;
  1631 					return false;
  1632         }
  1632 				}
  1633         response = parseJSON(response);
  1633 				response = parseJSON(response);
  1634         if ( blackbox )
  1634 				if ( blackbox )
  1635         {
  1635 				{
  1636           blackbox.parentNode.removeChild(blackbox);
  1636 					blackbox.parentNode.removeChild(blackbox);
  1637         }
  1637 				}
  1638         if ( response.success )
  1638 				if ( response.success )
  1639         {
  1639 				{
  1640           ajaxPage( namespace_list['Admin'] + 'PluginManager' );
  1640 					ajaxPage( namespace_list['Admin'] + 'PluginManager' );
  1641           return true;
  1641 					return true;
  1642         }
  1642 				}
  1643         if ( response.need_confirm )
  1643 				if ( response.need_confirm )
  1644         {
  1644 				{
  1645           miniPromptMessage({
  1645 					miniPromptMessage({
  1646               title: $lang.get(response.confirm_title),
  1646 							title: $lang.get(response.confirm_title),
  1647               message: $lang.get(response.confirm_body),
  1647 							message: $lang.get(response.confirm_body),
  1648               buttons: [
  1648 							buttons: [
  1649                 {
  1649 								{
  1650                   text: $lang.get('acppl_btn_install'),
  1650 									text: $lang.get('acppl_btn_install'),
  1651                   color: 'red',
  1651 									color: 'red',
  1652                   style: {
  1652 									style: {
  1653                     fontWeight: 'bold'
  1653 										fontWeight: 'bold'
  1654                   },
  1654 									},
  1655                   onclick: function() {
  1655 									onclick: function() {
  1656                     ajaxPluginAction(action + '_confirm', plugin_filename, btnobj, true);
  1656 										ajaxPluginAction(action + '_confirm', plugin_filename, btnobj, true);
  1657                     miniPromptDestroy(this);
  1657 										miniPromptDestroy(this);
  1658                   }
  1658 									}
  1659                 },
  1659 								},
  1660                 {
  1660 								{
  1661                   text: $lang.get('etc_cancel'),
  1661 									text: $lang.get('etc_cancel'),
  1662                   color: 'blue',
  1662 									color: 'blue',
  1663                   onclick: function() {
  1663 									onclick: function() {
  1664                     miniPromptDestroy(this);
  1664 										miniPromptDestroy(this);
  1665                   }
  1665 									}
  1666                 }
  1666 								}
  1667               ]
  1667 							]
  1668             });
  1668 						});
  1669           return true;
  1669 					return true;
  1670         }
  1670 				}
  1671         // wait for fade effect to finish its run
  1671 				// wait for fade effect to finish its run
  1672         setTimeout(function()
  1672 				setTimeout(function()
  1673           {
  1673 					{
  1674             miniPrompt(function(div)
  1674 						miniPrompt(function(div)
  1675               {
  1675 							{
  1676                 if ( blackbox )
  1676 								if ( blackbox )
  1677                 {
  1677 								{
  1678                   blackbox.parentNode.removeChild(blackbox);
  1678 									blackbox.parentNode.removeChild(blackbox);
  1679                 }
  1679 								}
  1680                 var txtholder = document.createElement('div');
  1680 								var txtholder = document.createElement('div');
  1681                 txtholder.style.textAlign = 'center';
  1681 								txtholder.style.textAlign = 'center';
  1682                 txtholder.appendChild(document.createTextNode(response.error));
  1682 								txtholder.appendChild(document.createTextNode(response.error));
  1683                 txtholder.appendChild(document.createElement('br'));
  1683 								txtholder.appendChild(document.createElement('br'));
  1684                 txtholder.appendChild(document.createElement('br'));
  1684 								txtholder.appendChild(document.createElement('br'));
  1685                 
  1685 								
  1686                 // close button
  1686 								// close button
  1687                 var btn_cancel = document.createElement('a');
  1687 								var btn_cancel = document.createElement('a');
  1688                 btn_cancel.className = 'abutton abutton_red';
  1688 								btn_cancel.className = 'abutton abutton_red';
  1689                 btn_cancel.href = '#';
  1689 								btn_cancel.href = '#';
  1690                 btn_cancel.appendChild(document.createTextNode($lang.get('etc_ok')));
  1690 								btn_cancel.appendChild(document.createTextNode($lang.get('etc_ok')));
  1691                 
  1691 								
  1692                 txtholder.appendChild(btn_cancel);
  1692 								txtholder.appendChild(btn_cancel);
  1693                 div.appendChild(txtholder);
  1693 								div.appendChild(txtholder);
  1694                 
  1694 								
  1695                 btn_cancel.onclick = function()
  1695 								btn_cancel.onclick = function()
  1696                 {
  1696 								{
  1697                   miniPromptDestroy(this);
  1697 									miniPromptDestroy(this);
  1698                   return false;
  1698 									return false;
  1699                 }
  1699 								}
  1700               });
  1700 							});
  1701           }, 750);
  1701 					}, 750);
  1702       }
  1702 			}
  1703     });
  1703 		});
  1704 }
  1704 }
  1705 
  1705 
  1706 window.ajaxReverseDNS = function(o, text)
  1706 window.ajaxReverseDNS = function(o, text)
  1707 {
  1707 {
  1708   if(text) var ipaddr = text;
  1708 	if(text) var ipaddr = text;
  1709   else var ipaddr = o.innerHTML;
  1709 	else var ipaddr = o.innerHTML;
  1710   rDnsObj = o;
  1710 	rDnsObj = o;
  1711   rDnsBannerObj = bannerOn('Retrieving reverse DNS info...');
  1711 	rDnsBannerObj = bannerOn('Retrieving reverse DNS info...');
  1712   ajaxGet(stdAjaxPrefix+'&_mode=rdns&ip='+ipaddr, function(ajax) {
  1712 	ajaxGet(stdAjaxPrefix+'&_mode=rdns&ip='+ipaddr, function(ajax) {
  1713       if ( ajax.readyState == 4 && ajax.status == 200 )
  1713 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1714       {
  1714 			{
  1715         off = fetch_offset(rDnsObj);
  1715 				off = fetch_offset(rDnsObj);
  1716         dim = fetch_dimensions(rDnsObj);
  1716 				dim = fetch_dimensions(rDnsObj);
  1717         right = off['left'] + dim['w'];
  1717 				right = off['left'] + dim['w'];
  1718         top = off['top'] + dim['h'];
  1718 				top = off['top'] + dim['h'];
  1719         var thediv = document.createElement('div');
  1719 				var thediv = document.createElement('div');
  1720         thediv.className = 'info-box';
  1720 				thediv.className = 'info-box';
  1721         thediv.style.margin = '0';
  1721 				thediv.style.margin = '0';
  1722         thediv.style.position = 'absolute';
  1722 				thediv.style.position = 'absolute';
  1723         thediv.style.top  = top  + 'px';
  1723 				thediv.style.top  = top  + 'px';
  1724         thediv.style.display = 'none';
  1724 				thediv.style.display = 'none';
  1725         thediv.style.zIndex = getHighestZ() + 2;
  1725 				thediv.style.zIndex = getHighestZ() + 2;
  1726         thediv.id = 'mdgDynamic_rDnsInfoDiv_'+Math.floor(Math.random() * 1000000);
  1726 				thediv.id = 'mdgDynamic_rDnsInfoDiv_'+Math.floor(Math.random() * 1000000);
  1727         // FIXME: l10n
  1727 				// FIXME: l10n
  1728         thediv.innerHTML = '<b>Reverse DNS:</b><br />'+ajax.responseText+' <a href="#" onclick="elem = document.getElementById(\''+thediv.id+'\'); elem.innerHTML = \'\'; elem.style.display = \'none\';return false;">Close</a>';
  1728 				thediv.innerHTML = '<b>Reverse DNS:</b><br />'+ajax.responseText+' <a href="#" onclick="elem = document.getElementById(\''+thediv.id+'\'); elem.innerHTML = \'\'; elem.style.display = \'none\';return false;">Close</a>';
  1729         var body = document.getElementsByTagName('body');
  1729 				var body = document.getElementsByTagName('body');
  1730         body = body[0];
  1730 				body = body[0];
  1731         bannerOff(rDnsBannerObj);
  1731 				bannerOff(rDnsBannerObj);
  1732         body.appendChild(thediv);
  1732 				body.appendChild(thediv);
  1733         thediv.style.display = 'block';
  1733 				thediv.style.display = 'block';
  1734         left = fetch_dimensions(thediv);
  1734 				left = fetch_dimensions(thediv);
  1735         thediv.style.display = 'none';
  1735 				thediv.style.display = 'none';
  1736         left = right - left['w'];
  1736 				left = right - left['w'];
  1737         thediv.style.left = left + 'px';
  1737 				thediv.style.left = left + 'px';
  1738         thediv.style.display = 'block';
  1738 				thediv.style.display = 'block';
  1739         fadeInfoBoxes();
  1739 				fadeInfoBoxes();
  1740       }
  1740 			}
  1741     });
  1741 		});
  1742 }
  1742 }
  1743 
  1743 
  1744 window.ajaxGzipCheck = function()
  1744 window.ajaxGzipCheck = function()
  1745 {
  1745 {
  1746   var resultdiv = document.getElementById('gzip_check_result');
  1746 	var resultdiv = document.getElementById('gzip_check_result');
  1747   if ( !resultdiv )
  1747 	if ( !resultdiv )
  1748     return false;
  1748 		return false;
  1749   
  1749 	
  1750   resultdiv.innerHTML = '<img alt="Loading..." src="' + cdnPath + '/images/loading.gif" />';
  1750 	resultdiv.innerHTML = '<img alt="Loading..." src="' + cdnPath + '/images/loading.gif" />';
  1751   ajaxPost(makeUrlNS('Admin', 'GeneralConfig'), 'act=gzip_check', function(ajax)
  1751 	ajaxPost(makeUrlNS('Admin', 'GeneralConfig'), 'act=gzip_check', function(ajax)
  1752     {
  1752 		{
  1753       if ( ajax.readyState == 4 && ajax.status == 200 )
  1753 			if ( ajax.readyState == 4 && ajax.status == 200 )
  1754       {
  1754 			{
  1755         resultdiv.innerHTML = '';
  1755 				resultdiv.innerHTML = '';
  1756         var response = String(ajax.responseText + '');
  1756 				var response = String(ajax.responseText + '');
  1757         if ( !check_json_response(response) )
  1757 				if ( !check_json_response(response) )
  1758         {
  1758 				{
  1759           handle_invalid_json(response);
  1759 					handle_invalid_json(response);
  1760           return false;
  1760 					return false;
  1761         }
  1761 				}
  1762         response = parseJSON(response);
  1762 				response = parseJSON(response);
  1763         if ( response.error )
  1763 				if ( response.error )
  1764         {
  1764 				{
  1765           resultdiv.innerHTML = '<div class="error-box-mini">' + response.error + '</div>';
  1765 					resultdiv.innerHTML = '<div class="error-box-mini">' + response.error + '</div>';
  1766         }
  1766 				}
  1767         else
  1767 				else
  1768         {
  1768 				{
  1769           // probably success.
  1769 					// probably success.
  1770           resultdiv.innerHTML += response.server_does_it ?
  1770 					resultdiv.innerHTML += response.server_does_it ?
  1771             '<div class="error-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_server_does_it') + '</div>' :
  1771 						'<div class="error-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_server_does_it') + '</div>' :
  1772             '<div class="info-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_server_good') + '</div>';
  1772 						'<div class="info-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_server_good') + '</div>';
  1773           resultdiv.innerHTML += response.php_supports_gzip ?
  1773 					resultdiv.innerHTML += response.php_supports_gzip ?
  1774             '<div class="info-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_php_good') + '</div>' :
  1774 						'<div class="info-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_php_good') + '</div>' :
  1775             '<div class="error-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_php_bad') + '</div>';
  1775 						'<div class="error-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_php_bad') + '</div>';
  1776             
  1776 						
  1777           if ( response.php_supports_gzip && !response.server_does_it )
  1777 					if ( response.php_supports_gzip && !response.server_does_it )
  1778           {
  1778 					{
  1779             resultdiv.innerHTML += '<div class="success-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_success') + '</div>';
  1779 						resultdiv.innerHTML += '<div class="success-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_success') + '</div>';
  1780           }
  1780 					}
  1781           else
  1781 					else
  1782           {
  1782 					{
  1783             resultdiv.innerHTML += '<div class="error-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_failure') + '</div>';
  1783 						resultdiv.innerHTML += '<div class="error-box-mini">' + $lang.get('acpgc_field_gzip_check_msg_failure') + '</div>';
  1784           }
  1784 					}
  1785         }
  1785 				}
  1786       }
  1786 			}
  1787     });
  1787 		});
  1788 }
  1788 }