function startOrder (product) {

    $.post('/services/verify-product/'+product+'/', {'verify': Math.random()}, function(result) {

        if(result== 1) {

            $.post('/services/verify-session/', {'verify': Math.random()}, function(result) {
                
                if(result== 1) {

                    showDialog('/forms/order-product/'+product);

                } else {

                    showDialog('/forms/enter-card/'+product);

                }

            });

        }

    });

}

function updateCart (item) {

    $.post('/shop/cart/update/', {'item': item, 'quantity': $('#cart-item-'+item).val()}, function (result) {

        if(result== 1) {

            document.location= '/shop/cart/';

        } else {
        
            alert('Je hebt een ongeldig aantal opgegeven')

        }

    });

}

function showDialog (url) {

    var page_size= get_page_size();
    var page_scroll= get_page_scroll();

    $('#dialog iframe').attr('src', url);
    $('#dialog').css({
        top: 105 + page_scroll[1]
    });

    $('#dialog').show();
    $('#fade').show();
    $('#fade').css('height', page_size[1] + page_scroll[1] + 'px');
    $('#fade').css('width', '100%');

}

function hideDialog () {

    $('#dialog iframe').attr('src', 'about:blank');
    $('#dialog').hide();
    $('#fade').hide();

}

function get_page_size() {

    var x_scroll, y_scroll;

    x_scroll= $(document).width();
    y_scroll= $(document).height();

    var window_width, window_height;

    window_width= $(window).width();
    window_height= $(window).height();

    if(y_scroll < window_height) {

        page_height= window_height;

    } else {

        page_height= y_scroll;

    }

    if(x_scroll < window_width) {

        page_width= x_scroll;

    } else {

        page_width= window_width;

    }

    array_page_size= new Array(
        page_width,
        page_height,
        window_width,
        window_height
    );

    return array_page_size;

}

function get_page_scroll() {

    var x_scroll, y_scroll;

    if (self.pageYOffset) {

        y_scroll= self.pageYOffset;
        x_scroll= self.pageXOffset;

    } else if (document.documentElement && document.documentElement.scrollTop) {

        y_scroll= document.documentElement.scrollTop;
        x_scroll= document.documentElement.scrollLeft;

    } else if (document.body) {

        y_scroll= document.body.scrollTop;
        x_scroll= document.body.scrollLeft;

    }

    array_page_scroll= new Array(x_scroll, y_scroll);

    return array_page_scroll;

}

/*$(document).ready(function() {

    $('a').click(function() {
        var $a= $(this);
        var href= $a.attr('href');
 
        if (href && href.match(/^http/i) && !href.match(document.domain)) {
            var category = 'outgoing';
            var event = 'click';
            var label = href;
            pageTracker._trackEvent(category, event, href);
        }
    }); 

    setTimeout("$('#notice').hide();", 30000);

});*/

Cufon.replace('h1', {
    color: '-linear-gradient(#9f9c9c, #373837)'
});

Cufon.replace('.link-back', {
    'font-size': '8px'
});
