//check from flash
var jsReady = false;
function isReady(){
	return jsReady;
}
//body onload invokes this function
function pageInit(){
	jsReady = true;
}
//get element (with IE exception)
function thisMovie(movieName){
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

//call to actionScript
function sendToFlash( method , args){
	thisMovie("tidewayFlashContent").sendToFlash(method, args);
	hideUploadForm();
}

//here we receive messages from actionscript
function sendToJavaScript(status){
	switch(status){
		case 'ready':
			
		break;
		case 'initUpload':
			showUploadForm();
			return false;
		break;
		case 'abortUpload':
			hideUploadForm();
			return false;
		break;
	}
}

function showUploadForm(){
	document.getElementById('flash_overlay').style.visibility = 'visible';
}

function hideUploadForm(){
	document.getElementById('cv_upload_form').reset();
	document.getElementById('flash_overlay').style.visibility = 'hidden';
}

function detectEvent(e) {
	var evt = e || window.event;
	if(evt.type && evt.keyCode == 27){
		hideUploadForm();
	}
}

document.onkeydown = detectEvent;
