function initElements() {
    initProductElements();
    $('.ebCatalogueBox').hover(overCatalogueBox, overCatalogueBox);
    $('#ebProductCompare').find('.remove').click(removeCompareProduct);
}
function initProductElements() {
    $('.ebButton.compare').click(compareProduct);
}
function overCatalogueBox() {
    $(this).toggleClass('over');
}
function compareProduct() {
    var nProductId = $(this).attr('name').split('_')[1];
    /* 2. haal product op */
    sUrl = 'rightclick-ajax.cfm?id=627285';
    $.get(sUrl, {product_id: nProductId}, function(sHtml) {
        /* 3. insert & attach handlers & show & save to cookie */
        $('#ebProductCompare').prepend(sHtml).find('.ebProductCompareBox:first-child').css('width', 0).css('opacity', 0).animate({width: 45, opacity: 100}).find('.remove').click(removeCompareProduct).end().end().find('.ebProductCompareBox:eq(3)').animate({width: 0, opacity: 0}, function() {
            $(this).remove();
            setProductCompareCookie();
        });
    });
   
    /* 4. transfer */
    
    $(this).TransferTo({
        to: 'ebProductCompare'
        , className: 'ebTransferer'
        , duration: 500
    });
}
function setProductCompareCookie() {
    var a = [];
    $('#ebProductCompare').find('input:hidden').each(function(){a.push(this.value)});
    goRCCookie.set('compareProducts', a.join(','));
}
function removeCompareProduct() {
    sUrl = 'rightclick-ajax.cfm?id=627285';
    $.get(sUrl, {product_id: 0}, function(sHtml) {
        /* 3. insert & attach handlers & show */
        $('#ebProductCompare').append(sHtml).find('.ebProductCompareBox:last-child').css('width', 0).css('opacity', 0).animate({width: 45, opacity: 100}).find('.remove').click(removeCompareProduct);
    });
    $(this).parents('.ebProductCompareBox').hide(function() {
        $(this).remove();
        setProductCompareCookie();
    });
}

function getkey(e) {
    if (window.event)
        return window.event.keyCode;
    else if (e)
        return e.which;
    else
        return null;
}

function goodchars(e, goods) {
    var key, keychar;
    key = getkey(e);
    if (key == null)
        return true;
    // get character
    keychar = String.fromCharCode(key);
    keychar = keychar.toLowerCase();
    goods = goods.toLowerCase();
    // check goodkeys
    if (goods.indexOf(keychar) != -1)
        return true;
    // control keys
    if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
        return true;
    // else return false
    return false;
}

/*
    stripe tables:
    - all even rows in tables with class 'stripeMe' will be given an extra class 'alt'. 
    - e.g. use '.stripeMe tr' in css for uneven rows, '.stripe tr.alt' for even rows
*/
$(document).ready(function() {
    $('.stripeMe tr:even').addClass('alt'); 
}); 
 