// *********************** HEADER ************************************************

// removes the pipes characters in the toolbar header
YE.onAvailable('toolbar', function(e) {
this.innerHTML = this.innerHTML.replace(new RegExp(/\|/g),"");
});

// *********************** LANGUAGE TRANSLATION **********************************

var _g_myServer = "http://www.lonesometiger.com"; // where css files are, no / at end
var lang1 = "deutsch";
var lang1_file = "de.css";
var lang2 = "english";
var lang2_file = "en.css";
 
function readCookieStyle(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
 
function createCookieStyle(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
 
function setSheet(lang) {
  createCookieStyle("style", lang, 365);
  location.reload();
}
 
function includeBrowserCSS() {
  document.writeln("<style type=\"text/css\">");
  var lang;
  var lang_file;
  var cookie = readCookieStyle("style");
  if (cookie == lang1) {
    lang = lang1;
    lang_file = lang1_file;
  }
  if (cookie == lang2) {
    lang = lang2;
    lang_file = lang2_file;
  }
  // when no cookie is found, use lang1 as standard language
  if (cookie != lang1 && cookie != lang2) {
    lang = lang1;
    lang_file = lang1_file;
  }
  document.writeln("@import url("+_g_myServer+"/"+lang_file+");");
  document.writeln("</style>");
  createCookieStyle("style", lang, 365);
}


// *********************** GALLERIES *********************************************
// removes the bubble popup when you hover over a picture
function delHover() {
    oLst = YD.getElementsBy(function(el) {return (YD.hasClass(el,'imgBorder') || YD.hasClass(el,'imgBorderOn'))},'img');
    for (i=0; i < oLst.length ; i++) {
        if (oLst[i].title && oLst[i].title != '') oLst[i].title = '';
        if (oLst[i].alt && oLst[i].alt != '') oLst[i].alt = '';
    }
}
YE.onContentReady('bodyWrapper', function() {if (!YD.hasClass(document.body, 'smugmug_ajax')) delHover()});
onPhotoShow.subscribe(function(){YE.onAvailable('mainImage', delHover)});

// ************************ FOOTER *************************************************

// fix the pesky pipes in the footer
YE.onAvailable("cobrand_footer", function() {this.innerHTML = this.innerHTML.replace(/\||what are feeds\?/gi, '');});

