var expandRows = '0,0,*,40';
var popupRows = '45,0,*,40';
var reduceRows = '45,150,*,40';

var expandCols = '5,175,5,*,0,0,5';
var reduceCols = '*,175,*,795,*,250,*';

function getArguments()
{
  if (!(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent) || /Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)))
  {
    mainURL = window.location.search;

    if (mainURL.indexOf("?") >= 0)
    {
      URLparts = mainURL.split('?');

      Arguments = URLparts[1].split('&');

      for (i in Arguments)
      {
        if (URLparts[1].indexOf("=") >= 0)
        {
          pair = Arguments[i].split('=');
  
          if (pair[0].toUpperCase() == "CONTENT")
          Content.location.href = pair[1];
        }
      }
    }
  }
}
function loadImage(strImage)
{
  parent.PicturePanel['mainpic'].src = strImage;
}
function changePage(strPage)
{
  parent.location.href = strPage;
}
function replacePicture(strImage)
{
  if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent) || /Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent))
  {
    parent.frames['PicturePanel'].document.documentElement.innerHTML = 
      "<HTML><HEAD>" +
        "  <TITLE>Picture</TITLE>" +
      "  <meta http-equiv='Content-Language' content='en-gb'>" +
      "  <META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=windows-1252'>" +
      "  <link href='styles.css' rel='stylesheet' type='text/css'>" +
      "</HEAD>" +
      "<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>" +
      "  <img name='mainpic' border='0' src='" + strImage + "'>" +
      "</BODY></HTML>";
  }
  else
  {
    parent.PicturePanel['mainpic'].src = strImage;
  }
}
function membersPage()
{
  //var oForm = parent.frames['Login'].document.forms['loginForm'];
  //var page = oForm.elements['membersPage1'].value

  var oForm = parent.frames['Footer'].document.forms['frmPicture'];
  var page = oForm.elements['membersPage2'].value
  if (page == "")
  {
    parent.Logo.location.href = 'PTCLogin.htm';
    alert("Please log in");
  }
  else
  {
    changeContent(page, 'PTCPicture1.jpg');
  }
}
function changeContent(strPage, strImage)
{
  // Change content
  parent.Content.location.href = strPage;

  // Change picture panel
  if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent) || /Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent))
  {
    if (strImage != "")
    {
      replacePicture(strImage);
      parent.document.getElementById('frmCentre').rows = reduceRows;
      parent.Footer.frmPicture.picture.value = "TRUE";
    }
    else
    {
      parent.document.getElementById('frmCentre').rows = popupRows;      
      parent.Footer.frmPicture.picture.value = "FALSE";
    }
  }
  else
  {
    var expand = parent.Footer.exform.expand.value;
    if (strImage == "")
    {
      if (expand == "TRUE")
      {
        //alert('1. changeContent(' + strPage + ',' + strImage + '): ' + expand + ' 0,0,*,30');
        parent.document.getElementById('frmCentre').rows = expandRows;
      }
      else
      {
        //alert('2. changeContent(' + strPage + ',' + strImage + '): ' + expand + ' 55,0,*,30');
        parent.document.getElementById('frmCentre').rows = popupRows;
      }
      parent.Footer.frmPicture.picture.value = "FALSE";
    }
    else
    {
      if (expand == "TRUE")
      {
        //alert('3. changeContent(' + strPage + ',' + strImage + '): ' + expand + ' 0,0,*,30');
        parent.document.getElementById('frmCentre').rows = expandRows;
      }
      else
      {
        //alert('4. changeContent(' + strPage + ',' + strImage + '): ' + expand + ' 55,150,*,30');
        parent.document.getElementById('frmCentre').rows = reduceRows;
      }
      replacePicture(strImage);
      parent.Footer.frmPicture.picture.value = "TRUE";
    }
  }
}
function popupPage(strPage, strImage) // ** NOTE: CURRENTLY IGNORING strImage **
{
  
  if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent) || /Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent))
  {
    iwin = window.open(strPage,strPage,
      'status=no,toolbar=no,location=no,menu=no,scrollbars=no,resizable=no,width=600,height=400');
  }
  else
  {
    // Change content
    parent.Content.location.href = strPage;

    // Change picture panel
    var expand = parent.Footer.exform.expand.value;
    //if (strImage == "")
    //{
      if (expand == "TRUE")
      {
        //alert('5. popupPage(' + strPage + ',' + strImage + '): ' + expand + ' 0,0,*,30');
        parent.document.getElementById('frmCentre').rows = expandRows;
      }
      else
      {
        //alert('6. popupPage(' + strPage + ',' + strImage + '): ' + expand + ' 55,0,*,30');
        parent.document.getElementById('frmCentre').rows = popupRows;
      }
      parent.Footer.frmPicture.picture.value = "FALSE";
    //}
    //else
    //{
    //  if (expand == "TRUE")
    //  {
    //    //alert('7. popupPage(' + strPage + ',' + strImage + '): ' + expand + ' 0,0,*,30');
    //    parent.document.getElementById('frmCentre').rows = expandRows;
    //  }
    //  else
    //  {
    //    //alert('8. popupPage(' + strPage + ',' + strImage + '): ' + expand + ' 55,150,*,30');
    //    parent.document.getElementById('frmCentre').rows = reduceRows;
    //  }
    //  replacePicture(strImage);
    //  parent.Footer.frmPicture.picture.value = "TRUE";
    //}
  }
}
//function handleOver()
//{ 
//  document.tabImage.src='ExpandTabHover.jpg';
//}
function expandContent()
{
  //parent.location.href = parent.Content.location.href;

  parent.document.getElementById('frmMain').cols = expandCols;
  parent.document.getElementById('frmCentre').rows = expandRows;

  document.getElementById('displayedTab').innerHTML = 
    "<A HREF='javascript:void(0);' onClick='reduceContent()'><img name=tabImage border='0' src='ReduceTab.gif'></A><form id='exform' method='get'><input type='hidden' name='expand' value='TRUE'/></form>";

}
function reduceContent()
{
  parent.document.getElementById('frmMain').cols = reduceCols;
  
  var picture = parent.Footer.frmPicture.picture.value;
  if (picture == "TRUE")
  {
    parent.document.getElementById('frmCentre').rows = reduceRows;
  }
  else
  {
    parent.document.getElementById('frmCentre').rows = popupRows;
  }

  document.getElementById('displayedTab').innerHTML = 
    "<A HREF='javascript:void(0);' onClick='expandContent()'><img name=tabImage border='0' src='ExpandTab.gif'></A><form id='exform' method='get'><input type='hidden' name='expand' value='FALSE'/></form>";

}

function changeItemBackground(item, background)
{
  var type = background.substring(0,1);
  if (type == '#')
  {
    document.getElementById(item).style.background = background;
  }
  else
  {
    var url = "url('" + background + "')";
    document.getElementById(item).style.backgroundImage=url;
  }
}

