function togglebottomlinks() {
  thediv = document.getElementById('bottomlinks');
  thelink = document.getElementById('togglelinks');
  if (thediv.style.display == 'block') {
    thediv.style.display = 'none';
    thelink.innerHTML="&gt;";
  }
  else {
    thediv.style.display = 'block';
    thelink.innerHTML="&lt;";
  }
}
function togglemoreinfo() {
  info = document.getElementById('caketopperinfo');
  moreinfo = document.getElementById('caketoppermoreinfo');
  if (info.style.display == 'block') {
    info.style.display = 'none';
    moreinfo.style.display = 'block';
  }
  else {
    info.style.display = 'block';
    moreinfo.style.display = 'none';
  }
}

g_imagewin = null;
function setImage(id,maxid) {
  var d = document.getElementById('divimage' + id);
  var img = document.getElementById('thumb' + id);
  d.style.display = 'block';
  img.border=2;
  for (i = 1; i <= maxid; i++) {
    if(i != id) {
      d = document.getElementById('divimage' + i);
      img = document.getElementById('thumb' + i);
      d.style.display = 'none';
      img.border=0;
    }
  }
}
function setImageA(id,maxid) {
  var d = document.getElementById('divimage' + id);
  var img = document.getElementById('thumb' + id);
  d.style.display = 'block';
  img.style.borderColor = 'white';
  for (i = 1; i <= maxid; i++) {
    if(i != id) {
      d = document.getElementById('divimage' + i);
      img = document.getElementById('thumb' + i);
      d.style.display = 'none';
      img.style.borderColor = 'transparent';
    }
  }
}

function popupimage(URL,w,h) {
    if (g_imagewin != null) {
        g_imagewin.close();
        g_imagewin = null;
    }
    g_imagewin = window.open('about:blank', 'mdimage', 'dependent=yes,top=100,left=100,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + w + ',height=' + h);
    g_imagewin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Magical Day</title></head><body style="margin: 0pt"><a href="javascript:self.close();">close window</a><img id="mdimage" src="' + URL + '" border="0" alt="" onerror="javscript:alert();"/></body></html>');
}

function setwwwaction(formName) {
  if (window.location.protocol != "file:") {
  var theAction = document.forms[formName].action;
  var lastSlash = theAction.lastIndexOf("/");
  theAction = theAction.slice(lastSlash + 1);
  document.forms[formName].action = window.location.protocol + '//www.magicalday.com/' + theAction;
  }
}

function friendlypops() {
 if (!document.getElementsByTagName) {
  return false;
 }
 var popuplinks = document.getElementsByTagName("a");
 for (var i=0; i < popuplinks.length; i++) {
  if (popuplinks[i].getAttribute("class") == "popup") {
   hr = popuplinks[i].href;
   theSize = popuplinks[i].id;
   if (theSize == "") {
    theSize="500,600";
   }
   else if (theSize.charAt(0) == "h") {
    // h100:w300
    // 012345678
    imageHeight = theSize.slice(1,4);
    imageWidth = theSize.slice(6,9);
    theSize = imageHeight + "," + imageWidth;
   }
   popuplinks[i].href = 'javascript:popupimage("' + hr + '",' + theSize + ')';
  }
 }
}

