Subversion Repositories SmartDukaan

Rev

Rev 1922 | Rev 2235 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function(){
        $('#loopedSlider').loopedSlider();
        
        runEffect();
        
        $(".controls").tabs();
        
        $('#forgot_username_link').tipsy({gravity: 'w'});

        $("#zipcode").val($("#defaultpincode").val());

    updateEstimate();
    
    var prodid = $("#product_id").val();
    
        add_to_storage_set("histitems", prodid);
    
    load_history_widget();

    /**
     * Code to track user clicks on Product slides and 'Proceed to Payment' option
     */
        $('a.vt').click(function(){
                trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());
        });
        
    $("#addcart").click(function(){
                jQuery.ajax({
                        type: "POST",
                        url: "/addtocart",
                        data: "productid=" + $("#item_id").val(),
                        success: function(msg)  {
                                 if(msg==""){
                                         window.location = "/cart";
                                 }else{
                                         alert(msg);
                                 }                      }
                });
        });
        
        $("#colorselector").change(function(){
                var output = "";
                var itemid = $("#colorselector option:selected").val();

                $('#sp').html(PARAMETERS[itemid].SP);
                $('#mrp').html(PARAMETERS[itemid].MRP);
                $('#saving').html(PARAMETERS[itemid].SAVING);
                $("#item_id").val(itemid);
                updateEstimate(itemid);
                return false;
        });
        
        $("a.colorselector").click(function() {
                $('.a.colorselector').addClass('deselect');
                $(this).addClass('deselect');
                var itemid = $(this).attr('itemid');
                $('#sp').html(" "+PARAMETERS[itemid].SP);
                $('#mrp').html(" "+PARAMETERS[itemid].MRP);
                $('#saving').html(PARAMETERS[itemid].SAVING);
                $("#item_id").val(itemid);
                return false;
        });
});

function changeSignInClass(){
        if(document.getElementById("signinClass").className.indexOf("signin1") > -1)    {
                document.getElementById("signinClass").className = 'signin';
        } else  {
                document.getElementById("signinClass").className = 'signin1';
        }
}

function updateEstimate(itemId) {
        itemId = itemId || $("#item_id").val();
        
        jQuery.ajax({
                type: "GET",
                url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
                beforeSend: function()  {
                        $("#days").html("<img src='../images/loader_l.gif'>");
                },
                success: function(msg)  {
                        $("#shipping_time").html(msg);
                }
        });
}