function loaded(){
	createRCM()
  smarterTags()
  printNavTabs()
  }
var op=''

//  navXML=half_loadXML("xml-workings/xml-nav.xml","none")
//  peopleXML=half_loadXML("xml-workings/xml-people.xml","none")
function peopleXMLF(tXML){ peopleXML=tXML	}
loadXML("xml-workings/xml-people.xml",peopleXMLF)
function navXMLF(tXML){ navXML=tXML	}
loadXML("xml-workings/xml-nav.xml",navXMLF)
	

function hardReload(){
  nu=Math.round(Math.random()*999999999999)+1;
  location.href.indexOf("?")==-1?newURL=location.href+"?ex="+nu:newURL=location.href.substring(0,location.href.indexOf("?"))+"?ex="+nu
  location.replace(newURL)
  }

function smarterTags(){
  if(peopleXML){
	  ltstObj=getObj('latest')
	  txt=ltstObj.innerHTML
	  allPeopleList=peopleXML.getElementsByTagName("person")
	  for(n=0;n<allPeopleList.length;n++){
	    left=txt.substring(0,txt.indexOf(allPeopleList[n].attributes.getNamedItem("word").nodeValue))
	    if(left.lastIndexOf("<a") < left.lastIndexOf(">")){ txt=txt.replace(allPeopleList[n].attributes.getNamedItem("word").nodeValue,"<span class=\"link\" href='bcf-squad.html' onclick='showSmarterTag("+n+")'>"+allPeopleList[n].attributes.getNamedItem("word").nodeValue+"</span>") }
	    }
	  ltstObj.innerHTML=txt
	  makeElement('div','stg','',document.body)
	  }
  }
function show_side_panel(obj){
  obj.nextSibling.style.display='block'
  }
function showSmarterTag(n){
  op=''
  hdr=''
  if(allPeopleList[n].getAttribute("squadNo")){
    if(allPeopleList[n].getAttribute("squadNo")!='null' && allPeopleList[n].getAttribute("squadNo").length>0){ hdr=allPeopleList[n].getAttribute("squadNo")+". " }
    }
  hdr+= allPeopleList[n].getAttribute("word")
  op+='<div class=\"toptn\">'+ hdr +"</div>"
  if(allPeopleList[n].getAttribute("nat")!='unknown'){
    nt=allPeopleList[n].getAttribute("nat")+'&#160;'
    }
//  op+='<div class=\"info\">'+ allPeopleList[n].getElementsByTagName('club')[0].getAttribute("name") +"</div>"
  op+='<div class=\"info\">'+ nt + allPeopleList[n].getAttribute("role") +"</div>"
  tdob=parseInt(allPeopleList[n].getAttribute("dob"))
  if(allPeopleList[n].getAttribute("dob")!='' && allPeopleList[n].getAttribute("dob")){ op+='<div class=\"info\">Age: '+ age(tdob) + '</div>'}
  if(allPeopleList[n].getAttribute("sd")!='' && allPeopleList[n].getAttribute("sd") && !allPeopleList[n].getAttribute("ld") && allPeopleList[n].getElementsByTagName('club')[0].getAttribute("name")=="Bradford City"){ op+='<div class=\"info\">At City: '+atClub(allPeopleList[n].getAttribute("sd"))+'</div>' }
  if(allPeopleList[n].getElementsByTagName('club')[0].getAttribute("name")=="Bradford City"){ 
//  allPeopleList[n].getElementsByTagName('club')[0].getAttribute("cost")?op+="<div class=\"info\">Cost City "+allPeopleList[n].getElementsByTagName('club')[0].getAttribute("cost")+"</div>":null
	  if(allPeopleList[n].getElementsByTagName('club').length>1){ op+="<div class=\"info\">Previously with " }
	  for(m=0;m<allPeopleList[n].getElementsByTagName('club').length;m++){
	    if(allPeopleList[n].getElementsByTagName('club')[m].getAttribute("name")!="Bradford City"){ 
	      op+=allPeopleList[n].getElementsByTagName('club')[m].getAttribute("name")
	    	if(allPeopleList[n].getElementsByTagName('club')[m].getAttribute("loan") && allPeopleList[n].getElementsByTagName('club')[m].getAttribute("loan")=="true"){
	        op+=" [Loan]"
	        }
	    	if(allPeopleList[n].getElementsByTagName('club')[m].getAttribute("role") && allPeopleList[n].getElementsByTagName('club')[m].getAttribute("role")!="player"){
	        op+=" ["+allPeopleList[n].getElementsByTagName('club')[m].getAttribute("role") + "]"
	        }
	    	if(allPeopleList[n].getElementsByTagName('club')[m+1]){ 
	        allPeopleList[n].getElementsByTagName('club')[m+2]?op+=", ":op+=" and "
	        }
	      }
	    }
	  if(allPeopleList[n].getElementsByTagName('club').length>0){ op+="</div>" }
    }
  else{
    allPeopleList[n].getAttribute("retired")=="true"?null:op+="<div class=\"info\">Currently with "+allPeopleList[n].getElementsByTagName('club')[0].getAttribute("name")+"</div>"
	  if(allPeopleList[n].getElementsByTagName('club').length>1){
      allPeopleList[n].getAttribute("retired")=="true"?op+="<div class=\"info\">Represented ":op+="<div class=\"info\">Previously with "
	    }
    allPeopleList[n].getAttribute("retired")=="true"?m_srt=0:m_srt=1
	  for(m=m_srt;m<allPeopleList[n].getElementsByTagName('club').length;m++){
      op+=allPeopleList[n].getElementsByTagName('club')[m].getAttribute("name")
    	if(allPeopleList[n].getElementsByTagName('club')[m].getAttribute("loan") && allPeopleList[n].getElementsByTagName('club')[m].getAttribute("loan")=="true"){
        op+=" [Loan]"
        }
    	if(allPeopleList[n].getElementsByTagName('club')[m].getAttribute("role") && allPeopleList[n].getElementsByTagName('club')[m].getAttribute("role")!="player"){
        op+=" ["+allPeopleList[n].getElementsByTagName('club')[m].getAttribute("role") + "]"
        }
    	if(allPeopleList[n].getElementsByTagName('club')[m+1]){ 
        allPeopleList[n].getElementsByTagName('club')[m+2]?op+=", ":op+=" and "
        }
	    }
	  if(allPeopleList[n].getElementsByTagName('club').length>0){ op+="</div>" }
    }
  if(allPeopleList[n].getElementsByTagName('profile')[0]){
  	 //  KEEP THESE LINES TOGETHER
		op+='<div class=\"optn\" onmouseover=\"rcm_over(this)\" onmouseout=\"rcm_out(this)\" onclick=\"this.nextSibling.style.display=\'block\'\">More on ' + allPeopleList[n].getAttribute("word") + '</div>';
		op+="<div class=\"side_panel\"><div class=\"cnt\">"+allPeopleList[n].getElementsByTagName('profile')[0].firstChild.nodeValue+"</div></div>";
		}
  if(allPeopleList[n].getAttribute("link") && allPeopleList[n].getAttribute("link")!=""){
	  if(allPeopleList[n].getAttribute("link").indexOf('hof-')!=-1){
	    op+='<div class=\"optn\" onmouseover=\"rcm_over(this)\" onmouseout=\"rcm_out(this)\" onclick=\"rcm_click(\'' + allPeopleList[n].getAttribute("link") + '\')\">Hall Of Fame: ' + allPeopleList[n].getAttribute("word") + '</div>'
	    }
		else{
//  Removed to stop links to BfB profile pages
//		  op+='<div class=\"optn\" onmouseover=\"rcm_over(this)\" onmouseout=\"rcm_out(this)\" onclick=\"rcm_click(\'' + allPeopleList[n].getAttribute("link") + '\')\">BfB ' + allPeopleList[n].getAttribute("word") + ' profile</div>'
		  }
  	}

  for(m=0;m<allPeopleList[n].getElementsByTagName('line').length;m++){
    op+="<div class=\"optn\" onmouseover=\"rcm_over(this)\" onmouseout=\"rcm_out(this)\" onclick=\"rcm_click(\'"+ allPeopleList[n].getElementsByTagName('line')[m].attributes.getNamedItem('link').nodeValue +"\')\">"+allPeopleList[n].getElementsByTagName('line')[m].childNodes[0].nodeValue+"</div>" 
    }

  op+='<div class=\"optn\" style=\"text-align:right;\" onmouseover=\"rcm_over(this)\" onmouseout=\"rcm_out(this)\" onclick=\"hideSmarterTag()\">close [x]</div>'

  stgObj=getObj('stg')
  setInnerHTML(stgObj,op)
  showObj(stgObj)
  win_y=getWinSizeY()
  mp_y-getScrlOfY()+getHeightOfObj(stgObj)<win_y?setObjToMouseY(stgObj,1):setTopOfObj(stgObj,mp_y-getHeightOfObj(stgObj)-6)
  win_x=getWinSizeX()
  mp_x-getScrlOfX()+getWidthOfObj(stgObj)<win_x?setObjToMouseX(stgObj,1):setLeftOfObj(stgObj,mp_x-getWidthOfObj(stgObj)-6)
  return false
  }
function hideSmarterTag(){ hideObj(getObj('stg')) }

function net4(){
  cnt="<h1>www.boyfrombrazil.co.uk</h1>"
  cnt+="<p><a href=\"index.html\">Latest News</a> | <a href=\"news_index.html\">Old News</a> | <a href=\"2k1-div1.html\">Match Reports</a> | <a href=\"bcf-squad.html\">The Squad</a></p>"
  cnt+="<p><i>BfB is even better with <a href=\"http://www.webstandards.org/upgrade\">a standards compliant browser</a></i></p>"
  document.write(cnt)
  }

function printLogo(){
  op='<img src=\"../images/bkg01.jpg\" border=\"0\" alt=\"BfB\" />'
  op=''
  makeElement('div','pagelogo',op,getObj("pageChrome").firstChild)
  }
function printWith(){
  rd=new Date();
  rs=rd.getSeconds();
//	if(rs>10 && rs< 55){ el.innerHTML+='<div class="cnt"><p>Boy From Brazil<br /><a href="his-halloffame.html">Bradford City Hall Of Fame</a></p></div>'}
//	else{ el.innerHTML+='<div class="cnt"><p>Boy From Brazil coded by<br /><a href="http://www.boyfrombrazil.co.uk/michaelwood" target="_blank">../michaelwood</a></p></div>' }
//  op='<div class="cnt"><div class="tl">this website is a</div><div class="bl"><a href="http://www.cabinpressure.co.uk/">cabinpressure website</a></div></div>'
//  op='<div class="cnt"><span class="tl"><a href="http://www.punchdrunklove.com/">Punch Drunk Love</a></span> <span class="bl">A PT Anderson Movie</span></div>'
//  HARVEY GREENWOOD
//    op='<div class="cnt"><span class="tl"><a href="http://www.4homeworking.net">Top Up Your Pension</a></span> <span class="bl">Home Based Business Opportunity</span></div>'
//  	op='<div class="cnt"><span class="tl"><a href="http://www.4homeworking.net">Join the Internet Revolution</a></span> <span class="bl">Home Based Business Opportunity</span></div>'
//  	op='<div class="cnt"><span class="tl"><a href="http://www.4homeworking.net">Secure Your Future</a></span> <span class="bl">Home Based Business Opportunity</span></div>'
//    op='<div class="cnt"><span class="tl"><a href="http://www.4homeworking.net">Sack Your Boss!</a></span> <span class="bl">Home Based Business Opportunity</span></div>'
//    op='<div class="cnt"><span class="tl"><a href="http://www.4homeworking.net">Earn an Extra £300-£500 a Month!</a></span> <span class="bl">Home Based Business Opportunity</span></div>'
//    op='<div class="cnt"><span class="tl"><a href="http://www.4homeworking.net">Quit the Commute!</a></span> <span class="bl">Home Based Business Opportunity</span></div>'
//    op='<div class="cnt"><span class="tl"><a href="http://www.4homeworking.net">Work - Life Balance Solution</a></span> <span class="bl">Home Based Business Opportunity</span></div>'
//	op='<div class="cnt"><span class="tl">Play Sport? Use the Gym?</span> <span class="bl"><a href="http://www.4sportsnutrition.net">Click here to Increase Performance!</a></span></div>'
	op='<div class="cnt"><span class="tl">Work From Home</span> <span class="bl"><a href="http://www.4homeworking.net">Earn £500+ per month Part Time</a></span></div>'
  makeElement('div','pageWith',op,getObj("pageChrome").firstChild)
  }

function printName(){
  op='<div class="cnt">'
  op+='<h1><span class="tl"><a href="index.html">www.boyfrombrazil.co.uk</a></span> '
  op+='<span class="bl"><a href="index.html">theBRADFORDCITYsite</a></span></h1>'
  op+='</div>'
  makeElement('div','pagename',op,getObj("pageChrome").firstChild)  }

function printControls(){
  op='<div class="cnt">'
	op+='<select id="kitPicker" onchange="this.value==0?null:setCss(this.value)">'
	op+='<option value="0">Select your style...</option>'
	op+='<option value="1">Home :: We based this on City\'s traditional colours</option>'
	op+='<option value="2">Away :: Same as above but based on our Barca away kit</option>'
	op+='<option value="3">Fresh :: Our current favourite design</option>'
	op+='<option value="4">Clean :: Kind of professional looking in a 37Signals.com way</option>'
	op+='<option value="5">Nostalgic :: The summer of 2000 and theBRADFORDCITYsite</option>'
	op+='<option value="6">Image :: For those people who like things in boxes</option>'
	op+='<option value="7">White :: Cold and business like...</option>'
	op+='<option value="8">Bambino :: Cute, so cute</option>'
	op+='</select>'
  op+='</div>'
  op='<div class="cnt"><span class="e1"><a href="javascript:setCss(1)">Home</a> | </span><span class="e2"><a href="javascript:setCss(2)">Away</a> | </span><a href="javascript:setCss(3)">Fresh</a> | <a href="javascript:setCss(4)">Clean</a> | <a href="javascript:setCss(5)">Nostalgic</a> | <a href="javascript:setCss(6)">Image</a> | <a href="javascript:setCss(7)">White</a> | <a href="javascript:setCss(8)">Bambino</a></div>'
  makeElement('div','pagecontrols',op,getObj("pageChrome").firstChild)  }

function printNavTabs(){
  if(document.createElement){
	  makeElement('div','nav',"",getObj("recent"))
	  var el=document.createElement("div");
	  el.id="nav"
	  getObj("recent").getElementsByTagName("div")[0].insertBefore(el,getObj("recent").getElementsByTagName("div")[0].getElementsByTagName("div")[0]); 
	  allChildNodes=getObj("recent").getElementsByTagName("div")[0].getElementsByTagName("div")
	  for(q=1;q<allChildNodes.length;q++){
	    tls=allChildNodes[q].getElementsByTagName("h2"); tTls="";
	    for(t=0;t<tls.length;t++){ 
	      tls[t+1]?tTls+=tls[t].innerHTML+"&#160;/&#160;":tTls+=tls[t].innerHTML 
	      }
	    regNavTab(tTls,"clkNavTab(\'"+allChildNodes[q].id+"\')")
	    }
	  displayNavTab()
	  }
  }

function clkNavTab(div){
  tabs=getObj("nav").getElementsByTagName("a")
  for(n=0;n<tabs.length;n++){
    hrf=tabs[n].getAttribute("href")
    v=hrf.slice(hrf.indexOf("'")+1,hrf.lastIndexOf("'"))
    getObj(v).style.display='none'
    }
  getObj(div).style.display='block'
  }

function regNavTab(op,lnk){
  var el=document.createElement("a"); 
  el.setAttribute("href","javascript:"+lnk)
  el.innerHTML=op
  if(getObj("nav").innerHTML!=""){ getObj("nav").innerHTML+= " | " }
  getObj("nav").appendChild(el);
  }

function displayNavTab(){
  t=getObj("nav").getElementsByTagName("a")
//  eval(t[t.length-1].href.substring(11))
  eval(t[0].href.substring(11))
  }


function dif(mDt){
  var mD,mM,mY,gD,gM,gY,dD,dM,dY,d
  mDt=mDt+''
	mD=mDt.substring(6,8);
  mM=mDt.substring(4,6);
  mY=mDt.substring(0,4);
	dt=new Date();
	gD=dt.getDate();
	gM=dt.getMonth()+1;
	gY=dt.getYear();
	if(gY<1900){gY=parseInt(gY+1900)}
	dM=gM-mM;
	dY=parseInt(gY-mY)*12;
	d=parseInt(dY+dM);
	dD=gD-mD;
	if(dD<0){ d-- };
	return d;
	}
function age(mDt){
  aStg='';
  tM=dif(mDt);
  a=tM/12+''
  a.indexOf(".")!=-1?aY=a.substring(0,a.indexOf(".")):aY=a
  if(aY==0){
    rY=''
    }
  else if(aY==1){
    rY=aY+'&#160;year&#160;'
    }
  else{
    rY=aY+'&#160;years&#160;'
    }
  aM=parseInt(tM-aY*12)
  if(aM==0){
     rM=''
     }
  else if(aM==1){
    rM=aM+'&#160;month'
    }
  else{
    rM=aM+'&#160;months&#160;'
    }
  aStg=rY+rM;
 	return aStg;
  }

function atClub(mDt){
  aStg=''; tM=dif(mDt); a=tM/12+''
  a.indexOf(".")!=-1?aY=a.substring(0,a.indexOf(".")):aY=a
  if(aY==0){
    rY=''
    }
  else if(aY==1){
    rY=aY+'&#160;year&#160;'
    }
  else{
    rY=aY+'&#160;years&#160;'
    }
  aM=parseInt(tM-aY*12)
  if(aM==0){
    rM=''
    }
  else if(aM==1){
    rM=aM+'&#160;month'
    }
  else{
    rM=aM+'&#160;months&#160;'
    }
  if(aM==0 && aY==0){
    rY='Recent Signing'
    }
  aStg=rY+rM;
  return aStg;
  }

function createRCM(){
  op=''
  addedImg=0
  if(navXML){
	  areaList=navXML.getElementsByTagName("pageElements")[0].getElementsByTagName("rcm")[0].getElementsByTagName("area")
	  for(b=0;b<areaList.length;b++){
		  allLinesList=areaList[b].childNodes
		  op+="<div id='ls"+parseInt(b+1)+"'><div class='cnt'>"
		  for(n=0;n<allLinesList.length;n++){
		    if(allLinesList[n].tagName=='head'){ op+="<div class='head'>"+allLinesList[n].childNodes[0].nodeValue+"</div>" }
		    if(allLinesList[n].tagName=='line'){ 
		      if(allLinesList[n].getAttribute('link')){ op+="<div onmouseover=\"rcm_over(this)\" onmouseout=\"rcm_out(this)\" onclick=\"rcm_click(\'"+allLinesList[n].getAttribute('link')+"\')\">"+allLinesList[n].childNodes[0].nodeValue+"</div>" }
		      else{ op+="<div>"+allLinesList[n].childNodes[0].nodeValue+"</div>" }
		      }
		    }
		  op+="</div></div>"
	    addedImg==0?op+="<div id=\"img\"><img src=\"../images/rcm/x20p.jpg\" alt=\"Edhino, the Boy From Brazil himself\" /></div>":null
	    addedImg=1
		  }
	  makeElement("div","rcm",op,"document.body")
	  hideObj(getObj('rcm'))
	  document.body.oncontextmenu=rcm_show
	  document.body.onclick=rcm_hide
	  }
  }


function rcm_show(){
	shw=false
	window.event?!event.ctrlKey?shw=true:shw=false:shw=true
  if(shw){
	  rcmObj=getObj('rcm')
	  setObjToRelativeMouseX(rcmObj,1)
	  rcmObj.style.display='block'
	  win_y=getWinSizeY()
	  mp_y-getScrlOfY()+getHeightOfObj(rcmObj)<win_y?setObjToMouseY(rcmObj,1-half(getHeightOfObj(rcmObj))):setTopOfObj(rcmObj,mp_y-getHeightOfObj(rcmObj)-6)
	  win_x=getWinSizeX()
	  mp_x-getScrlOfX()+getWidthOfObj(rcmObj)<win_x?setObjToMouseX(rcmObj,1-half(getWidthOfObj(rcmObj))):setLeftOfObj(rcmObj,mp_x-getWidthOfObj(rcmObj))
	  return false
	  }
  }
function rcm_hide(){ hideObj(getObj('rcm')) }
function rcm_over(obj){ obj.style.color='#ffffff'; obj.style.backgroundColor='#93021a'  }
function rcm_out(obj){ obj.style.color='#000000'; obj.style.backgroundColor='#F0B830' }
function rcm_click(url){ location.href=url }

function showObj(obj){ obj.style.display='block' }
function hideObj(obj){obj.style.display='none' }

onload=loaded
