var lib = new Array(56, 54, 56);

// CHECK SHORTCUTS ---
var pressString = ""
function checkShortcuts(e) {
	var myKey = e.which;
	if (!myKey) { myKey = e.keyCode; }
	if (myKey == lib[0] && pressString == "") {
		pressString = 1;
	} else if (myKey == lib[1] && pressString == 1) {
		pressString = 2;
	} else if (myKey == lib[2] && pressString == 2) {
		showLogin();
		pressString = "";
	} else {
		pressString = "";
	}
}

// SHOW LOGIN JAVASCRIPT
function showLogin() {
	document.getElementById("cms_login_push").style.display = "block";
	moveLogin();
}

// MOVE LOGIN
var divPos = -60;
var destination = 0;

function moveLogin() {
	if(divPos < destination) {
		divPos += 10;
		document.getElementById("cms_login").style.top = divPos;
		if(divPos < destination-10) {
			document.getElementById("cms_login_push").style.height = divPos + 52;
		} else {
			document.getElementById("cms_login_push").style.height = 52;
		}
		t = setTimeout("moveLogin();", 20);
	} else {
		document.getElementById("username").select();
	}
}

// SHOW LOGIN JAVASCRIPT
function hideLogin() {
	moveLoginHide();
}

// MOVE LOGIN HIDE
function moveLoginHide() {
	if(divPos > -60) {
		divPos -= 10;
		document.getElementById("cms_login").style.top = divPos;
		document.getElementById("cms_login_push").style.height = divPos + 52;
		t = setTimeout("moveLoginHide();", 20);
	} else {
		document.getElementById("cms_login_push").style.display = "none";
	}
}// SHOW CONFIRM
function myConfirm(myText,action) {
	$("myConfirmText").innerHTML = myText;
	//$("myConfirmAction").href = "javascript:"+action;
	$("myConfirmAction").onclick = function() { closeTopElement('myConfirm'); eval(action); };
	showTopElement('myConfirm');
}
// SHOW ALERT
function myAlert(myText) {
	$("myAlertText").innerHTML = myText;
	showTopElement('myAlert');
}
// SHOW ACTION
function myAction(myText) {
	$("myActionText").innerHTML = myText;
	showTopElement('myAction');
}
function closeAction() {
	closeTopElement('myAction');
}
// SHOW POP
function showElement(element) {
	$(element).style.display = "block";
	loadScreen();
	$(element).style.left = ((myWidth / 2) - ($(element).offsetWidth / 2)) + "px";
	$(element).style.top = ((myHeight / 2) - ($(element).offsetHeight / 2) + myScroll) + "px";
	showBG();
}
// CLOSE POP
function closeElement(element) {
	$(element).style.display = "none";
	hideBG();
}
// SHOW TOP POP
function showTopElement(element) {
	$(element).style.display = "block";
	loadScreen();
	$(element).style.left = ((myWidth / 2) - ($(element).offsetWidth / 2)) + "px";
	$(element).style.top = ((myHeight / 2) - ($(element).offsetHeight / 2) + myScroll) + "px";
	showTopBG();
}
// CLOSE TOP POP
function closeTopElement(element) {
	$(element).style.display = "none";
	hideTopBG();
}
// SHOW BG
function showBG() {
	loadBG();
	$("editBG").style.display = "block";
}
// HIDE BG
function hideBG() {
	$("editBG").style.display = "none";
}
// SHOW TOP BG
function showTopBG() {
	loadBG();
	$("alertBG").style.display = "block";
}
// HIDE TOP BG
function hideTopBG() {
	$("alertBG").style.display = "none";
}
// HIDE BG
function loadBG() {
	loadScreen();
	$("editBG").style.width = myScrollWidth;
	$("editBG").style.height = myScrollHeight;
	$("alertBG").style.width = myScrollWidth;
	$("alertBG").style.height = myScrollHeight;
}
// LOAD SCREEN ATTRIBUTES
var myWidth = 0, myHeight = 0, myScroll = 0; myScrollWidth = 0; myScrollHeight = 0;
function loadScreen() {
	if (document.all) {
		myWidth  = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		myHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		myScroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	} else {
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	}
	if (window.innerHeight && window.scrollMaxY) {	
        myScrollWidth = document.body.scrollWidth;
		myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { 
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = document.body.scrollHeight;
	} else { 
		myScrollWidth = document.body.offsetWidth;
		myScrollHeight = document.body.offsetHeight;
	}
}