﻿// Fichier JScript
var ApplicationWebFolder = location.pathname.slice(0, location.pathname.indexOf ("/aspx/"));

function open_popup(page, hauteur, largeur,resizable) {
  var lalargeur =  largeur+20  ; // ici la largeur du popup 
  var lahauteur = hauteur+20 ;  // ici la hauteur du popup 
  var t = (screen.height-lahauteur)/2 ;  // pour centre selon la hauteur de l'écran 
  var l = (screen.width-lalargeur)/2 ; // pour centrer selon la largeur de l'écran 	
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	window.open(page,'popup','width='+lalargeur+',height='+lahauteur+',toolbar=no,scrollbars=yes, resizable='+resizable+',menubar=no,top ='+t+',left='+l+'');	
}

function launchGame(numGame, theme) {
    var w = screen.availWidth; 
    var h = screen.availHeight; 
    var myWin = window.open(ApplicationWebFolder + "/aspx/member/LaunchGame.aspx?gameNum=" + numGame + "&debugLevel=1&consoleMode=1&theme=" + theme, "fenetreJeu","toolbar=no,status=no,directories=no,menubar=no,fullscreen=no,location=no,scrollbars=yes,resizable=yes");
    myWin.moveTo(0,0);myWin.resizeTo(w, h);myWin.focus();
}

function launchGameNoDebug(numGame, theme) {
    var w = screen.availWidth; 
    var h = screen.availHeight; 
    var myWin = window.open(ApplicationWebFolder + "/aspx/member/LaunchGame.aspx?gameNum=" + numGame + "&debugLevel=0&consoleMode=0&theme=" + theme, "fenetreJeu","toolbar=no,status=no,directories=no,menubar=no,fullscreen=no,location=no,scrollbars=yes,resizable=yes");
    myWin.moveTo(0,0);myWin.resizeTo(w, h);myWin.focus();
}

//Fonctions utilisées pour l'affichage de cartouche de jeux
/* variables */
__ACTIVE_GAME__=false;
__INIT_MASK__=false;
__HIDE_TIMEOUT__=false;
__DEFAULT_MENU_NAME__=false;
var iframetmp = null;


ifrlayer = {
	make:function(obj) 
	{
	    if(!obj) return;
	    obj = (typeof(obj)=="string") ? document.getElementById(obj) : obj;
	    if(!obj) return;
		if(document.all && window.print && !window.opera && document.getElementById && !obj.iframelayer )
		{
			if(obj.parentNode && !obj.iframelayer) var ifr = obj.parentNode.insertBefore(document.createElement("iframe"), obj);
			if(obj.currentStyle.zIndex != "" && parseInt(obj.currentStyle.zIndex)>1 ) 
			{
				ifr.style.zIndex = parseInt(obj.currentStyle.zIndex)-1;
			}
			ifr.src = "javascript:false";
			with(ifr.style) 
			{ 
				filter = "mask()";
				position = "absolute";
			}
			obj.iframelayer = ifr;
		}
		if (obj.iframelayer) 
		{
			with(obj.iframelayer.style) 
			{
				width  =  obj.offsetWidth+"px";
				height =  obj.offsetHeight+"px";
				visibility = "visible";
			}
			ifrlayer.move(obj)
		}
		
	},
	hide:function(obj) {
		if(!obj) return; obj = typeof(obj)=="string" ? document.getElementById(obj) : obj; if (!obj) return;
		if(obj.iframelayer) {
			obj.iframelayer.style.visibility="hidden";
		}
	},
	move:function(obj) 
	{
		if(obj && obj.iframelayer) 
		{
		    with(obj.iframelayer.style) 
		    {
			    top = obj.offsetTop+"px";
			    left =  obj.offsetLeft+"px"
		    }
		}
	}
}
function openGame(strGameName)
{
    var menu = document.getElementById(strGameName);
    if(__HIDE_TIMEOUT__) clearTimeout(__HIDE_TIMEOUT__); 
    closeGame()
    if (menu) 
    {		
	    menu.style.visibility = "visible";
	    ifrlayer.make(menu);
    }
    else
    { 
	    closeGame();
	}
    menu.onmouseover= function() { clearTimeout(__HIDE_TIMEOUT__); }
    menu.onmouseout=activetimeout;
    __ACTIVE_GAME__ = strGameName;
}

function activetimeout()
{
	if(__HIDE_TIMEOUT__) clearTimeout(__HIDE_TIMEOUT__);
	__HIDE_TIMEOUT__= setTimeout("closeGame()", 10);
}

function closeGame()
{
	var activemenu = document.getElementById(__ACTIVE_GAME__);
	if (activemenu) 
	{
		activemenu.style.visibility = "hidden";
	}
	ifrlayer.hide(activemenu);
}


/*****************EMPECHE COPIER COLLER**************/
/*****************Globals****************/
var currentText = '';//initualizes the text of the text area.
var EmailCon = null;//this will be the textarea.
/****************************************/


/****************************************************************************
void startPreventPaste();
initializes the copy paste monitor.

****************************************************************************/

function startPreventPaste(EmailConfLbl)
{
    EmailCon = document.getElementById(EmailConfLbl);
    var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
    if (isIE)
    {
    }
    else
    {
        doLoop();
    }
}
/****************************************************************************
void doLoop()
starts the timer. Checks the text.
****************************************************************************/

function doLoop()
{
    checkText();            
    pccpTimer = window.setTimeout("doLoop();", 10);
}
/****************************************************************************
void checkText()
checks the length of the string in the textbox and compares it with
the length of the string in the saved currentText string. If the
text box text is 10 characters longer than the saved string then it
assumes that they have pasted. it puts the current string back into
the textarea over what they pasted and then shows them the message.
if it isn't longer then it just puts the text into the saved text.

****************************************************************************/

function checkText()
{
    if(EmailCon)
    {
        newTextLength = EmailCon.value.length;//gets length of the textarea right now.
        currentTextLength = currentText.length;//gets length of the saved text from the textarea
        
        if(newTextLength > (currentTextLength + 3))
        {
            //is the new more then 3 characters longer?
            EmailCon.value = currentText;//put the saved text back in/
        }
        else
        {
            currentText = EmailCon.value;//if it is ok then save the text.
        }
    }
}

