
function previewArticle(){
	
	
	
	var Params = $H({
		ArticleContent: $('ArticleContent').value
 	}).toQueryString()
	
	
	
	var aj = new Ajax.Request(AbsolutePath+'/article/preview',{
		parameters: Params,
		method: 'post',
		onComplete: function(res){
			$('preview').innerHTML = res.responseText;
			$('preview').focus();
//alert(res.responseText); 
		}
	});
}







function checkProfileForm(){

	var newPassword = document.getElementById('NewPassword');
	var newPassword2= document.getElementById('NewPassword2');
	var oldPassword	= document.getElementById('OldPassword');
	var password	= document.getElementById('Password');
	var passwordCurr= document.getElementById('PasswordCurrent');
	var profileForm = document.getElementById('profileForm');
	if(newPassword.value != newPassword2.value || newPassword.value == "" || newPassword2.value == ""){
		alert('Password error');
	} else {
		password.value = hex_md5(newPassword.value);
		
		if(hex_md5(oldPassword.value) != passwordCurr.value){
			alert('Please check your old password.');
		} else {
			profileForm.submit();
		}
	}
}


function checkNewUserForm(){
	alert('checkNewUserForm');
}
























/**************************Completer************************/
Autocompleter.Article = Class.create(Autocompleter.Base, {
  initialize: function(element, update, array, options) {
    this.baseInitialize(element, update, options);
    this.options.array = array;
  },
  
  
  updateElement: function(e){
  	var aaa = e;
  },

  getUpdatedChoices: function() {
    this.updateChoices(this.options.selector(this));
  },

  setOptions: function(options) {
    this.options = Object.extend({
      choices: 10,
      partialSearch: true,
      partialChars: 2,
      ignoreCase: true,
      fullSearch: false,
      selector: function(instance) {
        var ret       = []; // Beginning matches
        var partial   = []; // Inside matches
        var entry     = instance.getToken();
        var count     = 0;
        
        
        
        for (var i = 0; i < instance.options.array.length &&  
          ret.length < instance.options.choices ; i++) { 

          var elem = instance.options.array[i]['Title'];


          var foundPos = instance.options.ignoreCase ? 
            elem.toLowerCase().indexOf(entry.toLowerCase()) : 
            elem.indexOf(entry);
            

          while (foundPos != -1) {
            if (foundPos == 0 && elem.length != entry.length) {
            /*
            Articles.without($(instance.options.array[i].Id)).each(function(elm){
            	elm.hide();
            });
            
            $(instance.options.array[i].Id).show();
             */
              ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" + 
                elem.substr(entry.length) + "</li>");
              break;
            } else if (entry.length >= instance.options.partialChars && 
              instance.options.partialSearch && foundPos != -1) {
              
              
              if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
                partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
                  elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
                  foundPos + entry.length) + "</li>");
                break;
              }
            }

            foundPos = instance.options.ignoreCase ? 
              elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : 
              elem.indexOf(entry, foundPos + 1);

          }
        }
        if (partial.length)
          ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
        return "<ul>" + ret.join('') + "</ul>";
      }
    }, options || { });
  }
});
/**************************Completer************************/



/**

var s=document.createElement('script');
s.setAttribute('src', 'http://jquery.com/src/jquery-1.0.4.js');
document.getElementsByTagName('body')[0].appendChild(s);
alert('thank you for using jquery!');
void(s);


function require(file){
	var path = file.split('.').join('/');
	alert(path);
}


**/
