/**
 * @author Aravintha Krishnan Jagannathan
 * @since Moveo 1.0
 * Key Handler
 */

if(window.history) {
	window.history.forward();
}
function doHourglass(a){
  document.getElementById("cccPassengerListForm").style.cursor = "wait";
}


function mouseEvent() {
	if(window.event && document.readyState!="complete" && document.body) {
		document.body.style.cursor="busy";
		return;
    }
	document.body.style.cursor="default";
}

function keysEvent() {
	if(window.event) {
		var elemTagName = event.srcElement.tagName;
		if((window.event.keyCode == 8 && elemTagName != "INPUT" && elemTagName != "TEXTAREA") || window.event.keyCode == 27) {
			return noEventAction();
		}
		mouseEvent();
	}
	return TRUE_FLAG;
}

function noEventAction() {
	window.event.cancelBubble = TRUE_FLAG;
	window.event.returnValue = FALSE_FLAG;
	return FALSE_FLAG;
}

//alert_window.js must be included on top of this js 
function disableEvents() {
	if(popupIsShown) {
		
		if(window.event.keyCode == 13 || window.event.keyCode == 32) {  // Events for Enter,Space
			return;
		}
		else if(window.event.keyCode == 27){
			if(document.getElementById(btn2)){
				hidePopWin(btn2);
			}else
				hidePopWin(btn1);
			return;
		}
		else {
			setPopupButtonEvent();
		}
		return false;
	}
	else {
		return keysEvent();
	}
}

window.onscroll = centerPopWin;

//document.onmousemove = mouseEvent;
document.oncontextmenu=setPopupButtonEvent
document.onkeydown=disableEvents
