/*****************************************************************************
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.
*****************************************************************************/

// Make an object pointing to the location of the Flash movie on your web server.
// Try using the font name as the variable name, makes it easy to remember which
// object you're using. As an example in this file, we'll use Futura.

var sifrPath = '/assets/swf/sifr/';
var copperPlateBold = { src: sifrPath + 'sifr-copperplate-gothic-bold.swf' };
var tradeGothic = { src: sifrPath + 'sifr-tradegothic-bld_condensed_20.swf' };

// Now you can set some configuration settings.
// See also <http://wiki.novemberborn.net/sifr3/JavaScript+Configuration>.
// One setting you probably want to use is `sIFR.useStyleCheck`. Before you do that,
// read <http://wiki.novemberborn.net/sifr3/DetectingCSSLoad>.

// sIFR.useStyleCheck = true;
sIFR.useStyleCheck = true;
sIFR.useDomLoaded = false;
if (FlashDetect.installed && FlashDetect.versionAtLeast(9, 0))
{
    sIFR.activate(copperPlateBold, tradeGothic);
}
//sIFR.fitExactly = true;
//sIFR.fixHover = true;
//sIFR.fixWrap = true;
 
// Next, activate sIFR:

// If you want, you can use multiple movies, like so:
//
//    var futura = { src: '/path/to/futura.swf' };
//    var garamond = { src '/path/to/garamond.swf' };
//    
//    sIFR.activate(futura, garamond, rockwell);
//
// Remember, there must be *only one* `sIFR.activate()`!

// Now we can do the replacements. You can do as many as you like, but just
// as an example, we'll replace all `<h1>` elements with the Futura movie.
// 
// The first argument to `sIFR.replace` is the `futura` object we created earlier.
// The second argument is another object, on which you can specify a number of
// parameters or "keyword arguemnts". For the full list, see "Keyword arguments"
// under `replace(kwargs, mergeKwargs)` at 
// <http://wiki.novemberborn.net/sifr3/JavaScript+Methods>.
// 
// The first argument you see here is `selector`, which is a normal CSS selector.
// That means you can also do things like '#content h1' or 'h1.title'.
//
// The second argument determines what the Flash text looks like. The main text
// is styled via the `.sIFR-root` class. Here we've specified `background-color`
// of the entire Flash movie to be a light grey, and the `color` of the text to
// be red. Read more about styling at <http://wiki.novemberborn.net/sifr3/Styling>.

var sifrRoot = '.sIFR-root {text-align: left; text-transform: uppercase;}';
var sifrRootCopperplate = '.sIFR-root {letter-spacing:0}';
var sifrRootTradeGothic =  '.sIFR-root {letter-spacing:-2}';

function LoadSifr(selectorPrefix)
{
    LoadSifrHeaderTags('#content ' + selectorPrefix);
    LoadSifrHeroBoxes('#content ' + selectorPrefix);
}

function LoadSifrH1Top(selectorPrefix)
{
    sIFR.replace(copperPlateBold, {
        selector: selectorPrefix + ' h1 .top',
        ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],
        css: [
            sifrRoot,
		    '.sIFR-root { color:#ffffff;}'
	],
        offsetTop: -6,
        tuneHeight: -15,
        preventWrap: true,
        forceSingleLine: true,
        transparent: true
    });
}

function LoadSifrH2Top(selectorPrefix)
{
    sIFR.replace(copperPlateBold, {
        selector: selectorPrefix + ' h2.center .top',
        ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],
        css: [
            sifrRoot,
		    '.sIFR-root { color:#ffffff; text-align:center;}'
	],
        offsetTop: -2,
        tuneHeight: -8,
        preventWrap: true,
        forceSingleLine: true,
        transparent: true,
        onReplacement: function(fi)
        {
            LoadAfterSifrHeaders();
        }
    });

    sIFR.replace(copperPlateBold, {
        selector: selectorPrefix + ' h2 .top',
        ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],
        css: [
            sifrRoot,
		    '.sIFR-root { color:#ffffff;}'
	],
        offsetTop: -2,
        tuneHeight: -8,
        preventWrap: true,
        forceSingleLine: true,
        transparent: true,
        onReplacement: function(fi)
        {
            LoadAfterSifrHeaders();
        }
    });
}

function LoadSifrH1Bottom(selectorPrefix, color)
{
    sIFR.replace(tradeGothic, {
        selector: selectorPrefix + ' h1 .bottom',
        ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],
        css: [
            '.white { color: #ffffff; }',
            sifrRoot,
            sifrRootTradeGothic,
		    '.sIFR-root {  color:' + color + ';}'
	],
        offsetTop: -10,
        tuneHeight: -26,
        tuneWidth: 2,
        preventWrap: true,
        forceSingleLine: true,
        transparent: true
    });
}

function LoadSifrH2Bottom(selectorPrefix, color)
{
    sIFR.replace(tradeGothic, {
        selector: selectorPrefix + ' h2.center .bottom',
        ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],
        css: [
            '.white { color: #ffffff; }',
            sifrRoot,
            sifrRootTradeGothic,
		    '.sIFR-root { color:' + color + '; leading:-12; text-align:center;}'
	],
        offsetTop: -8,
        tuneHeight: -18,
        tuneWidth: 2,
        transparent: true,
        onReplacement: function(fi)
        {
            LoadAfterSifrHeaders();
        }
    });
    
    sIFR.replace(tradeGothic, {
        selector: selectorPrefix + ' h2 .bottom',
        ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],
        css: [
            '.white { color: #ffffff; }',
            sifrRoot,
            sifrRootTradeGothic,
		    '.sIFR-root { color:' + color + '; leading:-12;}'
	],
        offsetTop: -8,
        tuneHeight: -18,
        tuneWidth: 2,
        transparent: true,
        onReplacement: function(fi)
        {
            LoadAfterSifrHeaders();
        }
    });
}

function LoadSifrHeaderTags(selectorPrefix)
{
    LoadSifrH1Top(selectorPrefix);
        
    LoadSifrH1Bottom(selectorPrefix + ' .alt-text-color.blue', '#062c27');
    LoadSifrH1Bottom(selectorPrefix + ' .alt-text-color.red', '#e9af1e');
    LoadSifrH1Bottom(selectorPrefix + ' .alt-text-color.orange', '#754010');
    LoadSifrH1Bottom(selectorPrefix + ' .alt-text-color.green', '#F9FF00');
    LoadSifrH1Bottom(selectorPrefix + ' .white', '#ffffff');
    LoadSifrH1Bottom(selectorPrefix + ' .blue', '#0aa59f');
    LoadSifrH1Bottom(selectorPrefix + ' .red', '#d83535');
    LoadSifrH1Bottom(selectorPrefix + ' .orange', '#e9af1e');
    LoadSifrH1Bottom(selectorPrefix + ' .green', '#d1d400');
    LoadSifrH1Bottom(selectorPrefix + ' .yellow', '#ffcc00');
    

    LoadSifrH2Bottom(selectorPrefix + ' .alt-text-color.fancyborder.red', '#ffffff');
    LoadSifrH2Bottom(selectorPrefix + ' .alt-text-color.blue', '#062c27');
    LoadSifrH2Bottom(selectorPrefix + ' .alt-text-color.red', '#e9af1e');
    LoadSifrH2Bottom(selectorPrefix + ' .alt-text-color.orange', '#754010');
    LoadSifrH2Bottom(selectorPrefix + ' .alt-text-color.green', '#F9FF00');
    LoadSifrH2Bottom(selectorPrefix + ' .white', '#ffffff');
    LoadSifrH2Bottom(selectorPrefix + ' .blue', '#0aa59f');
    LoadSifrH2Bottom(selectorPrefix + ' .red', '#d83535');
    LoadSifrH2Bottom(selectorPrefix + ' .orange', '#e9af1e');
    LoadSifrH2Bottom(selectorPrefix + ' .green', '#d1d400');
    LoadSifrH2Bottom(selectorPrefix + ' .yellow', '#ffcc00');

    LoadSifrH2Top(selectorPrefix);
}
function LoadSifrHeroBoxes(selectorPrefix)
{
    ReLoadSifrHeroBoxes(selectorPrefix);
}
function ReLoadSifrHeroBoxes(selectorPrefix)
{
    sIFR.replace(tradeGothic, {
        selector: selectorPrefix + ' .hero-box .highlight',
        ratios: [9, 1.16, 16, 1.09, 24, 1.06, 37, 1.04, 74, 1.02, 1.01],
        css: [
        sifrRoot,
        sifrRootTradeGothic,
		'.sIFR-root { color:#ffcc00;leading:-18;}'		
	],
        offsetTop: -10,
        tuneHeight: -22,
        transparent: true,
        onReplacement: function(fi)
        {
            PositionTabSelector();
        }
    });
}
