Subversion Repositories SmartDukaan

Rev

Rev 1567 | Rev 1623 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1456 varun.gupt 1
$(function(){
2
	$('#loopedSlider').loopedSlider();
3
 
4
	runEffect();
5
 
6
	$(".controls").tabs();
7
 
8
	$('#forgot_username_link').tipsy({gravity: 'w'});
9
 
10
	$("#zipcode").val($("#defaultpincode").val());
11
 
12
    updateEstimate();
13
 
1614 rajveer 14
    if($.cookie("uid")){
15
    	load_history_widget(true);
16
    }else{
17
    	if($.Storage.get("historyitems")){
18
    		var prodid = $("#product_id").val();
19
    		var hisitems = $.Storage.get("historyitems");
20
    		if (hisitems.indexOf(prodid) < 0){
21
    			//alert("prodid is" + prodid);
22
    			$.Storage.set("historyitems",  hisitems + "-" + prodid);
23
    		}
24
 
25
    	}else{
26
    		$.Storage.set("historyitems",  $("#product_id").val());
27
    	}
28
    	load_history_widget(false);
29
    }
1456 varun.gupt 30
 
31
	$("#addcart").click(function(){
32
		jQuery.ajax({
33
			type: "POST",
1614 rajveer 34
			url: "/addtocart",
1456 varun.gupt 35
			data: "productid=" + $("#item_id").val(),
36
			success: function(msg)	{
37
				$("#cartItemCount").html((msg*1));
38
				window.location = "/cart";
39
			}
40
		});
41
	});
42
 
43
	$("#colorselector").change(function(){
44
		var output = "";
45
		var itemid = $("#colorselector option:selected").val();
46
 
47
		$('#sp').html(PARAMETERS[itemid].SP);
48
		$('#mrp').html(PARAMETERS[itemid].MRP);
49
		$('#saving').html(PARAMETERS[itemid].SAVING);
50
		$("#item_id").val(itemid);
51
		updateEstimate(itemid);
52
		return false;
53
	});
54
 
55
	$("a.colorselector").click(function() {
56
		$('.a.colorselector').addClass('deselect');
57
		$(this).addClass('deselect');
1567 vikas 58
		var itemid = $(this).attr('itemid');
1456 varun.gupt 59
		$('#sp').html(" "+PARAMETERS[itemid].SP);
60
		$('#mrp').html(" "+PARAMETERS[itemid].MRP);
61
		$('#saving').html(PARAMETERS[itemid].SAVING);
62
		$("#item_id").val(itemid);
63
		return false;
64
	});
65
});
66
 
67
function changeSignInClass(){
68
	if(document.getElementById("signinClass").className.indexOf("signin1") > -1)	{
69
		document.getElementById("signinClass").className = 'signin';
70
	} else	{
71
		document.getElementById("signinClass").className = 'signin1';
72
	}
73
}
74
 
75
function updateEstimate(itemId)	{
76
	itemId = itemId || $("#item_id").val();
77
 
78
	jQuery.ajax({
79
		type: "GET",
80
		url: "../estimate/" + $("#zipcode").val() + "_" + itemId,
81
		beforeSend: function()	{
82
			$("#days").html("<img src='../images/loader_l.gif'>");
83
		},
84
		success: function(msg)	{
85
			$("#shipping_time").html(msg);
86
		}
87
	});
88
}