﻿// prevent a Form submir with ENTER
document.onkeypress = function(objEvent) {
    if (!objEvent)
        var objEvent = window.event; // IE

    // check if the target is a textarea element
    var elem = (objEvent.target) ? objEvent.target : objEvent.srcElement;
    if (elem.type == "textarea") {
        // a textarea has the focus, allow Enter
        return true;
    }

    if (objEvent.keyCode == 13) // enter key
    {
        return false; // this will prevent bubbling ( sending it to children ) the event!
    }
}

function FixRadioStyle() {
    jQuery(":radio").css("border", "none");
    jQuery(":checkbox").css("border", "none");
}

function DecreaseFont(min) {
    var val = GetResizeFontCookie();
    if (val > min) {
        var currentFontSize = jQuery('.MainContentPlaceDiv').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 0.85;
        jQuery('.MainContentPlaceDiv').css('font-size', newFontSize);
        SetResizeFontCookie(val - 1);
    }
}

function IncreaseFont(max) {
    var val = GetResizeFontCookie();
    if (val < max) {
        var currentFontSize = jQuery('.MainContentPlaceDiv').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 1.15;
        jQuery('.MainContentPlaceDiv').css('font-size', newFontSize);
        SetResizeFontCookie(val + 1);
    }
}

function ResetFont(originalFontSize) {
    SetResizeFontCookie(0);
    jQuery('.MainContentPlaceDiv').css('font-size', originalFontSize);
}

function ResizeFont() {
    var val = GetResizeFontCookie();
    if (val > 0) {
        for (i = 0; i < val; i++) {
            IncreaseFont(100);   
        }
    }
    else if (val < 0) {
        for (i = 0; i > val; i--) {
            DecreaseFont(-100);
        }
    }
    SetResizeFontCookie(val);
}

function GetResizeFontCookie()
{
    if(jQuery.cookie("fontresize") != null)
    {
        return parseInt(jQuery.cookie("fontresize"));
    }
    else
    {
        return 0;
    }
}

function SetResizeFontCookie(val){
    jQuery.cookie("fontresize", val, { path: '/', expires: 2 })
}
