$(document).ready(function() {
    $(".rollover").hover(
            function() {
                if ($(this).attr("src").indexOf("_on") == -1) {
                    var newSrc = $(this).attr("src").replace("_off.png", "_on.png");
                    $(this).attr("src", newSrc);
                }
            },
            function() {
                if ($(this).attr("src").indexOf("_on") != -1) {
                    var oldSrc = $(this).attr("src").replace("_on.png", "_off.png");
                    $(this).attr("src", oldSrc);
                }
            })
});

$.preloadImages = function() {
    for (var i = 0; i < arguments.length; i++) {
        img = new Image();
        img.src = arguments[i];
    }
}

$.preloadImages(
        "/images/menu/food_on.png",
        "/images/menu/gift_cards_on.png",
        "/images/menu/kids_on.png",
        "/images/menu/RR_eclub_on.png",
        "/images/rrfoundation/RRF_01_on.png",
        "/images/rrfoundation/RRF_02_on.png",
        "/images/rrfoundation/RRF_03_on.png",
        "/images/rrfoundation/RRF_04_on.png"
        );
/*
    Clear pre-populated fields in the find section.
*/
function clearTextbox(ele) {
    if (ele.value == 'City Name') {
        ele.value = "";
    }
    if (ele.value == 'Zip Code') {
        ele.value = "";
    }
}

/*
All Pages: Facebook and Find a location sections
Used to send information to double click via iframe
*/
function switchOnFloodLight(params) {
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.getElementById('floodlight').innerHTML = '<iframe src="http://fls.doubleclick.net/activityi;' + params + ';ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>';
return true;
}

/*
Food : Burger Browser
Used on the burger browser page to associate the burgers found in the flash page with the customizer burgers.
*/
function customize(customURL) {
    // var burgers = new Array("11", "300", "10", "49", "298", "4517", "8", "50", "437", "1", "54", "553", "3252", "3439", "484", "7", "9");
    GB_customizer('', customURL, 850, 952);
}


/*
Used to launch 
*/
function burgerblaster() {
    GB_greyboxGame('', 'http://www.redrobin.com/games/burgerblaster/', 680, 950);
}
function sciencekids() {
    GB_greyboxGame('', 'http://stg.redrobin.com/games/sciencekids/', 567, 810);
}

/*
Used to launch 
*/
function opengamewindow() {
    GB_greyboxGame('', 'http://www.redrobin.com/games/gonefishin/', 680, 950);
}

function IsNumeric(e, isUsingEnter) {
    var keyCode = e.which ? e.which : e.keyCode;
    if (keyCode == 8 || keyCode == 9) {
        return true;
    }
    if (isUsingEnter) {
        if (keyCode == 13) {
            event.returnValue = false;
            event.cancel = true;
            document.getElementById('ctl00_MainContent_Button2').click();
        }
    }
    if (keyCode == 46 || (keyCode >= 48 && keyCode <= 57)) {
        if (keyCode == 46) {
            var sCurrVal = $get(event.srcElement.id).value
            if (sCurrVal.indexOf(".") > -1) {
                return false;
            }
        }
        return true;
    } else {
        return false;
    }
}
