/*****************************************************************************
It is adviced to place the sIFR JavaScript calls in this file, keeping it
separate from the `sifr.js` file. That way, you can easily swap the `sifr.js`
file for a new version, while keeping the configuration.

You must load this file *after* loading `sifr.js`.

That said, you're of course free to merge the JavaScript files. Just make sure
the copyright statement in `sifr.js` is kept intact.
*****************************************************************************/

var trajan = { src: 'http://www.combermereabbey.co.uk/media/layout/sifr/trajan.swf' };

// sIFR.useStyleCheck = true;

// Next, activate sIFR:
sIFR.activate(trajan);

sIFR.replace(trajan, {
  selector: 'h1',
  wmode: 'transparent',
  forceSingleLine: true,
  tuneWidth: 1,
  css: '.sIFR-root { background-color: #fff; color: #365348; font-size: 24px; }'
});



var min=8;
var max=18;



if(get_cookie("page_size") != null){   
    var current = get_cookie("page_size");
}else{
    var current = 12;
}

//document.write(current);

function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = parseFloat(current);
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px";
   }
    set_cookie('page_size', ''+s+'', 30);
}

function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = parseFloat(current);
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px";
 }
 set_cookie('page_size', ''+s+'', 30);
 }
 

function set_cookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function get_cookie(name) {
    var name_eq = 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(name_eq) == 0) return c.substring(name_eq.length,c.length);
    }
    return null;
}


if(get_cookie("page_size") != null){   
    document.write('<style>');
    document.write('body p{');
    document.write('font-size:'+ get_cookie("page_size") + 'px');
    document.write('}');
    document.write('</style>')
}else{
    document.write('<style>');
    document.write('body{');
    document.write('font-size: 12px;');
    document.write('}');
    document.write('</style>')   
}
    
