//
// **************************************************
//

function changeContent(buttonid)
{
  if (buttonid == 'button_links')
  {
    var newHTML = "<BR>"
                + "<H3><P><U>Links</U>"
                + "<BR>"
                + "<BR>"
                + "<A href='http://www.tractorpanels.com' target='_blank'>EFL Tractor Panels - http://www.tractorpanels.com</A>";
  }
  if (buttonid == 'button_email')
  {
    var newHTML = "<BR>"
                + "<H3><P><U>Email</U>"
                + "<BR>"
                + "<BR>"
                + "<FORM name='emailform' method='post' action='sendemail.php' onSubmit=\"return checkemailform()\">"
                + "  <BR>"
                + "  <H1>&nbsp;&nbsp;&nbsp;Name:<BR>"
                + "  &nbsp;&nbsp;&nbsp;<INPUT type='text' name='emailsendername' size='35'>"
                + "  <BR>"
                + "  <H1>&nbsp;&nbsp;&nbsp;Email Address:<BR>"
                + "  &nbsp;&nbsp;&nbsp;<INPUT type='text' name='emailaddress' size='35'>"
                + "  <BR>"
                + "  <H1>&nbsp;&nbsp;&nbsp;Subject:<BR>"
                + "  &nbsp;&nbsp;&nbsp;<INPUT type='text' name='emailsubject' size='35'>"
                + "  <BR>"
                + "  <H1>&nbsp;&nbsp;&nbsp;Mail Message:<BR>"
                + "  &nbsp;&nbsp;&nbsp;<TEXTAREA name='emailmessage' rows='7' cols='70'></TEXTAREA>"
                + "  <BR>"
                + "  <BR>"
                + "  &nbsp;&nbsp;&nbsp;<INPUT type='submit' value='Send Email'>"
                + "  <BR>"
                + "</FORM>";
  }
  document.getElementById('content').innerHTML=newHTML;
}

//
// **************************************************
//

function gotoPage(urlname)
{
  window.location=urlname;
}

//
// **************************************************
//

function writeHTML(section)
{
  if (section == 'title')
  {
    document.write('<TABLE height="150" width="1000" border="0" cellpadding="0" cellspacing="0">');
    document.write('  <TR>');
    document.write('    <TD height="150" width="1000" align="left" valign="center" bgcolor="#004020">');
    document.write('      <IMG src="images/title.jpg" alt="US Tractors" border="0">');
    document.write('    </TD>');
    document.write('  </TR>');
    document.write('</TABLE>');
  }
  if (section == 'contact_details')
  {
    document.write('<TABLE height="1790" width="180" border="1" bordercolor="#002000" cellpadding="0" cellspacing="0">');
    document.write('  <TR>');
    document.write('    <TD height="1790" width="180" align="center" valign="top" bgcolor="#007020">');
    document.write('      <BR>');
    document.write('      <BR>');
    document.write('      <H1><U>Contact Details:</U>');
    document.write('      <BR>');
    document.write('      <BR>');
    document.write('      <BR>');
    document.write('      <H1>WILLIAM ENGELMANN');
    document.write('      <H1>Essex UK');
    document.write('      <H2>williamengelmann@hotmail.co.uk');
    document.write('      <H1>MOB: 07850 392943');
    document.write('      <BR>');
    document.write('      <BR>');
    document.write('      <U>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U>');
    document.write('      <BR>');
    document.write('      <BR>');
    document.write('      <BR>');
    document.write('      <H1>CORIN HARRIS');
    document.write('      <H1>Bedford UK');
    document.write('      <H1>TEL: 01462 812616');
    document.write('      <H1>MOB: 07860 263240');
    document.write('      <BR>');
    document.write('      <BR>');
    document.write('      <BR>');
    document.write('      <FORM action="">');
    document.write('        <INPUT type="Button" name="Email" value="Email" class="btn" onmouseover="this.className=\'btn btnhov\'" onmouseout="this.className=\'btn\'" onClick="changeContent(\'button_email\')">');
    document.write('      </FORM>');
    document.write('    </TD>');
    document.write('  </TR>');
    document.write('</TABLE>');
  }
  if (section == 'admin_button')
  {
    document.write('<TABLE height="60" width="180" border="1" bordercolor="#002000" cellpadding="0" cellspacing="0">');
    document.write('  <TR>');
    document.write('    <TD height="60" width="180" align="center" valign="bottom" bgcolor="#007020">');
    document.write('      <FORM method="post" action="admin.php?entrymode=1">');
    document.write('        <INPUT type="submit" name="Admin" value="Admin" class="btn" onmouseover="this.className=\'btn btnhov\'" onmouseout="this.className=\'btn\'">');
    document.write('      </FORM>');
    document.write('    </TD>');
    document.write('  </TR>');
    document.write('</TABLE>');
  }
  if (section == 'logout_button')
  {
    document.write('<TABLE height="60" width="180" border="1" bordercolor="#002000" cellpadding="0" cellspacing="0">');
    document.write('  <TR>');
    document.write('    <TD height="60" width="180" align="center" valign="bottom" bgcolor="#007020">');
    document.write('      <FORM method="link" action="logout.php">');
    document.write('        <INPUT type="submit" name="Logout" value="Logout" class="btn" onmouseover="this.className=\'btn btnhov\'" onmouseout="this.className=\'btn\'">');
    document.write('      </FORM>');
    document.write('    </TD>');
    document.write('  </TR>');
    document.write('</TABLE>');
  }
  if (section == 'menu_buttons_0')
  {
    document.write('<TABLE height="30" width="820" border="1" bordercolor="#002000" cellpadding="0" cellspacing="0">');
    document.write('  <TR>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('  </TR>');
    document.write('</TABLE>');
  }
  if (section == 'menu_buttons_1')
  {
    document.write('<TABLE height="30" width="820" border="1" bordercolor="#002000" cellpadding="0" cellspacing="0">');
    document.write('  <TR>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20" onMouseOver="this.style.backgroundColor=\'#996600\'" onMouseOut="this.style.backgroundColor=\'#00AA20\'" onClick="gotoPage(\'index.htm\')">');
    document.write('      <A href="index.htm">Home</A>');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20" onMouseOver="this.style.backgroundColor=\'#996600\'" onMouseOut="this.style.backgroundColor=\'#00AA20\'" onClick="gotoPage(\'index_1.php\')">');
    document.write('      <A href="index_1.php">Stock</A>');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20" onMouseOver="this.style.backgroundColor=\'#996600\'" onMouseOut="this.style.backgroundColor=\'#00AA20\'" onClick="gotoPage(\'index_2.php\')">');
    document.write('      <A href="index_2.php">Parts</A>');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20" onMouseOver="this.style.backgroundColor=\'#996600\'" onMouseOut="this.style.backgroundColor=\'#00AA20\'" onClick="gotoPage(\'index_3.php\')">');
    document.write('      <A href="index_3.php">What You\'ve Missed</A>');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20" onMouseOver="this.style.backgroundColor=\'#996600\'" onMouseOut="this.style.backgroundColor=\'#00AA20\'" onClick="changeContent(\'button_links\')">');
    document.write('      <A href="javascript:changeContent(\'button_links\')">Links</A>');
    document.write('    </TD>');
    document.write('  </TR>');
    document.write('</TABLE>');
  }
  if (section == 'menu_buttons_2')
  {
    document.write('<TABLE height="30" width="820" border="1" bordercolor="#002000" cellpadding="0" cellspacing="0">');
    document.write('  <TR>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20" onMouseOver="this.style.backgroundColor=\'#996600\'" onMouseOut="this.style.backgroundColor=\'#00AA20\'" onClick="gotoPage(\'index.htm\')">');
    document.write('      <A href="index.htm">Home</A>');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('    <TD height="30" width="164" align="center" valign="center" bgcolor="#00AA20">');
    document.write('      &nbsp;');
    document.write('    </TD>');
    document.write('  </TR>');
    document.write('</TABLE>');
  }
}

//
// **************************************************
//

function checkemailform()
{
  var emailsendername = document.emailform.emailsendername.value;
  var emailaddress = document.emailform.emailaddress.value;
  var emailsubject = document.emailform.emailsubject.value;
  var emailmessage = document.emailform.emailmessage.value;

  if(emailsendername == "")
  {
    alert('Please enter a name.....');
    return false;
  }
  else if(emailaddress == "")
  {
    alert('Please enter an email address.....');
    return false;
  }
  else if(emailsubject == "")
  {
    alert('Please enter a subject.....');
    return false;
  }
  else if(emailmessage == "")
  {
    alert('Please enter a message.....');
    return false;
  }
  return true;
}

//
// **************************************************
//

function pause(link)
{
  var command = "endpause('" + link + "')";
  timer = setTimeout(command,3000);          // 3 seconds
  return false;
}

function endpause(link)
{
  location.href = link;
  return false;
}

//
// **************************************************
//

function displayPhotos(stock_name,stock_photo_name_1,stock_photo_name_2,stock_photo_name_3)
{
  var newHTML = "<BR>"
              + "<H3><U>Tractors and Machinery</U></H3>"
              + "<H1>" + stock_name + "&nbsp;-&nbsp;More Photos</H1>"
              + "<BR>"
              + "<TABLE height='600' width='790' border='0' bordercolor='#002000' cellpadding='0' cellspacing='0'>"
              + "  <TR>"
              + "    <TD height='300' width='10' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      &nbsp;"
              + "    </TD>"
              + "    <TD height='300' width='390' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      <IMG src='uploaded_photos/" + stock_photo_name_1 + "' alt='" + stock_name + " (Photo 1)' border='1' onClick=\"displayLargeImage('uploaded_photos/large_" + stock_photo_name_1 + "')\">"
              + "    </TD>"
              + "    <TD height='300' width='10' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      &nbsp;"
              + "    </TD>"
              + "    <TD height='300' width='390' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      <IMG src='uploaded_photos/" + stock_photo_name_2 + "' alt='" + stock_name + " (Photo 2)' border='1' onClick=\"displayLargeImage('uploaded_photos/large_" + stock_photo_name_2 + "')\">"
              + "    </TD>"
              + "    <TD height='300' width='10' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      &nbsp;"
              + "    </TD>"
              + "  </TR>"
              + "  <TR>"
              + "    <TD height='10' width='10' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      &nbsp;"
              + "    </TD>"
              + "  </TR>"
              + "  <TR>"
              + "    <TD height='300' width='10' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      &nbsp;"
              + "    </TD>"
              + "    <TD height='300' width='390' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      <IMG src='uploaded_photos/" + stock_photo_name_3 + "' alt='" + stock_name + " (Photo 3)' border='1' onClick=\"displayLargeImage('uploaded_photos/large_" + stock_photo_name_3 + "')\">"
              + "    </TD>"
              + "    <TD height='300' width='10' align='center' valign='center' bgcolor='#DDFFDD'>"
              + "      &nbsp;"
              + "    </TD>"
              + "  </TR>"
              + "</TABLE>"
              + "<BR>";
  document.getElementById('content').innerHTML=newHTML;
}

//
// **************************************************
//

function cpBlend(i, newsrc)
{
  i.filters.blendTrans.Apply();
  i.src = newsrc;
  i.filters.blendTrans.Play();
}

//
// **************************************************
//

function loadImage(imageVar, imageName)
{
  imageVar.src = "images/" + imageName + ".jpg";
}

//
// **************************************************
//

var postLocation="pgbar.php";

/* 
 * add any extension that you do no want to upload to the list 
 * below they should be placed with in the /^ and / characters
 * separate each extension by a pipe symbol |
 */
 
var re = /^(\.php)|(\.sh)/;  // disallow shell scripts and php

/**
 * dofilter = true; to enable filtering
 */

var dofilter=true;

/**
 * this method will match each of the filenames with a
 * given list of banned extension. If any one of the
 * extensions match, an alert will be popped up and the
 * upload will not continue;
 */
 
function check_types()
{
  if (dofilter==false)
    return true;
  with(document.forms['uploadform'])
  {
    for (i=0 ; i < elements.length ; i++)
    {
      if(elements[i].value.match(re))
      {
        alert('Sorry ' + elements[i].value + ' is not allowed');
        return false;
      }
    }
  }
  return true;
}

function popUP(mypage, myname, w, h, scroll, titlebar)
{
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
  win = window.open(mypage, myname, winprops)
  if (parseInt(navigator.appVersion) >= 4)
  {
    win.window.focus();
  }
}

function postIt()
{
  if (check_types() == false)
  {
    return false;
  }
  baseUrl = postLocation;
  sid = document.forms['uploadform'].sessionid.value;
  iTotal = escape("-1");
  baseUrl += "?iTotal=" + iTotal;
  baseUrl += "&iRead=0";
  baseUrl += "&iStatus=1";
  baseUrl += "&sessionid=" + sid;
  popUP(baseUrl,"Uploader",450,200,false,false);
  document.forms['uploadform'].submit();
}

//
// **************************************************
//

function popupconfirm(message)
{
  var return_value = confirm(message);
  if (return_value == true)
  {
    return true;
  }
  else
  {
    return false;
  }
}

//
// **************************************************
//

function displayLargeImage(imagename)
{
 var imageWin = window.open("", "newwindow", "height=500, width=660, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
 var htmlcode = "<IMG src='" + imagename + "' border='1' alt=''>";
 imageWin.document.write(htmlcode);
 imageWin.moveTo(100,100);
}

//
// **************************************************
//
