function inittab() { 
   pagedivs = new Array();
   pagedivs[0] = document.getElementById("promo_Area1");
  
   for (var j = 0; j < pagedivs.length; j++) {

	   if (pagedivs[j]) {
		   thiscomponent = pagedivs[j];
		   var tabnumber = 0; 
		   var totalwidth = 0;    
		   thisbox = thiscomponent.id;
		   thiswidth = thiscomponent.offsetWidth - 1;     
		   elements = getChildElements(thiscomponent);
		   tablist = elements[0];
		   tabs = tablist.getElementsByTagName("li");  
		   promolist = elements[1];
		   promo = getChildElements(promolist);
		   for (var i = 0; i < tabs.length; i++) {
			  	 tabnumber = tabnumber + 1;
					 tabs[i].id = thisbox + "tab" + tabnumber;
					 promo[i].id = thisbox + "promo" + tabnumber;	
			  	 eval("tabs[" + i + "].onclick = function(){showPromo(\"" + thisbox + "\", " + tabnumber + ",\"on\");return false;}");
					 eval("tabs[" + i + "].onfocus = function(){showPromo(\"" + thisbox + "\", " + tabnumber + ",\"on\");return false;}");
					 totalwidth = totalwidth + tabs[i].offsetWidth;	
      }
			eval(thisbox + "totaltabs = " + tabnumber);
			totalwidth = (totalwidth+tabnumber)
			widthdiff = (thiswidth - totalwidth);	
		  extrawidth = parseInt(widthdiff/tabnumber);
			for (var k = 0; k < tabs.length; k++) {
			tabs[k].style.width = tabs[k].offsetWidth + extrawidth + "px";
			}
			remainder = widthdiff % tabnumber;
			tabs[0].style.width = tabs[0].offsetWidth + remainder + "px";	
		}
	}

   pagedivs[0] = document.getElementById("promo_Area2");
  
   for (var j = 0; j < pagedivs.length; j++) {

	   if (pagedivs[j]) {
		   thiscomponent = pagedivs[j];
		   var tabnumber = 0; 
		   var totalwidth = 0;    
		   thisbox = thiscomponent.id;
		   thiswidth = thiscomponent.offsetWidth - 1;     
		   elements = getChildElements(thiscomponent);
		   tablist = elements[0];
		   tabs = tablist.getElementsByTagName("li");  
		   promolist = elements[1];
		   promo = getChildElements(promolist);
		   for (var i = 0; i < tabs.length; i++) {
			  	 tabnumber = tabnumber + 1;
					 tabs[i].id = thisbox + "tab" + tabnumber;
					 promo[i].id = thisbox + "promo" + tabnumber;	
			  	 eval("tabs[" + i + "].onclick = function(){showPromo(\"" + thisbox + "\", " + tabnumber + ",\"on\");return false;}");
					 eval("tabs[" + i + "].onfocus = function(){showPromo(\"" + thisbox + "\", " + tabnumber + ",\"on\");return false;}");
					 totalwidth = totalwidth + tabs[i].offsetWidth;	
      }
			eval(thisbox + "totaltabs = " + tabnumber);
			totalwidth = (totalwidth+tabnumber)
			widthdiff = (thiswidth - totalwidth);	
		  extrawidth = parseInt(widthdiff/tabnumber);
			for (var k = 0; k < tabs.length; k++) {
			tabs[k].style.width = tabs[k].offsetWidth + extrawidth + "px";
			}
			remainder = widthdiff % tabnumber;
			tabs[0].style.width = tabs[0].offsetWidth + remainder + "px";	
		}
	}	
}

function showPromo(thisbox,promoNo,onoff) {
    eval("totaltabs = " + thisbox + "totaltabs");
    for (var i = 1; i <= totaltabs; i++) {
	document.getElementById(thisbox + "promo" + i).style.display = 'none';
	document.getElementById(thisbox + "tab" + i).className = 'none';
	}
	if ( onoff == "on" ) {
	document.getElementById(thisbox + "promo" + promoNo).style.display = 'block';
	document.getElementById(thisbox + "tab" + promoNo).className = 'selected';
	}
}

function getChildElements(elemName) {
   nodesList = elemName.childNodes;
   var childElems = new Array();
   var counter = 0;
   for (var m = 0; m < nodesList.length; m++) {
   if (nodesList[m].nodeType == 1) {
   childElems[counter] = nodesList[m];
   counter = counter + 1;
   }
   }  
   return childElems;
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


function addLoadEvent(func) {
	var oldonload = window.onload;
	  	if (typeof window.onload != 'function') {
    	window.onload = func;
  	} else {
    	window.onload = function() {
    	oldonload();
    	func();
    	}
	}
}


function addBookmark() {
url = window.location.href;
title = document.title;
if (window.external) {
window.external.AddFavorite(url,title);
} else {
alert("Press CTRL + D to bookmark this page");
}
return false;
}



function initStoryLinks() {
if (document.getElementById("printsaveline")) {
linksdiv = document.getElementById("printsaveline");
storylinks = linksdiv.getElementsByTagName("a");
storylinks[0].href = "mailto:Your friend's email address?subject=" + document.title + "&body=I found this story on World Cup 365, thought you'd be interested: " + this.location.href;
storylinks[1].onclick = function(){window.print()};
storylinks[2].onclick = function(){addBookmark()};
}
}


function movePic() {

	if (document.getElementById("articleblock") && document.getElementById("topsearches")) {
		articleBody = document.getElementById("articlebody");
		pars = articleBody.getElementsByTagName("p");
		par3 = pars[2];
		articleImg = document.getElementById("articleblock");
		var newImage = articleImg.cloneNode(true);
		articleBody.insertBefore(newImage, par3);
		articleImg.parentNode.removeChild(articleImg);
	} else {
		alert(document.getElementById("articleblock"));
		alert(document.getElementById("topsearches"));
	}

}


function loadStory (basketId, storyId) {
		var targetUrl = 'http://www.rugby365.com/story/0,18881,thisisnotanoid,00.html';
		
		if (targetUrl.length > 0) {
			if (storyId == 0) {
				targetUrl = targetUrl.replace("thisisnotanoid", basketId);
			} else {
				targetUrl = targetUrl.replace("thisisnotanoid", basketId + "_" + storyId );
			}
			window.location.href = targetUrl;
		}
}

function loadIndex (basketId) {

		var targetUrl = 'http://www.rugby365.com/news/0,18836,thisisnotanoid,00.html';

		if (targetUrl.length > 0) {
			targetUrl = targetUrl.replace("thisisnotanoid", basketId);
			window.location.href = targetUrl;
		}
}

function loadStoryPopup (basketId,storyId,windowOptions) {

		var targetUrl = 'http://www.rugby365.com/story/0,18881,thisisnotanoid,00.html';
		
		if (storyId == 0) {
			targetUrl = targetUrl.replace("thisisnotanoid", basketId);
		} else {
			targetUrl = targetUrl.replace("thisisnotanoid", basketId + "_" + storyId );
		}

		window.open(targetUrl,'Football365_pop',windowOptions);
}

function loadGalleryStory (basketId,storyId) {

		var targetUrl = "";
		
		targetUrl = 'http://www.rugby365.com/gallery/0,18938,thisisnotanoid,00.html';

		//this will replace thisisnotanOID with the id passed in

		if (targetUrl.length > 0) {
			targetUrl = targetUrl.replace("thisisnotanoid", basketId + "_" + storyId );
			window.location.href = targetUrl;
		}
}

<!-- JAVASCRIPT POP UP -->
function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

/*** REGISTRATION STUFF ***/
function showReg() {
	window.open('http://www.rugby365.com/PlanetRugby/register/1,18773,,00.html','plrReg','width=1000px,height=570px,toolbar=no,scrollbars=yes,resize=yes');
}

function forgotPword() {
	window.open('http://www.rugby365.com/PlanetRugby/register/forgot_password/1,18775,,00.html','forgotPword','width=450px,height=400px,toolbar=no,scrollbars=yes,resize=yes');
}

function showInfo() {
	var infoWin = window.open('http://www.rugby365.com/cricket365/infomation/terms_conditions/0,18585,,00.html','infowin','width=550,height=560,scrollbars=yes,resize=yes,xpos=30,ypos=30');
}

function isEmail(email, useAlerts) {
	var str = email;
	if (window.RegExp) {
		var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
		var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
		var reg1 = new RegExp(reg1str);
		var reg2 = new RegExp(reg2str);
		if (!reg1.test(str) && reg2.test(str)) {
		  return true;
		}
		if (useAlerts=="1") {
			alert("The email address entered is not valid");
		}
		return false;
	} else {
		if(str.indexOf("@") >= 0) {
		  return true;
		} else {
			if (useAlerts=="1") {
				alert("The email address entered is not valid");
			}
			return false;
		}
	}
}

function validateNewsletter(f) {
	if (f.Email.value=="") {
		alert("Please enter your email address");
		f.Email.focus();
		return false;	
	} else {
		return isEmail(f.Email.value, "1");
	}		
}


function submitform(txt)
{
  nameOfForm = txt.name;
  
  if (form_check(nameOfForm) != true) { return false; }
  else 
  {
    if (checkbox(nameOfForm) != true) { return false; }
    else
      document.forms[nameOfForm].submit();
  }

}

function submitform2(txt) {

  nameOfForm = txt.name;
  if (form_check(nameOfForm) != true) {
  	return false; 
  } else {
    if (checkbox(nameOfForm) != true) { 
		return false; 
	} else {
      document.forms[nameOfForm].submit();
	 }
  }

}

function form_check(txt) 
{
  if (document.forms[txt].firstname.value == "") 
  {
  alert ("Please Complete The Name Field");
  document.forms[txt].firstname.focus()
  return false;
  }
  
 
  
  if (document.forms[txt].email.value == "") 
  {
    alert ("Please Complete The Email Field");
    document.forms[txt].email.focus()
    return false;
  }

  if (!IsEmailValid(document.forms[txt].email.value))
  {
    alert("Please Supply A Valid Email Address");
    document.forms[txt].email.focus()
    return false;
  }
  
  return true; 
}

function checkbox(txt)
{
  if (document.forms[txt].details.checked)
  { return true; }
  else
  {
    alert ("Sorry, you did not check the box.\nIf you wish to proceed, please check the box,\nthereby confirming your consent to our privacy policy.");
    return false;
  }
}

function IsEmailValid(text)
{
  var EmailOk  = true;
  var AtSym    = text.indexOf('@');
  var Period   = text.lastIndexOf('.');
  var Space    = text.indexOf(' ');
  var Length   = text.length - 1;

  if ((AtSym < 1) || 
    (Period <= AtSym+1) ||
    (Period == Length ) ||
    (Space  != -1))
    {
      EmailOk = false;
    }
    return EmailOk;
}