Subversion Repositories SmartDukaan

Rev

Rev 1614 | Rev 1919 | 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();
    
    if(!($.cookie("uid"))){
        if($.Storage.get("historyitems")){
                var prodid = $("#product_id").val();
                var hisitems = $.Storage.get("historyitems");
                if (hisitems.indexOf(prodid) < 0){
                        //alert("prodid is" + prodid);
                        $.Storage.set("historyitems",  hisitems + "-" + prodid);
                }
                
        }else{
                $.Storage.set("historyitems",  $("#product_id").val());
        }
    }
        
    load_history_widget();
    
        $("#addcart").click(function(){
                jQuery.ajax({
                        type: "POST",
                        url: "/addtocart",
                        data: "productid=" + $("#item_id").val(),
                        success: function(msg)  {
                                $("#cartItemCount").html((msg*1));
                                window.location = "/cart";
                        }
                });
        });
        
        $("#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);
                }
        });
}