function hasPath(sPath)
{
re = new RegExp("\/" + sPath + "(\/|$)");
return re.test(window.location)
}

function createSWF( w, h, params) { 
 var args = ""; 
 for (var i in params) { 
     args += i + "=" + params[i] + "&amp;"; 
 } 
 document.writeln('<object width="100%" height="100%" align="middle">'+ 
'<param name="movie" value="http://www.smugmug.com/ria/ShizamSlides-2007091201.swf?'+args+'"/>'+ 
'<param name="wmode" value="transparent" />'+ 
'<embed src="http://www.smugmug.com/ria/ShizamSlides-2007091201.swf?'+args+'" wmode="transparent" width="' + w + '" height="' + h + '" type="application/x-shockwave-flash" allowScriptAccess="always" allowNetworking="all"/></object>'); 
return 1; 
} 


function getCookie(name) {
  var start = document.cookie.indexOf(name + "=");
  var len = start + name.length + 1;
  
  if ((!start) && (name != document.cookie.substring(0, name.length))) {
    return null;
  }

  if (start == -1) {
    return null;
  }

  var end = document.cookie.indexOf(";", len);

  if (end == -1) {
    end = document.cookie.length;
  }

  return unescape(document.cookie.substring(len, end));
}


function setCookie(name, value, expires, path, domain, secure) {
  var today = new Date();
  today.setTime( today.getTime() );

  if (expires) {
    expires = expires * 1000 * 60 * 60 * 24;
  }

  var expires_date = new Date(today.getTime() + (expires));

  document.cookie = name + '='+escape(value) +
    ((expires) ? ';expires=' + expires_date.toGMTString() : '') +
    ((path) ? ';path=' + path : '') +
    ((domain) ? ';domain=' + domain : '') +
    ((secure) ? ';secure' : '');
}


function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
  }
}
// fix the pesky pipes

YE.onAvailable("cobrand_footer", function() {this.innerHTML = this.innerHTML.replace(/\||what are feeds\?/gi, '');});

rightClickWarning = "All photographs are property of Martynas Milkevicius. All rights reserved. Unauthorized use is prohibited."; 
SM.PhotoBar.config.position = 'bottom';


function ModifyText () 
{
  if (YD.hasClass(document.body, "gallery_3704147")) 
  {
    var objElement = YD.get("comment")
    if (objElement != null) 
    {
      var str = new String(objElement.innerHTML);
      str = str.replace(/\gallery/gi, 'guestbook');
      objElement.innerHTML = str;
    }
  }
}

YE.onAvailable("comment", ModifyText);

function redirectPath() { 
re = /(mmfoto.smugmug.com)/; 
tmp = window.location.href; 
if (re.test(tmp)) { 
tmp = tmp.replace(re, 'www.martynas.org'); 
window.location.href = tmp; 
} 
}
redirectPath();

var vanityTable = 
 {
     "scenery" : " http://mmfoto.smugmug.com/gallery/3676249",
     "faces" : " http://mmfoto.smugmug.com/gallery/3678269",
     "about": " http://mmfoto.smugmug.com/gallery/3678524",
     "news": " http://mmfoto.smugmug.com/gallery/3690809",
     "sign": " http://mmfoto.smugmug.com/gallery/3704147",
    "things" : " http://mmfoto.smugmug.com/gallery/6352852"
 };

function IsHomePage()
  {
  	// test for the "homepage" class name in the <BODY> tag
  	var bodyLinks = document.getElementsByTagName("BODY");
  	if ((bodyLinks != undefined) && (bodyLinks != null) && (bodyLinks.length > 0))
  	{
  		var classStr = bodyLinks[0].className;
 		if ((classStr != undefined) && (classStr != null) && (classStr.indexOf("homepage") != -1))
  		{
  			return(true);
  		}
  	}
  	return(false);
  }
  
  function CheckRedirects()
  {
  	if (IsHomePage())	// 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 != undefined) && (newURL != window.location))
  		{
 		 window.location = newURL;		// go to the new URL
  		}
  	}
  }
