Import('myLib/events/CreatorEvents.js');

LoadAdmin = function(url, serviceId, parentId, pageId){
	this.url = url;
	this.serviceId = serviceId;
	this.parentId =parentId;
	this.pageId = pageId;
	this.keyCode1 = 54; //55 - klawisz 7
	this.keyCode2 = 17;
	this.keyCode3 = 190;
	this.reset();
};

LoadAdmin.prototype.reset = function(){
	this.key1 = 0;
	this.key2 = 0;
	this.key3 = 0;
};

LoadAdmin.prototype.addEvents = function(){
	LoadAdmin.self = this;
	new CreatorEvents(window).add('keydown', function(e){ LoadAdmin.self.open(e); });
};

LoadAdmin.prototype.open = function(e){
	if(window.event)
		var key = window.event.keyCode;
	else
		var key = e.which;

	if(key == this.keyCode1){
		this.reset();
	}

	if(this.key1 == 0){
		this.key1 = key;
		return;
	}
	if(this.key2 == 0){
		this.key2 = key;
		return;
	}
	if(this.key3 == 0){
		this.key3 = key;
	}

	if(this.key1 == this.keyCode1 && this.key2 == this.keyCode2 && this.key3 == this.keyCode3){
		window.open(this.url + '?redirect=admin/index.php%serwis='
		+ this.serviceId + '@id=' + this.parentId + '@zaz=' + this.pageId); // + '#' + this.parentId
		this.reset();
	}
};
