<!-- Popup function -->
function PopUp(win_name,URL,width,height,scrollbars,menubar){

if (scrollbars==null){
   scrollbars=0;
}

if (menubar==null){
   menubar="no"
}

    open( URL,win_name, "width="+width+",height="+height+",status=0,toolbar=0,menubar="+menubar+",resizable=no,location=0,scrollbars="+scrollbars+"");
}

<!-- Date function -->
Months=new Array()
Months[0]="January"
Months[1]="February"
Months[2]="March"
Months[3]="April"
Months[4]="May"
Months[5]="June"
Months[6]="July"
Months[7]="August"
Months[8]="September"
Months[9]="October"
Months[10]="November"
Months[11]="December"

function showTime() {
  var dte=new Date();  
  var hours=dte.getHours();
  var minutes=dte.getMinutes();
  var ender="";
  if (hours < 12) {
    ender="am";
    if (hours == 0) {
      hours += 12;
    }
  } else {
    ender="pm";
    if (hours > 12) {
      hours -= 12;
    }  
  }
  return(hours+":"+minutes+" "+ender);
}

function showDate() {
  var dte=new Date();
  var date=dte.getDate();
  var month=Months[dte.getMonth()];
  var year=dte.getFullYear();
  var spc=" ";
  var com=",";
  var ender="";
  if(date==1||date==21||date==31)
    ender="st";
  else if(date==2||date==22)
    ender="nd";
  else if(date==3||date==23)
    ender="rd";
  else
    ender="th";
  return(date+spc+month+spc+year);
}

<!-- Dropdown nav function -->
function surfto(form,select_name,scope) {

var myindex=form.elements[select_name.name].selectedIndex;

 if (form.elements[select_name.name].options[myindex].value != "0") {

  if (scope==0) {
    window.location=form.elements[select_name.name].options[myindex].value;
  } else if (scope==1) {
    top.location=form.elements[select_name.name].options[myindex].value;
  } else if (scope==2) {
    // Defining scope this way allows specific conditions to be met for certain pages in future
    window.open(form.elements[select_name.name].options[myindex].value,"","scrollbars,resizable,width=400,height=480");
  }
 }
}

<!-- Print wizard function -->
function printPage() {
  if (window.print)
    window.print()
  else
    alert("Sorry, your browser doesn't support automated printing.\nPress 'CTRL' and 'P' on a PC, or 'Apple key' and 'P' on a Mac to print.");
}

<!-- Email format validation function -->
function emailCheck (emailStr) {
  var emailPat=/^(.+)@(.+)$/
  var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
  var validChars="\[^\\s" + specialChars + "\]"
  var quotedUser="(\"[^\"]*\")"
  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
  var atom=validChars + '+'
  var word="(" + atom + "|" + quotedUser + ")"
  var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
  var matchArray=emailStr.match(emailPat)
  if (matchArray==null) {
    alert("The email address seems incorrect (check @ and .'s)")
    return false
  }
  var user=matchArray[1]
  var domain=matchArray[2]
  if (user.match(userPat)==null) {
    alert("The email address doesn't seem to be valid.")
    return false
  }
  var IPArray=domain.match(ipDomainPat)
  if (IPArray!=null) {
    for (var i=1;i<=4;i++) {
      if (IPArray[i]>255) {
        alert("The destination IP address is invalid")
        return false
      }
    }
    return true
  }
  var domainArray=domain.match(domainPat)
  if (domainArray==null) {
    alert("Your domain name doesn't seem to be valid.")
    return false
  }
  var atomPat=new RegExp(atom,"g")
  var domArr=domain.match(atomPat)
  var len=domArr.length
  if(domArr[domArr.length-1].length<2||domArr[domArr.length-1].length>3){
    alert("The E-mail address must end in a three-letter domain, or two letter country.")
    return false
  }
  if (len<2) {
    var errStr="Your address is missing a hostname"
    alert(errStr)
    return false
  }
  return true;
}

function getCookie(name){
var dc=document.cookie;
var prefix=name+"=";
var begin=dc.indexOf("; "+prefix);
if(begin==-1){
begin=dc.indexOf(prefix);
if(begin!=0)return null;
}else
begin+=2;
var end=document.cookie.indexOf(";",begin);
if(end==-1)
end=dc.length;
return unescape(dc.substring(begin+prefix.length,end));}

<!-- Reader Reviews - call registration if no cookie -- >
function doreviews(){
var szc=getCookie("USERID");
if(szc){
window.location.href ="http://" +window.location.host+"/haveyoursay/readerreviews/readerreviewspage/?action=submit";
} 
else { 
var url = "https://register.anm.co.uk/register/til2.htm";
var action = "5";
var success_action = "1433";
var success_url =
"http:%2F%2F" +window.location.host+"%2Ftil%2Fjsp%2Fuser%2Fvalidate.jsp";
var redirect_url = 
"http:%2F%2F" +window.location.host+"%2Fhaveyoursay%2Freaderreviews%2Freaderreviewspage%2F%3Faction=submit";
var fullUrl = url +
"?in_action="+action
+"&in_success_action="+success_action
+"&in_success_url="+success_url
+"&in_redirect_url="+redirect_url;
window.location.href = fullUrl;
}
}


function popup_cross(url,height,width){
window.open(url, 'til_popup', 'width='+width+',height='+height+',toolbar=no, resizable=no, scrolling=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes');
}

function goNewsletter(){
var url = "https://register.anm.co.uk/register/til2.htm?in_action=1415&in_success_action=1415";
window.location.href = url;
}

function goTable(){
  var compId = document.table.tableComps.options[document.table.tableComps.selectedIndex].value;
  var seasId = document.table.tableSeason.options[document.table.tableSeason.selectedIndex].value;
  window.location = "table.jsp?compId="+compId+"&sId="+seasId;
}

function goFixtures(){
  var compId = document.fixtures.fixturesComps.options[document.fixtures.fixturesComps.selectedIndex].value;
  var seasId = document.fixtures.fixturesSeason.options[document.fixtures.fixturesSeason.selectedIndex].value;
  window.location = "fixtures.jsp?compId="+compId+"&sId="+seasId;
}

function goClubFixtures(){
  var compId = document.clubfixtures.clubfixturesComps.options[document.clubfixtures.clubfixturesComps.selectedIndex].value;
  varClubId = document.clubfixtures.clubid.value;
  var seasId = document.clubfixtures.clubfixturesSeason.options[document.clubfixtures.clubfixturesSeason.selectedIndex].value;
  window.location = "clubFixtures.jsp?compId="+compId+"&Clubid="+varClubId+"&sId="+seasId;
}

function goClubStats(){
  var ClubId = document.clubStats.Clubid.value;
  var seasId = document.clubStats.clubStatsSeason.options[document.clubStats.clubStatsSeason.selectedIndex].value;
  window.location = "clubStats.jsp?Clubid="+ClubId+"&sId="+seasId;
}

function goStats(){
  var seasId = document.stats.statsSeason.options[document.stats.statsSeason.selectedIndex].value;
  window.location = "stats.jsp?sId="+seasId;
}

function goClub2(){
  var ClubId = document.club.Clubid.value;
  var seasId = document.club.clubSeason.options[document.club.clubSeason.selectedIndex].value;
  window.location = "club.jsp?Clubid="+ClubId+"&sId="+seasId;
}

function goClub(form,select_name,scope) {
  var myindex=form.elements[select_name.name].selectedIndex;
  var Val = form.elements[select_name.name].options[myindex].value;
  if (Val != "NOCLUB"){
    if (scope==0) {
         window.location=Val;
      } else if (scope==1) {
          top.location=Val;
      } else if (scope==2) {
       window.open(Val,"","scrollbars,resizable,00,height=480");
      }
  }
}

function retreat() {
last_url=document.referrer;
if (navigator.appName.indexOf("Netscape") != -1) {
	if (last_url.indexOf("/dynamic/index.html") != -1) {
		last_last_url=parent.document.referrer;
		if (last_last_url.indexOf("/dynamic/index.html") != -1) {
			top.history.back();
		}
		else {
			parent.history.back();
		}
	}
	else {
		window.history.back();
	}
}
else {
	// msie 3 getis its referrers shift by one place so workaround 
	if (navigator.appVersion.indexOf("MSIE 3") != -1) {
		last_url=parent.document.referrer;
		last_last_url=parent.parent.document.referrer;
	}
	else {
		// msie 4 is the only browser that does this correctly so make it the default
		last_last_url=parent.document.referrer;
	}

	if (last_url.indexOf("bottom.html") != -1) {
// strip the /dynamic/ of the beginning of the string
		new_string=last_last_url.substring(10);
		if (new_string.indexOf("nav.html") != -1) {
			parent.history.back();
		}
		else {
			top.history.back();
		}
	}
	else {
		window.history.back();
	}
}
}






