var strHBase							//Base url for header links
var strPBase							//Base url for page links

if(window.location.href.substring(0,4)=='file')
 {self.strHBase = 'file:///C:/AppWork/www/public_html/'}
else
 {self.strHBase = 'http://www.mc2racing.com/'}
self.strPBase = window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1)


function EnlargePicture(strURL)
 {
  imgLargeImage = new Image();
  imgLargeImage.src = (strURL);
  PopupLargeImage(strURL);
}


function PopupLargeImage(strURL)
 {
  if((imgLargeImage.width!=0) && (imgLargeImage.height!=0))
   {
    intWindowWidth = imgLargeImage.width + 20;
    intWindowHeight = imgLargeImage.height + 25;
    strArguments = 'toolbar=no,status=no,menuBar=no,scrollbars=no,width=' + intWindowWidth + ',height=' + intWindowHeight;
    winPopup = window.open(strURL, '', strArguments);
   }
  else
   {
    func = 'PopupLargeImage(\'' + strURL + '\')';
    interval = setTimeout(func, 50);
   }
 }


function ShowOrderingTips()
 {
  window5=window.open(strHBase + 'products/ordering/orderingtips/index.html', 'OrderingTips', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=500');
 }


function ltrim(str)
 {
  for(var i=0; ((str.charAt(i)<=' ') && (str.charAt(i)!='')); i++);
  return str.substring(i, str.length);
 }


function rtrim(str)
 {
  for(var i=str.length-1; ((str.charAt(i)<=' ') && (str.charAt(i)!='')); i--);
  return str.substring(0, i+1)
 } 

 
function UpdateItemInfo(strItemNumber)
 {
  fltShippingCostPerPound = 0.79;
  strItemData = GetItemData(strItemNumber);
  astrItemData = strItemData.split('|');
    
  document.getElementById('ppitemnumber').value = astrItemData[0];
  document.getElementById('ppitemname').value = rtrim(astrItemData[1]);
  document.getElementById('ppos0').value = ltrim(astrItemData[3]);
  document.getElementById('ppos1').value = rtrim(astrItemData[6]);
  fltPriceWithCore = Math.round((parseFloat(ltrim(astrItemData[2])) + parseFloat(ltrim(astrItemData[4]))) * 100.0) / 100.0;
  document.getElementById('ppamount').value = fltPriceWithCore + '';
  document.getElementById('ppweight').value = ltrim(astrItemData[3]);
  document.getElementById('price').innerHTML = '$' + ltrim(astrItemData[2]);
  document.getElementById('liweight').innerHTML = 'Weight: ' + ltrim(astrItemData[3]) + 'lbs';
  document.getElementById('liapplication').innerHTML = 'Application: ' + rtrim(astrItemData[6]);
 }


function WriteDirectoryList()
 {
  strPath = '';
  strloc = '' + window.location.href;
  astrpaths = strloc.substring(7).split('/');
  strfile = strloc.substring(0,6);
  document.write('&nbsp&nbsp')
  for (intcount=0, intnum=astrpaths.length; intcount<intnum; intcount++)
   {
    if(astrpaths[intcount]!='index.html')
     {strfile += "/" + astrpaths[intcount];
      if(astrpaths[intcount]!='mc2racing')
       {if(astrpaths[intcount]=='www.mc2racing.com')
         {strPath += '/ <a href="' + strfile + '">' + astrpaths[intcount] + '</a> ';}
        else
         {strPath += '/ <a href="' + strfile + '/index.html">' + astrpaths[intcount] + '</a> ';}
       }
     }
   }
  document.write(strPath.substring(2));
 }


function WritePageHeader(strHeaderText)
 {
  document.write('<table class="fullsize" border="0" cellspacing="0" cellpadding="0">');
  document.write(' <tr class="borderrowgray7">');
  document.write('  <td colspan="5"></td>');
  document.write(' </tr>');
  document.write(' <tr class="borderrowblack">');
  document.write('  <td colspan="5"></td>');
  document.write(' </tr>');
  document.write(' <tr class="fullheight">');
  document.write('  <td class="bordercolwhite"></td>');
  document.write('  <td class="bordercolgray"></td>');
  document.write('  <td align="center">');
  document.write('   <table class="main" border="0" cellspacing="0" cellpadding="0">');
  document.write('    <tr>');
  document.write('     <td class="bordercolgray"></td>');
  document.write('     <td valign="top">');
  document.write('      <table class="sectionlist" border="0" cellspacing="0" cellpadding="0">');
  document.write('       <tr>');
  document.write('        <td>');
  document.write('         <a href="javascript:window.location.href = strHBase + \'contact/index.html\'"><img class="noborder" src="header_contact.gif" width="96" height="25" alt=""></a>');
  document.write('         <a href="javascript:window.location.href = strHBase + \'teaminfo/index.html\'"><img class="noborder" src="header_theteam.gif" width="96" height="25" alt=""></a>');
  document.write('         <a href="javascript:window.location.href = strHBase + \'equipment/index.html\'"><img class="noborder" src="header_teamcars.gif" width="96" height="25" alt=""></a>');
  document.write('         <a href="javascript:window.location.href = strHBase + \'gallery/index.html\'"><img class="noborder" src="header_gallery.gif" width="96" height="25" alt=""></a><br>');
  document.write('         <a href="javascript:window.location.href = strHBase + \'results/index.html\'"><img class="noborder" src="header_results.gif" width="96" height="25" alt=""></a>');
  document.write('         <a href="javascript:window.location.href = strHBase + \'affiliations/index.html\'"><img class="noborder" src="header_affiliations.gif" width="96" height="25" alt=""></a>');
  document.write('         <a href="javascript:window.location.href = strHBase + \'tech/index.html\'"><img class="noborder" src="header_tech.gif" width="96" height="25" alt=""></a>');
  document.write('         <a href="javascript:window.location.href = strHBase + \'products/index.html\'"><img class="noborder" src="header_products.gif" width="96" height="25" alt=""></a>');
  document.write('        </td>');
  document.write('       </tr>');
  document.write('      </table>');
  document.write('      <table class="directorylist" border="0" cellspacing="0" cellpadding="0">');
  document.write('       <tr>');
  document.write('        <td>');
  WriteDirectoryList();
  document.write('        </td>');
  document.write('       </tr>');
  document.write('      </table>');
  document.write('      <table class="fullwidth" border="0" cellspacing="0" cellpadding="0">');
  document.write('       <tr>');
  document.write('        <td class="bordercolwhite"></td>');  
  document.write('        <td>');
  document.write('         <table class="fullwidth" border="0" cellspacing="0" cellpadding="0">');
  document.write('          <tr class="borderrowwhite">');
  document.write('           <td></td>');
  document.write('          </tr>');
  document.write('          <tr>');
  document.write('           <td>');
  document.write('            <br><span class="contenttitle">' + strHeaderText + '</span>');
  document.write('           </td>');
  document.write('           <td align="right">');
  document.write('            <form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="this.target=\'paypal\';">');
  document.write('             <p style="display:inline;">');
  document.write('              <input type="hidden" name="cmd" value="_cart">');
  document.write('              <input type="hidden" name="business" value="grayson@mc2racing.com">');
  document.write('              <input type="image" name="submit" src="viewcart.gif">');
  document.write('              <input type="hidden" name="display" value="1">');
  document.write('              <input type="hidden" name="page_style" value="Primary">');
  document.write('              <br>');
  document.write('              <a class="orderingtips" href="" onclick="javascript:ShowOrderingTips(); return false;">Ordering Tips</a>');
  document.write('             </p>');
  document.write('            </form>');
  document.write('           </td>');
  document.write('          </tr>');
  document.write('         </table>');
  document.write('         <br><br>');
 }


function WritePageFooter()
 {
  document.write('         <table class="fullsize" border="0" cellspacing="0" cellpadding="0">');
  document.write('          <tr class="borderrowwhite">');
  document.write('           <td colspan="2"></td>');
  document.write('          </tr>');
  document.write('          <tr class="borderrowgray1">');
  document.write('           <td colspan="2"></td>');
  document.write('          </tr>');
  document.write('          <tr>');
  document.write('           <td valign="middle"><span class="signature">mc<span class="squared">˛</span>racing - Copyright 1995-2010, <a href="mailto:sales@mc2racing.com">mc˛racing</a></span></td>');
  document.write('           <td align="right"><img class="noborder" src="creditcards.gif" width="263" height="29" alt="We accept MasterCard, Visa, American Express, Discover, and PayPal!"></td>');
  document.write('          </tr>');
  document.write('         </table>');
  document.write('        </td>');
  document.write('        <td class="bordercolwhite"></td>');  
  document.write('       </tr>');
  document.write('      </table>');
  document.write('     </td>');
  document.write('     <td class="bordercolgray"></td>');
  document.write('    </tr>');
  document.write('   </table>');
  document.write('  </td>');
  document.write('  <td class="bordercolgray"></td>');
  document.write('  <td class="bordercolwhite"></td>');
  document.write(' </tr>');
  document.write(' <tr class="borderrowblack">');
  document.write('  <td colspan="5"></td>');
  document.write(' </tr>');
  document.write(' <tr class="borderrowgray7">');
  document.write('  <td colspan="5"></td>');
  document.write(' </tr>');
  document.write('</table>');
 } 


function WriteImageCode(strImageName)
 {
  document.write('<a href="" onclick="EnlargePicture(strHBase + \'images/' + strImageName + '_large.gif\'); return false;"><img class="noborder" src="' + strImageName + '.gif" width="94" height="94" alt=""><br><img class="noborder" src="largeimage.gif" width="94" height="22" alt=""></a>');
 }


function WriteResultRow(strPosition, strName, strCar, strTime, intMember)
 {
  if(intMember==1)
   {
    document.write('<tr class="resultmember">');
   }
  else
   {
    document.write('<tr class="resultother">');
   }
  document.write(' <td class="resultplace">' + strPosition + '</td>');
  document.write(' <td class="resultname">' + strName + '</td>');
  document.write(' <td class="resultcar">' + strCar + '</td>');
  document.write(' <td class="resulttime">' + strTime + '</td>');
  document.write('</tr>');
 }
 
 
function WritePAXResultRow(strPosition, strName, strCar, strTime, strPAX, intMember)
 {
  if(intMember==1)
   {
    document.write('<tr class="resultmember">');
   }
  else
   {
    document.write('<tr class="resultother">');
   }
  document.write(' <td class="resultplace">' + strPosition + '</td>');
  document.write(' <td class="resultname">' + strName + '</td>');
  document.write(' <td class="resultcar">' + strCar + '</td>');
  document.write(' <td class="resulttime">' + strTime + '</td>');
  document.write(' <td class="resulttime">' + strPAX + '</td>');
  document.write('</tr>');
 }


function WritePointsRow(strPosition, strName, strPoints, intMember)
 {
  if(intMember==1)
   {
    document.write('<tr class="resultmember">');
   }
  else
   {
    document.write('<tr class="resultother">');
   }
  document.write(' <td class="resultplace">' + strPosition + '</td>');
  document.write(' <td class="resultname">' + strName + '</td>');
  document.write(' <td class="resulttime">' + strPoints + '</td>');
  document.write('</tr>');
 }
 
 
function WriteResultTableHeader(strClassName)
 {
  document.write('<table class="fullwidth" style="margin:0; padding:0;">');
  document.write(' <tr>');
  document.write('  <td align="center">');
  document.write('   <table style="margin:0; padding:0;">');
  document.write('    <tr>');
  document.write('     <td align="left"><span class="resulttitle">' + strClassName + '</span></td>');
  document.write('    </tr>');
  document.write('    <tr>');
  document.write('     <td align="center">');
  document.write('      <table class="resulttimes" border="1">');
 }

 
function WriteResultTableFooter()
 {
  document.write('      </table>');
  document.write('     </td>');
  document.write('    </tr>');
  document.write('   </table>'); 
  document.write('  </td>');
  document.write(' </tr>');
  document.write('</table>');
 }