<!-- 
function DatePosition(dateString,dateType) {
/* Just to let you guys know what this is! - Marc.
   function name : DatePosition 
   parameters    : dateString, dateType
   returns       : integer (-1, 0, 1)
   Author	 : the ever smiling guys!

   dateString is a date passed as a string in the following
   formats (example of year=1997, month=05, day=29):

   type 1 : 19970529
   type 2 : 970529
   type 3 : 29/05/1997
   type 4 : 29/05/97
   type 5 : 05/29/1997
   type 6 : 05291997
   type 7 : 052997
   
   dateType is a numeric integer from 1 to 7, representing
   the type of dateString passed, as defined above.

   Returns -1 if the date passed is behind todays date
   Returns 0 if the date passed is equal to todays date
   or if dateType is not 1 to 7
   Returns 1 if the date passed is ahead of todays date
   This could all be used sometime .. Iam sure!!
   Added Y2K/Y3k/YwhateverK checking.Works for any century cross over! - Marc
*/


    var now = new Date();
    var today = new Date(2001, 5, 2);  // this is our cut off date! - Marc
    // this is minus 1 of whatever usually we would have written for the month! - Marc.
    var century = parseInt(now.getYear()/100)*100;
        
    if (dateType == 1)
        var date = new Date(dateString.substring(0,4),
                            dateString.substring(4,6)-1,
                            dateString.substring(6,8));
    else if (dateType == 2)
    {
        if ((now.getYear()%100)>=parseInt(dateString.substring(0,2)))
        {
            var date = new Date(century+parseInt(dateString.substring(4,6)),
                            parseInt(dateString.substring(2,4)-1),
                            dateString.substring(4,6));
        }
        else
        {
            var date = new Date(century-100+parseInt(dateString.substring(0,2)),
                            parseInt(dateString.substring(2,4)-1),
                            dateString.substring(4,6));
        }
        
    }
    else if (dateType == 3)
        var date = new Date(dateString.substring(6,10),
                            dateString.substring(3,5)-1,
                            dateString.substring(0,2));
    else if (dateType == 4)
    {
        if ((now.getYear()%100)>=parseInt(dateString.substring(6,8)))
        {
            document.write(century+parseInt(dateString.substring(6,8)),'<P>');
            var date = new Date(century+parseInt(dateString.substring(4,6)),
                            parseInt(dateString.substring(3,5)-1),
                            dateString.substring(0,2));
        }
        else
        {
            document.write(century-100+parseInt(dateString.substring(6,8)),'<P>');
            var date = new Date(century-100+parseInt(dateString.substring(4,6)),
                            parseInt(dateString.substring(3,5)-1),
                            dateString.substring(0,2));
        }
        
    }
    else if (dateType == 5)
        var date = new Date(dateString.substring(6,10),
                            dateString.substring(0,2)-1,
                            dateString.substring(3,5));
    else if (dateType == 6)
        var date = new Date(dateString.substring(4,8),
                            dateString.substring(0,2)-1,
                            dateString.substring(2,4));
    else if (dateType == 7)
    {
        if ((now.getYear()%100)>=parseInt(dateString.substring(4,6)))
        {
            document.write('datestring Century:',century+parseInt(dateString.substring(4,6)),'<P>');
            var date = new Date(century+parseInt(dateString.substring(4,6)),
                            parseInt(dateString.substring(0,2)-1),
                            dateString.substring(2,4));
        }
        else
        {
            document.write('datestring Century:',century-100+parseInt(dateString.substring(4,6)),'<P>');
            var date = new Date(century-100+parseInt(dateString.substring(4,6)),
                            parseInt(dateString.substring(0,2)-1),
                            dateString.substring(2,4));
        }
        
    }
    else
        return false;

    if (date < today)
    {
        return -1;
    }
    else if (date > today)
    {
        return 1;
        
    }
    else
    {
       return 0;
    }
}

// Function to format 1 to 9 into 01 to 09 -  Marc
// Introduced in June 2005 along with DHTML calendar in the archive page

function ToFmt(x){
 this.x=x;
 this.fmt00 = fmt00;
 this.spacer=" ";
}

function fmt00(){
 // fmt00: Tags leading zero onto numbers 0 - 9.
 // Particularly useful for displaying results from Date methods.

 if (parseInt(this.x) < 0) var neg = true;
 if (Math.abs(parseInt(this.x)) < 10){
  this.x = "0"+ Math.abs(this.x);
 }
 if (neg) this.x = "-"+this.x;
 return this.x;
}

// set of new functions for foramtting ends here ... Marc

function PaoYengge()
{
  var arrMnth = new Array("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec");
// Get the date component values - Marc (added in June 2005)

// Commented the old value collecting section in to the following ... Marc (June 2005)
  d2 = document.epfrmArchives.epArchiveDate.value.substring(0,2);
  m2 = document.epfrmArchives.epArchiveDate.value.substring(3,6);
  m2 = m2.toLowerCase();
  y2 = document.epfrmArchives.epArchiveDate.value.substring(7,11);


  // get month value. - Marc!
//   Commented the whole section of getting values form the combo
//  as the archive selction page is added with a DHTML calendar
//  Now the date is stored in a hidden text field called epArchiveDate - Marc (added in June 2005)

//  for (var i = 0; i< 12; i++)
//  {
//   if (document.epfrmArchives.epArchiveMonth.options[i].selected == true)
//   {
//    var m2 = document.epfrmArchives.epArchiveMonth.options[i].value;
//   }
//  }
  // get Day Value. - Marc!
//  for (var i = 0; i< 31; i++)
//  {
//   if (document.epfrmArchives.epArchiveDay.options[i].selected == true)
//   { 
//    var d2 = document.epfrmArchives.epArchiveDay.options[i].value;
//   }
//  }
  // get Year Value. - Marc!
  // Change the value of i<6 to i<7, when year 2006 comes and make changes to 
  //archive.html(news_section) for selected Year Option - Surchand 2/01/2003
//  for (var i = 0; i< 6; i++)
//  {
//   if (document.epfrmArchives.epArchiveYear.options[i].selected == true)
//   { 
//    var y2 = document.epfrmArchives.epArchiveYear.options[i].value;
//   }
//  }
   
//  var mnth = arrMnth[m2 - 1]; ... re-organised - Marc
//  above assignment is done as below now .... (June 2005)

  for (var i = 0; i< 12; i++)
  {

   if (arrMnth[i] == m2)
   {
    var a = new ToFmt(i+1);
    mnth = a.fmt00();
   }
  }

  var yr = y2.substring(2,4); // get those 2 last things in the string! - Marc.

//  var Selection = "archives/" + mnth + yr + "/A" + d2 + m2 + yr + ".html"; ... re-organised - Marc
  var Selection = "archives/" + m2 + yr + "/A" + d2 + mnth + yr + ".html";

//  var SelDate = m2 + d2 + y2;  ... re-organised - Marc
  var SelDate = mnth + d2 + y2;

//alert ("seldate " + SelDate);

  // now do the date comparison and redirecting stuff! - Marc.
  if (DatePosition(SelDate,6) < 0)
    {
      window.open(Selection);
    }
  else
    {
      document.epfrmArchives.action = "http://www.e-pao.net/epArcDisplay.asp?src=" + d2 + mnth + yr;
	  document.epfrmArchives.method="post";
	  document.epfrmArchives.submit();
    }
    if (DatePosition(SelDate,6) < 0)
    {
     //history.back(1);
     location.replace("http://www.e-pao.net/epPageSelector.asp?src=archive&ch=news_section");
    }
}



function PaoYenggeMM()
{
  var arrMnth = new Array("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec");
// Get the date component values - Marc (added in June 2005)

// Commented the old value collecting section in to the following ... Marc (June 2005)
  d2 = document.epfrmArchivesMM.epArchiveDate.value.substring(0,2);
  m2 = document.epfrmArchivesMM.epArchiveDate.value.substring(3,6);
  m2 = m2.toLowerCase();
  y2 = document.epfrmArchivesMM.epArchiveDate.value.substring(7,11);


//  var mnth = arrMnth[m2 - 1]; ... re-organised - Marc
//  above assignment is done as below now .... (June 2005)

  for (var i = 0; i< 12; i++)
  {

   if (arrMnth[i] == m2)
   {
    var a = new ToFmt(i+1);
    mnth = a.fmt00();
   }
  }

  var yr = y2.substring(2,4); // get those 2 last things in the string! - Marc.

//  var Selection = "archives/" + mnth + yr + "/A" + d2 + m2 + yr + ".html"; ... re-organised - Marc
  var Selection = "archives/" + m2 + yr + "/A" + d2 + mnth + yr + ".html";

//  var SelDate = m2 + d2 + y2;  ... re-organised - Marc
  var SelDate = mnth + d2 + y2;


  // now do the date comparison and redirecting stuff! - Marc.
  if (DatePosition(SelDate,6) < 0)
    {
      window.open(Selection);
    }
  else
    {
      document.epfrmArchivesMM.action = "http://www.e-pao.net/epArcDisplay.asp?src=" + d2 + mnth + yr + "&news=HL";
	  document.epfrmArchivesMM.method="post";
	  document.epfrmArchivesMM.submit();
    }
    if (DatePosition(SelDate,6) < 0)
    {
     //history.back(1);
     location.replace("http://www.e-pao.net/epPageSelector.asp?src=archive&ch=news_section");
    }
}



