Subversion Repositories SmartDukaan

Rev

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