$(function(){
    $('a.info').each(function(){
       $(this).fancybox({
        'overlayShow':          false,
        'frameWidth':           546,
        'frameHeight':          505 
       }); 
    });
});

$(function(){
    $('a.button').each(function(){
       $(this).fancybox({
        'overlayShow': true
       }); 
    });
});

$(function(){
    $("input.actiecode").each(function(){
        
        $(this).click(function(){
            $(this).val('');
            
        });
        
        $(this).keyup(
          function() { checkActionCodes(this); }
        ); 
    });
})

function checkActionCodes(obj) {

       var code = $(obj).val();
       
       if(code != '' && code != 'actiecode') {
           $.post(
            ABS_URI+'ajax/check_code.php',
            {
                'code'  : code,
                'pid'   : obj.name
            },
            function(data) {
               if(data.valid) {
                   $(obj).attr('disabled', true);
                   $(obj).addClass('check');
                   cartCalculation();
               }
           },"json");
       } 

    
    return true;
}

$(function() {
    element = $('#tellafriend-form');
    if(element.attr('id') == 'tellafriend-form') {
        element.submit(
            function() {
                own_email   = $('input[name=own_email]');
                own_name    = $('input[name=own_name]');
                if( (own_name.val() != '') && (own_email.val() != '') ) {
                    return true;
                } else {
                    own_email.addClass('verplicht');
                    own_email.focus(
                        function() { $(this).removeClass('verplicht') }
                    );
                    
                    own_name.addClass('verplicht');
                    own_name.focus(
                        function() { $(this).removeClass('verplicht') }
                    );
                    return false;
                }
            }
        );
    }
});