<?xml-stylesheet ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0">
   <xsl:template match="/">
      <HTML>
         <HEAD>
            <TITLE>Interfootball</TITLE>

            <META http-equiv="Content-Type" content="text/html;" charset="iso-8859-1" />

            <link REL="stylesheet" TYPE="text/css" HREF="../../css/style.css" />

            <link REL="stylesheet" TYPE="text/css" HREF="css/style.css" />

            <SCRIPT LANGUAGE="JavaScript" SRC="script/util.js" />

            <xsl:call-template name="fly" />
         </HEAD>

         <BODY onload="data_status = 0;oSelSource.selectedIndex=0;" onselectstart="javascript:event.cancelBubble = 'true';return false">
            <XML ID="xmlSource">
            </XML>

            <XML ID="xslFixtureFilter" src="xsl/fixturefilter.xsl">
            </XML>

            <XML ID="xslDataBtns" src="xsl/databtns.xsl">
            </XML>

            <XML ID="xslScoreFocus" src="xsl/gettargetscore.xsl">
            </XML>

            <XML ID="xslPresentData" src="xsl/presentprocessed.xsl">
            </XML>

            <XML ID="xmlDummy">
            </XML>

            <XML ID="xmlOnce">
            </XML>

            <CENTER>
               <TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
                  <TR bgColor="black">
                     <TD align="left" rowspan="1" width="92">
                        <A href="../../home.htm">
                           <IMG height="62" src="../../images/logo.gif" width="290" />

                           <BR />

                           <IMG height="3" src="../../images/pix.gif" width="1" />
                        </A>
                     </TD>

                     <TD style="background-color:black;color:yellow;text-align:right;vertical-align:bottom;padding-bottom:4;padding-right:30">
                     <A style="color:yellow" href="default.htm">Interfootball</A>

                     &#160;&#160;
                     <A style="color:yellow" href="../../chess/default.htm">Problem Mate</A>

                      &#160;&#160;
                     <A style="color:yellow" href="../../monty/default.htm">Monty Hall</A>

                      &#160;&#160;
                      <A style="color:yellow" href="../../balldrop/default.htm">Big Chain</A>

                      &#160;&#160;
                      <A style="color:yellow" href="../../svgreport/default.htm">Report It</A>

                      &#160;&#160;
                      <A style="color:yellow" href="../../calander/default.htm">Get a Date</A>

                      &#160;&#160;
                     
                      </TD>
                  </TR>
               </TABLE>

               <xsl:call-template name="DataSource" />

               <TABLE id="abox" width="100%" border="0" cellpadding="0" cellspacing="0" style="display:none">
                  <TR>
                     <TD align="center" style="padding-bottom:1px">
                        <TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
                           <TR>
                              <TD id="p3" onclick="ViewChange(this,1,null)" onmouseover="javascript:datBtnHover(this)" onmouseout="javascript:datBtnHover(this)" class="datBtn">Tables</TD>

                              <TD id="p1" onclick="ViewChange(this,2,null)" onmouseover="javascript:datBtnHover(this)" onmouseout="javascript:datBtnHover(this)" class="datBtnSel">Fixtures</TD>
                           </TR>
                        </TABLE>
                     </TD>
                  </TR>

                  <TR>
                     <TD id="dataBtns" align="center" >
                     </TD>
                  </TR>

                  <TR>
                     <TD id="shapeparam" style="display:none;text-align:center">
                        <xsl:call-template name="ShapeParam" />
                     </TD>
                  </TR>

                  <TR>
                     <TD id="lgeshapeparam" style="display:none;text-align:center">
                        <xsl:call-template name="lgeShapeParam" />
                     </TD>
                  </TR>

                  <TR>
                     <TD id="workarea" style="visibility:visible;text-align:center">
                     <DIV id="workhere1"></DIV>
                     </TD>
                  </TR>
               		<TR style="visibility:hidden">
               		<TD>
               		<IMG height="25" src="images/lpix.gif" width="1" />
               		<IMG height="1" src="images/dpix.gif" width="1" />
               		<IMG height="1" src="images/wpix.gif" width="1" />
               		</TD>
               		</TR>
<TR>
<TD style="text-align:center;vertical-align:top">
<TABLE class="footer">
	<TR>
		<TD class="mfooter"><A style="color:black" href="../../home.htm">Home</A></TD>
		<TD class="mfooter"><A style="color:black" href="default.htm">Interfootball</A></TD>
		<TD class="mfooter"><A style="color:black" href="../../chess/default.htm">Problem Mate</A></TD>
		<TD class="mfooter"><A style="color:black" href="../../monty/default.htm">Monty Hall</A></TD>
		<TD class="mfooter"><A style="color:black" href="../../balldrop/default.htm">Big Chain</A></TD>
		<TD class="mfooter"><A style="color:black" href="../../svgreport/default.htm">Report It</A></TD>
		<TD class="mfooter"><A style="color:black" href="../../calander/default.htm">Get a Date</A></TD>
	</TR>
	<TR>
		<TD colspan="7" style="text-align:center">
		Contact <A href="mailto:pw@interfootball.co.uk">pw@interfootball.co.uk</A>
		</TD>
	</TR>
	<TR>
		<TD colspan="7"></TD>
	</TR>
	
</TABLE></TD>
</TR>               		
               </TABLE>
            </CENTER>
         </BODY>
      </HTML>
   </xsl:template>

   <xsl:template match="itm" mode="comboItm">
      <OPTION value="{@id}">
         <xsl:if test="position() = 1">
            <xsl:attribute name="selected">1</xsl:attribute>
         </xsl:if>

         <xsl:value-of select="@nm" />
      </OPTION>
   </xsl:template>

   <xsl:template match="itm" mode="comboFixDates">
      <SELECT id="oSelFixDate{@id}" onchange="btnLoad.style.visibility = 'visible';" style="display:none">
         <xsl:if test="position() = 1">
            <xsl:attribute name="style">display:block</xsl:attribute>
         </xsl:if>

         <OPTION value="0" selected="1">Latest</OPTION>

         <xsl:apply-templates select="FIXDATES/FD">
            <xsl:sort select="day[1]/@d" data-type="number" order="descending" />
         </xsl:apply-templates>
      </SELECT>
   </xsl:template>

   <xsl:template match="FD">
      <xsl:variable name="lastday" select="count(day)" />

      <OPTION value="{day[1]/@od}:{day[$lastday]/@od}">
         <xsl:value-of select="day[1]/@d" />
      </OPTION>
   </xsl:template>

   <xsl:template name="DataSource">
      <TABLE border="0" cellpadding="0" cellspacing="0">
         <TR>
            <TD class="pageheader">InterFootball: England - Scotland</TD>

            <TD id="cellFixDates" style="text-align:left;padding-left:12">
               <xsl:apply-templates select="//itm" mode="comboFixDates" />
            </TD>

            <TD style="padding-left:6px">
               <IMG id="btnLoad" alt="load data" style="cursor:hand;visibility:visible" height="16" src="../../images/next.gif" width="16" onclick="SourceChange()" />
            </TD>

            <TD style="display:none">
               <SELECT id="oSelSource" onchange="changeSource()">
                  <xsl:apply-templates select="//itm" mode="comboItm" />
               </SELECT>
            </TD>
         </TR>
      </TABLE>
   </xsl:template>

   <xsl:template name="ShapeParam">
      <table cellspacing="0" cellpadding="0" border="0">
         <tr>
            <td colspan="2" style="line-height:19px">1. 
            <B>Result Set</B>

            : Consider last 
            <input onkeypress="wrap_change(this,1,50)" onblur="ExitParameter(this,1,50)" class="sp" title="between 1 and 50 inclusive" maxlength="2" onselectstart="javascript:event.cancelBubble = 'false';return true" type="text" id="lastN" style="width:30px" value="4" />
			<input type="hidden" id="hlastN" value="4"/>
            results</td>
         </tr>

         <tr>
            <td colspan="2" style="line-height:19px">2. 
            <B>Time Factor</B>

            : A result is weighted 100. What weight the result after 
            <input class="sp" title="between 100 and 200 inclusive" maxlength="3" type="text"  onkeypress="wrap_change(this,100,200)" onblur="ExitParameter(this,100,200)" onselectstart="javascript:event.cancelBubble = 'false';return true" id="fgamebefore" style="width:30px" value="100" />
 			<input type="hidden" id="hfgamebefore" value="100"/>
           </td>
         </tr>

         <tr>
            <td colspan="2" style="line-height:19px">3. 
            <B>Fixture Context</B>

            : A home teams home results are weighted 100. What weight away results 
            <input class="sp" title="between 0 and 100 inclusive" maxlength="3" type="text"  onkeypress="wrap_change(this,0,100)" onblur="ExitParameter(this,0,100)" onselectstart="javascript:event.cancelBubble = 'false';return true" id="fcontext_scalar" style="width:30px" value="100" />
			<input type="hidden" id="hfcontext_scalar" value="100"/>

            * Away team viscia-veria</td>
         </tr>

         <tr>
            <td colspan="2" style="line-height:19px">4. 
            <B>Result Type</B>

            : Associated Points Won 
            <input class="sp" title="between 0 and 9 inclusive" maxlength="1" type="text" onkeypress="wrap_change(this,0,9)" onblur="ExitParameter(this,0,9)" onselectstart="javascript:event.cancelBubble = 'false';return true" id="won" style="width:30px" value="3" />
			<input type="hidden" id="hwon" value="3"/>

            Draw 
            <input class="sp" title="between 0 and 9 inclusive" maxlength="1" type="text" onkeypress="wrap_change(this,0,9)" onblur="ExitParameter(this,0,9)" onselectstart="javascript:event.cancelBubble = 'false';return true" id="draw" style="width:30px" value="1" />
			<input type="hidden" id="hdraw" value="1"/>

            Lost 
            <input class="sp" title="between 0 and 9 inclusive" maxlength="1" type="text" onkeypress="wrap_change(this,0,9)" onblur="ExitParameter(this,0,9)" onselectstart="javascript:event.cancelBubble = 'false';return true" id="lost" style="width:30px" value="0" />
			<input type="hidden" id="hlost" value="0"/>
            </td>
         </tr>
      </table>
   </xsl:template>

   <xsl:template name="lgeShapeParam">
      <table cellspacing="0" cellpadding="0" border="0">
         <tr>
            <td colspan="2" style="line-height:19px">1. 
            <B>Result Type</B>

            : Associated Points Won 
            <input class="sp" title="between 0 and 9 inclusive" maxlength="1" type="text" onkeypress="wrap_change(this,0,9)" onblur="ExitParameter(this,0,9)" onselectstart="javascript:event.cancelBubble = 'false';return true" id="lgwon" style="width:30px" value="3" />
			<input type="hidden" id="hlgwon" value="3"/>

            Draw 
            <input class="sp" title="between 0 and 9 inclusive" maxlength="1" type="text" onkeypress="wrap_change(this,0,9)" onblur="ExitParameter(this,0,9)" onselectstart="javascript:event.cancelBubble = 'false';return true" id="lgdraw" style="width:30px" value="1" />
			<input type="hidden" id="hlgdraw" value="1"/>

            Lost 
            <input class="sp" title="between 0 and 9 inclusive" maxlength="1" type="text" onkeypress="wrap_change(this,0,9)" onblur="ExitParameter(this,0,9)" onselectstart="javascript:event.cancelBubble = 'false';return true" id="lglost" style="width:30px" value="0" />
 			<input type="hidden" id="hlglost" value="0"/>
           </td>
         </tr>

         <tr>
            <td colspan="2" style="line-height:19px">2. 
            <B>Result Set</B>

            : Consider last 
            <input class="sp" title="between 1 and 50 inclusive" maxlength="2"  onkeypress="wrap_change(this,1,50)" onblur="ExitParameter(this,1,50)" onselectstart="javascript:event.cancelBubble = 'false';return true" type="text" id="lglastN" style="width:30px" value="6" />
 			<input type="hidden" id="hlglastN" value="6"/>

            results</td>
         </tr>
      </table>
   </xsl:template>

   <xsl:template name="fly">
<SCRIPT language="javascript">

<![CDATA[ 

var data_source = 0;
var data_at = '';
var data_subset_id = 0;
var data_subset_level = 0;
var data_subset_type = 'dvn';
var data_view_id = 2;


var view_selected_page = new Array();


var pInitVal = 0;


function SourceChange() {
btnLoad.style.visibility = 'hidden';
  document.body.style.cursor = 'Wait';
 view_selected_page[0] = 1;
 view_selected_page[1] = 2;
 view_selected_page[2] = 1;
 view_selected_page[3] = 1;
 
 data_source = oSelSource.value;

 data_at = document.all('oSelFixDate' + data_source).value; 
 setTimeout('loadprocess()',20);

}


function loadprocess() {
 xmlSource.async=false;
 xmlSource.src = 'xml/s' + data_source + '.xml'

 if (data_at != 0) {
  ApplyXslParams(xslFixtureFilter,'fixStartEnd',data_at)
  xmlSource.loadXML(xmlSource.transformNode(xslFixtureFilter));
  workarea.innerText =xmlSource.xml;
 }

 xmlDummy.loadXML(xmlSource.transformNode(xslDataBtns))
 process_menus(xmlDummy.selectNodes("//stuff/getthis[@div]"))
 //xmlOnce.loadXML(xmlDummy.selectSingleNode("//stuff/island").xml)
 
 
 
 //first page shown
 setFixShapeParameter();
 setLgeShapeParameter();
 btnRow.children(2).click()
 abox.style.display = 'block';
}

function SubsetChange(obBtn,dataid,datatype,datalevel) {
 if (manage_tabs(obBtn,'datBtn')) {
  data_subset_level = datalevel;
  data_subset_id = dataid;
  data_subset_type = datatype;
  
  ApplyXslParams(xslScoreFocus,'data-type',data_subset_type)
  ApplyXslParams(xslScoreFocus,'data-level',data_subset_level)
  ApplyXslParams(xslScoreFocus,'data-id',data_subset_id)
  if (p3.className == 'datBtn' && p1.className == 'datBtn') {p1.className = 'datBtnSel'}

  document.body.style.cursor = 'Wait';
  workarea.style.visibility = 'hidden';
  workarea.innerHTML = '';
  setTimeout('process_target()',20);
 }
}


function ViewChange(obBtn,dataview,isauto) {
 data_view_id = dataview;
 if (obBtn) {
  if (manage_tabs(obBtn,'datBtn')) {
   document.body.style.cursor = 'Wait';
   workarea.style.visibility = 'hidden';
   shapeparam.style.display = 'none';
   if (isauto != 1) {lgeshapeparam.style.display = 'none';}
   workarea.style.top = '52px';
   workarea.innerHTML = '';      
   setTimeout('process_target()',20);
    //debug.innerText = workarea.innerHTML 
  }
 }

}



function PageChange(inp,page) {
view_selected_page[data_view_id - 1] = page
 switch (data_view_id) {
  case 1: 

  //ViewChange(tblge2,data_view_id,1);
  manage_tabs(inp,'datBtn');
 ApplyXslParams(xslPresentData,'page-view',view_selected_page[data_view_id - 1]) 
 xmlOnce.loadXML(xmlDummy.transformNode(xslPresentData))

 workhere1.innerHTML = xmlOnce.selectSingleNode("//p/DIV[@id = 'workhere1']/table").xml  

  break;
  case 2: FixturePageChange(inp)
   break;
  case 3: break;
 }
}

function sortFixLst(inp,sortcode) {
 ApplyXslParams(xslPresentData,'fixSort',sortcode) 

			  document.body.style.cursor = 'Wait';
			  workarea.style.visibility = 'hidden';
			  workarea.innerHTML = '';
			  setTimeout('process_target()',20);

}


function sort_thisTable(obBtn,col) {
 ApplyXslParams(xslPresentData,'tableSort1',col)
 xmlOnce.loadXML(xmlDummy.transformNode(xslPresentData))

 workhere1.innerHTML = xmlOnce.selectSingleNode("//p/DIV[@id = 'workhere1']/table").xml  

}





function select_fixture(rowpos,adiv,atab) {

adiv.style.display = "none";
workheresub.style.display = "block";
shapeparam.style.display = 'none';
workarea.style.top = '52px';


var oRow = atab.children(0).children(rowpos)
var fid = oRow.children(0).innerText 

//alert(fid)
ApplyXslParams(xslPresentData,'display-view',21)
ApplyXslParams(xslPresentData,'this-fix',fid)
ApplyXslParams(xslPresentData,'prev-fix',rowpos - 1)
ApplyXslParams(xslPresentData,'next-fix',rowpos + 1)
workheresub.innerHTML =  xmlDummy.transformNode(xslPresentData)
p1.className = 'datBtn'
}
















function select_tablerow(inp,col) {

 var rid = inp.parentElement.id;
 var tChar = (rid.substr(0,1)=='R')?'L':'R';

 rid = tChar + rid.substr(1,rid.length - 1)
 var mirror = document.all.item(rid).getElementsByTagName('TD');



 var objparentcells = inp.parentElement.getElementsByTagName('TD');
 for (i=objparentcells.length-1;i>-1;i--) {
  objparentcells.item(i).style.backgroundColor = col
  mirror.item(i).style.backgroundColor = col
  if (col == 'black') {
   objparentcells.item(i).style.borderBottom = "#EEA500 1px solid"
   objparentcells.item(i).style.color = 'white';
   mirror.item(i).style.borderBottom = "#EEA500 1px solid"
   mirror.item(i).style.color = 'white';
   
   
   
  }
  else {
   objparentcells.item(i).style.borderBottom = "black 1px solid"
   objparentcells.item(i).style.color = 'black';
   mirror.item(i).style.borderBottom = "black 1px solid"
   mirror.item(i).style.color = 'black';
  }
 }
}









function select_row(inp,col) {
 var objparentcells = inp.parentElement.getElementsByTagName('td');
 for (i=objparentcells.length-1;i>-1;i--) {
  objparentcells.item(i).style.backgroundColor = col
  if (col == 'black') {
   objparentcells.item(i).style.borderBottom = "#EEA500 1px solid"
   objparentcells.item(i).style.color = 'white';
  }
  else {
  objparentcells.item(i).style.borderBottom = "black 1px solid"
  objparentcells.item(i).style.color = 'black';
  }
 }
}







function FixturePageChange(obBtn) {
 if (obBtn.className != 'tabSel') {
  workheresub.style.display = "none";
  manage_tabs(obBtn,'tab');
  if (view_selected_page[data_view_id - 1] == 1) {
   fixtable1.style.display = 'block'; 
   workhere2.style.display = 'none'; 
   //workhere1.style.display = 'block'; 
  }
  else {
   fixtable2.style.display = 'block'; 
   workhere2.style.display = 'block'; 
   //workhere1.style.display = 'none'; 

  }
 }
}

var bdo = true;

function wrap_change(inp, mn, mx) {
var ekey = window.event.keyCode;
 if (ekey != 13) {
 return
 }
 bdo = true;
ExitParameter(inp, mn, mx)
 bdo = false;

}


function ExitParameter(inp, mn, mx) {
var hval = document.all.item('h' + inp.id);
if (inp.value != hval.value) {

	 var rtn = validateParameter(inp, mn, mx)
	 if (rtn) {
			   hval.value = inp.value;
				   switch (data_view_id) {
				    case 1: setLgeShapeParameter();
				     break;
				    case 2: setFixShapeParameter();
				     break;
				   }
		   
			  document.body.style.cursor = 'Wait';
			  workarea.style.visibility = 'hidden';
			  workarea.innerHTML = '';
			  setTimeout('process_target()',20);
	   
	  		}
			 else {
			 inp.value = hval.value
			 inp.focus();
			 }	  		
 }


}




function validateParameter(inp, mn, mx) {
var sVal = inp.value;
 if (isgoodInt(sVal)) {
  if (!numInRange(sVal,mn,mx)) {
   alert('Not within range ' + mn + ' to ' + mx + ' inclusive');
  // inp.value = pInitVal;
   return false;
  }
 }
 else {
  alert('Invalid Charater');
 // inp.value = pInitVal;
  return false;
 }
 return true;
}



































function process_target() {
 ApplyXslParams(xslScoreFocus,'data_view',data_view_id)
 if (data_view_id == 3) {
  xmlDummy.loadXML(xmlOnce.transformNode(xslScoreFocus))
 }
 else {
  xmlDummy.loadXML(xmlSource.transformNode(xslScoreFocus))
 }
 present_processed()
}

function present_processed() { 
 ApplyXslParams(xslPresentData,'display-view',data_view_id)
 ApplyXslParams(xslPresentData,'page-view',view_selected_page[data_view_id - 1]) 
 if (data_view_id == 2) {
 //workarea.style.top = '144px';
  shapeparam.style.display = 'block';
 workarea.innerHTML = xmlDummy.transformNode(xslPresentData) 
 } 
 else if  (data_view_id == 1) {
 //workarea.style.top = '99px';
  lgeshapeparam.style.display = 'block';
 workarea.innerHTML = xmlDummy.transformNode(xslPresentData)  
 } 
 else if  (data_view_id == 3) {
 workarea.innerHTML = xmlDummy.transformNode(xslPresentData)  
 }
 else {
 workarea.innerHTML = xmlOnce.xml
 }
 //tabBar.style.display = 'block'; 
 document.body.style.cursor = 'Default';
 workarea.style.visibility = 'visible'; 
}

































function setFixShapeParameter() {
 var mpts =Math.max(Math.max(won.value,draw.value),lost.value)
 var ptsStr = lost.value + ':' + draw.value + ':' + won.value
 ApplyXslParams(xslScoreFocus,'max-pts',mpts)
 ApplyXslParams(xslScoreFocus,'ptsStr',ptsStr)
 ApplyXslParams(xslScoreFocus,'context-scalar',fcontext_scalar.value)
 ApplyXslParams(xslScoreFocus,'Last-N',lastN.value)
 ApplyXslParams(xslScoreFocus,'game-before',fgamebefore.value)
}


function setLgeShapeParameter() {
 var mpts =Math.max(Math.max(lgwon.value,lgdraw.value),lglost.value)
 var ptsStr = lglost.value + ':' + lgdraw.value + ':' + lgwon.value
 ApplyXslParams(xslScoreFocus,'LGE_lastN',lglastN.value)
 ApplyXslParams(xslScoreFocus,'LGE_max-pts',mpts)
 
 ApplyXslParams(xslScoreFocus,'LGE_ptsStr',ptsStr)
}










//combo oSelSource Change
function changeSource() {
 var sid = oSelSource.value;
 HideChildern(cellFixDates);
 document.all('oSelFixDate' + sid).style.display = 'block'; 
 btnLoad.style.visibility = 'hidden';
 }








//-------------------------------------------------------------------------------------
//Response to data change -------------------------------------------------------------




]]>






</SCRIPT>
   </xsl:template>
</xsl:transform>


