function startApplet() {
	if((navigator.userAgent.indexOf('Safari')!=-1 && navigator.userAgent.indexOf('Chrome')==-1) || navigator.appVersion.toLowerCase().indexOf("mac")>0)
		return false;
	else 
		return true;
}

var newWindowAjedrez = null;
var newWindowTrivia = null;
var newWindowTablero = null;
var newWindowCartas = null;

function closeWin(sala){
	if(sala=='Ajedrez') {
		if (newWindowAjedrez != null){
			if(!newWindowAjedrez.closed)
				newWindowAjedrez.close();
		}
	} else if(sala=='Trivia') {
		if (newWindowTrivia != null){
			if(!newWindowTrivia.closed)
				newWindowTrivia.close();
		}
	} else if(sala=='Tablero') {
		if (newWindowTablero != null){
			if(!newWindowTablero.closed)
				newWindowTablero.close();
		}
	} else if(sala=='Cartas') {
		if (newWindowCartas != null){
			if(!newWindowCartas.closed)
				newWindowCartas.close();
		}
	}
}

function abrirSala(sala, juego) {
	
	var  top=0;
	var left=0;
	var awidth=1210;
	var aheight=858;
	
	if(screen.availWidth>1210 && screen.availHeight>858) {
		awidth=1210;
		aheight=858;
		left = (screen.availWidth-1210)/2;
		top = (screen.availHeight-858)/2-20;
	} else {
		awidth=screen.availWidth;
		aheight=screen.availHeight;
		left = 0;
		top = 0;		
	}
	
	var params = 'width='+awidth+', height='+aheight;
	 params += ', top='+top+', left='+left;
	 params += ', directories=no';
	 params += ', location=no';
	 params += ', menubar=no';
	 params += ', resizable=yes';
	 params += ', scrollbars=no';
	 params += ', status=no';
	 params += ', toolbar=no';
	 params += ', titlebar=no';

 if (sala == 'Ajedrez') {
	 closeWin('Ajedrez');
	 newWindowAjedrez = window.open('/salas/ajedrez.jsp','Ajedrez',params);
	 if(newWindowAjedrez!=null) {	 
		 newWindowAjedrez.resizeTo(awidth,aheight);
		 newWindowAjedrez.focus();
	 }
	 return;
 } else if(sala == 'Trivia') {
	 closeWin('Trivia');
	 newWindowTrivia = window.open('/salas/trivia.jsp?juego='+juego,'Trivia',params);
	 if(newWindowTrivia!=null) {
		 newWindowTrivia.resizeTo(awidth,aheight);
		 newWindowTrivia.focus();
	 }
	 return;
 } else if(sala == 'Tablero') {
	 closeWin('Tablero');
	 newWindowTablero = window.open('/salas/tablero.jsp?juego='+juego,'Tablero',params);
	 if(newWindowTablero!=null) {	 
		 newWindowTablero.resizeTo(awidth,aheight);
		 newWindowTablero.focus();
	 }
	 return;
 } else if(sala == 'Cartas') {
	 closeWin('Cartas');
	 newWindowCartas = window.open('/salas/cartas.jsp?juego='+juego,'Cartas',params);
	 if(newWindowCartas!=null) {
		 newWindowCartas.resizeTo(awidth,aheight);
		 newWindowCartas.focus();
	 }
	 return;
 }
}
