// JavaScript Document


//scroll

var scrj = 1;
function softScrollBack() {
   if(navigator.appName == "Microsoft Internet Explorer" && document.compatMode == "CSS1Compat") {
      var scdist = document.body.parentNode.scrollTop;
   } else {
      var scdist = document.body.scrollTop;
   }
   if(scrj<50 && scdist) {
      scdist = (scdist>2) ? Math.ceil(scdist*.2) : 1;
      scrj++;
      scrollBy(0,-scdist);
      setTimeout("softScrollBack()",20);
   } else {
      scrollTo(0,0);
      scrj = 1;
   }
}


function item_added() {
			for (i=0;i<document.forms[0].elements.length;i++) {
				document.forms[0].elements[i].disabled = false;
			}
			document.forms[0].text.value = '';
			new Effect.Fade('progress');
			new Effect.Appear('newComment');
		}
		function item_loading() {
			for (i=0;i<document.forms[0].elements.length;i++) {
				document.forms[0].elements[i].disabled = true;
			}
			new Effect.Appear('progress');
			if (document.forms[0].bakecookie[0].checked) rememberMe(document.forms[0]);
		}
		Ajax.Responders.register({
			onCreate: function() {
				if($('busy') && Ajax.activeRequestCount>0)
				Effect.Appear('busy',{duration:0.5,queue:'end'});
			},
			onComplete: function() {
				if($('busy') && Ajax.activeRequestCount==0)
				Effect.Fade('busy',{duration:0.25,queue:'end'});
			}
		});

		function ajax_post()
		{
			Form.disable('comments-open-footer');
			new Effect.Appear('progress', {duration: 0.0});
			var url = '/mt/mt-comments.cgi';
			var pars = Form.serialize('comments_form')+'&post=Post';
			var myAjax = new Ajax.Updater( 'comment_posted', url, { 
																		method: 'post', 
																		parameters: pars,
																		onComplete: highlight_comment
																		});	
			
			
			return false;
		}
		
		function highlight_comment()
		{
			new Effect.Fade('comment_form_block', { duration: 0.2, queue:'end' });
			new Effect.Appear('comment_posted', { duration: 0.5, queue:'end' } );
			new Effect.Highlight('comment_posted',{ startcolor: '#FF9933', duration: 2.0 });
		}
		
		function ajax_preview()
		{
			var url = '/mt/mt-comments.cgi';
			var pars = Form.serialize('comments_form')+'&preview=Preview';
			var myAjax = new Ajax.Updater( 'comment_posted', url, { 
																		method: 'post', 
																		parameters: pars,
																		onComplete: highlight_preview
																		});	
			
			return false;
		}
		
		function highlight_preview()
		{
			new Effect.Appear('comment_posted', { duration: 0.5, queue:'end' } );
			new Effect.Highlight('comment_posted',{ startcolor: '#FF9933', duration: 2 });
		}
		
		function comment_error()
		{
			Form.enable('comments-open-footer');
		}
		
		function ReloadTextDiv()
		{
		var NewText = document.getElementById("DynamicText").value;
		splitText = NewText.split(/\n/);
		var DivElement = document.getElementById("TextDisplay");
		var i = 0;
			DivElement.innerHTML = '';
			for(i = 0; i < splitText.length; i++) {
			  if(splitText[i].length > 0 ) {
				DivElement.innerHTML += splitText[i] + "<br />";
			  }
			}
		}
		
		function ReloadNameDiv()
		{
		var NewText = document.getElementById("author").value;
		var DivElement = document.getElementById("NameDisplay");
		DivElement.innerHTML = NewText;
		}
		
		function ReloadWebDiv()
		{
		var NewText = document.getElementById("website").value;
		var DivElement = document.getElementById("WebDisplay");
		DivElement.innerHTML = "<img style='position:absolute; right:100px;' align='absmiddle' border='0' src='http://www.brettdewoody.com/graphics/comment-url.gif' />";
		}








