function jsPopUp(url, width, height, left, top) {
  if (width == null) {width = 500;}
  if (height == null) {height = 550;}
  if (left == null) {left = 100;}
  if (top == null) {top = 100;}
	var x = window.open(url, 'ProntoGame', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height+',left='+left+',top='+top+'');
  x.focus();
}
function jsSH(n) {
  var obj = self.document.getElementById('FAQ' + n);
  if (obj != null) {
	obj.style.display = (obj.style.display == 'none') ? '' : 'none';
  }
}

/*
var nav = navigator.appName;
var ns = (nav.indexOf("Netscape") != -1);
if (ns) {
  if (document.layers) {
	document.captureEvents(Event.KEYPRESS);
	document.onkeypress = trap;
  }
  if (document.getElementById) {
	document.onkeypress = trap;
  }
} else {
  document.onkeypress = trap;
}

function trap(e) {
  var kr = false;
  if (window.event) {
	if (window.event.keyCode == 13) {
	  window.event.keyCode = 0;
	  kr = true;
	}
  } else if (e) {
	if (e.which == 13) {
	  //e.which = 0; //readonly
	  kr = true;
	}
  }
  if (kr == true) {
	if (self.document.forms[0] != null) {
	  var oF = self.document.forms[0];
	  for (var n=0; n<oF.elements.length; n++) {
		var oE = oF.elements[n];
		if (oE.type == 'submit') {
		  oE.click();
		  break;
		}
	  }
	}
  }
}		
*/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function jsShow(id) {
  MM_showHideLayers(id,'','show');
}
function jsHide(id) {
  MM_showHideLayers(id,'','hide');
}

var engineDir  = "G3P/"
var gamesDir = engineDir + "games/"

function popUpGame(code) {	
	var w = 500
	var h = 400
	var l = Math.floor((screen.width-w)/2);
	var t = Math.floor((screen.height-h)/2);
	//
	var URL = 'http://' + self.location.host + '/';
	if (self.location.host == 'localhost') {URL += 'pgFE/';}
	URL += engineDir + 'instantGame.htm?' + code;
	if (typeof gameWindow != "undefined") gameWindow.close();
	//alert(URL)
	gameWindow = window.open(URL, 'game', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,' + 'width='+w+',height='+h+',left ='+l+',top ='+t);
}

function jsInsertChat(lang) {
  if (lang == null) {lang = 'en';}
  //var str = '<script language="JavaScript" src="http://livesupport.prontogame.com/als.aspx?lang=' + lang + '"></script>';
  var str = '<script language=\"JavaScript\" src=\"http://livesupport.prontogame.com/als.aspx?lang=' + lang + '\"><\/script>';
  //var str = '<img src="images/falsechat.gif">';
  self.document.write(str);
}

function getRules(gameCode, lang) {
  var winW = 700, winH = screen.height - 100;
  self.open('G3P/rules/rules.aspx?gameCode=' + gameCode + '&lang=' + lang, 'GameRules', 'toolbar=0, scrollbars=1,	location=0, statusbar=0, menubar=0, resizable=1, width=' + winW + ', height=' + winH + ' , left = 0, top = 0 ');
}
function writeGamesHelps(games, lang) {
  for (var i=0; i<games.length ;i++) {
	gameCode = games[i][0];
	strictGameCode = gameCode.split('/')[2];
	gameLabel = games[i][1];
	self.document.write('<div style="text-align:left; padding:4px 0px 4px 10px;"> <a href="#" onclick="getRules(\'' + gameCode +'\',\'' + lang + '\')" style="text-decoration:none;">' + gameLabel + ' </a></div>');
	self.document.write('<hr />');
  }
}

