var vanityTable = 
 {
     about: "http://www.sweetdreamsstudio.com/gallery/4500103_rXMT4",
     // blog: "http://www.sweetdreamsstudio.com/gallery/4529962_jmjdx",
     blog: "http://sweetdreamsstudio.blogspot.com",
     testimonials: "http://www.sweetdreamsstudio.com/gallery/5316921_oHGJS",
     video: "http://www.sweetdreamsstudio.com/gallery/4486661_tAKWa",
     contact: "http://www.sweetdreamsstudio.com/gallery/4499857_k9Ae3",
     promotion:"http://www.sweetdreamsstudio.com/gallery/7333161_xcuGr",
     jobopening:"http://sweetdreamsstudio.com/gallery/7421295_NEA5k",
     weddingpackages:"http://www.sweetdreamsstudio.com/gallery/4500082_p8BsQ",

     homefav:"http://www.sweetdreamsstudio.com/Sweet-Dreams-Studio-Photos/Slideshow-Home/7731416_KmY7X",
     homeweddings:"http://www.sweetdreamsstudio.com/gallery/7652252_pNBXb",
     homeevents:"http://www.sweetdreamsstudio.com/Sweet-Dreams-Studio-Photos/Slideshow-Events/7664592_VkYye",
     homeportraits:"http://www.sweetdreamsstudio.com/Sweet-Dreams-Studio-Photos/Slideshow-Portraits/7664593_9Wwyb",
     homefamilies:"http://www.sweetdreamsstudio.com/Sweet-Dreams-Studio-Photos/Slideshow-Families/7664590_ebjeQ",
     options:"http://www.sweetdreamsstudio.com/Sweet-Dreams-Studio-Photos/Sample-Wedding-Album/10509447_gXzNe",
     photobooth:"http://www.sweetdreamsstudio.com/Sweet-Dreams-Studio-Photos/Sample-Photo-Booth/11082738_EAHDY",
     abe:"http://www.sweetdreamsstudio.com/Admin/Associate/Abe/11128701_UCEqn",
     chris:"http://www.sweetdreamsstudio.com/Admin/Associate/Chris/11072566_SqC9X"    
 };


 function CheckRedirects()
 {
     if (YD.hasClass(document.body, 'homepage'))    // only run this code on the home page
     {
         // get the path from the current URL, 
         // convert it to lowercase and remove the leading slash
         var path = window.location.pathname.toLowerCase().substr(1);
         
         var newURL = vanityTable[path];        // look it up in our table
         
         // if we found it in the table && newURL is different than where we are
         if (newURL && (newURL != window.location))
         {
             window.location.replace(newURL);        // go to the new URL
         }
     }
 }




// hides count photos in category
function changeCategoryInfo() {
  re = /^([0-9]+ )(galler(y|ies))/;

  oEl = YD.get("categoriesBox")? YD.get("categoriesBox") : YD.get("subcategoriesBox");
  if (oEl) {
    oList = YD.getElementsByClassName("miniBox", "div", oEl);

    for (i=0; i<oList.length; i++) {
      pTags = oList[i].getElementsByTagName("p");
      re.exec(pTags[1].innerHTML);
      pTags[1].innerHTML = RegExp.$1 + RegExp.$2;
    }
  }
}

// scrambles email addresses
function nomail(aUser, aDomain) { document.location = "mailto:" + aUser + "@" + aDomain; }

// replace gallery title with guestbook
function ModifyText ()
{
  if (YD.hasClass(document.body, "gallery_4483868"))
  {
    var objElement = YD.get("comment")
    if (objElement != null)
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/\gallery/gi, 'guestbook/testimonial');
      objElement.innerHTML = str;
    }
  }
}
YE.onAvailable("comment", ModifyText);




function AddReferralCode() {
var links = this.getElementsByTagName("A");
if (links && (links.length != 0)) {
var smugLink = links.item(0);
smugLink.href = "http://www.smugmug.com/?referrer=AZg9CvtCxY77M";
}
}
YE.onAvailable('footer', AddReferralCode);


rightClickWarning = "All photos are property of Jin Yong of Sweet Dreams Studio. All rights reserved. Unauthorized use is prohibited. Have a nice day";

SM.PhotoBar.config.position = 'bottom';


// Enable virtual gallery
function addKeywordFeatured(text, description, keyword, thumbUrl)
{
  if (IsClass("homepage"))
  {
    divTag = document.getElementById("featuredBox");

    if (divTag)
    {
      divTags = divTag.getElementsByTagName("div");

      for (i=0; i<divTags.length; i++)
      {
        if (divTags[i].className == "boxBottom")
        {
          miniBox = document.createElement("div");
          miniBox.className = "miniBox";

          photoBox = document.createElement("div");
          photoBox.className = "photo";
          miniBox.appendChild(photoBox);

          photoLink = document.createElement("a");
          photoLink.setAttribute("href", "/keyword/" + keyword);
          photoBox.appendChild(photoLink);

          photoImg = document.createElement("img");
          photoImg.setAttribute("border", "0");
          photoImg.setAttribute("alt", text);
          photoImg.setAttribute("title", text);
          photoImg.src = thumbUrl;
          photoImg.className = "imgBorder";
          photoLink.appendChild(photoImg);

          albumTitle = document.createElement("p");
          albumTitle.className = "albumTitle";
          miniBox.appendChild(albumTitle);

          albumLink = document.createElement("a");
          albumLink.className = "nav";
          albumLink.setAttribute("href", "/keyword/" + keyword);
          albumTitle.appendChild(albumLink);

          albumLinkText = document.createTextNode(text);
          albumLink.appendChild(albumLinkText);
          
          albumDescription = document.createElement("p");
          albumDescription.className = "description";
          miniBox.appendChild(albumDescription);

          albumDescriptionText = document.createTextNode(description);
          albumDescription .appendChild(albumDescriptionText);

          spacerDiv = document.createElement("div");
          spacerDiv.className = "spacer";
          miniBox.appendChild(spacerDiv);

          divTags[i].insertBefore(miniBox, divTags[i].childNodes[1]);


          break;
        }
      }
    }
  }
}


function IsClass(sClass) 
{
  sClassName = document.body.className;

  re = new RegExp(sClass + "( |$)") 

  if (!sClassName)
    return false;
  return re.test(sClassName);
}
  
function OnLoadHandler()
{
    // modify the addKeywordFeatured function call to customize your keyword gallery
    // Variables are (in order): the title of your gallery, the description of your gallery, 
    // the keyword to find the pictures, the path to the thumbnail for the gallery.

  	addKeywordFeatured('Favorites', 'Favorite Sweet Photos', 'Fav', 'photos/264046759_Py6Nm-Ti-1.jpg'); 
  
}


// these functions enable mouse rollover of homepage buttons

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_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_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];}
}
//-->
