var secs
var timerID = null
var timerRunning = false
var delay = 1000

var now
var theDay
var theDate
var theMonth
var theYear
var theHour
var theMinute
var theSecond
var theTime
var dayType
var thePMAM

var days = new Array(7);
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";

var months = new Array(12);
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 InitializeTimer()
{
    // Set the length of the timer, in seconds
    var currentDay = document.getElementById('currentDay');
    var currentDate = document.getElementById('currentDate');
    var currentTime = document.getElementById('currentTime');
    secs = 10000000
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        //alert("You have just wasted 10 seconds of your life.")
    }
    else
    {
      now = new Date();
	  theDay = now.getDay();
      theDate = now.getDate();
	  theMonth = now.getMonth();
      theYear = now.getYear();
      theHour = now.getHours();
      theMinute = now.getMinutes();
      theSecond = now.getSeconds();

      if (theHour > 12)
	  {
        theHour = theHour - 12
		thePMAM = 'pm'
	  }
      else if (theHour == 12)
	  {
		thePMAM = 'pm'
	  }
      else
	  {
		thePMAM = 'am'
	  }

      if (theSecond < 10)
	  {
        theSecond = '0' + theSecond;
      }

      if (theMinute < 10)
      {
//        theTime = theHour + ':' + '0' + theMinute + ':' + theSecond + thePMAM
        theTime = theHour + ':' + '0' + theMinute + thePMAM
	  }
        else
      {
//        theTime = theHour + ':' + theMinute + ':' + theSecond + thePMAM
        theTime = theHour + ':' + theMinute + thePMAM
	  }
		
      if (theDate == 1 || theDate == 21 || theDate == 31)
      {
        dayType = "st"
      }
	  else if (theDate == 2 || theDate == 22)
      {
        dayType = "nd"
      }
	  else if (theDate == 3 || theDate == 23)
      {
        dayType = "rd"
      }
	  else
      {
	    dayType = "th"
      }

      currentDay.value = days[theDay]
      currentDate.value = theDate + dayType + ' ' + months[theMonth]
      currentTime.value = theTime
      timerRunning = true
      timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function loadFV()
{
  window.open("http://www.footballvillage.co.uk");
}

function submitForm()
{
  var objCompany = document.getElementById("company");
  var objContact = document.getElementById("contact");
  var objPhone = document.getElementById("telephone");
  var objFax = document.getElementById("fax");
  var objEmail = document.getElementById("email");
  var objConfirmEmail = document.getElementById("confirm_email");
  var regExp = / /g;

  if (objCompany.value == "")
  {
    alert("The Company Name field is required - please complete");
    objCompany.focus();
	return;
  }

  if (objContact.value == "")
  {
    alert("The Contact field is required - please complete");
    objContact.focus();
	return;
  }

  if (objPhone.value == "" && objEmail.value == "")
  {
    alert("At least one of 'Telephone' or 'e-mail' is required - please complete");
    objPhone.focus();
	return;
  }

//  if (objEmail.value != "" && )
//  {
//    alert("The e-mail field is required - please complete");
//    objEmail.focus();
//	return;
//  }
//
//  if (objConfirmEmail.value == "")
//  {
//    alert("The Confirm e-mail field is required - please complete");
//    objConfirmEmail.focus();
//	return;
//  }

  if (objEmail.value != "" && objEmail.value != objConfirmEmail.value)
  {
    alert("The e-mail fields are different - please corect");
    objConfirmEmail.focus();
	return;
  }

  if (isNaN(objPhone.value.replace(regExp,"")))
  {
    alert("The phone number entered is not valid - please correct");
    objPhone.focus();
	return;
  }

  if (isNaN(objFax.value.replace(regExp,"")))
  {
    alert("The fax number entered is not valid - please correct");
    objFax.focus();
	return;
  }

  document.contact_form.submit();
}

var isNS4 = (document.layers) ? true : false;
var isIE4 = (document.all && !document.getElementById) ? true : false;
var isIE5 = (document.all && document.getElementById) ? true : false;
var isNS6 = (!document.all && document.getElementById) ? true : false;

function switchDiv(strDivName,bolVisible)
{
  alert("isNS4 = " + isNS4)
  alert("isIE4 = " + isIE4)
  alert("isNS6 = " + isNS6)
  alert("isIE5 = " + isIE5)

  alert("here - " + strDivName + " - " + bolVisible)
//  return;

  //identify the element based on browser type
  if (isNS4)
  {
    objElement = document.layers[strDivName];
  }
  else if (isIE4)
  {
    objElement = document.all[strDivName];
  }
  else if (isIE5 || isNS6)
  {
    objElement = document.getElementById(strDivName);
  }
 
  if(isNS4)
  {
    if(!bolVisible)
    {
      objElement.visibility ="hidden"
    }
    else
    {
      objElement.visibility ="visible"
    }     
  }
  else
  {
    if(!bolVisible)
	{
      objElement.style.visibility = "hidden";
    }
	else
	{
      objElement.style.visibility = "visible";
    }
  }
}

function scrollBttn()
{  
  if (document.documentElement.scrollTop >= 0)
    document.getElementById("date_div").style.pixelTop = document.documentElement.clientHeight - document.all['date_div'].offsetHeight + document.documentElement.scrollTop;

  var NewLocation = parseInt((document.documentElement.scrollTop - document.getElementById("menu").style.pixelTop)*.5)

  if (isNaN(NewLocation)) 
    NewLocation=0

  if (document.getElementById("menu").style.pixelTop+NewLocation >= document.getElementById("divPageTop").offsetTop)
  {
    document.getElementById("menu").style.pixelTop +=NewLocation;
  }
  else
  {
    document.getElementById("menu").style.pixelTop=document.getElementById("divPageTop").offsetTop-10;
  }
}

function doLoad() 
{
  document.getElementById("div_date").style.visibility = "visible";

//  document.getElementById("div_main").style.width = document.documentElement.clientWidth - 170;
  document.getElementById("div_main").style.height = document.documentElement.clientHeight - 140;

  document.getElementById("div_header").style.width = document.documentElement.clientWidth - 20;
  document.getElementById("header_marquee").style.width = document.documentElement.clientWidth - 30;
  document.getElementById("div_footer").style.width = document.documentElement.clientWidth - 20;
  document.getElementById("div_footer").style.pixelTop = document.documentElement.clientHeight - 30;
  document.getElementById("div_footer").style.visibility = "visible";
}

