if (typeof jQuery !== 'undefined') {
	
	jQuery(function ($) {
		
		var mt_edit = function (o) {
			if(page_id && blog_id){
				window.open('/cgi-bin/mt/mt.cgi?__mode=view&_type=' + type + '&id=' + page_id + '&blog_id=' + blog_id, "mt");
			}else{
				alert("Questetra BPM Suite!");
			}
		},
		unbind = function (o) {
			if (o.unbind === true) {
				$(this).unbind('keydown.cheatCode' + o.code.toString());
			}
		};

		$.fn.extend({
			cheatCode: function (options) {
				var $$	= $(this),
					s	= $.extend({}, $.fn.cheatCode.defaults, options),
					o	= $.metadata ? $.extend({}, s, $$.metadata()) : s,
					k	= [];
				
				return this.each(function () {
					$$.bind('keydown.cheatCode' + o.code.toString(), function (event) {
						k.push(event.keyCode);
						if (k.toString().indexOf(o.code) >= 0) {
							k = [];
							o.activated.call(this, o);
							unbind.call(this, o);
						}
					});
				});
			}
		});
		
		$.fn.cheatCode.defaults = {
			code:		'38,38,40,40,37,39,37,39,66,65',
			unbind:		true,
			activated:	function (o) {mt_edit(o)},
			message:	'Cheat Code Activated'
		};
	}(jQuery));
	
	// UI-Buttons
	jQuery( function( $ ){
		// btns
		$('.btn-new-win').button({
			icons:{
			primary: 'ui-icon-newwin'
		  },
		  text: true
		});
		$('.btn-detail').button({
			icons:{
			primary: 'ui-icon-search'
		  },
		  text: true
		});
		$('.btn-next').button({
			icons:{
			secondary: 'ui-icon-arrowthick-1-e'
		  },
		  text: true
		});
		$('.btn-previous').button({
			icons:{
			primary: 'ui-icon-arrowthick-1-w'
		  },
		  text: true
		});
		$('.btn-return').button({
			icons:{
			primary: 'ui-icon-arrowreturnthick-1-n'
		  },
		  text: true
		});
	});
	
}
