;(function($){
	
	var sky = window.sky || ( window.sky = {} );
	var ocp = sky.ocp || ( sky.ocp = {} );	
	
	ocp.LivePerson = {
		determineLivePersonCustomerTypeOnSelfId : function(customerType){
			//used by storefront
			if(customerType == 'EC') {
				sky.ocp.LivePerson.setLivepersonCustomer();
			} else if (customerType == 'PC') {
				sky.ocp.LivePerson.setLivepersonProspect();
			}
		},

		determineLivePersonCustomerType : function() {
			switch ($.cookie('custype')) {
				case "PC" :
					sky.ocp.LivePerson.setLivepersonProspect();
					break;
		
				case "EC" :
					var partyIdPresent = $.cookie('partyid') != undefined;
					if ($.cookie('VALIDCUSTOMER') == 'true' || !partyIdPresent) {
						sky.ocp.LivePerson.setLivepersonCustomer();
					} else {
						sky.ocp.LivePerson.setLivepersonUnservicable();
					}
					break;
				};
		},
		toggleSelfIdLightBoxActive : function() {
			if(!window.LivePersonActive){
				return;
			}
			var sky = window.sky || ( window.sky = {} );
			var ocp = sky.ocp || ( sky.ocp = {} );
			if(window.LightBoxActive == "No"){
				lpSendData("page","LightBoxActive","Yes");
				window.LightBoxActive="Yes";
			}else{
				lpSendData("page","LightBoxActive","No");
				window.LightBoxActive="No";
			}
		},
		toggleSigninLightBoxActive : function() {
			if(!window.LivePersonActive){
				return;
			}
			if(window.SignInBoxActive == "No"){
				lpSendData("page","SignInBoxActive","Yes");
				window.SignInBoxActive="Yes";
			}else{
				lpSendData("page","SignInBoxActive","No");
				window.SignInBoxActive="No";
			}
		},
		setLivepersonCustomer : function() {
			sky.ocp.LivePerson.setLivepersonCustomerType('existing');
		},
		setLivepersonProspect : function() {
			sky.ocp.LivePerson.setLivepersonCustomerType('new');
		},
		setLivepersonUnservicable : function() {
			if(!window.LivePersonActive){
				return;
			}
			sky.ocp.LivePerson.setLivepersonCustomerType('existing');
			if(typeof(lpSendData)!="undefined") {
				lpSendData("page","ErrorName","Unservicable Customer");
			}
		},
		setLivepersonCustomerType : function(type) {
			if(!window.LivePersonActive){
				return;
			}
			if (typeof(window.SkyCustomerType)!="undefined") {
				window.SkyCustomerType=type;
				window.lpUnit=type + '-sales';
				try {
					if(typeof(lpSendData)!="undefined") {
						lpSendData("page","unit",window.lpUnit);
						lpSendData('page','SkyCustomerType',window.SkyCustomerType);
					}
					window.lpMTagConfig.defaultInvite ='chat'+'-' + window.lpUnit;
					if(typeof(lpMTagConfig.dynButton)!="undefined") {
						//do we need to replace the new-sales one?? window.lpMTagConfig.dynButton[1]
						window.lpMTagConfig.dynButton[window.lpMTagConfig.dynButton.length] = {"name":"chat-"+window.lpUnit + "-productselection","pid":"divButtonProductselection", 'ovr':'lpMTagConfig.db1'};
					}
				} catch(e) {}
			}
		}		
	};
})(jQuery);
