﻿function externalSite(src) {
    var externalSite = window.open(src);
    externalSite.focus();
    //return false;
}

function PopItUp(src, w, h, s) {
    if (s) w = w + 17;
    if (w) {
        Popwin = window.open(src, "pop_up", "toolbar=0,width=" + w + ", height=" + h + ", location=0, directories=0, status=1, scrollbars=" + s + ", menubar=0, resizable=0, copyhistory=0");
        Popwin.focus();
    }
    else {
        window.location = src
    }
}


function str_replace(search, replace, subject, count) {
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
					f = [].concat(search),
					r = [].concat(replace),
					s = subject,
					ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i = 0, sl = s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j = 0, fl = f.length; j < fl; j++) {
            temp = s[i] + '';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length - s[i].length) / f[j].length;
            }
        }
    }
    return sa ? s : s[0];
}

var str1 = window.location.pathname;
var pieces = str1.split('/');
alt1 = [];
alt2 = [];
alt1.push("-");
alt2.push("");
actword = str_replace(alt1, alt2, pieces[1]).toLowerCase();
//console.log(actword);


$(document).ready(function() {

    //SSS show-hide

    $('.sss div').hide();
    $('.sss h3').click(function() {
        if ($(this).hasClass('active')) {
            $(this).removeClass('active');
            $(this).next().hide();
        }
        else {
            $('.sss div').hide();
            $('.sss h3').removeClass('active');
            $(this).addClass('active');
            $(this).next().show()
        }
    });

    //form show-hide

    $('.formcont').hide();
    $('.f1').show();

    $("#formswitch a").click(function() {
        $("#formswitch a").removeClass('factive');
        $('.displayerrors').html('');
        $('.displayerrors').hide();
        $(this).addClass('factive');
        var formpos = $("#formswitch a").index(this) + 1;
        $('.formcont').hide();
        $('.f' + formpos).fadeIn('fast');
        return false;
    });

    //isube show-hide

    $("#isube").hover(
        function() {
            $(this).addClass('open');
            $('#rest').hide();
            $('#sbuttons').show();
        },
        function() {
            $(this).removeClass('open');
            $('#sbuttons').hide();
            $('#rest').show();

        }
    );

    $('#wrapper').addClass(actword);

    // pagecontrols

    function resizeText() {
        $('#cwide').attr("class", "size" + sizepos);
    }

    var sizepos = 1;
    $("#pc1").click(function() {
        if (sizepos < 3) {
            sizepos++;
            resizeText();
        }
        return false;
    });

    $("#pc2").click(function() {
        if (sizepos > 0) {
            sizepos--;
            resizeText();
        }
        return false;
    });

    $("#pc3").click(function() {
        sizepos = 1;
        resizeText();
        return false;
    });

    $("#pc4").click(function() {
        window.print();
        return false;
    });


    // min-height

    if ($('#cnarrow').height() < 550) {
        $('#cnarrow').css('height', '550px');
    }

    // hover

    $('.selected').children('a').addClass('rs');

});

    
    

