/************************************************************************************/
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output="";
   var chr1,chr2,chr3,enc1,enc2,enc3,enc4;
   var i=0;
   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);
      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;
      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }
      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   return output;
}
/****************************************************************************************/
function decode64(input) {
   var output="";
   var chr1,chr2,chr3,enc1,enc2,enc3,enc4;
   var i = 0;
   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));
      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;
      output = output + String.fromCharCode(chr1);
      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
     } 
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);
   return output;
}
/*****************************************************************************************/
function getordate(dm)
{

        var m = dm.substring(dm.length-8,dm.length-5);
        var dd;
        switch(m)
        {
                case 'Jan':
                dd='January ';
                break;
                case 'Feb':
                dd='February ';
                break;
                case 'Mar':
                dd='March ';
                break;
                case 'Apr':
                dd='April ';
                break;
                case 'May':
                dd='May ';
                break;
                case 'Jun':
                dd='June ';
                break;
                case 'Jul':
                dd='July ';
                break;
                case 'Aug':
                dd='August ';
                break;
                case 'Sep':
                dd='September';
                break;
                case 'Oct':
                dd='October';
                break;
                case 'Nov':
                dd='November';
                break;
                case 'Dec':
                dd='December';
                break;
                }

 dd = dd+dm.substring(0,dm.length-9)+", ";
        dd=dd+dm.substring(dm.length-4);
        return new Date(dd);
        }
/*************************************************************************************/
var cookies = new Object();
function extractCookies()
{
var name,value,beginning,middle,end,b,m,e,v;
for(name in cookies)
{cookies=new Object();break;}
beginning=0;
while(beginning<document.cookie.length)
{
        middle=document.cookie.indexOf('=',beginning);
        end=document.cookie.indexOf(';',beginning);
        if(end==-1)
                end=document.cookie.length;
        if((middle>end)||(middle==-1))
        {
                name=documet.cookie.substring(beginning,end);
                value="";
                }
        else
        {
                name=document.cookie.substring(beginning,middle);
                value=document.cookie.substring(middle+1,end);
                }
        cookies[name]=unescape(value);
        beginning=end+2;
	}
if(cookies['orrfc'])
{
	v=decode64(cookies['orrfc']);
         b=0;
       // alert(v);
	while(b<v.length)
        {
                m=v.indexOf('=',b);
                e=v.indexOf(';',b);
                if(e==-1)
                        e=v.length;
                if((m>e)||(m==-1))
                {
                        name=v.substring(b,e);
                        value="";
                        }
                else
                {
                        name=v.substring(b,m);
                        value=v.substring(m+1,e);
			
                        }
		cookies[name]=unescape(value);
		//alert(cookies[name]+":"+name);
		b=e+1;
                }
        }
	//for(name in cookies)
	//	alert(name);
}
/************************************************************************************/
function isdatepast(d)
{
	if(new Date() < getordate(d))
	return false;
	return true;
}
/************************************************************************************/
function isloggedin()
{
	//alert("");
	if(!(cookies['orrfc']))
		extractCookies();
	if(cookies['name'])
	{
		var rlogin=document.getElementById('rloggeduser');
		if(rlogin)
		{
	       		while(rlogin.hasChildNodes())
        	        	rlogin.removeChild(rlogin.firstChild);
                	var ruser=document.createElement('p');
			ruser.className="ruser";
			ruser.appendChild(document.createTextNode("Welcome: "+cookies['name']+"   "));
			var rsadmin =document.createElement('a');
			rsadmin.className="selfAdmin";
			rsadmin.href="javascript:buildpage(23,0);";
			rsadmin.appendChild(document.createTextNode("Self Admin"));
			ruser.appendChild(rsadmin);
			if(cookies['level'] > 7)
			{
				var radmin =document.createElement('a');
                        	radmin.className="selfAdmin";
                        	radmin.href="orrfcApplet.php";
				radmin.target="_blank";
                        	radmin.appendChild(document.createTextNode("Site Admin"));
				ruser.appendChild(document.createTextNode("    "));
				ruser.appendChild(radmin);
				}
			rlogin.appendChild(ruser);
			}
                }	
        
		
	}
/************************************************************************************/
function delgame(id,parent,team)
{
	var request;
        var pdata="id="+id+"&del=1&team="+team+"&test=1";
	alert(pdata);
	try
        {request=new XMLHttpRequest();}
        catch (e)
        { request = new ActiveXObject("Msxml2.XMLHTTP");}
        try{
        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
        }
        catch(e)
        {}
        request.open("POST","php/updategamexml.php",false);
        request.setRequestHeader(     'Content-Type',     'application/x-www-form-urlencoded; charset=UTF-8' );
        request.send(pdata);
	buildpage(parent,team);

}
/************************************************************************************/
function matchupdate()
{
	var id=document.getElementById('id').value;
        var opp=document.getElementById('opp').value;
	var team=document.getElementById('team').value;       
	var comp=document.getElementById('comp').value;
	var sponsor=document.getElementById('sponsor').value;
	var done=document.getElementById('done').value;
	var venue=document.getElementById('venue').value;
        var gdate=document.getElementById('date').value;
	var ptf=document.getElementById('ptf').value;
	var pta=document.getElementById('pta').value;
	var season=document.getElementById('season').value;
	var parent=document.getElementById('parent').value;
	var go4it=true;
	if(gdate.length == 10)
		gdate = "0"+gdate;
	if(opp < 1)
        {
                alert("No Opposition Selected!");
                go4it=false;
                }
	if(team < 1)
        {
                alert("No Club Team Selected!");
                go4it=false;
                }
	if(comp < 1)
        {
                alert("No Competition Selected!");
                go4it=false;
                }
	if(gdate.length < 11)
        {
                alert("Invalid Date Entered!");
                go4it=false;
                }
	if(done == 1)
	{
		if(!(/\d{1,3}/.test(pta)))
		{
			alert("Pts Against not valid!!");
			go4it=false;
			}
		if(!(/\d{1,3}/.test(ptf)))
                {
                        alert("Pts For not valid!!");
                        go4it=false;
                        }
		}
	if(go4it)
	{
		var request;
                var pdata="id="+id+"&date="+gdate+"&venue="+venue+"&team="+team+"&opposition="+opp+"&competition="+comp+"&sponsor="+sponsor+"&ptf="+ptf+"&pta="+pta+"&season="+season+"&complete="+done;
                try
                {request=new XMLHttpRequest();}
                catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
                try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
                catch(e)
                {}
                request.open("POST","php/updategamexml.php",false);
                request.setRequestHeader(     'Content-Type',     'application/x-www-form-urlencoded; charset=UTF-8' );
                request.send(pdata);
		buildpage(parent,team);
		}
	}
/************************************************************************************/
function eventupdate()
{
	var id=document.getElementById('id').value;
        var artist=document.getElementById('artist').value;
        var link=document.getElementById('link').value;
        var comment=document.getElementById('comment').value;
        var entry=document.getElementById('entry').value;
        var gdate=document.getElementById('date').value;
        var go4it=true;
        if(artist.length < 2)
        {
                alert("No Artist Entered!");
                go4it=false;
                }
        if(comment.length < 10 )
        {
                alert("Description not Entered!");
                go4it=false;
                }
        if(gdate.length < 11)
        {
                alert("Date Invalid!");
                go4it=false;
                }
	if(entry.length < 1)
        {
                alert("No Entry policy entered!");
                go4it=false;
                }
	if(go4it)
	{
        $id = $_POST['id'];
		var request;
                var pdata="id="+id+"&entry="+entry+"&comment="+comment+"&artist="+artist+"&date="+gdate+"&link="+link;
                try
                {request=new XMLHttpRequest();}
                catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
                try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
                catch(e)
                {}
                request.open("POST","php/updateevent.php",false);
                request.setRequestHeader(     'Content-Type',     'application/x-www-form-urlencoded; charset=UTF-8' );
                request.send(pdata);
		buildpage(7,id);
		}
	}	

/************************************************************************************/
function userUpdate()
{
	var dname=document.getElementById('name');
        var name=dname.value;
        var dpass1=document.getElementById('pwd1');
        var pwd1=dpass1.value;
	var dpass2=document.getElementById('pwd2');
        var pwd2=dpass2.value;
	var dtel=document.getElementById('tel');
        var tel=dtel.value;
	var demail=document.getElementById('email');
        var email=demail.value;
	var did=document.getElementById('id');
        var id=did.value;
        var go4it=true;
        if(email.length == 0)
        {
                alert("Email Required!");
                go4it=false;
                }
	 if(name.length == 0)
        {
                alert("Name Required!");
                go4it=false;
                }

        if(!(pwd1 == pwd2))
        {
                alert("Passwords must Match!");
                go4it=false;
                }
	
        if(go4it)
        {
                var request;
                var pdata="id="+id+"&email="+email+"&drow="+pwd1+"&tel="+tel+"&name="+name;
                try
                {request=new XMLHttpRequest();}
                catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
                try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
                catch(e)
                {}
                request.open("POST","php/updatebyuserxml.php",false);
                request.setRequestHeader(     'Content-Type',     'application/x-www-form-urlencoded; charset=UTF-8' );
                request.send(pdata);
                buildpage(1,0);
                }
        }

/***********************************************************************************/
function orrfclogin()
{
        var user=document.getElementById('user');
        var usr=user.value;
	var pass=document.getElementById('pwd');
	var pwd=pass.value;
	var go4it=true;
	if(usr.length == 0)
	{
		alert("Email Required!");
		go4it=false;
		}
	if(pwd.length == 0)
        {
	        alert("Password Required!");
		go4it=false;
		}
	if(go4it)
	{
		var request;
		var pdata="login="+usr+"&pwd="+pwd;
		try
                {request=new XMLHttpRequest();}
        	catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
        	try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        	catch(e)
                {}
        	request.open("POST","auth_in.php",false);
        	request.setRequestHeader(     'Content-Type',     'application/x-www-form-urlencoded; charset=UTF-8' ); 
		request.send(pdata);
		isloggedin();   		 

		} 
	}
/************************************************************************************/
function buildpage(a,b)
{
       	var rcontent = document.getElementById('rcontent');
	while(rcontent.hasChildNodes())
                rcontent.removeChild(rcontent.firstChild);
	var extrabscript = document.getElementById('extrabscript');
        while(extrabscript.hasChildNodes())
                extrabscript.removeChild(extrabscript.firstChild);
	var gmenu = document.getElementById('gmenu');

        var request;
	var sen = true;
	var gmenu1 = gmenu.firstChild;
	if (gmenu1)
	{
		sen=(!(gmenu1.id == 'lijun'));
		}
	if(((a == 1 || a==2 )&& b==1 ) || a == 0 || (b == 0 &&(a==10 || a==15)))
	{
		gmenu = document.getElementById('gmenu');
       		while(gmenu.hasChildNodes())
                	gmenu.removeChild(gmenu.firstChild);
		try
                {request=new XMLHttpRequest();}
	        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
        	try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        	catch(e)
                {}
        	var url = "../xml/menus.xml?nocache="+ Math.random();
        	request.open("GET",url,false);
        	request.send(null);
        	var feed = request.responseXML;
		var menusList = feed.getElementsByTagName('menu');
        	var nummenus = menusList.length;
		for (var i=0;i <nummenus;i++)
        	{
			var menuid = menusList[i].getElementsByTagName('name');
			if(((a == 1 || a==0) && menuid[0].firstChild.nodeValue == 'Senior') || (a == 2 && menuid[0].firstChild.nodeValue == 'Junior') || (a==10 && menuid[0].firstChild.nodeValue == 'Senior Fixtures') || (a==15 && menuid[0].firstChild.nodeValue == 'Junior Fixtures'))
			{
				var itemList=menusList[i].getElementsByTagName('item');
				numitems=itemList.length;
				for(var j=0;j<numitems;j++)
				{
					var newliTag = document.createElement('li');
					var newaTag = document.createElement('a');
               				var lilink = itemList[j].getElementsByTagName('id');
                			newliTag.id=lilink[0].firstChild.nodeValue;
					var alink = itemList[j].getElementsByTagName('link');
					newaTag.href=alink[0].firstChild.nodeValue;
                			var label = itemList[j].getElementsByTagName('label');
					var labelTxt = document.createTextNode(label[0].firstChild.nodeValue); 
					var target = itemList[j].getElementsByTagName('target');
					//alert(target);
					//if(target.hasChildNodes())
					//	newaTag.target=target1[0].firstChild.nodeValue;
					newaTag.appendChild(labelTxt);
                			newliTag.appendChild(newaTag);




					gmenu.appendChild(newliTag);
					}
				}
			}

		}
	admin = false;
	if(a==0)
		a = 1;
	if(cookies['level'])
        {
        	//alert(cookies['level']);
		if(((cookies['level'] == 4 || cookies['level']> 7) && a == 7) || (cookies['level']> 5 && (a == 10 || a == 15 || a== 9 || a == 14)))
        		admin = true;
		}
/*	alert(a+" "+b);
	switch(a)
	{
		case 1://senior
		getmain(rcontent,true);
		break;

		case 2://junior
		getmain(rcontent,false);
		break;
		
		case 7://events
 		getevents(rcontent,admin);
                var ali = document.getElementById('lievent');
                if(ali)
                {
                        ali.className="selected";
                        }
                break;
		
		case 10://senior fixtures
		if (b == 0)
                        team=1;
                else
                        team=b;
                getfixtures(rcontent,team,admin,18);
                break;
		
		case 15://junior fixtures
		alert("");
		 if (b == 0)
                        team=7;
                else
                        team=b;
                getfixtures(rcontent,team,admin,21);

		break;
		
		case 18://edit senior matches
		buildmatchform(rcontent,extrabscript,b,10);
		break;

		case 19://edit events
		buildeventsform(rcontent,extrabscript,b);
		break;

		case 21://edit junior matches
		buildmatchform(rcontent,extrabscript,b,15);
		break;

		case 23://user self admin
		BuildUserAdminForm(rcontent,cookies['id']);
		break;
		}*/
        if(a == 1)//senior
	{
		
		getmain(rcontent,true)
		}
	if(a == 2)//junior
	{
		getmain(rcontent,false)
		}
	if(a == 7)//events
	{
		getevents(rcontent,admin);
		var ali = document.getElementById('lievent');
		if(ali)
		{
			ali.className="selected";
			}
		}
	if(a == 10 )//senior fixtures
        {
                if (b == 0)
			team=1;
		else
			team=b;
		getfixtures(rcontent,team,admin,18);
                }
	if(a == 15)//junior fixtures
	{
		if (b == 0)
                        team=7;
                else
                        team=b;
                getfixtures(rcontent,team,admin,21);
		}
	if(a==18) //edit senior matches
	{
		buildmatchform(rcontent,extrabscript,b,10);
		}
	if(a == 19) //edit events
	{
		buildeventsform(rcontent,extrabscript,b);
		}
	if(a==21) //edit Junior matches
        {
                buildmatchform(rcontent,extrabscript,b,15);
                }
	if(a==23) // user self admin
	{
		BuildUserAdminForm(rcontent,cookies['id']);
		}
	}

/***********************************************************************************/
function addlabelfield(rc,fn,l)
{
	idiv=document.createElement('div');
        idiv.className=fn;
        ilab=document.createElement('label');
       // ilab.htmlFor=lin;
        ilab.appendChild(document.createTextNode(l));
        idiv.appendChild(ilab);
        //iin=document.createElement('input');
        //iin.name=lin;
        //iin.id=lin;
        //iin.type="text";
        //idiv.appendChild(iin);
        rc.appendChild(idiv);

}
/***********************************************************************************/
function addaninputfield(rc,fn,lin,l)
{
	idiv=document.createElement('div');
	idiv.className=fn;
	ilab=document.createElement('label');
	ilab.htmlFor=lin;
	ilab.appendChild(document.createTextNode(l));
        idiv.appendChild(ilab);
        iin=document.createElement('input');
        iin.name=lin;
        iin.id=lin;
        iin.type="text";
        idiv.appendChild(iin);
        rc.appendChild(idiv);
       } 
/***********************************************************************************/
function addaselectfield(rc,fn,lin,l)
{
        idiv=document.createElement('div');
        idiv.className=fn;
        ilab=document.createElement('label');
        ilab.htmlFor=lin;
        ilab.appendChild(document.createTextNode(l));
        idiv.appendChild(ilab);
        iin=document.createElement('select');
        iin.name=lin;
        iin.id=lin;
        idiv.appendChild(iin);
        rc.appendChild(idiv);
       }
/***********************************************************************************/
function addatextareafield(rc,fn,lin,l,r,c)
{
        idiv=document.createElement('div');
        idiv.className=fn;
        ilab=document.createElement('label');
        ilab.htmlFor=lin;
        ilab.appendChild(document.createTextNode(l));
        idiv.appendChild(ilab);
        iin=document.createElement('textarea');
        iin.name=lin;
        iin.id=lin;
	iin.rows=r;
	iin.cols=c;
        idiv.appendChild(iin);
        rc.appendChild(idiv);
       }

/**********************************************************************************/
function BuildUserAdminForm(rcontent,id)
{
        
	addlabelfield(rcontent,"headerfield","User Self Administration");
	addaninputfield(rcontent,"namefield","name","User Name:");
        
        addaninputfield(rcontent,"emailfield","email","E-Mail:");
        addaninputfield(rcontent,"telfield","tel","Tel No:");
        ihid=document.createElement('input');
	ihid.id="id";
        ihid.value=id;
        ihid.type="hidden";
        rcontent.appendChild(ihid);
 	addaninputfield(rcontent,"passfield","pwd1","PassWord(for pwd change only):");
        addaninputfield(rcontent,"passfield","pwd2","PassWord(confirmation of change):");
        idiv=document.createElement('div');
        idiv.className="submitfield";
        iin=document.createElement('input');
        iin.type="button";
        iin.onclick=function(){ userUpdate();}
        iin.value="Update Profile";
        idiv.appendChild(iin);
        rcontent.appendChild(idiv);
	var feed,request,opt,name,tel,email;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
	user = "";
	tel = "";
	email = "";
	
        if(id > 0)
        {
                url = "../xml/users.xml?nocache="+ Math.random();
                request.open("GET",url,false);
                request.send(null);
                feed = request.responseXML;
                var userList = feed.getElementsByTagName('user');
                var numuser = userList.length;
                for (var i=0;i <numuser;i++)
                {
                        var gid = userList[i].getElementsByTagName('id');
                        if(gid[0].firstChild.nodeValue == id)
                        {
                                var nid=userList[i].getElementsByTagName('name');
                                name=nid[0].firstChild.nodeValue;
				nid=userList[i].getElementsByTagName('email');
                                email=nid[0].firstChild.nodeValue;
                                nid=userList[i].getElementsByTagName('tel');
				if(nid[0])
					tel=nid[0].firstChild.nodeValue;
				}
			}
		}
       	document.getElementById('name').value=name;
        document.getElementById('email').value=email;
        document.getElementById('tel').value=tel;


}
/**********************************************************************************/

function buildeventsform(rcontent,bscript,id)
{
	bscript.text="\tsetupeventsform();";
	addlabelfield(rcontenr,"headerfield","EventInput");
	addaninputfield(rcontent,"datefield","date","Date:");
	idiv=document.createElement('div');
	idiv.id="container";
	cdiv=document.createElement('div');
	cdiv.className="bd";
	ccdiv=document.createElement('div');
	ccdiv.id="cal";
	ccdiv.name="cal";
	cdiv.appendChild(ccdiv);
	idiv.appendChild(cdiv);
	rcontent.appendChild(idiv);
	addaninputfield(rcontent,"artistfield","artist","Artist:");
	addaninputfield(rcontent,"linkfield","link","Link:");
	addaninputfield(rcontent,"entryfield","entry","Entry Policy:");
	ihid=document.createElement('input');
	ihid.id="id";
	ihid.value=id;
	ihid.type="hidden";
	rcontent.appendChild(ihid);
	addatextareafield(rcontent,"descfield","comment","Description:","5","60");
	idiv=document.createElement('div');
	idiv.className="submitfield";
	iin=document.createElement('input');
	iin.type="submit";
	iin.onclick=function(){eventupdate();}
	iin.value="Update Events";
	idiv.appendChild(iin);
	rcontent.appendChild(idiv);
	}
/***********************************************************************************/
var defSeason = 0;
function buildmatchform(rcontent,bscript,id,parent)
{
	bscript.text="\tsetupeventsform();";
        addlabelfield(rcontent,"headerfield","Match Input");
	addaninputfield(rcontent,"datefield","date","Date:");
        var idiv=document.createElement('div');
        idiv.id="container";
        var cdiv=document.createElement('div');
        cdiv.className="bd";
        var ccdiv=document.createElement('div');
        ccdiv.id="cal";
        ccdiv.name="cal";
        cdiv.appendChild(ccdiv);
        idiv.appendChild(cdiv);
        rcontent.appendChild(idiv);
        addaselectfield(rcontent,"seasonfield","season","Season:");
        addaselectfield(rcontent,"teamfield","team","Team:");
        addaselectfield(rcontent,"oppfield","opp","Opposition:");
        addaselectfield(rcontent,"compfield","comp","Competition:");
	addaselectfield(rcontent,"sponsorfield","sponsor","Sponsor:");
	addaselectfield(rcontent,"venuefield","venue","Venue:");
	addaninputfield(rcontent,"forfield","ptf","Pts +:");
        addaninputfield(rcontent,"confield","pta","Pts -:");
        addaselectfield(rcontent,"donefield","done","Played:");
	var ihid=document.createElement('input');
        ihid.id="id";
	ihid.value=id;
        ihid.type="hidden";
        rcontent.appendChild(ihid);
	var iparent=document.createElement('input');
        iparent.id="parent";
        iparent.value=parent;
        iparent.type="hidden";
        rcontent.appendChild(iparent);
        idiv=document.createElement('div');
	idiv.className="submitfield";
        var iin=document.createElement('input');
        iin.type="button";
        iin.value="Update Fixture";
	iin.onclick=function(){matchupdate();};
	idiv.appendChild(iin);
	//var ia = document.createElement('a');
	//ia.href="javascript: matchupdate();";
	//ia.appendChild(document.createTextNode("Update Fixture"));
	//idiv.appendChild(ia);
        rcontent.appendChild(idiv);
	var team=0;
	var comp=0;
	var gdate="";
	var opp=0;
	var venue=0;
	var ptf=0;
	var pta=0;
	var done=0;
	var season=0;
	var sponsor=0;
	var feed,request,opt,id,name,url;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
	if(id > 0)
	{
		url = "../xml/matches.xml?nocache="+ Math.random();
        	request.open("GET",url,false);
        	request.send(null);
        	feed = request.responseXML;
		var matchList = feed.getElementsByTagName('match');
        	var nummatch = matchList.length;
        	for (var i=0;i <nummatch;i++)
        	{
                	var gid = matchList[i].getElementsByTagName('id');
			if(gid[0].firstChild.nodeValue == id)
                	{
  				var tid=matchList[i].getElementsByTagName('team');
				team=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('competition');
                                comp=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('season');
                                season=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('date');
                                gdate=tid[0].firstChild.nodeValue;
  				tid=matchList[i].getElementsByTagName('venue');
                                venue=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('season');
                                season=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('complete');
                                done=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('opposition');
                                opp=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('ptf');
                                ptf=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('pta');
                                pta=tid[0].firstChild.nodeValue;
				tid=matchList[i].getElementsByTagName('sponsor');
                                sponsor=tid[0].firstChild.nodeValue;
				}
			}
                }
	if(season == 0 && defSeason == 0)
	{
		url = "../xml/system.xml?nocache="+ Math.random();
        	request.open("GET",url,false);
        	request.send(null);
        	var feed = request.responseXML;
        	var sysList = feed.getElementsByTagName('system');
        	var numsys = sysList.length;
        	for (var i=0;i <numsys;i++)
        	{
                	var sid = sysList[i].getElementsByTagName('id');
                	if(sid[0].firstChild.nodeValue == "1")
                	{
                        	var ss= sysList[i].getElementsByTagName('season');
                        	season = ss[0].firstChild.nodeValue;
                        	defSeason = season;
				}
                	}
		}
	if(season == 0)
		season=defSeason;
	
	fillopplist(document.getElementById('opp'),opp);
	fillseasonlist(document.getElementById('season'),season);
	fillcomplist(document.getElementById('comp'),comp);
	fillteamlist(document.getElementById('team'),team);
	fillsponsorlist(document.getElementById('sponsor'),sponsor);
	fillteamlist(document.getElementById('team'),team,(parent ==10));
	filldonelist(document.getElementById('done'));	
	fillvenuelist(document.getElementById('venue'),venue);
	document.getElementById('date').value=gdate;
	document.getElementById('ptf').value=ptf;
	document.getElementById('pta').value=pta;
	
}
/**********************************************************************************/
function filldonelist(inp)
{
        var request,opt,id,name;
        var inpTag = document.getElementById(inp);
        opt=document.createElement('Option');
        opt.value="0";
        opt.appendChild(document.createTextNode("UnPlayed"));
        opt.selected = true;
	inp.appendChild(opt);
        opt=document.createElement('Option');
	opt.value="1";
        opt.appendChild(document.createTextNode("Played"));        
	inp.appendChild(opt);
        }
/**********************************************************************************/
function fillvenuelist(inp,sel)
{
        var request,opt,id,name;
        var inpTag = document.getElementById(inp);
        opt=document.createElement('Option');
        opt.value="0";
        opt.appendChild(document.createTextNode("Away"));
        if(sel == 0)
		opt.selected = true;
        inp.appendChild(opt);
        opt=document.createElement('Option');
	opt.value="1";
        opt.appendChild(document.createTextNode("Home"));
	if(sel == 1)
                opt.selected = true;
        inp.appendChild(opt);
        }

/**********************************************************************************/
function fillseasonlist(inp,sel)
{
        var request,opt,id,name;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
        var url = "../xml/seasons.xml?nocache="+ Math.random();
        request.open("GET",url,false);
        request.send(null);
        var feed = request.responseXML;
        var teamList = feed.getElementsByTagName('season');
        var numteams = teamList.length;
        var inpTag = document.getElementById(inp);
        opt=document.createElement('Option');
        opt.value="0";
        opt.appendChild(document.createTextNode("No Season"));
        inp.appendChild(opt);
                
	for (var i=0;i <numteams;i++)
        {
                opt=document.createElement('Option');
                id=teamList[i].getElementsByTagName('id');
                opt.value=id[0].firstChild.nodeValue;
                name=teamList[i].getElementsByTagName('name');
                opt.appendChild(document.createTextNode(name[0].firstChild.nodeValue));
		if(opt.value == sel.toString())

                        opt.selected=true;
                inp.appendChild(opt);
                }
        }

/**********************************************************************************/
function fillsponsorlist(inp,sel)
{
        var request,opt,id,name;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
        var url = "../xml/sponsors.xml?nocache="+ Math.random();
        request.open("GET",url,false);
        request.send(null);
        var feed = request.responseXML;
        var teamList = feed.getElementsByTagName('sponsor');
        var numteams = teamList.length;
        var inpTag = document.getElementById(inp);
        opt=document.createElement('Option');
        opt.value="0";
        opt.appendChild(document.createTextNode("No Sponsor"));
        if(sel=="0")
                opt.selected = true;
	inp.appendChild(opt);
                
        for (var i=0;i <numteams;i++)
        {
                opt=document.createElement('Option');
                id=teamList[i].getElementsByTagName('id');
                opt.value=id[0].firstChild.nodeValue;
                name=teamList[i].getElementsByTagName('name');
                opt.appendChild(document.createTextNode(name[0].firstChild.nodeValue));
                if(opt.value == sel)
                        opt.selected=true;
                inp.appendChild(opt);
                }
        }

/**********************************************************************************/
function fillcomplist(inp,sel)
{
        var request,opt,id,name;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
        var url = "../xml/comps.xml?nocache="+ Math.random();
        request.open("GET",url,false);
        request.send(null);
        var feed = request.responseXML;
        var teamList = feed.getElementsByTagName('competition');
        var numteams = teamList.length;
        var inpTag = document.getElementById(inp);
        opt=document.createElement('Option');
        opt.value="0";
        opt.appendChild(document.createTextNode("No Competition"));
        if(sel=="0")
                opt.selected = true;
	inp.appendChild(opt);
                
        for (var i=0;i <numteams;i++)
        {
                opt=document.createElement('Option');
                id=teamList[i].getElementsByTagName('id');
                opt.value=id[0].firstChild.nodeValue;
                name=teamList[i].getElementsByTagName('name');
                opt.appendChild(document.createTextNode(name[0].firstChild.nodeValue));
                if(opt.value == sel)
                        opt.selected=true;
                inp.appendChild(opt);
                }
        }

/**********************************************************************************/
function fillopplist(inp,sel)
{
        var request,opt,id,name;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
        var url = "../xml/oppositions.xml?nocache="+ Math.random();
        request.open("GET",url,false);
        request.send(null);
        var feed = request.responseXML;
        var teamList = feed.getElementsByTagName('opposition');
        var numteams = teamList.length;
        var inpTag = document.getElementById(inp);
        
	opt=document.createElement('Option');
        opt.value="0";
        opt.appendChild(document.createTextNode("No Opposition Selected"));
        if(sel=="0")
                opt.selected = true;
	inp.appendChild(opt);
        for (var i=0;i <numteams;i++)
        {
                opt=document.createElement('Option');
                id=teamList[i].getElementsByTagName('id');
                opt.value=id[0].firstChild.nodeValue;
                name=teamList[i].getElementsByTagName('name');
                opt.appendChild(document.createTextNode(name[0].firstChild.nodeValue));
                if(opt.value == sel)
                        opt.selected=true;
                inp.appendChild(opt);
		}
        }

/**********************************************************************************/
function fillteamlist(inp,sel,senior)
{
  	var request,opt,id,name;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
        var url = "../xml/teams.xml?nocache="+ Math.random();
        request.open("GET",url,false);
        request.send(null);
        var feed = request.responseXML;
        var teamList = feed.getElementsByTagName('team');
        var numteams = teamList.length;
        var inpTag = document.getElementById(inp);
	opt=document.createElement('Option');
        opt.value="0";
	opt.appendChild(document.createTextNode("No Team Selected"));
	if(sel=="0")
		opt.selected = true;
	inp.appendChild(opt);
                 
        for (var i=0;i <numteams;i++)
        {
		id=teamList[i].getElementsByTagName('id');
		if((id[0].firstChild.nodeValue < 5 && senior) || (id[0].firstChild.nodeValue > 5 && senior==false)) 
		{
			opt=document.createElement('Option');
                	opt.value=id[0].firstChild.nodeValue;
			name=teamList[i].getElementsByTagName('name');
			opt.appendChild(document.createTextNode(name[0].firstChild.nodeValue));
			if(opt.value == sel)
				opt.selected=true;
			inp.appendChild(opt);
			}
		}
	}
/**********************************************************************************/
function entersite()
{
	buildpage(0);
	isloggedin();
	}
/***********************************************************************************/
function getselection(team)
{
	var request;
 	var dochead = document.getElementById('selecthead');
      	while(dochead.hasChildNodes())
		dochead.removeChild(dochead.firstChild);
	var docfoot = document.getElementById('selectfoot');
      	while(docfoot.hasChildNodes())
		docfoot.removeChild(docfoot.firstChild);
	var theadTag = document.getElementById('players');
	while(theadTag.hasChildNodes())
		theadTag.removeChild(theadTag.firstChild);
	var tsel = document.getElementById('tselect');
	tsel.style.visibility="hidden"
	var pnsel = document.getElementById('pnselect');
	pnsel.style.visibility="visible"
	try
		{request=new XMLHttpRequest();}
	catch (e)
		{ request = new ActiveXObject("Msxml2.XMLHTTP");}
	try{
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
		}
	catch(e)
		{}
	var url = "../xml/t"+team+"select.xml?nocache="+ Math.random();
	request.open("GET",url,false);
	request.send(null);
  	var feed = request.responseXML;
	var head = feed.getElementsByTagName('head');
	var headtxt = document.createTextNode(head[0].firstChild.nodeValue);
	dochead.appendChild(headtxt);
	var playerList = feed.getElementsByTagName('player');
	var numplayers = playerList.length;
	for (var i=0;i <numplayers;i++)
	{
 		var newtrTag = document.createElement('tr');
		var newtdTag = document.createElement('td');
		var playerPosn = playerList[i].getElementsByTagName('posn');
		var playerPosnTxt = document.createTextNode(playerPosn[0].firstChild.nodeValue);
		newtdTag.appendChild(playerPosnTxt);
		newtrTag.appendChild(newtdTag);
		var newtd1Tag = document.createElement('td');
		var playerName = playerList[i].getElementsByTagName('name');
		var playerNameTxt = document.createTextNode(playerName[0].firstChild.nodeValue);
     		newtd1Tag.appendChild(playerNameTxt);
		newtrTag.appendChild(newtd1Tag);
		theadTag.appendChild(newtrTag);
		}
	var foot = feed.getElementsByTagName('foot');
	var foottxt = document.createTextNode(foot[0].firstChild.nodeValue);
	docfoot.appendChild(foottxt);
      	if(numplayers > 0)
	{
      		tsel.style.visibility="visible";
		pnsel.style.visibility="hidden";
		}
	}
/*********************************************************************************/
function setselection(team)
{
        var request;
        var dochead = document.getElementById('mdetail');
	var docfoot = document.getElementById('mfoot');
	var docteam = document.getElementById('team');
	docteam.value = team;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
        try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
        var url = "../xml/t"+team+"select.xml?nocache="+ Math.random();
        request.open("GET",url,false);
        request.send(null);
        var feed = request.responseXML;
	var head = feed.getElementsByTagName('head');
        dochead.value = head[0].firstChild.nodeValue;
        var foot = feed.getElementsByTagName('foot');
        docfoot.value = foot[0].firstChild.nodeValue;
	var playerList = feed.getElementsByTagName('player');
        var numplayers = playerList.length;
        var posn;
        for (var i=0;i <numplayers;i++)
        {
                var Id = playerList[i].getElementsByTagName('id');
		var name 		
alert(Id[0].firstChild);
		switch(Id[0].firstChild.nodeValue)
		{
			case '15':
			posn = document.getElementById("p15");
			break;
			
			case '14':
                        posn = document.getElementById("p14");
                        break;
			case '13':
                        posn = document.getElementById("p13");
                        break;
			case '12':
                        posn = document.getElementById("p12");
                        break;
			case '11':
                        posn = document.getElementById("p11");
                        break;
			case '10':
                        posn = document.getElementById("p10");
                        break;
			case '9':
                        posn = document.getElementById("p9");
                        break;
			case '1':
                        posn = document.getElementById("p1");
                        break;
			case '2':
                        posn = document.getElementById("p2");
                        break;
			case '3':
                        posn = document.getElementById("p3");
                        break;
			case '4':
                        posn = document.getElementById("p4");
                        break;
			case '5':
                        posn = document.getElementById("p5");
                        break;
			case '6':
                        posn = document.getElementById("p6");
                        break;
			case '8':
                        posn = document.getElementById("p8");
                        break;
			case '7':
                        posn = document.getElementById("p7");
                        break;
			case '16':
                        posn = document.getElementById("p16");
                        break;
			case '17':
                        posn = document.getElementById("p17");
                        break;
			case '18':
                        posn = document.getElementById("p18");
                        break;
			case '19':
                        posn = document.getElementById("p19");
                        break;
			}
		posn.value = playerList[i].getElementsByTagName('name')[0].firstChild.nodeValue;	
                }
        }

/*********************************************************************************/

function getcontacts()
{
	var request;
	try
		{request=new XMLHttpRequest();}
	catch (e)
		{ request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
		}
	catch(e)
		{}
	var url = "../xml/contacts.xml?nocache="+ Math.random();

	request.open("GET",url,false);
	request.send(null);
  	var feed = request.responseXML;
	var contactList = feed.getElementsByTagName('contact');
	var numcontacts = contactList.length;
        var theadTag = document.getElementById('contacts');
	for (var i=0;i <numcontacts;i++)
	{
 		var newtrTag = document.createElement('tr');
		var newtdTag = document.createElement('td');
		var contactPosn = contactList[i].getElementsByTagName('office');
		var contactPosnTxt = document.createTextNode(contactPosn[0].firstChild.nodeValue);
		newtdTag.appendChild(contactPosnTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
            	contactPosn = contactList[i].getElementsByTagName('name');
		contactPosnTxt = document.createTextNode(contactPosn[0].firstChild.nodeValue);
		var contactEmail = contactList[i].getElementsByTagName('email');
                if(contactEmail[0].hasChildNodes())
                {
                        var newaTag = document.createElement('a');
                        var linkTxt = document.createTextNode(contactEmail[0].firstChild.nodeValue);
                        newaTag.href = 'mailto:'+contactEmail[0].firstChild.nodeValue;
                        newaTag.appendChild(contactPosnTxt);
                        newtdTag.appendChild(newaTag);

                        }
                else
                        newtdTag.appendChild(contactPosnTxt);
		newtrTag.appendChild(newtdTag);
		/*newtdTag = document.createElement('td');
            	contactPosn = contactList[i].getElementsByTagName('email');
		contactPosnTxt = document.createTextNode(contactPosn[0].firstChild.nodeValue);
		newtdTag.appendChild(contactPosnTxt);
		newtrTag.appendChild(newtdTag);
		*/newtdTag = document.createElement('td');
            	contactPosn = contactList[i].getElementsByTagName('tel');
		contactPosnTxt = document.createTextNode(contactPosn[0].firstChild.nodeValue);
		newtdTag.appendChild(contactPosnTxt);
		newtrTag.appendChild(newtdTag);
		theadTag.appendChild(newtrTag);
		}
	}
/*********************************************************************************/
function getguestbook()
{
	var request;
	var eindex;
	var doctitle = document.getElementById('ghead');
      while(doctitle.hasChildNodes())
		doctitle.removeChild(doctitle.firstChild);
	var theadTag = document.getElementById('guestentries');
	while(theadTag.hasChildNodes())
		theadTag.removeChild(theadTag.firstChild);
	try
		{request=new XMLHttpRequest();}
	catch (e)
		{ request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
		}
	catch(e)
		{}
        var url = "../xml/guestbook.xml?nocache="+ Math.random();
	request.open("GET",url,false);
	request.send(null);
        var i = 1;
        while (request.readyState != 4)
             i = i+1;       
        
  	var feed = request.responseXML;
	var titleof = feed.getElementsByTagName('title');

	var title ="Guest Book";
	if(titleof.length == 1)
		title = titleof[0].firstChild.nodeValue;
	var titleText = document.createTextNode(title);
 	doctitle.appendChild(titleText);
	var indexof = feed.getElementsByTagName('entry');
	gindex = indexof.length;
	
	eindex = gindex -10;
	
	if(eindex < 0 )
		eindex = 0;
	for (var i=eindex;i < gindex;i++)
	{
		var newtrTag = document.createElement('tr');
		var newtdTag = document.createElement('td');
		var newdivTag = document.createElement('div');
		newdivTag.className='gb';
		var newpTag = document.createElement('p');
		newpTag.className='gbdate';
                var gdate = indexof[i].getElementsByTagName('date');
            	var newaTag = document.createElement('a');
		var gdateTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
		newpTag.appendChild(gdateTxt);
		newdivTag.appendChild(newpTag);
                newpTag = document.createElement('p');
		newpTag.className='gbcomment';
                gdate = indexof[i].getElementsByTagName('comment');
		gdateTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
		newpTag.appendChild(gdateTxt);
		newdivTag.appendChild(newpTag);
		gdate = indexof[i].getElementsByTagName('author');
		gdateTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
		newaTag.href = 'mailto:'+gdate[0].firstChild.nodeValue;
		newaTag.appendChild(gdateTxt);
		newpTag = document.createElement('p');
		newpTag.className='gbsign';
                newpTag.appendChild(newaTag);
		newdivTag.appendChild(newpTag);
 
		gdate = indexof[i].getElementsByTagName('answer');
         	
		if(gdate[0].hasChildNodes())
		{
			gdateTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
			newpTag = document.createElement('p');
			newpTag.className='gbanswer';
                	newpTag.appendChild(gdateTxt);
			newdivTag.appendChild(newpTag);
			}
		newtdTag.appendChild(newdivTag);
		newtrTag.appendChild(newtdTag);
		theadTag.appendChild(newtrTag);
		}
	}
/***************************************************************/
function getmain(rcontent,senior)
{
        var moddiv = document.createElement('div');
	moddiv.id ="modules";
	var t1div = document.createElement('div');
	t1div.className="yui-gb";
        var c1div = document.createElement('div');
        c1div.className="yui-u first";
	c1div.id="c_1";
	//c1div.style="DISPLAY: block; WIDTH: 32%";
	var dmdiv = document.createElement('div');
	dmdiv.className="dm";
	c1div.appendChild(dmdiv);
	var c2div = document.createElement('div');
        c2div.className="yui-u second";
	c2div.id="c_2";
 	//c2div.style="DISPLAY: block; WIDTH: 32%";
	dmdiv = document.createElement('div');
        dmdiv.className="dm";
        c2div.appendChild(dmdiv);
	var c3div = document.createElement('div');
        c3div.className="yui-u third";
	c3div.id="c_3";
 	//c3div.style="DISPLAY: block; WIDTH: 32%";
        dmdiv = document.createElement('div');
        dmdiv.className="dm";
        c3div.appendChild(dmdiv);
	t1div.appendChild(c1div);
	t1div.appendChild(c2div);
	t1div.appendChild(c3div);
	moddiv.appendChild(t1div);
      	rcontent.appendChild(moddiv)
	addabox(1,1,false);
	if(senior)
	{
		addabox(2,2,false);
		addabox(2,3,false);
		addabox(2,4,false);
		addabox(2,5,false);
		}
	else
	{
		addabox(2,6,false);
                addabox(2,7,false);
                addabox(2,8,false);
                addabox(2,9,false);
		addabox(2,10,false);
                addabox(2,11,false);
                addabox(2,12,false);
                addabox(2,13,false);
		addabox(2,14,false);
                addabox(2,15,false);
                addabox(2,16,false);
		addabox(2,17,false);

	//	 addabox("2","2",false,5);

		}
}
/***************************************************************/
function getevents(rcontent,admin)
{
        var request;
        var eindex;
        try
                {request=new XMLHttpRequest();}
        catch (e)
                { request = new ActiveXObject("Msxml2.XMLHTTP");}
      	try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                }
        catch(e)
                {}
        var url = "../xml/events.xml?nocache="+ Math.random();
        request.open("GET",url,false);
        request.send(null);
	var i = 1;
        while (request.readyState != 4)
             i = i+1;
	var newtableTag = document.createElement('table');
        var feed = request.responseXML;
        var indexof = feed.getElementsByTagName('event');
        gindex = indexof.length;
	var theadTag = document.createElement('thead');
	var trTag=document.createElement('tr');
	var tdTag=document.createElement('td');
	tdTag.className="selr";
	tdTag.appendChild(document.createTextNode("Forthcoming Events"));
	trTag.appendChild(tdTag);
	theadTag.appendChild(trTag);
	newtableTag.appendChild(theadTag);
	var bodyTag=document.createElement('tbody');
        eindex = gindex -15;

        if(eindex < 0 )
                eindex = 0;
	for (var i=eindex;i < gindex;i++)
        {
		var newtrTag = document.createElement('tr');
                var newtdTag = document.createElement('td');
                var newdivTag = document.createElement('div');
                var newaaTag = document.createElement('a');
		var gname = indexof[i].getElementsByTagName('id');
                newaaTag.id=gname[0].firstChild.nodeValue
		newdivTag.appendChild(newaaTag);
		newdivTag.className='gb';
                var newpTag = document.createElement('p');
                newpTag.className='gbdate';
                var gdate = indexof[i].getElementsByTagName('date');
                var gdateTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
                var edate = gdate[0].firstChild.nodeValue;
		newpTag.appendChild(gdateTxt);
                newdivTag.appendChild(newpTag);
                gdate = indexof[i].getElementsByTagName('artist');
                gdateTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
                newpTag = document.createElement('p');
                newpTag.className='eartist';

                gdate = indexof[i].getElementsByTagName('link');
                if(gdate[0].hasChildNodes())
                {
                        var newaTag = document.createElement('a');
                        var linkTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
                        newaTag.href = gdate[0].firstChild.nodeValue;
                        newaTag.appendChild(gdateTxt);
                        newpTag.appendChild(newaTag);

                        }
                else
                        newpTag.appendChild(gdateTxt);
                newdivTag.appendChild(newpTag);
		newpTag = document.createElement('p');
                newpTag.className='gbcomment';
                gdate = indexof[i].getElementsByTagName('comment');
                gdateTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
                newpTag.appendChild(gdateTxt);
                newdivTag.appendChild(newpTag);
                newpTag = document.createElement('p');
                newpTag.className='eentry';
                gdate = indexof[i].getElementsByTagName('entry');
                gdateTxt = document.createTextNode(gdate[0].firstChild.nodeValue);
                newpTag.appendChild(gdateTxt);
                newdivTag.appendChild(newpTag);
                gdate = indexof[i].getElementsByTagName('id');
		if(admin)
		{
			newpTag = document.createElement('p');
               		newpTag.className='eedit';
	        	var newaaTag = document.createElement('a');
			gdate = indexof[i].getElementsByTagName('id');
                       	editTxt = document.createTextNode("Edit");
			newaaTag.href="javascript: buildpage(19,"+gdate[0].firstChild.nodeValue+");";
			//newaaTag.href = "/php/eventsform.php?id="+gdate[0].firstChild.nodeValue;
			//alert(newaaTag.href);
			newaaTag.appendChild(editTxt);
			newpTag.appendChild(newaaTag);
			newdivTag.appendChild(newpTag);
			}
		if(isdatepast(edate) && cookies['level'])
		{
			newpTag = document.createElement('p');
                       	newpTag.className='addcomment';
                       	var newcTag = document.createElement('a');
                       	gdate = indexof[i].getElementsByTagName('id');
                       	var comTxt = document.createTextNode("Add a comment");
                       	newcTag.href = "/php/eventcomform.php?id="+gdate[0].firstChild.nodeValue;
                               //alert(newaaTag.href);
                       	newcTag.appendChild(comTxt);
                       	newpTag.appendChild(newcTag);
                       	newdivTag.appendChild(newpTag);
			}
	
		newtdTag.appendChild(newdivTag);
                newtrTag.appendChild(newtdTag);
                bodyTag.appendChild(newtrTag);

		}
	if(admin)
	{
		var newnaTag = document.createElement('a');
		newnaTag.href="javascript: buildpage(19,0);";
		//newnaTag.href="/php/eventsform.php";
		newnaTag.appendChild(document.createTextNode("New Event"));
		newtrTag = document.createElement('tr');
               	newtdTag = document.createElement('td');
               	newtdTag.appendChild(newnaTag);
       		newtrTag.appendChild(newtdTag);
        	bodyTag.appendChild(newtrTag);
	        } 
		
		
	newtableTag.appendChild(bodyTag);
	rcontent.appendChild(newtableTag);
	}

/*****************************************************************************/
function getfixtures(rcontent,team,admin,parent)
{
	var request;
	try
		{request=new XMLHttpRequest();}
	catch (e)
		{ request = new ActiveXObject("Msxml2.XMLHTTP");}
	try{
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
		}
	catch(e)
		{}
	
	var url = "../xml/fixl"+team+".xml?nocache="+ Math.random();
	request.open("GET",url,false);
	request.send(null);
  	var feed = request.responseXML;
      	var pteam = feed.getElementsByTagName('team');
      	var season = feed.getElementsByTagName('season');
	var pfix=document.createElement('p');
	pfix.className="subhead";
	pfix.id="teamf";
	pfix.appendChild(document.createTextNode(pteam[0].firstChild.nodeValue+" - "+season[0].firstChild.nodeValue));		
	rcontent.appendChild(pfix);
	var rfixture=document.createElement('table');
	rfixture.id="rfixture";
	var rhead=document.createElement('thead');
	var rtr=document.createElement('tr');
	var rtd=document.createElement('td');
        rtd.className="selr";
	 rtd.appendChild(document.createTextNode("Date"));
	rtr.appendChild(rtd);
	rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("H/A"));
        rtr.appendChild(rtd);
	rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Opposition"));
        rtr.appendChild(rtd);	
	rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Competition"));
        rtr.appendChild(rtd);
	rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Sponsor"));
        rtr.appendChild(rtd);
	rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("+"));
        rtr.appendChild(rtd);
	rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("-"));
        rtr.appendChild(rtd);
	rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("W/D/L"));
        rtr.appendChild(rtd);
	rhead.appendChild(rtr);
	
	rfixture.appendChild(rhead);
	var rbody=document.createElement('tbody');
	rbody.id="results";
	var resultsList = feed.getElementsByTagName('result');
	var numresults = resultsList.length;
      	for (var i=0;i <numresults;i++)
	{
 		var newtrTag = document.createElement('tr');
		var newtdTag = document.createElement('td');
		var resultdate = resultsList[i].getElementsByTagName('date');
		var resultdateTxt = document.createTextNode(resultdate[0].firstChild.nodeValue);
		newtdTag.appendChild(resultdateTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var venue = resultsList[i].getElementsByTagName('venue');
		var venueTxt = document.createTextNode(venue[0].firstChild.nodeValue);
    		newtdTag.appendChild(venueTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var opp = resultsList[i].getElementsByTagName('opposition');
		var oppTxt = document.createTextNode(opp[0].firstChild.nodeValue);
    		newtdTag.appendChild(oppTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var comp = resultsList[i].getElementsByTagName('competition');
		var compTxt = document.createTextNode(comp[0].firstChild.nodeValue);
     		newtdTag.appendChild(compTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var spon = resultsList[i].getElementsByTagName('sponsor');
		var sponTxt;
		if(spon[0].hasChildNodes())
			sponTxt = document.createTextNode(spon[0].firstChild.nodeValue);
		else
			sponTxt = document.createTextNode('-');
     		newtdTag.appendChild(sponTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var pf = resultsList[i].getElementsByTagName('ptf');
		var pfTxt = document.createTextNode(pf[0].firstChild.nodeValue);
     		newtdTag.appendChild(pfTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var pa = resultsList[i].getElementsByTagName('pta');
		var paTxt = document.createTextNode(pa[0].firstChild.nodeValue);
     		newtdTag.appendChild(paTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var wda = resultsList[i].getElementsByTagName('wda');
		var wdaTxt = document.createTextNode(wda[0].firstChild.nodeValue);
     		newtdTag.appendChild(wdaTxt);
		newtrTag.appendChild(newtdTag);
		rbody.appendChild(newtrTag);
		}
	rfixture.appendChild(rbody);
	rcontent.appendChild(rfixture);
	var hr = document.createElement('hr');
	hr.className="blue";
	rcontent.appendChild(hr);
	var ffixture=document.createElement('table');
        ffixture.id="ffixture";
        rhead=document.createElement('thead');
        rtr=document.createElement('tr');
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Date"));
        rtr.appendChild(rtd);
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("H/A"));
        rtr.appendChild(rtd);
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Opposition"));
        rtr.appendChild(rtd);
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Competition"));
        rtr.appendChild(rtd);
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Sponsor"));
        rtr.appendChild(rtd);
        if(admin)
	{
		rtd=document.createElement('td');
        	rtd.className="selr";
        	rtr.appendChild(rtd);
		}
	rhead.appendChild(rtr);
        ffixture.appendChild(rhead);
        var fbody=document.createElement('tbody');
        fbody.id="fixtures";
	var fixtureList = feed.getElementsByTagName('fixture');
	var numfix = fixtureList.length;
      	for (var i=0;i <numfix;i++)
	{
 	        var newtrTag = document.createElement('tr');
		var newtdTag = document.createElement('td');
		var fixdate = fixtureList[i].getElementsByTagName('date');
		var fixdateTxt = document.createTextNode(fixdate[0].firstChild.nodeValue);
		newtdTag.appendChild(fixdateTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var venue = fixtureList[i].getElementsByTagName('venue');
		var venueTxt = document.createTextNode(venue[0].firstChild.nodeValue);
       		newtdTag.appendChild(venueTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var opp = fixtureList[i].getElementsByTagName('opposition');
		var oppTxt = document.createTextNode(opp[0].firstChild.nodeValue);
       		newtdTag.appendChild(oppTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var comp = fixtureList[i].getElementsByTagName('competition');
		var compTxt = document.createTextNode(comp[0].firstChild.nodeValue);
       		newtdTag.appendChild(compTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		
                var spon = fixtureList[i].getElementsByTagName('sponsor');
                var sponTxt;
                if(spon[0].hasChildNodes())
                    sponTxt = document.createTextNode(spon[0].firstChild.nodeValue);
                else
                    sponTxt = document.createTextNode('-');
                newtdTag.appendChild(sponTxt);
		newtrTag.appendChild(newtdTag);
		 if(admin)
                {
                        var id = fixtureList[i].getElementsByTagName('id');
                        if(id[0])
                        {
                                newtdTag = document.createElement('td');
                                var newaTag = document.createElement('a');
                                var newimgTag = document.createElement('img');
                                newimgTag.src="../images/del.JPG";
                                newimgTag.alt="Delete game";
                                newaTag.appendChild(newimgTag);
				if(parent==18)
					newaTag.href="javascript: delgame("+id[0].firstChild.nodeValue+",10,"+team+");";
				else
					newaTag.href="javascript: delgame("+id[0].firstChild.nodeValue+",15,"+team+");";
                                newtdTag.appendChild(newaTag);
                                newaTag = document.createElement('a');
                                newimgTag = document.createElement('img');
                                newimgTag.src="../images/edit.JPG";
                                newimgTag.alt="Edit game";
                                newaTag.appendChild(newimgTag);
                                newaTag.href="javascript: buildpage("+parent+","+id[0].firstChild.nodeValue+");";
                                newtdTag.appendChild(newaTag);
                                newaTag = document.createElement('a');
                                newimgTag = document.createElement('img');
                                newimgTag.src="../images/sel.JPG";
                                newimgTag.alt="Selection";
                                newaTag.appendChild(newimgTag);
				if(parent==18)
					newaTag.href="javascript: buildpage(20,"+id[0].firstChild.nodeValue+");";
				else
					newaTag.href="javascript: buildpage(22,"+id[0].firstChild.nodeValue+");";
                                newtdTag.appendChild(newaTag);
                                newtrTag.appendChild(newtdTag);
                                }

                        }
		fbody.appendChild(newtrTag);
	        
		}
	ffixture.appendChild(fbody);
        rcontent.appendChild(ffixture);
        if(admin)
                {
                        var newaTag = document.createElement('a');
                        newaTag.href="javascript: buildpage("+parent+",0);";
                        var newimgTag = document.createElement('img');
                        newimgTag.src="../images/add.JPG";
                        newimgTag.alt="Add a Game";
			newaTag.appendChild(newimgTag);
                        rcontent.appendChild(newaTag);
                        }
       	rcontent.appendChild(hr);
	var pfixture=document.createElement('table');
        pfixture.id="pfixture";
        var rhead=document.createElement('thead');
        var rtr=document.createElement('tr');
        var rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Competition"));
        rtr.appendChild(rtd);
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Played"));
        rtr.appendChild(rtd);
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Won"));
        rtr.appendChild(rtd);
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Drawn"));
        rtr.appendChild(rtd);
        rtd=document.createElement('td');
        rtd.className="selr";
        rtd.appendChild(document.createTextNode("Lost"));
        rtr.appendChild(rtd);
	rtd=document.createElement('td');
        rtd.className="selr";
	rtd.appendChild(document.createTextNode("Pts +"));
        rtr.appendChild(rtd);
	rtd=document.createElement('td');
        rtd.className="selr";
	rtr.appendChild(rtd);
	rtd.appendChild(document.createTextNode("Pts -"));
        rtr.appendChild(rtd);
	rtd=document.createElement('td');
	rtd.className="selr";
	rtd.appendChild(document.createTextNode("Agg"));
	rtr.appendChild(rtd);
        rhead.appendChild(rtr);
        pfixture.appendChild(rhead);
        var pbody=document.createElement('tbody');
        pbody.id="points";
 
	var tabList = feed.getElementsByTagName('table');
	var numtab = tabList.length;
	for (var i=0;i <numtab;i++)
	{
 		var newtrTag = document.createElement('tr');
		var newtdTag = document.createElement('td');
		var comp = tabList[i].getElementsByTagName('competition');
		var compTxt = document.createTextNode(comp[0].firstChild.nodeValue);
		newtdTag.appendChild(compTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var pld = tabList[i].getElementsByTagName('played');
		var pldTxt = document.createTextNode(pld[0].firstChild.nodeValue);
       		newtdTag.appendChild(pldTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
	
		var won = tabList[i].getElementsByTagName('won');
		var wonTxt = document.createTextNode(won[0].firstChild.nodeValue);
       		newtdTag.appendChild(wonTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var drawn = tabList[i].getElementsByTagName('drawn');
		var drawnTxt = document.createTextNode(drawn[0].firstChild.nodeValue);
       		newtdTag.appendChild(drawnTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var lost = tabList[i].getElementsByTagName('lost');
		var lostTxt = document.createTextNode(lost[0].firstChild.nodeValue);
       		newtdTag.appendChild(lostTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var pf = tabList[i].getElementsByTagName('pf');
		var pfTxt = document.createTextNode(pf[0].firstChild.nodeValue);
       		newtdTag.appendChild(pfTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var pa = tabList[i].getElementsByTagName('pa');
		var paTxt = document.createTextNode(pa[0].firstChild.nodeValue);
       		newtdTag.appendChild(paTxt);
		newtrTag.appendChild(newtdTag);
		newtdTag = document.createElement('td');
		var pagg = tabList[i].getElementsByTagName('pagg');
		var paggTxt = document.createTextNode(pagg[0].firstChild.nodeValue);
       		newtdTag.appendChild(paggTxt);
		newtrTag.appendChild(newtdTag);
		pbody.appendChild(newtrTag);
	
		}
	pfixture.appendChild(pbody);
        rcontent.appendChild(pfixture);
        rcontent.appendChild(hr);
	
	if(numresults > 0)
	      	rfixture.style.visibility="visible";
	else
		rfixture.style.visibility="hidden";
	if(numfix > 0)
	      	ffixture.style.visibility="visible";
	else
		ffixture.style.visibility="hidden";
	if(numtab > 0)
	      	pfixture.style.visibility="visible";
	else
		pfixture.style.visibility="hidden";
		

	}
/*********************************************************************************/
/**********************************************/
function getordate(dm)
{
	
	var m = dm.substring(dm.length-8,dm.length-5);
	var dd;
	switch(m)
	{
		case 'Jan':
		dd='January ';
		break;
		case 'Feb':
		dd='February ';
		break;
		case 'Mar':
		dd='March ';
		break;
		case 'Apr':
		dd='April ';
		break;
		case 'May':
		dd='May ';
		break;
		case 'Jun':
		dd='June ';
		break;
		case 'Jul':
		dd='July ';
		break;
		case 'Aug':
		dd='August ';
		break;
		case 'Sep':
		dd='September';
		break;
		case 'Oct':
		dd='October';
		break;
		case 'Nov':
		dd='November';
		break;
		case 'Dec':
		dd='December';
		break;
		}
	dd = dd+dm.substring(0,dm.length-9)+", ";
	dd=dd+dm.substring(dm.length-4);
	return new Date(dd);
	}
/*********************************************/
function _del(c,id)
{
  	var target=document.getElementById(id);
	var cont=document.getElementById(c);
	if(target && cont)
		cont.removeChild(target);
	//cookie stuff
	return true;
	}
/***************************************************/
function getinfo(id,count)
{
	var mc,mcp,mcpt,mca,mcat,e,tid;
	var request,gindex,eindex,flag=false;
      var url,i,feed,indexof,gdate,hdate,ecount=0;
	var mboxin = document.getElementById('m_'+id+'_info');
	try
      	{request=new XMLHttpRequest();
		}
      catch (e)
            { 
		request = new ActiveXObject("Msxml2.XMLHTTP");}
      try{
      	netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
            }
      catch(e)
           {}
	if(id > 1 && id < 6)
		tid = id -1;
	else
		tid = id+1;
	if(mboxin)
	{
	 
		switch(id)
		{
			case 1://events
			url = "../xml/events.xml?nocache="+ Math.random();
      			request.open("GET",url,false);
        		request.send(null);
			i = 1;
        		while (request.readyState != 4)
            			i = i+1;
     			feed = request.responseXML;
     			indexof = feed.getElementsByTagName('event');
     			gindex = indexof.length;
			for (i=0;i < gindex;i++)
     			{
				gdate = indexof[i].getElementsByTagName('date');
           			hdate = getordate(gdate[0].firstChild.nodeValue);
				if(!(hdate < new Date()) && ecount < count)
				{
					mc = document.createElement('div');
					mc.className="mc";
					//mcp=document.createElement('p');
					var arti = indexof[i].getElementsByTagName('artist');
					mcpt=document.createTextNode(gdate[0].firstChild.nodeValue+"  "+arti[0].firstChild.nodeValue)
					//mcp.appendChild(mcpt);
					mc.appendChild(mcpt);
					//gdate = indexof[i].getElementsByTagName('artist');
					//mcat=document.createTextNode(gdate[0].firstChild.nodeValue);
					//mca = document.createElement('a');
					//gdate = indexof[i].getElementsByTagName('id');
					//mca.href="../events.htm#"+gdate[0].firstChild.nodeValue;
					//mca.appendChild(mcat);
					//mc.appendChild(mca);
					mboxin.appendChild(mc);
					ecount = ecount+1;
					}
				}
			break;
			case 2://matches
			case 3:
			case 4:
                        case 5:
                        case 6:
			case 7:
			case 8:
			case 9:
			case 10:
			case 11:
			case 12:
			case 13:
			case 14:
			case 15:
			case 16:
			case 17:
			case 18:
			case 19:	
			url = "../xml/fixl"+(tid)+".xml?nocache="+ Math.random();
			request.open("GET",url,false);
                        request.send(null);
                        i = 1;
			while (request.readyState != 4)
                                i = i+1;
                        feed = request.responseXML;
			indexof = feed.getElementsByTagName('fixture');
			if(indexof)
			{
                        	gindex = indexof.length;
                        	for (i=0;i < gindex;i++)
                        	{
                                	gdate = indexof[i].getElementsByTagName('date');
                                	hdate = getordate(gdate[0].firstChild.nodeValue);
                                	if(!(hdate < new Date()) && ecount < count)
                                	{
                                        	mc = document.createElement('div');
                                        	mc.className="mc";
                                        	var opp = indexof[i].getElementsByTagName('opposition');
						mcpt=document.createTextNode(gdate[0].firstChild.nodeValue+"  "+opp[0].firstChild.nodeValue)
                                        	mc.appendChild(mcpt);
                                        	//gdate = indexof[i].getElementsByTagName('opposition');
                                        	//mcat=document.createTextNode(gdate[0].firstChild.nodeValue);
                                        	//mca = document.createElement('a');
                                        	//gdate = indexof[i].getElementsByTagName('id');
                                        	//mca.href="../events.htm#"+gdate[0].firstChild.nodeValue;
                                        	//mca.appendChild(mcat);
                                        	//mc.appendChild(mca);
                                        	mboxin.appendChild(mc);
                                        	ecount = ecount+1;
                                        	}
                                	}
				}
			break;
			}
		}
	}

/************************************************/
function _zm(id)
{
	var target=document.getElementById('m_'+id+'_info');
	var cont=document.getElementById('m_'+id);
	var mm=document.getElementById('m_'+id+'_min');
	if(target && cont && mm)
	{
		cont.removeChild(target);
		mm.id="m_"+id+"_max";
		mm.title="Maximize";
		mm.className="maxbox";
		mm.onclick=function(){return _am(id);}
		//cookie stuff
		}
	return true;
	}
/**************************************************/
function _am(id)
{
	var cont=document.getElementById('m_'+id);
	var mm=document.getElementById('m_'+id+'_max');
	if(cont && mm)
	{
		var mboxin = document.createElement('Div');
		mboxin.className="modboxin";
		mboxin.id="m_"+id+"_info";
		cont.appendChild(mboxin);
		mm.id="m_"+id+"_min";
		mm.title="Minimize";
		mm.className="minbox";
		mm.onclick=function(){return _zm(id);}
	 	getinfo(id,5);	//cookie stuff
		}
	return true;
	}
/****************************************************/
function addabox(a,id,f)
{
	var chead = document.getElementById("c_"+a);
	var mspan = document.createElement("SPAN");
	var mspantxt;
	var tid;
	mspan.className="mtitle_text";
	mspan.id="m_"+id+"_title";
	var ma = document.createElement("A");
	ma.className="mtlink";
	ma.id="m_"+id+"_url";
	
	var mlink = document.createElement('H2');
	mlink.className="lnk";
	mlink.id="m_"+id+"_link";
	var mtbox= document.createElement('div');
	mtbox.className="modtitle";
	var mbox = document.createElement('div');

	mbox.classname="modbox";
	mbox.id="m_"+id;

	var delb = document.createElement('A');
	delb.className="delbox";
	delb.title="Delete";

	delb.href="javascript:void(0)";
	delb.onclick=function() {return _del('c_'+a,'m_'+id);}
	var delbs=document.createElement("Span");
	delbs.className="athidden";
	var delbstxt;
        var maxmin = document.createElement('A');
	maxmin.href="javascript:void(0)";
	var maxmins = document.createElement('Span');
	maxmins.className="athidden";
	if(f)
	{
		maxmin.className="maxbox";
		maxmin.id="m_"+id+"_max";
		maxmin.title="Maximize";
		
	}
	else
	{
		maxmin.className="minbox";
		maxmin.id="m_"+id+"_min";
		maxmin.title="Minimize";
		var mboxin = document.createElement('Div');
		mboxin.className="modboxin";
		mboxin.id="m_"+id+"_info";
			
		
	}
	switch(id)
	{
		case 1:
		ma.href="javascript:buildpage(7,0);";
		mspantxt=document.createTextNode("Forthcoming Events");
		delbstxt=document.createTextNode("Delete: Forthcoming Event");
		break;
		case 2: //1st fixtures
		ma.href="javascript:buildpage(10,1);";
                mspantxt=document.createTextNode("Forthcoming 1st Xv Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming 1st XV  Matches");
		break;
		case 3: //1st fixtures
                ma.href="javascript:buildpage(10,2);";
                mspantxt=document.createTextNode("Forthcoming 2nd Xv Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming 2nd XV  Matches");
                break;
		case 4: //1st fixtures
                ma.href="javascript:buildpage(10,3);";
                mspantxt=document.createTextNode("Forthcoming 3rd Xv Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming 3rd XV  Matches");
                break;
		case 5: //1st fixtures
                ma.href="javascript:buildpage(10,4);";
                mspantxt=document.createTextNode("Forthcoming Vets Xv Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming Vets XV  Matches");
                break;
		case 6: //U8 fixtures
                ma.href="javascript:buildpage(15,7);";
                mspantxt=document.createTextNode("Forthcoming U8's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U8's Matches");
                break;
		case 7: //U9 Blues fixtures
                ma.href="javascript:buildpage(15,8);";
                mspantxt=document.createTextNode("Forthcoming U9's Blues Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U9's Blues Matches");
                break;
	        case 8: //U9 Yellows fixtures
                ma.href="javascript:buildpage(15,18);";
                mspantxt=document.createTextNode("Forthcoming U9's Yellows Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U9's Yellows Matches");
                break;

		case 9: //U10 fixtures
                ma.href="javascript:buildpage(15,9);";
                mspantxt=document.createTextNode("Forthcoming U10's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U10's Matches");
                break;
		case 9: //U11 fixtures
                ma.href="javascript:buildpage(15,10);";
                mspantxt=document.createTextNode("Forthcoming U11's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U11's Matches");
                break;
		case 10: //U12 fixtures
                ma.href="javascript:buildpage(15,11);";
                mspantxt=document.createTextNode("Forthcoming U12's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U12's Matches");
                break;
		case 11: //U13 fixtures
                ma.href="javascript:buildpage(15,12);";
                mspantxt=document.createTextNode("Forthcoming U13's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U13's Matches");
                break;
		case 12: //U14 fixtures
                ma.href="javascript:buildpage(15,13);";
                mspantxt=document.createTextNode("Forthcoming U14's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U14's Matches");
                break;
		case 13: //U15 fixtures
                ma.href="javascript:buildpage(15,14);";
                mspantxt=document.createTextNode("Forthcoming U15's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U15's Matches");
                break;
		case 14: //U16 fixtures
                ma.href="javascript:buildpage(15,15);";
                mspantxt=document.createTextNode("Forthcoming U16's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U16's Matches");
                break;
		case 15: //U17 fixtures
                ma.href="javascript:buildpage(15,16);";
                mspantxt=document.createTextNode("Forthcoming U17's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming U17's Matches");
                break;
		case 16: //U19 fixtures
                ma.href="javascript:buildpage(15,17);";
                mspantxt=document.createTextNode("Forthcoming Colt's Matches");
                delbstxt=document.createTextNode("Delete: Forthcoming Colt's Matches");
                break;
		}
	if(f)
        	maxmin.onclick=function(){return _am('1');}
        else
                maxmin.onclick=function(){return _zm(id);}

	
	maxmin.appendChild(maxmins);
	delbs.appendChild(delbstxt);
	delb.appendChild(delbs);
	mspan.appendChild(mspantxt);
	ma.appendChild(mspan);
	mlink.appendChild(ma);
	mtbox.appendChild(mlink);
	mtbox.appendChild(delb);
	mtbox.appendChild(maxmin);
	mbox.appendChild(mtbox);
	if(f==false)
		mbox.appendChild(mboxin);
	chead.appendChild(mbox);
	if(f==false)
		getinfo(id,5);
	}
/***********************************************/

