var originalFontSize;
var currentStep = 0;

$(document).ready(function() {

    setup_print_friendly();

    // alert($(this).attr('title') + ":" + $(location).attr('href'));

    // add a "rel" attrib if Opera 7+
    if (window.opera) {
        if ($("a.jqbookmark").attr("rel") != "") { // don't overwrite the rel attrib if already set
            $("a.jqbookmark").attr("rel", "sidebar");
        }
    }

    $("a.jqbookmark").click(function(event) {
        event.preventDefault(); // prevent the anchor tag from sending the user off to the link
        var url = $(location).attr('href');
        // alert("href:" + url);
        var title = $(document).attr('title');


        if (window.chrome) {
            alert("Press <Control>+D to bookmark in Chrome");
            return false;
        }
        if (window.sidebar) { // Mozilla Firefox Bookmark
            // alert("sidebar");
            window.sidebar.addPanel(title, url, "");
        } else if (window.external) { // IE Favorite
            // alert("external");
            window.external.AddFavorite(url, title);
        } else if (window.opera) { // Opera 7+
            // alert("opera");
            return false; // do nothing - the rel="sidebar" should do the trick
        } else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
            alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
        }

    });


    // alert($(".emaillink").attr('href'));
    var strhref = $(".emaillink").attr('href');
    if (strhref == undefined) {
       //  alert("strhref undefined");
    }
    else {
        strhref = strhref.replace("BODY", window.location.href);
        $(".emaillink").attr('href', strhref);
    }
});

function setup_print_friendly() {
    checkprint();
}

function checkprint() {
    // alert("checkprint");
    strurl = window.location.href;
    if (window.location.href.indexOf("#printpage") != -1) {
        // alert("print: " + b["print"]);
        // alert("printpage found");
        strCss = $("link[id*='printcss']").attr("href");
        strCss = strCss.replace("print_empty.css", "print.css");
        $("link[id*='printcss']").attr("href", strCss);
        $("#sub_main_content2_print_back_page").show();
        printurl = strurl.replace("#printpage", "");
        $('.printpageurl').attr('href', printurl);

    }
    else {
    
    }
  
}


function create_print_page() {

    var newurl;
    strurl = window.location.href;

    if (strurl.indexOf("#printpage") < 0) {
        // alert("printpage not found");
        $('.printpageurl').attr('href', strurl);
        window.location.href = window.location.href + "#printpage";
        strCss = $("link[id*='printcss']").attr("href");
        strCss = strCss.replace("print_empty.css", "print.css");
        $("link[id*='printcss']").attr("href", strCss);
        $("#sub_main_content2_print_back_page").show();
        
        
    }
    else {
         window.location.href = window.location.href;
    }
}

function changeFontSize(step) {
    var intStep = parseInt(step);
    currentStep = currentStep + intStep;

    // alert("currentStep:" + currentStep + ":" + step);
    if (currentStep > 8 || currentStep < -5) {
        return false;
    }

    var currentFontSizeNum;
    var newFontSize;
    var currentFontSize;

    currentFontSize = $('#leftnavlinks a').css('font-size');
    if (currentFontSize != undefined) {
        // alert("currentFontSize:" + currentFontSize);
        currentFontSizeNum = parseInt(currentFontSize);
        newFontSize = currentFontSizeNum + intStep;
        // alert("newFontSize:" + newFontSize);
        $('#leftnavlinks a').css('font-size', newFontSize);
    }
    
    var currentFontSize_2 = $('#sub_main_content2_1').css('font-size');
    // alert("font 2:" + $('#sub_main_content2_1').css('font-size'));
    if (currentFontSize_2 != undefined) {
        currentFontSizeNum = parseInt(currentFontSize_2);
        var newFontSize_2 = currentFontSizeNum + intStep;
        $('#sub_main_content2_1').css('font-size', newFontSize_2);
    }

    var currentFontSize_3 = $('.breadcrumbs').css('font-size');
    if (currentFontSize_3 != undefined) {
        currentFontSizeNum = parseInt(currentFontSize_3);
        var newFontSize_3 = currentFontSizeNum + intStep;
        $('.breadcrumbs').css('font-size', newFontSize_3);
    }
    
    var currentFontSize_4 = $('.rightnavBtn11_mid_text').css('font-size');
    if (currentFontSize_4 != undefined) {
        currentFontSizeNum = parseInt(currentFontSize_4);
        var newFontSize_4 = currentFontSizeNum + intStep;
        $('.rightnavBtn11_mid_text').css('font-size', newFontSize_4);
    }

    var currentFontSize_5 = $('.breadcrumbs a').css('font-size');
    if (currentFontSize_5 != undefined) {
        // alert("currentFontSize b:" + currentFontSize_5);
        currentFontSizeNum = parseInt(currentFontSize_5);
        var newFontSize_5 = currentFontSizeNum + intStep;
        // alert("newfontsize b:" + newFontSize_5);
        $('.breadcrumbs a').css('font-size', newFontSize_5);
    }

    currentFontSize = $('#defaultmainContenet1').css('font-size');
    if (currentFontSize != undefined) {
        // alert("currentFontSize:" + currentFontSize);
        currentFontSizeNum = parseInt(currentFontSize);
        // alert("currentFontSizeNum:" + currentFontSizeNum);
        var newFontSize = currentFontSizeNum + intStep;
        // alert("newfontsize" + newFontSize);
        $('#defaultmainContenet1').css('font-size', newFontSize);
    }

    currentFontSize = $('.defaultmainhead').css('font-size');
    if (currentFontSize != undefined) {
        // alert("currentFontSize:" + currentFontSize);
        currentFontSizeNum = parseInt(currentFontSize);
        // alert("currentFontSizeNum:" + currentFontSizeNum);
        var newFontSize = currentFontSizeNum + intStep;
        // alert("newfontsize" + newFontSize);
        $('.defaultmainhead').css('font-size', newFontSize);
    }

    currentFontSize = $('#defaultmainContenet2 ul li').css('font-size');
    if (currentFontSize != undefined) {
        // alert("currentFontSize:" + currentFontSize);
        currentFontSizeNum = parseInt(currentFontSize);
        // alert("currentFontSizeNum:" + currentFontSizeNum);
        var newFontSize = currentFontSizeNum + intStep;
        // alert("newfontsize" + newFontSize);
        $('#defaultmainContenet2 ul li').css('font-size', newFontSize);
    }

    currentFontSize = $('#defaultmainContenet3').css('font-size');
    if (currentFontSize != undefined) {
        // alert("currentFontSize:" + currentFontSize);
        currentFontSizeNum = parseInt(currentFontSize);
        // alert("currentFontSizeNum:" + currentFontSizeNum);
        var newFontSize = currentFontSizeNum + intStep;
        // alert("newfontsize" + newFontSize);
        $('#defaultmainContenet3').css('font-size', newFontSize);
    }

    currentFontSize = $('#defaultmainContenet3 ul li').css('font-size');
    if (currentFontSize != undefined) {
        // alert("currentFontSize:" + currentFontSize);
        currentFontSizeNum = parseInt(currentFontSize);
        // alert("currentFontSizeNum:" + currentFontSizeNum);
        var newFontSize = currentFontSizeNum + intStep;
        // alert("newfontsize" + newFontSize);
        $('#defaultmainContenet3 ul li').css('font-size', newFontSize);
    }


    return false;
}
