﻿// Main

////window.addEvent('domready', function() {
////    replaceHeaders();
////});

////// sIFR header replacement

////function replaceHeaders() {
////    if (typeof sIFR == "function") {
////        //sIFR.replaceElement(named({sSelector:'h1', sFlashSrc:'/Flash/aldo.swf', sColor: '#d4470f', sCase: 'upper', sWmode: 'transparent'}));
////        sIFR.replaceElement(named({ sSelector: '#page_title h2', sFlashSrc: '/Flash/monalisa.swf', sColor: '#b5121b', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'h2.mona_lisa_red', sFlashSrc: '/Flash/monalisa.swf', sColor: '#b5121b', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'h2.mona_lisa_green', sFlashSrc: '/Flash/monalisa.swf', sColor: '#6d8d24', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'span.trade_gothic_red', sFlashSrc: '/Flash/tradegothic.swf', sColor: '#b5121b', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'span.trade_gothic_green', sFlashSrc: '/Flash/tradegothic.swf', sColor: '#6d8d24', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'div.recipe_featured div.content h3', sFlashSrc: '/Flash/tradegothic_regular.swf', sColor: '#b5121b', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'div.recipe h3', sFlashSrc: '/Flash/tradegothic_regular.swf', sColor: '#b5121b', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: '#featured_specials h3', sFlashSrc: '/Flash/tradegothic_regular.swf', sColor: '#6d8d24', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'div.box h3', sFlashSrc: '/Flash/tradegothic_regular.swf', sColor: '#6d8d24', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'div.misc_callout h3', sFlashSrc: '/Flash/tradegothic_regular.swf', sColor: '#6d8d24', sWmode: 'transparent' }));
////        sIFR.replaceElement(named({ sSelector: 'div.green_box div.content h3', sFlashSrc: '/Flash/tradegothic_regular.swf', sColor: '#f5dfc4', sWmode: 'transparent' }));
////        //sIFR.replaceElement(named({ sSelector: 'div.green_box div.content p', sFlashSrc: '/Flash/ tradegothic_regular.swf', sColor: '#ffffff', sWmode: 'transparent' }));
////        //sIFR.replaceElement(named({sSelector:'h3', sFlashSrc:'/Flash/aldo.swf', sColor: '#94948f', sCase: 'upper', sWmode: 'opaque'}));
////        sIFR.setup();
////    }
////}


$(document).ready(function() {
    $('#page_title h2').sifr({ path: 'flash/', font: 'monalisa', roY: 6.5, color: '#b5121b'});
    $('h2.mona_lisa_red').sifr({ path: 'flash/', font: 'monalisa', roY: 6.5, color: '#b5121b', fontSize: '32px' });
    $('h2.mona_lisa_green').sifr({ path: 'flash/', font: 'monalisa', roY: 6.5, color: '#6d8d24', fontSize: '32px' });
    $('span.trade_gothic_red').sifr({ path: 'flash/', font: 'tradegothic', roY: 6.5, color: '#b5121b'});
    $('span.trade_gothic_green').sifr({ path: 'flash/', font: 'tradegothic', roY: 6.5, color: '#6d8d24' });
    $('div.recipe_featured div.content h3').sifr({ path: 'flash/', font: 'tradegothic_regular', roY: 6.5, color: '#b5121b' });
    $('div.recipe h3').sifr({ path: 'flash/', font: 'tradegothic_regular', roY: 6.5, color: '#b5121b' });
    $('#featured_specials h3').sifr({ path: 'flash/', font: 'tradegothic_regular', roY: 6.5, color: '#6d8d24' });
    $('div.box h3').sifr({ path: 'flash/', font: 'tradegothic_regular', roY: 6.5, color: '#6d8d24' });
    $('div.misc_callout h3').sifr({ path: 'flash/', font: 'tradegothic_regular', roY: 6.5, color: '#6d8d24' });
    $('div.green_box div.content h3').sifr({ path: 'flash/', font: 'tradegothic_regular', roY: 6.5, color: '#f5dfc4' });
});

//Subscription page beer div

function ShowAgeDivMain(sender) {
    if (sender.checked) {
        $(".subsBirthMonth").val('');
        $(".subsBirthYear").val('');
        $(".subsBirthDay").val('');
        $(".beerDiv").show();
        //$(".beer1 input:checkbox").removeAttr('checked');
    } else {
        $(".beerDiv").hide();
    }
}
function SubsBirthDateValidationMain() {
    $("#SubsBirthDateError").html('');
    if ($(".subsBirthDay").val() == "" || $(".subsBirthMonth").val() == "" || $(".subsBirthYear").val() == "") {
        $('#SubsBirthDateError').html("Birth date is required");
        $(".beer1 input:checkbox").removeAttr('checked');
    }
    else {
        if (validateAgeMain($(".subsBirthDay").val(), $(".subsBirthMonth").val(), $(".subsBirthYear").val()) >= 21) {
            $(".beer1 input:checkbox").attr('checked', 'checked');
        }
        else {
            $(".beer1 input:checkbox").removeAttr('checked');
            $('#SubsBirthDateError').html("You must be 21 years of age or older.");
        }
    }
}

function validateAgeMain(dd, mm, yy) {
    var currDate = $(".CurrentDate").val();
    var temp = new Array();
    temp = currDate.split("/");

    var gmonth = temp[0];
    var gdate = temp[1];
    var gyear = temp[2];
    var age = gyear - yy;
    if ((mm == (gmonth + 1)) && (dd <= parseInt(gdate))) {
        return age;
    }
    else {
        if (mm <= (gmonth)) {
            return age;
        }
        else {
            return age - 1;
        }
    }
    return age;
}
