
var last_tab = 'tab1';

function ztabs_show(layerName) {
  document.getElementById(layerName).style.display = '';
}

function ztabs_hide(layerName) {
  document.getElementById(layerName).style.display = 'none';
}

function ztabs_show_next(tab_name) {
  document.getElementById(last_tab).className = 'tab_regular';
  var curr = document.getElementById(tab_name);
  curr.className='tab_selected';
  ztabs_hide(last_tab+'_data');
  ztabs_show(tab_name+'_data');
  last_tab=tab_name;
}

//~ function tableRowClick(f,i) { //IFRAMED!
  //~ document.getElementById(f).src=document.getElementById(i).href;
//~ }

function MailtoPageLink(Ride)
{
  var sRef = 'mailto:?subject=' + document.title + '&body=Link: ' + 'http://'+document.domain+'/ride'+Ride+'.html';
  location.href = sRef;
}

function addBookmark(Ride)
{
  var title = document.title;
  var url = location.href;

if (window.sidebar) // firefox
  //window.sidebar.addPanel(title, url, "");
  alert('Your browser does not allow Javascript to add Bookmarks.')
else if(window.opera && window.print){ // opera
  var elem = document.createElement('a');
  elem.setAttribute('href','http://'+document.domain+'/ride'+Ride+'.html');
  elem.setAttribute('title',title);
  elem.setAttribute('rel','sidebar');
  elem.click();
}
else if(document.all)// ie
  window.external.AddFavorite(url, title);
}

function urlCopyOpen(Ride) {
  var CBox = document.getElementById('CopyBox');
  var CTxt = document.getElementById('CopyText');
  var CRid = document.getElementById('CopyRide');
  CBox.style.display = 'block';
  CRid.innerHTML = 'Ride #'+Ride;
  CTxt.value = 'http://'+document.domain+'/ride'+Ride+'.html';
  CTxt.focus()
  CTxt.select()
  //CBox.style.top =  (GetPostionTop('CopyAnchor')  -  80)+'px';
  //CBox.style.left = (GetPostionLeft('CopyAnchor') - 200)+'px';
}

function urlCopyClose() {
  var CBox = document.getElementById('CopyBox');
  var CTxt = document.getElementById('CopyText');
  CBox.style.display = 'none';
  CTxt.value = '';
}

function copyit(ID) {
  var theField=document.getElementById(ID);
  theField.focus()
  theField.select()
}

function GetPostionLeft(xElement){

  var PosX = 0;
  var theElement = document.getElementById(xElement);

  while(theElement != null){
    PosX += theElement.offsetLeft;
    theElement = theElement.offsetParent;
  }

  return PosX;
}
function GetPostionTop(xElement){

  var PosY = 0;
  var theElement = document.getElementById(xElement);

  while(theElement != null){
    PosY += theElement.offsetTop;
    theElement = theElement.offsetParent;
  }

  return PosY;
}
//~ FOR OLD ROLLOVER IMAGES
//~ function MM_swapImgRestore() { //v3.0
  //~ var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
//~ }
//~
//~ function MM_preloadImages() { //v3.0
  //~ var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    //~ var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    //~ if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
//~ }
//~
//~ function MM_findObj(n, d) { //v4.01
  //~ var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    //~ d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  //~ if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  //~ for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  //~ if(!x && d.getElementById) x=d.getElementById(n); return x;
//~ }
//~
//~ function MM_swapImage() { //v3.0
  //~ var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   //~ if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
//~ }

function popup(mylink,z,w,h)
{
  var w = (w == null) ? 480 : w;
  var h = (h == null) ? 320 : h;
  var z = (z == null) ? 'newcomment' : z;

  if (! window.focus)return true;
  var href;
  if (typeof(mylink) == 'string')
     href=mylink;
  else
     href=mylink.href;
  window.open(href, z, 'width='+w+',height='+h+',scrollbars=1,resizable=1');
}
