<!--


//THIS FUNCTION IS NEEDS TO BE MADE MORE EFFICIENT!!!!

var tempProducts = new Array();
var tempProductsCount = 0;
function addProduct() {

  //input delimeter
  outerDelim = "{ODELIM}";
  innerDelim = "{IDELIM}";
  temp = "";

  //REP TEAMS
  if(document.getElementById('iPlayer')) {
    if (document.getElementById('iProduct') && document.getElementById('iSize') &&
        document.getElementById('iQuantity') && document.getElementById('iColour')) {

        if (document.getElementById('iPlayer').value!="" &&
            document.getElementById('iProduct').value!="" &&
            document.getElementById('iSize').value!="" &&
            document.getElementById('iQuantity').value!="" &&
            document.getElementById('iColour').value!="") {


            //build the temp display
            temp = '<tr>'
                      + '<td width="3%"><img src="/images/del.gif" class="pointer" border="0" onclick="deleteProduct('+tempProductsCount+')"></td>'
                      + '<td style="border:1px solid #6885A6;" width="25%">' + document.getElementById('iProduct').options[document.getElementById('iProduct').options.selectedIndex].text + "</td>"
                      + '<td style="border:1px solid #6885A6;" width="25%">' + document.getElementById('iColour').options[document.getElementById('iColour').options.selectedIndex].text + "</td>"
                      + '<td style="border:1px solid #6885A6;" width="10%">' + document.getElementById('iSize').options[document.getElementById('iSize').options.selectedIndex].text + "</td>"
                      + '<td style="border:1px solid #6885A6;" width="10%">' + document.getElementById('iQuantity').options[document.getElementById('iQuantity').options.selectedIndex].text + "</td>"
                 + '</tr>';


            //build temp products array
            tempProducts[tempProductsCount] = new Array();
            tempProducts[tempProductsCount][0] = document.getElementById('iPlayer').value;
            tempProducts[tempProductsCount][1] = document.getElementById('iProduct').value;
            tempProducts[tempProductsCount][2] = document.getElementById('iSize').value;
            tempProducts[tempProductsCount][3] = document.getElementById('iQuantity').value;
            tempProducts[tempProductsCount][4] = document.getElementById('iColour').value;
            tempProducts[tempProductsCount][5] = temp;


            //update product list
            currentContent = document.getElementById('productList').innerHTML;

            if (window.ActiveXObject){
              //for I.E.
              newContent = currentContent.replace('</TBODY></TABLE>', (temp + '</TBODY></TABLE>'));
            } else {
              //for others browsers
              newContent = currentContent.replace('</table>', (temp + '</table>'));
            }

            document.getElementById('productList').innerHTML = newContent;

            //set hidden input
            document.getElementById('aProducts').value = buildProductsArray();

            document.getElementById('iProduct').value = "";
            document.getElementById('iSize').value = "";
            document.getElementById('iQuantity').value = "";
            document.getElementById('iColour').value = "";

            tempProductsCount++;

            //enable button
            document.getElementById('addProductButton').disabled = false;

            //disable playernumber
            document.getElementById('iPlayer').disabled = true;


        } else {
            alert("Please check the form, all fields are mandatory");
        }
    }


  }

  //HOUSE LEAGUE
  if(document.getElementById('iAgeID') && document.getElementById('iLeagueID') && document.getElementById('iProduct') &&
        document.getElementById('iSize') && document.getElementById('iQuantity') &&
        document.getElementById('iColour')) {

        if (document.getElementById('iTeamID')!="" &&
            document.getElementById('iAgeID').value!="" &&
            document.getElementById('iProduct').value!="" &&
            document.getElementById('iSize').value!="" &&
            document.getElementById('iQuantity').value!="" &&
            document.getElementById('iColour').value!="") {


            //build the temp display
            temp = '<tr>'
                      + '<td width="3%"><img src="/images/del.gif" class="pointer" border="0" onclick="deleteProduct('+tempProductsCount+')"></td>'
                      + '<td style="border:1px solid #6885A6;" width="25%">' + document.getElementById('iAgeID').options[document.getElementById('iAgeID').options.selectedIndex].text + "</td>"
                      + '<td style="border:1px solid #6885A6;" width="25%">' + document.getElementById('iSize').options[document.getElementById('iSize').options.selectedIndex].text + "</td>"
                      + '<td style="border:1px solid #6885A6;" width="10%">' + document.getElementById('iQuantity').options[document.getElementById('iQuantity').options.selectedIndex].text + "</td>"
                      + '<td style="border:1px solid #6885A6;" width="10%">' + document.getElementById('iColour').options[document.getElementById('iColour').options.selectedIndex].text + "</td>"
                 + '</tr>';


            //build temp products array
            tempProducts[tempProductsCount] = new Array();
            tempProducts[tempProductsCount][0] = document.getElementById('iLeagueID').value;
            tempProducts[tempProductsCount][1] = document.getElementById('iAgeID').value;
            tempProducts[tempProductsCount][2] = document.getElementById('iSize').value;
            tempProducts[tempProductsCount][3] = document.getElementById('iQuantity').value;
            tempProducts[tempProductsCount][4] = document.getElementById('iColour').value;
            tempProducts[tempProductsCount][5] = temp;
            tempProducts[tempProductsCount][6] = document.getElementById('iProduct').value;


            //update product list
            currentContent = document.getElementById('productList').innerHTML;

            if (window.ActiveXObject){
              //for I.E.
              newContent = currentContent.replace('</TBODY></TABLE>', (temp + '</TBODY></TABLE>'));
            } else {
              //for others browsers
              newContent = currentContent.replace('</table>', (temp + '</table>'));
            }

            document.getElementById('productList').innerHTML = newContent;

            //set hidden input
            document.getElementById('aProducts').value = buildProductsArray();

            document.getElementById('iSize').value = "";
            document.getElementById('iQuantity').value = "";
            document.getElementById('iColour').value = "";

            tempProductsCount++;

            //enable button
            document.getElementById('addProductButton').disabled = false;

            //disable playernumber
            document.getElementById('iAgeID').disabled = true;


        } else {
            alert("Please check the form, all fields are mandatory");
        }

  }
}
function deleteProduct(id) {

  temp = '<table border="0" width="90%" align="center" cellpadding="2" cellspacing="2">';
  tempProducts[id] = "";
  for (count=0;count < tempProducts.length;count++) {
    if (tempProducts[count]!="") {
         temp += tempProducts[count][5];
    }
  }


  //update product list
  currentContent = temp;

  if (window.ActiveXObject){
    //for I.E.
    temp += "</TBODY></TABLE>";
    newContent = currentContent.replace('</TBODY></TABLE>', (temp + '</TBODY></TABLE>'));
  } else {
    //for others browsers
    temp += "</table>";
    newContent = currentContent.replace('</table>', (temp + '</table>'));
  }

  document.getElementById('productList').innerHTML = newContent;

  document.getElementById('aProducts').value = buildProductsArray();

  //deleted all the temp products
  if (document.getElementById('aProducts').value == "") {
    document.getElementById('productList').innerHTML = '<table border="0" width="90%" align="center" cellpadding="2" cellspacing="2"></table>';
    document.getElementById('addProductButton').disabled = true;

    if (document.getElementById('iPlayer'))
      document.getElementById('iPlayer').disabled = false;
    else if (document.getElementById('iAgeID'))
       document.getElementById('iAgeID').disabled = false;
  }

}

function buildProductsArray() {
  temp = "";
  for (count=0;count < tempProducts.length;count++) {
    if (tempProducts[count]!="") {

      temp += "{ODELIM}";
      for (innercount=0; innercount < tempProducts[count].length; innercount++) {
        if (innercount > 0)
          temp += "{IDELIM}";
        temp += tempProducts[count][innercount]
      }

    }
  }
  return temp;
}


function LmOver(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#033C95";
elem.style.cursor = 'hand'}

function LmOut(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";}


function LmUp(path)
{location.href = path;}


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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->

function VerifyFormData() {
	if (document.subscribe.realname.value == "") {
		alert("Please enter your name.")
		document.subscribe.realname.focus()
		return false;
	}
	if (!emailCheck(document.subscribe.email.value)) {
		document.subscribe.email.focus()
		return false;
	}
}
function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
// See if "user" is valid
if (user.match(userPat)==null) {
    // user is not valid
    alert("The username doesn't seem to be valid.")
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}
// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}
// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}
return true;
}
//  End -->