var ERRMSG = "";
var domain = "http://discofactory.com.au";

Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

String.prototype.trim = function() { return this.replace(/^\W+|\W+$/g, ''); }

String.prototype.startsWith = function(pattern) {
    return this.indexOf(pattern) === 0;
  }

String.prototype.endsWith = function(pattern) {
    var d = this.length - pattern.length;
    return d >= 0 && this.lastIndexOf(pattern) === d;
  }



$(document).ready ( function () {
	
	highlightNav();
	
	// dev only
	//var href = $(".cartSummaryLink").attr('href');
	//$(".cartSummaryLink").attr('href', domain + href);
	//$("#header a").attr('href', function() { return domain + $(this).attr('href'); });
	//$("#hire-steps a").attr('href', function() { return domain + $(this).attr('href'); });
	
	$("#nav a").hover(
		function() { 
			$(this).find("img").attr('src', function() {
				return $(this).attr('src').replace('nav.gif', 'nav-on.gif');										 
			});					   
		},
		
		function() { 
			$(this).find("img").attr('src', function() {
				return $(this).attr('src').replace('nav-on.gif', 'nav.gif');										 
			});					   
		}	
	);
	
	
	if($.cookie('pickup-date') == null || $.cookie('delivery-date') == null)
	{
		$('#hire-date-summary').hide();
	}
	else
	{
		$('#pickup-date-txt').val($.cookie('pickup-date').split(' ')[0]);
		$('#pickup-time-sel').val($.cookie('pickup-date').split(' ')[1]);
		$('#delivery-date-txt').val($.cookie('delivery-date').split(' ')[0]);
		$('#delivery-time-sel').val($.cookie('delivery-date').split(' ')[1]);	
		$('#delivery-postcode-txt').val($.cookie('postcode'));
		
		showCommsHireDates();
	}
	
	$('#ShippingOptions').val($.cookie('postcode-district-value')).change();
	$('#shippingSpan').before($('#ShippingOptions option:selected').attr('text')); //.attr('readonly', 'readonly');
	
	//$("#DiscountCode, #GiftVoucher").change(function() { doHReplace(); showCommsHireDates(); });
	
	$('#hire-date-config-btn').click( function() {
					
		var pickup = $('#pickup-date-txt').val() + " " + $('#pickup-time-sel').val();
		var delivery = $('#delivery-date-txt').val() + " " + $('#delivery-time-sel').val();
		var postcode = $('#delivery-postcode-txt').val();
		
		if(postcode == null || postcode == "" || isNaN(postcode) || postcode.toString().length != 4)
		{
			alert('A valid Australian Postcode must be entered');	
			return;
		}
		
		if(districts[postcode] == null)
		{
			alert('We do not deliver to that postcode');	
			return;
		}
				
		if(validateDeliveryDates(delivery, pickup))
		{
			var ass = delivery.replace(/-/g, ' ');
			//alert(ass + " | " + Date.parse(ass) + " | " + new Date(Date.parse(ass)));
			var deldate = new Date(Date.parse(ass));
			ass = pickup.replace(/-/g, ' ');
			var pudate= new Date(Date.parse(ass));
			var one_day=1000*60*60*24;
			var temppu = new Date(pudate.getFullYear(), pudate.getMonth(), pudate.getDate());
			var tempdel = new Date(deldate.getFullYear(), deldate.getMonth(), deldate.getDate());
			
			var hiredays = Math.ceil((temppu.getTime()-tempdel.getTime())/(one_day));
			//alert(hiredays);
			if(hiredays < 1) hiredays = 1;
			
			$.cookie('pickup-date', pickup, {path: "/"});
			$.cookie('delivery-date', delivery, {path: "/"});
			$.cookie('change-dates-btn', null,  {path: "/"});
			$.cookie('hire-days', hiredays, {path:"/"});
			$.cookie('postcode-district-value', districts[postcode], {path:"/"});
			$.cookie('postcode', postcode, {path:"/"});
					 
			
			doOutOfStock();

			window.location = domain + "/_catalog_45871/Equipment_Hire";
		}
		else
		{
			alert(ERRMSG);	
		}
	});
	
	$('#change-hire-dates-btn, #hire-step1').click( function() {  
		if(confirm("This action will clear your cart, ok?"))
		{		
			//ClearCart($.cookie("CartID"), "45871");
			var b=CMS.OrderRetrievev2.ServerSideDrawCartEmpty($.cookie("CartID"),"45871");
			$.cookie('incart', null, {path: "/"});	
			$.cookie('change-dates-btn', '1',  {path: "/"});
			window.location = domain + "/equipment-hire";
		}
	});
	
});

function highlightNav()
{
	var f = jQuery.url.segment(1) || this.path || window.location.pathname; //jQuery.url.segment(1);
	var i = "";
	
	switch(f)
	{
		case "dj-hire": i = "dj-hire-nav-img"; break;
		case "dj-school": i = "dj-school-nav-img"; break;
		case "about-us": i = "about-us-nav-img"; break;		
		default: return;
	}
	
	$("#" + i).attr("src", 
					function(z) { 
						return $(this).attr("src").replace("nav.gif", "nav-on.gif") 
						});
}

function validateDeliveryDates(delivery, pickup)
{
	if(delivery == null)
	{
		ERRMSG = "You must select a delivery date to continue...";
		return false;
	}

	if(pickup == null)
	{
		ERRMSG = "You must select a pickup date to continue...";
		return false;
	}
	
	var objRegex = /(\d{1,2})-(\w{3})-(\d{4}) (\d{1,2}):(\d{2})/ig;
	var matches = objRegex.exec(delivery);

	var ass = delivery.replace(/-/g, ' ');
	//alert(ass + " | " + Date.parse(ass) + " | " + new Date(Date.parse(ass)));
	var deldate = new Date(Date.parse(ass));
	ass = pickup.replace(/-/g, ' ');
	var pudate= new Date(Date.parse(ass));
	
	// must have a 24 hour lead time for orders
	var leadtime = new Date();
	leadtime.setDate(leadtime.getDate()+1);
	leadtime = new Date(leadtime.getFullYear(), leadtime.getMonth(), leadtime.getDate(), '12', '0','0','0');
	
	if(deldate < leadtime)
	{
		ERRMSG = "We need at least until " + leadtime + " to prepare your order. Your requested delivery date is too soon.";	
		return false;
	}	
	
	// delivery must happen before pickup
	if(deldate > pudate) 
	{
		ERRMSG = "Delivery date is after pickup date. Please select a delivery date that is earlier than the pickup date.";	
		return false;
	}
	
	return true;
}

function doOutOfStock()
{  
	$.getJSON('http://guerrillainnovation.com.au/discofactory/oostock.php?del=' + escape($.cookie('delivery-date')) + '&pick=' + escape($.cookie('pickup-date'))  + '&callback=?', outOfStock); 
}

function outOfStock(data)
{
	//alert(data);
	$.cookie('outofstock', data, {path: "/"});
	
}

function fillDeliveryDates()
{	
	//credit card option
	$("input[name='PaymentMethodType']").change( function () {
		if($("input[name='PaymentMethodType']:checked").val().toString() == "1")
		{
			$('#ccbod').show();
		}
		else
		{
			$('#ccbod').hide();
		}
	}).change();
	
	

	var deldate = jQuery.url.param("deldate").split(" ")[0];
	var deltime = jQuery.url.param("deldate").split(" ")[1] == "15:00" ? "Afternoon" : "Morning";
	
	var pudate = jQuery.url.param("pudate").split(" ")[0];
	var putime = jQuery.url.param("pudate").split(" ")[1] == "15:00" ? "Afternoon" : "Morning";
	
	
	
	$('#CAT_Custom_77978').val(deldate);
	$('#CAT_Custom_77979').val(pudate);	
	
	$('#CAT_Custom_77981').val(deltime);
	$('#CAT_Custom_77982').val(putime);	
	
	$('#ShippingZip').val(jQuery.url.param('shippc'));
	$('#ShippingState').val('Victoria');
	
	//set up the click event handler for the submit button to validate our stuff
	$('#catwebformbutton').click( function() {} );
}

function InCart(productid, productcode)
{
	if($.cookie('incart') == null) 
	{
		$.cookie('incart', productid, {path:"/"});
		return;
	}
		
	var content = $.cookie('incart');
	
	$.cookie('incart', content + "," + productid, {path:"/"});
}

function RemoveInCart(productid)
{
	if($.cookie('incart') == null) 
	{
		return;
	}
		
	var content = $.cookie('incart');
	var rx = new RegExp(productid.toString(), "g");
	content = content.replace(rx, '');
	content = content.replace(/,,/g, ',');
	content = content.trim();
	
	if(content == "") content = null;
	
	$.cookie('incart', content, {path:"/"});
}

function showCommsHireDates()
{
	$('#hire-date-summary').show().prepend("Your current hire dates are:<br /> Delivery - <strong>" + $.cookie('delivery-date').replace("15:00", "Afternoon").replace("10:00", "Morning") + "</strong>.<br /> Pickup - <strong>" + $.cookie('pickup-date').replace("15:00", "Afternoon").replace("10:00", "Morning") + "</strong>.<br />This equates to <strong>" + $.cookie('hire-days') + "</strong> days hire.<br />Delivering to <strong>" +  $.cookie('postcode') + "</strong><br />");
	
}

function catalogActions()
{
	$(".productItem input[class='productTextInput']").attr("readonly", "readonly").val($.cookie('hire-days'));
	$("input.cartInputText").attr("readonly", "readonly");
	$("input[name='AddToCart_Submit'], img[name='addtocart'], .cart .productitemcell a").click(catalogActions);
	
	
	var href = $('#catshopbuy').attr('href');
	$('#catshopbuy').attr('href', href + "&deldate=" + $.cookie('delivery-date') + "&pudate=" + $.cookie('pickup-date') + "&shippc=" + $.cookie('postcode'));
		
	if($.cookie('outofstock') != null)
	{
		var json = "['" + $.cookie('outofstock').replace(/,/gi, "','") + "']";

		jQuery.each(eval(json), function(){
			$("#ul" + this + " li.quantity").replaceWith('<li>Not in Stock for selected dates</li>'); 
			$("#qty" + this).replaceWith('<div class="quantity">Not in Stock for selected dates</div>'); 																																	   
		});
	}
	
	if($.cookie('incart') != null)
	{
		var json = "['" + $.cookie('incart').replace(/,/gi, "','") + "']";
		
		jQuery.each(eval(json), function(){
			$("#ul" + this).html('<li class="in-cart-note">Already in cart</li>'); 
			$("#qty" + this).replaceWith('<div class="quantity in-cart-note">Already in cart</div>'); 
		});
	}
	
	doHReplace();
}

function resetHireConfig() 
{
	clearDates();
	$.cookie('postcode', null, {path: "/"});	
	$.cookie('incart', null, {path: "/"});	
	$.cookie('postcode-district-value', null, {path: "/"});	
	$.cookie('incart', null, {path: "/"});	
}

function processResponse(respObj) {
	//alert(respObj);
	$('.modalBackground, .ajaxLoader').remove();
} 


function validDiscounts()
{
	var cur = $('#DiscountCode').val();
	
	if(cur == null || cur == "" && is15PercentDiscountValid())
	{
		$('#DiscountCode').val('15PCOFF').change();
	}
	else if(cur == '15PCOFF' && !is15PercentDiscountValid())
	{
		alert('This discount is only valid if you hire a sound AND lighting pack together');
		$('#DiscountCode').val('').change();
	}
}

function is15PercentDiscountValid()
{
	var l = 0; 
	var s = 0;
	
	$('#cartProductCodes div.productitemcell').each(function() {
			var t = $(this).text();

			if(t.startsWith("SP-") || t.endsWith("-SP"))
			{
				++s;		
			}
			else if(t.endsWith("-LP") || t.startsWith("LP-"))
			{
				++l;
			}			
			
			
	});
	
	if(l > 0 && s > 0)
	{
		return true;	
	}
	
	return false;
}



function clearDates()
{
	$.cookie('pickup-date', null, {path: "/"});	
	$.cookie('delivery-date', null, {path: "/"});	
	$.cookie('hire-days', null, {path:"/"});
	$.cookie('outofstock', null, {path: "/"});	
}


ClearCart = function (e,c)
{
	var d=document.getElementById("catCartDetails");
	var a=document.getElementById("catCartSummary");
	if(d)
	{
		var b=CMS.OrderRetrievev2.ServerSideDrawCartEmpty(e,c);
		//d.innerHTML=b.value;
		$('table.cart').replaceWith(b.value);
		alert(Oshoplang.CartUpdateSuccess)
	}
	if(a)
	{
		a.innerHTML=Oshoplang.CartEmpty
	}
	if(typeof UpdateProductExtras=="function")
	{
		UpdateProductExtras(c,-1,-1)
	}
	sIFR.replace(helveticaex, {selector: "h2.catalog-title", wmode: "transparent", css: '.sIFR-root { color: #505252; }'});
	$.cookie("incart", null);
}

//this.vale, cookie.CartID, catalogId
UpdateShipping = function (c,e,b)
{
	var d=document.getElementById("catCartDetails");
	if(d)
	{
		var a=CMS.OrderRetrievev2.ServerSideUpdateShipping(e,c,b);
		if(a.value[0])
		{
			d.innerHTML=a.value[2]
		}
		if(a.value[1].length>0)
		{
			//alert(a.value[1])
		}
		catalogActions();
		showCommsHireDates();
		sIFR.replace(helveticaex, {selector: "h2.catalog-title", wmode: "transparent", css: '.sIFR-root { color: #505252; }'});
	}
}

UpdateItemQuantity = function (d, i, f, e, j, l, g) {
    var b;
    var h;
    var a = false;
    var m = false;
    var k = true;
    b = document.getElementById("catCartDetails");
    h = document.getElementById("catCartSummary");
    if (h) {
        if (h.getAttribute("Vertical") == "True") {
            a = true
        }
        if (h.getAttribute("Quote") == "True") {
            m = true
        }
    }
    if (!IsNumeric(d)) {
        alert(Oshoplang.InvalidQuantity);
        return false
    }
    if (b) {
        var c;
        c = CMS.OrderRetrievev2.ServerSideUpdateItemQuanity(i, f, e, j, d, l, g, a, m, k);
        switch (c.value[0]) {
        case 0:
        case 2:
            b.innerHTML = c.value[1];
            if (h) {
                h.innerHTML = c.value[2]
            }
            break;
        case 1:
            alert(Oshoplang.OutOfStock);
            return;
        case 3:
            alert(Oshoplang.MinLimit);
            break;
        case 4:
            alert(Oshoplang.MaxLimit);
            break;
        case - 1 :
			//b.innerHTML = c.value[1];
			$("#carttable").replaceWith(c.value[1]);
            if (h) {
                h.innerHTML = c.value[2]
            }
            alert(Oshoplang.CartEmpty);
            break
        }
    }
    if (typeof UpdateProductExtras == "function") {
        UpdateProductExtras(f, e, c.value[0])
    }
	RemoveInCart(e);
}

ApplyDiscountCode = function (a, e, c) {
    var d = document.getElementById("catCartDetails");
    if (d) {
        var b = CMS.OrderRetrievev2.ServerSideApplyDiscountCode(e, a, c);
        if (b.value[0]) {
            d.innerHTML = b.value[2]
        }
        if (b.value[1].length > 0) {
            alert(b.value[1])
        }
    }
	
	doHReplace(); showCommsHireDates();
	$("input.cartInputText").attr("readonly", "readonly");
	$('#shippingSpan').before($('#ShippingOptions option:selected').attr('text'));
	catalogActions();
}

AddToCart = function (j, w, t, B, l) {
    var h = w;
    var q = "";
    var f = document.getElementById("Units_" + w);
    var A = readCookie("CartID");
    var v = document.getElementById("Grouping_" + w);
    var F = document.getElementById("Related_" + w);
    var e = document.getElementById("catProdTd_" + w);
    var n = document.getElementById("catProdAttributes_" + w);
    var u = document.getElementById("catProdAttributes2_" + w);
    var s = document.getElementById("catProdInstructions_" + w);
    var c = "";
    var p = new Array();
    var C = false;
    var a = false;
    var m;
    var g = 0;
    var E;
    var d = true;
    if (f) {
        m = f.value;
        if (m < 0) {
            alert(OshopLang.RemoveError);
            return false
        }
    } else {
        m = 1
    }
    if (A == null || A == "") {
        A = -1
    }
    E = document.getElementById("catCartSummary");
    if (v) {
        if (v.nodeName == "SELECT") {
            h = v.value
        } else {
            var r = v.getElementsByTagName("input");
            for (var z = 0; z < r.length; z++) {
                if (r[z].checked) {
                    h = r[z].value;
                    break
                }
            }
        }
    }
    if (F) {
        q = GetCheckListValue(F);
        if (q.length > 0) {
            g = q.split(",").length
        }
    }
    if (s) {
        c = s.value
    }
    if (n) {
        var o = n.getElementsByTagName("select");
        if (o) {
            if (c.length > 0) {
                c += ";"
            }
            for (var z = 0; z < o.length; z++) {
                if (o[z].value.length > 0) {
                    c += o[z].value + ";"
                }
            }
        }
    }
    if (u) {
        var D = 0;
        var o = u.getElementsByTagName("select");
        var y;
        var x;
        var k = "";
        if (o) {
            for (var z = 0; z < o.length; z++) {
                if (o[z].value.length > 0) {
                    p[D] = o[z].value + "|1";
                    D++
                } else {
                    if (o[z].getAttribute("mandatory")) {
                        alert(Oshoplang.ChooseAttribute);
                        return
                    }
                }
            }
        }
        var o = u.getElementsByTagName("input");
        if (o) {
            for (var z = 0; z < o.length; z++) {
                if (o[z].type == "checkbox" || o[z].type == "radio") {
                    if (k != o[z].getAttribute("name")) {
                        if (z > 0 && !x && o[z - 1].getAttribute("mandatory")) {
                            alert(Oshoplang.ChooseAttribute);
                            return
                        }
                        x = false
                    }
                    if (o[z].checked) {
                        p[D] = o[z].id + "|1";
                        D++;
                        x = true
                    }
                    k = o[z].getAttribute("name")
                } else {
                    if (o[z].value.length > 0) {
                        p[D] = o[z].id + "|" + o[z].value;
                        D++;
                        x = true
                    } else {
                        if (o[z].getAttribute("mandatory")) {
                            alert(Oshoplang.ChooseAttribute);
                            return
                        }
                    }
                }
            }
            if (o.length > 0 && (o[o.length - 1].type == "checkbox" || o[o.length - 1].type == "radio")) {
                if (!x && o[z - 1].getAttribute("mandatory")) {
                    alert(Oshoplang.ChooseAttribute);
                    return
                }
            }
        }
    }
    if (E) {
        if (E.getAttribute("Vertical") == "True") {
            C = true
        }
        if (E.getAttribute("Quote") == "True") {
            a = true
        }
    }
    var b = CMS.CatalogueRetrieve.ServerSideAddItemToOrder(A, j, h, m, q, p, c, C, B, a, t, d);
    g = parseInt(g) + parseInt(m);
    createCookie("CartID", b.value[0], 2);
    if (E) {
        E.innerHTML = b.value[2]
    }
    switch (b.value[1]) {
    case 0:
        if (!l) {
            if (e) {
                e.innerHTML = b.value[3];
                ProcessJS(e)
            }
            alert(g + Oshoplang.Added)
        } else {
            document.location = "/OrderRetrievev2.aspx?CatalogueID=" + j
        }
        break;
    case 1:
        alert(Oshoplang.OutOfStock);
        break;
    case 2:
        if (!l) {
            if (e) {
                e.innerHTML = b.value[3];
                ProcessJS(e)
            }
            alert(g + Oshoplang.PreOrder)
        } else {
            document.location = "/OrderRetrievev2.aspx?CatalogueID=" + j
        }
        break;
    case 3:
        alert(Oshoplang.MinLimit);
        break;
    case 4:
        alert(Oshoplang.MaxLimit);
        break
    }
    if (typeof AddProductExtras == "function") {
        AddProductExtras(j, h, b.value[1])
    }
	
	InCart(w.toString(), '{tag_productcode}');
}

ApplyGiftVoucher = function (e, d, b) {
    var c = document.getElementById("catCartDetails");
    if (c) {
        var a = CMS.OrderRetrievev2.ServerSideApplyGiftVoucher(d, e, b);
        if (a.value[0]) {
            c.innerHTML = a.value[2]
        }
        if (a.value[1].length > 0) {
            alert(a.value[1])
        }
    }
	
	doHReplace(); showCommsHireDates();
	$("input.cartInputText").attr("readonly", "readonly");
}

if (typeof AjaxPro != "undefined")
{
if (typeof CMS == "undefined") CMS = {};
if (typeof CMS.OrderRetrievev2 == "undefined") CMS.OrderRetrievev2 = {};
CMS.OrderRetrievev2_class = function() {};
Object.extend(CMS.OrderRetrievev2_class.prototype, Object.extend(new AjaxPro.AjaxClass(), {
    ServerSideUpdateItemQuanity: function(orderId, envCatalogueId, productId, itemId, quantity, cartType, countryCode, vertical, isQuote, v2) {
        return this.invoke("ServerSideUpdateItemQuanity", {
            "orderId": orderId,
            "envCatalogueId": envCatalogueId,
            "productId": productId,
            "itemId": itemId,
            "quantity": quantity,
            "cartType": cartType,
            "countryCode": countryCode,
            "vertical": vertical,
            "isQuote": isQuote,
            "v2": v2
        },
        this.ServerSideUpdateItemQuanity.getArguments().slice(10));
    },
    ServerSideDrawCartEmpty: function(orderId, envCatalogueId) {
        return this.invoke("ServerSideDrawCartEmpty", {
            "orderId": orderId,
            "envCatalogueId": envCatalogueId
        },
        this.ServerSideDrawCartEmpty.getArguments().slice(2));
    },
    ServerSideUpdateShipping: function(orderId, shippingOptionId, envCatalogueId) {
        return this.invoke("ServerSideUpdateShipping", {
            "orderId": orderId,
            "shippingOptionId": shippingOptionId,
            "envCatalogueId": envCatalogueId
        },
        this.ServerSideUpdateShipping.getArguments().slice(3));
    },
    ServerSideApplyDiscountCode: function(orderId, discountcode, envCatalogueId) {
        return this.invoke("ServerSideApplyDiscountCode", {
            "orderId": orderId,
            "discountcode": discountcode,
            "envCatalogueId": envCatalogueId
        },
        this.ServerSideApplyDiscountCode.getArguments().slice(3));
    },
    ServerSideApplyGiftVoucher: function(orderId, giftvoucherCode, envCatalogueId) {
        return this.invoke("ServerSideApplyGiftVoucher", {
            "orderId": orderId,
            "giftvoucherCode": giftvoucherCode,
            "envCatalogueId": envCatalogueId
        },
        this.ServerSideApplyGiftVoucher.getArguments().slice(3));
    },
    ServerSideUpdateTaxCode: function(orderId, taxcodeId, taxShipping, taxGiftVouchers, envCatalogueId) {
        return this.invoke("ServerSideUpdateTaxCode", {
            "orderId": orderId,
            "taxcodeId": taxcodeId,
            "taxShipping": taxShipping,
            "taxGiftVouchers": taxGiftVouchers,
            "envCatalogueId": envCatalogueId
        },
        this.ServerSideUpdateTaxCode.getArguments().slice(5));
    },
    ServerSideRegisterGiftVoucher: function(orderId, recipientName, recipientEmail, message) {
        return this.invoke("ServerSideRegisterGiftVoucher", {
            "orderId": orderId,
            "recipientName": recipientName,
            "recipientEmail": recipientEmail,
            "message": message
        },
        this.ServerSideRegisterGiftVoucher.getArguments().slice(4));
    },
    ServerSideSetShippingCountry: function(orderId, countrycode, state, postcode, envCatalogueId) {
        return this.invoke("ServerSideSetShippingCountry", {
            "orderId": orderId,
            "countrycode": countrycode,
            "state": state,
            "postcode": postcode,
            "envCatalogueId": envCatalogueId
        },
        this.ServerSideSetShippingCountry.getArguments().slice(5));
    },
    ServerSideSetShippingAddress: function(orderId, countrycode, state, postcode) {
        return this.invoke("ServerSideSetShippingAddress", {
            "orderId": orderId,
            "countrycode": countrycode,
            "state": state,
            "postcode": postcode
        },
        this.ServerSideSetShippingAddress.getArguments().slice(4));
    },
    ServerSideRetrieveShipping: function(orderId, countrycode, state, postcode, envCatalogueId, isResidential) {
        return this.invoke("ServerSideRetrieveShipping", {
            "orderId": orderId,
            "countrycode": countrycode,
            "state": state,
            "postcode": postcode,
            "envCatalogueId": envCatalogueId,
            "isResidential": isResidential
        },
        this.ServerSideRetrieveShipping.getArguments().slice(6));
    },
    ServerSideSaveShipping: function(orderId, shippingoptionId, catalogId, key) {
        return this.invoke("ServerSideSaveShipping", {
            "orderId": orderId,
            "shippingoptionId": shippingoptionId,
            "catalogId": catalogId,
            "key": key
        },
        this.ServerSideSaveShipping.getArguments().slice(4));
    },
    ServerSideReDrawShoppingCart: function(orderId) {
        return this.invoke("ServerSideReDrawShoppingCart", {
            "orderId": orderId
        },
        this.ServerSideReDrawShoppingCart.getArguments().slice(1));
    },
    url: '/ajaxpro/CMS.OrderRetrievev2,Catalyst.Web.CMS.ashx'
}));
CMS.OrderRetrievev2 = new CMS.OrderRetrievev2_class();
}

