// www.sonicbones.net .com .org (C)  2002-2004
// Sonic Web Star (C) 2001-2005

function url_hyperdrive()
{ var urlfile, place, pathway;
  urlfile = location.href.substring(location.href.lastIndexOf('/'));
// This if-then codes needed for google cache vs page not found error
  if ((urlfile.indexOf('.htm+') || urlfile.indexOf('.html+')) ) {
    if ( urlfile.substring(0,urlfile.indexOf('+')) ) {
    	urlfile = urlfile.substring(0,urlfile.indexOf('+'));
    }
  }
// End of google fix
  pathway = location.href.substring(location.href.lastIndexOf('/sonicbones')+11,location.href.lastIndexOf('/'));
  if (pathway && !(pathway.lastIndexOf('.com') || pathway.lastIndexOf('.net') || pathway.lastIndexOf('.org')) ) {
    pathway = pathway.substring(pathway.indexOf(location.hostname)+location.hostname.length-3);
  }
  place = location.hostname.substring(location.hostname.lastIndexOf('.'));
  if ((top.location == location) && !!place)
  {
    // Skip certain sections of site - sensors start
    if ((location.hostname == "music.sonicbones.com")) {
	top.location.replace = "http:" + "//" + "www.sonicbones.com";
	document.write('<meta http-equiv="refresh" content="0;url=http://www.sonicbones.com' + '">');
    // Skip certain sections of site - sensor end
    }
    else {
      if (!(place == ".net" || place == ".com" || place == ".org")) {place = ".com"}
      top.location.replace = "http:" + "//" + "www.sonicbones" + place + location.port + pathway + urlfile + location.search;
      document.write('<meta http-equiv="refresh" content="0;url=http://www.sonicbones' + place + location.port + pathway + urlfile + location.search + '">');
      }
    }
}

function link_hyperdrive()
{
  var place, globalpath, pathway, newurl, i;
  globalpath = location.href.substring(location.href.lastIndexOf('/sonicbones')+11,location.href.lastIndexOf('/'));
  place = location.hostname.substring(location.hostname.lastIndexOf('.'));
  if ((top.location != location) && !!place)
  {
    for (i = 0; i < document.links.length; i++)
    { 
       sniff = document.links[i].href.substring(document.links[i].href.lastIndexOf('.'));
       if (sniff == ".html")
       {
          newurl = document.links[i].href.substring(document.links[i].href.lastIndexOf('/'));
          pathway = document.links[i].href.substring(document.links[i].href.lastIndexOf('/sonicbones/')+11,document.links[i].href.lastIndexOf('/'));
          document.links[i].href = "http:" + "//" + "www.sonicbones" + place + pathway + newurl;
          document.links[i].target ="_top";
       }
       if (sniff == ".jpg" || sniff == ".m3u" || sniff == ".ram" || sniff == ".zip" || sniff == ".mid")
       {
          newurl = document.links[i].href.substring(document.links[i].href.lastIndexOf('/'));
          pathway = document.links[i].href.substring(document.links[i].href.lastIndexOf('/sonicbones/')+11,document.links[i].href.lastIndexOf('/'));
          //if (pathway  && !(pathway.lastIndexOf('.com') || pathway.lastIndexOf('.net') || pathway.lastIndexOf('.org')) ) {
          //  pathway = pathway.substring(pathway.indexOf(location.hostname)+location.hostname.length-3);
          //}
          if (!!document.links[i].href.substring(document.links[i].href.lastIndexOf('/sonicbones.gallery/')+19,document.links[i].href.lastIndexOf('/'))) {
		if (sniff == ".m3u" || sniff == ".ram" || sniff == ".zip" || sniff == ".mid") {
			// Skip certain sections of site - sensors start
			if (globalpath == "/booking") {
		    document.links[i].href = "http:" + "//" + "music.sonicbones.com/booking/music" + newurl;
			// Skip certain sections of site - sensor end
			}
			else {
	 	    document.links[i].href = "http:" + "//" + "music.sonicbones.com/music" + globalpath + pathway + newurl;
			}
		}
		else {
			// Skip certain sections of site - sensors start
			if (globalpath == "/trombonelessons") {
	            document.links[i].href = "http:" + "//" + "www.sonicbones" + place + newurl;
			// Skip certain sections of site - sensor end
			}
			else {
			// Skip special double directory sections, why does this bug exists?
			if (globalpath == "/booking") {
			    document.links[i].href = "http:" + "//" + "www.sonicbones" + place + pathway + newurl;
			}
			else {
	            document.links[i].href = "http:" + "//" + "www.sonicbones" + place + globalpath + pathway + newurl;
			}
			}
		}
            document.links[i].target ="_top";
          }
          else {
            document.links[i].href = "http:" + "//" + "gallery.sonicbones.com" + newurl;
            document.links[i].target ="_top";
          }
       }
    }
  }
}
