// JavaScript Document
var isLoggedIn = false;
var toolBarName = "Default";//"Basic" "Default"

function initApplication() {
	if(document.sms) {
		document.sms.initGateway(smsURL);
		document.sms.initMainApp(module);
	}
}
function initEditor() {
	if(document.sms) {
		document.sms.prueba(toolBarName);
	}
}
function setEditor(editor) {
	if(document.sms) {
		//document.sms.prueba(toolBarName);
		toolBarName=editor;
	}
}
function onBeforeUnload(e) {
	if(document.sms) {
		if(document.sms.isLoggedIn()) {
			isLoggedIn=true;
			if(window.event) {
				window.event.returnValue='Al cerrar o actualizar esta ventana se cerrara su sesion.';
			}
			else {
				e.preventDefault();
				e.returnValue='Al cerrar o actualizar esta ventana se cerrara su sesion.';
			}	
			if(document.sms.callPreventLogOut) document.sms.callPreventLogOut();
		}	
	}	
}

function onUnload(e) {
	if(document.sms) {
		if(isLoggedIn) {
			if(window.event) var newWindow = window.open(smsURL+'logout.php','logout','width=1 ,height=1');
			else var newWindow = window.open(smsURL+'logout.php');
		}
	}
}

function getClipboard() {
	var t = document.createElement('input');
	t.setAttribute('type','text');
	t.setAttribute('value','');
	t.style.visibility='hidden';
	document.body.appendChild(t);
	
	pTxt=t.createTextRange();
	pTxt.execCommand("Paste");
	
	document.body.removeChild(t);
	
	document.sms.returnClipboard(t.value);
}

function setStatus(msg) {
	window.status = msg;	
}
// handle when flash text field gets focus, text field in iframe is greedy
function fcDefocus() {
	//alert(navigator.appName);
	//var movie = fcGetMovieById(movieId);
	window.focus();
	document.sms.focus();
}

// get reference to the flash movie
/*
function fcGetMovieById(id) {
	if (navigator.appName.indexOf ("Microsoft") !=-1) {
		return window[id];
	} 
	else {
		return window.document[id];
	}
}
*/