﻿$(document).ready(function() {
       
       $("a.details").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'scrolling'     :   'no',
		'speedIn'		:	600, 
		'speedOut'		:	200
	});
	
	$("a.cal").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'scrolling'     :   'no',
		'height'        :   500,
		'width'         :   700,
		'speedIn'		:	600, 
		'speedOut'		:	200
	});

       
        $(".quote_box_container.new").click(function() {
            $("#signup").slideDown();
        });
        $(".quote_box_container.existing").click(function() {
            $("#signin").slideDown();
        });
 });
 
 function AddToBasket() {
    var product = $(".productinfo input:first").val();
    var size = 0;
    var sizeCount = 0;

    //  handle products without colours
    if (colour == undefined) colour = 0;

    //  see if this product has sizes
    $(".productsizeoptions td.select").each(function() {
        sizeCount += 1;
        if ($(this).find("input").attr("checked")) size = $(this).find("input").val();
    });

    //  build the JSON string.
    var JSON = "{" +
               " 'Product_ID' : '" + product + "' , " +
               " 'Colour_ID' : '" + colour + "' , " +
               " 'Size_ID' : '" + size + "' " +
               "}";

    //  call the web service passing the product and options
    //  and then retrieve the price.
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "/Assets/FearnleyCricket/WebServices/FearnleyCricket.asmx/GetPrice",
        data: JSON,
        dataType: "json",
        success: function(response) {
            var oResponse = eval("(" + response.d + ")");

            if (oResponse.Valid) {
                $("span.price").html(oResponse.Data);
            }
        },
        error: function(response) {
            alert(response.responseText);
        }
    });
}
