// Resize images that are too large
function resizeImages()
{
  var x = 0;
  var maxWidth = 600;
  for (x=0;x<document.images.length;x++)
  {
    img = document.images[x];
    if (img.src.indexOf('active_logo.jpg')<10)
    {
      if(img.width>maxWidth)
      {
        r = maxWidth/img.width;
        w = img.width;
        h = img.height;
        img.width = w * r;
        img.height = h * r;
        img.style.cursor='pointer';
        img.onclick = function() {window.open(this.src)}
      }
    }
  }
}
setTimeout('resizeImages()',250);


// Replace some links with other code using regular expressions
var Picasa1RegExp = new RegExp("^http:\/\/picasaweb\.google\.com\/.*\/.*\#$","i");
var Picasa2RegExp = new RegExp("^http:\/\/picasaweb\.google\.com\/.*\/.*","i");
var PhotoBucketRegExp = new RegExp("^http:\/\/.*\.photobucket\.com\/albums\/.*\/.*\/?albumview=.*","i");
var WeatherRegExp = new RegExp("^http\:\/\/www\.weather\.com\/(.*\/)*((US[A-Z]{2})*[0-9]+).*$","i");


for(x=0;x<document.links.length;x++)
{
  lnk = document.links[x];
  u = lnk.href;
  if (Picasa1RegExp.test(u))
  {
    lnk.innerHTML = '<center><iframe src="' + u + 'slideshow" width="600" height="500" style="border:1px solid black" scrolling="no"><\/iframe><br>visit Picasa to see the full album.<\/center>'
  }
  else if (Picasa2RegExp.test(u))
  {
    lnk.innerHTML = '<center><iframe src="' + u + '#slideshow" width="600" height="500" style="border:1px solid black" scrolling="no"><\/iframe><br>visit Picasa to see the full album.<\/center>'
  }
  else if (u.indexOf('http:\/\/www.youtube.com\/watch?v=')==0)
  {
    vid = u.replace(/^.*?v=([^&]*).*/,'$1');
    lnk.innerHTML = '<center>visit YouTube to see more about this video<\/center>';
    div = document.createElement('div');
    div.innerHTML = '<center><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/' + vid + '&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + vid + '&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><\/center>';
    lnk.parentNode.insertBefore(div,lnk);
  }
  else if(u.replace(/^http:\/\/maps.google.com\/maps\?.*daddr\=.*/,'')!=u)
  {

    lnk.innerHTML = '<center>View larger map at Google<\/center>';
    div = document.createElement('div');
    div.innerHTML = '<center><iframe width="600" height="500" frameborder="0" style="border:1px solid black" scrolling="no" marginheight="0" marginwidth="0" src="' + u.replace('&z=','&zzz=') + '&output=embed"><\/iframe><\/center>';
    lnk.parentNode.insertBefore(div,lnk);
  }
  else if (PhotoBucketRegExp.test(u))
  {
    lnk.innerHTML = '<center>View full album on PhotoBucket<\/center>';
    div = document.createElement('div');
    div.innerHTML = '<center><iframe width="650" height="500" frameborder="0" style="border:1px solid black" scrolling="no" marginheight="0" marginwidth="0" src="' + u + '&output=embed"><\/iframe><\/center>';
    lnk.parentNode.insertBefore(div,lnk);
  }
  else if (u.indexOf('http:\/\/schworak.com\/family\/photo_albums\/')==0)
  {
    lnk.innerHTML = '<center>View full album on Schworak.com<\/center>';
    div = document.createElement('div');
    div.innerHTML = '<center><iframe width="750" height="600" frameborder="0" style="" scrolling="auto" marginheight="0" marginwidth="0" src="' + u + '&e=1"><\/iframe><\/center>';
    lnk.parentNode.insertBefore(div,lnk);
  }
  else if (WeatherRegExp.test(u))
  {
    loc = u.replace(/^http\:\/\/www\.weather\.com\/(.*\/)*((US[A-Z]{2})*[0-9]+).*$/,"$2");
    lnk.innerHTML = '<center>Visit Weather.com for more info (' + loc + ')<\/center>';
    lnk.href = 'http:\/\/www.weather.com\/weather\/tenday\/' + loc;
    div = document.createElement('div');
    HTML  = '<center>';
    HTML += '<object title="Free Online Weather" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http:\/\/fpdownload.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,0,0" width="300" height="150" align="middle">';
    HTML += '<param name="allowScriptAccess" value="sameDomain" \/>';
    HTML += '<param name="movie" value="http:\/\/www.weatherlet.com\/forecast.swf?locid=' + loc + '&unit=s" \/>';
    HTML += '<param name="quality" value="high" \/>';
    HTML += '<param name="wmode" value="transparent" \/>';
    HTML += '<embed title="Free Online Weather" src="http:\/\/www.weatherlet.com\/forecast.swf?locid=' + loc + '&unit=s" quality="high" wmode="transparent" bgcolor="#CC00CC" width="300" height="150" align="middle" allowscriptaccess="sameDomain" type="application\/x-shockwave-flash" pluginspage="http:\/\/www.macromedia.com\/go\/getflashplayer" \/>';
    HTML += '<\/object>';
    HTML += '<\/center>';
    div.innerHTML = HTML;
    lnk.parentNode.insertBefore(div,lnk);
  }

  // Change the target for some links

  if (u.indexOf("javascript:")==0)
  {
    // Do Nothing
  }
  else if (u.indexOf('http://bikernw.com')==0)
  {
    lnk.target = '_top';
  }
  else
  {
    lnk.target = '_blank';
  }
}
