<!DOCTYPE HTML>
<html>

<!--
  pgn4web javascript chessboard
  copyright (C) 2009-2013 Paolo Casaschi
  see README file and http://pgn4web.casaschi.net
  for credits, license and more details
-->

<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

<title>pgn4web chess live broadcast</title>

<script src="pgn4web-server-config.js" type="text/javascript"></script>
<script type="text/javascript">
"use strict";

// this should have been defined in pgn4web-server-config.js
// setting default value here just in case
var pgn4web_live_pointer_url;
if (pgn4web_live_pointer_url === undefined) { pgn4web_live_pointer_url = "."; }
</script>

<style type="text/css">

html, body
{ margin: 0px; padding: 0px; }

body
{ color: #BBBBBB; background: white; font-family: sans-serif; padding: 28px; }

a
{ color: #BBBBBB; text-decoration: none; }

a:hover, a:active
{ color: red; }

</style>

<link rel="shortcut icon" href="pawn.ico" />

</head>

<body onResize="resizeFrameHeight(document.getElementById('liveframe'));">

<table border="0" cellpadding="0" cellspacing="0" width="99.9%" height="99.9%"><tbody><tr><td id="headRow">
<h1 style="margin-top:0px; padding-top:0px; text-align:right;">
<span style="float:left; color:red;">
pgn4web chess live broadcast
</span>
<a href="." onfocus="this.blur();" style="width:49px; height:29px; background:url(pawns.png) -47px -15px; vertical-align:baseline; display:inline-block;"></a>
</h1>
</td></tr><tr><td style="padding: 40px;">
<table id="framecontainer" cellpadding="0" cellspacing="0" width="100%" height="100%" style="background-color: #EDE8D5; box-shadow: 0px 0px 20px #663300; border-color: #EDE8D5; border-style: solid; border-width: 40px; border-radius: 10px;" onclick="toggleLiveMode();"><tbody><tr valign="middle"><td align="center">
<table id="frameinnercontainer" cellpadding="0" cellspacing="0" width="100%" height="100%" onclick="stopEvProp(event);"><tbody><tr valign="middle"><td align="left" valign="top">
<iframe style="opacity: 0.9;" id="analysisframe" name="analysisframeForLiveDotHtml" src="about:blank" height="0" width="0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">your browser does not support the required iframe functionality</iframe>
</td><td width="100%" align="center">
<iframe id="liveframe" src="about:blank" height="360" width="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">your browser does not support the required iframe functionality</iframe>
</td></tr></tbody></table>
</td></tr></tbody></table>
</td></tr></tbody></table>

<script type="text/javascript">
"use strict";

var thisRegExp, theObj;

thisRegExp = /(&|\?)(hp|headlessPage)=(t|true)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
  if (theObj = document.getElementById("headRow")) {
    theObj.style.display = "none";
  }
}

var liveMode = "compact";
thisRegExp = /(&|\?)(mode|m)=([^&]*)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
  liveMode = unescape(window.location.search.match(thisRegExp)[3]);
}
if ((liveMode == "random") || (liveMode == "r")) {
  liveMode = ["analysis", "compact", "dynamic", "widget"][Math.floor(4 * Math.random())];
}
if (liveMode == "a") { liveMode = "analysis"; }
if (liveMode == "c") { liveMode = "compact"; }
if (liveMode == "d") { liveMode = "dynamic"; }
if (liveMode == "w") { liveMode = "widget"; }
if ((liveMode != "analysis") && (liveMode != "compact") && (liveMode != "dynamic") && (liveMode != "widget")) {
  liveMode = "compact";
}

var pgnData = "";
thisRegExp = /(&|\?)(pgnData|pd)=([^&]*)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
  pgnData = unescape(window.location.search.match(thisRegExp)[3]);
}

setLiveMode(liveMode);

function setLiveMode(lm) {
  var iniGame='\\[\\s*Result\\s*"\\*"\\s*\\]';
  var extraParams = "ig=" + iniGame + (pgnData ? "&pd=" + pgnData : "");

  var theFrameObject = document.getElementById("liveframe");
  var theAnalysisObject = document.getElementById("analysisframe");
  var theContainerObject = document.getElementById("framecontainer");
  if (theFrameObject && theAnalysisObject && theContainerObject) {
    liveMode = lm;
    if (liveMode == "analysis") {
      theFrameObject.src = pgn4web_live_pointer_url + "/dynamic-frame.html?l=t&ct=pink&scf=t&pf=u&ewt=analysisframeForLiveDotHtml&ewh=240&eww=192&ewup=lch%3DEDE8D5%26dch%3DCFCBB3%26hch%3DF8CCA0%26fmch%3D302F29%26ctch%3D9C9886%26bch%3DEDE8D5%26ss%3D24%26fpr%3D0%26pf%3Du%26fms%3D11%26fcs%3D19&ewpi=t&" + extraParams;
      resizeFrameHeight(theFrameObject);
      theFrameObject.width = "100%";
      theAnalysisObject.src = pgn4web_live_pointer_url + "/blank.html";
      theAnalysisObject.height = "240";
      theAnalysisObject.width = "192";
      theAnalysisObject.style.marginRight = "80px";
      theContainerObject.style.borderRightWidth = "40px";
    } else if (liveMode == "compact") {
      theFrameObject.src = pgn4web_live_pointer_url + "/live-compact.html?" + extraParams;
      theFrameObject.height = "360";
      theFrameObject.width = "480";
      theAnalysisObject.src = "about:blank";
      theAnalysisObject.height = "0";
      theAnalysisObject.width = "0";
      theAnalysisObject.style.marginRight = "0";
      theContainerObject.style.borderRightWidth = "40px";
    } else if (liveMode == "dynamic") {
      theFrameObject.src = pgn4web_live_pointer_url + "/dynamic-frame.html?l=t&ct=pink&hch=t&scf=t&pf=m&" + extraParams;
      resizeFrameHeight(theFrameObject);
      theFrameObject.width = "100%";
      theAnalysisObject.src = "about:blank";
      theAnalysisObject.height = "0";
      theAnalysisObject.width = "0";
      theAnalysisObject.style.marginRight = "0";
      theContainerObject.style.borderRightWidth = "40px";
    } else if (liveMode == "widget") {
      theFrameObject.src = pgn4web_live_pointer_url + "/board.html?am=n&d=1000&ih=e&ss=41&ps=34&pf=u&lcs=Wtyk&dcs=OXJO&bbcs=OXJO&hm=b&hcs=ZbNv&bd=c&cbcs=UJ2e&ctcs=nkYj&hd=l&md=f&tm=17&fhcs=nkYj&fhs=14&fmcs=nkYj&fccs=nkYj&hmcs=ZbNv&fms=14&fcs=m&cd=h&bcs=Wtyk&fp=10&hl=t&fh=b&fw=779&rm=1&pd=live/live.pgn&" + extraParams;
      theFrameObject.height = "445";
      theFrameObject.width = "779";
      theAnalysisObject.src = "about:blank";
      theAnalysisObject.height = "0";
      theAnalysisObject.width = "0";
      theAnalysisObject.style.marginRight = "0";
      theContainerObject.style.borderRightWidth = "23px";
    } else {
      return;
    }
    theContainerObject.title = "\"" + liveMode + "\" live view, click here for a different view";
    if (theContainerObject = document.getElementById("frameinnercontainer")) {
      theContainerObject.title = "\"" + liveMode + "\" live view";
    }
  }
}

function resizeFrameHeight(frObj) {
  var wh;
  if ((frObj) && ((liveMode == "analysis") || (liveMode == "dynamic"))) {
    if (window.innerHeight) { wh = window.innerHeight; }
    else if (document.documentElement && document.documentElement.clientHeight) { wh = document.documentElement.clientHeight; }
    else if (document.body && document.body.clientHeight) { wh = document.body.clientHeight; }
    else { wh = 0; }

    frObj.height = Math.max(240, wh - document.getElementById("headRow").offsetHeight - 222) + "px";
  }
}

function toggleLiveMode() {
  if (liveMode == 'analysis') { liveMode = 'compact'; }
  else if (liveMode == 'compact') { liveMode = 'dynamic'; }
  else if (liveMode == 'dynamic') { liveMode = 'widget'; }
  else if (liveMode == 'widget') { liveMode = 'analysis'; }
  else { liveMode = 'analysis'; }
  setLiveMode(liveMode);
}

function stopEvProp(e) {
  e.cancelBubble = true;
  if (e.stopPropagation) { e.stopPropagation(); }
  if (e.preventDefault) { e.preventDefault(); }
  return false;
}

</script>

</body>

</html>