Event.observe(window, 'load', init);

var gui={
	updateContent:function(id){
		$(id).visualEffect('Pulsate',{pulses: 2});
	},
	showEdit:function(id){
		$(id).visualEffect('Highlight');
	},
	insertNewComment: function(response) {
		$('CommentBody').innerHTML = "";
		var ob = new Insertion.Bottom('postCommentsList', response.responseText);
		//ob.visualEffect('Pulsate',{pulses: 2});
	}
}

function init () {
	initKeyboard();
}

/**
* Checks if native keyboard is enabled, if not
* emulate thaana keyboard
*/
function initKeyboard() {
	if ($('commentPost') != null) {
		if ($('commentPost').hasClassName('dv')){
			var thaana=false;
			$('CommentBody').onkeypress = function (e) { 
				thaana = checkThaana(e); 
				if (!thaana){
					$('CommentBody').onkeypress = DhivehiKey;
				}
			};
			
		}
	}
} /* end initKeyboard */


/**
* Checks if native keyboard is enabled, if not
* emulate thaana keyboard
*/
function commentEditKeyboard(id) {
	if ($(id) != null) {
		if ($(id).hasClassName('dv')){
			$A($(id).getElementsByTagName('textarea')).each(function (obj) {
				obj.onkeypress = DhivehiKey;
			});
		}
	}
} /* end initKeyboard */


/**
* Auto Scroll Effects by Tobie Langel (http://tobielangel.com)
* requires prototype 1.5.1, scriptaculous 1.7.1
**/
function autoscroll () {
	if ($$('a[href^=#]:not([href=#])') != null) {
		$$('a[href^=#]:not([href=#])').each(function(element) {
		element.observe('click', function(event) {
		  new Effect.ScrollTo(this.hash.substr(1));
		  Event.stop(event);
		}.bindAsEventListener(element))
		})

	}
} /* end autoscroll */
