/* WWWWHITTARD Customer Account Scripts */

/**********************************************************************************/

/* PAF Address Search Functions */

/* Perform Address Search */

function performPAFAddressSearch() {
	var theTargetForm=document.getElementById("ADDRESSLOOKUPFORM");
	theTargetForm.submit();
}

/**********************************************************************************/

/* Select Address From Results */

function selectPAFAddress(pafAddressId) {

	var theTargetForm=document.getElementById("ADDRESSLOOKUPFORM");
	var theTargetRequestInput=document.getElementById("ADDRESSLOOKUPREQUEST");
	var theTargetRequestDataInput=document.getElementById("ADDRESSLOOKUPREQUESTDATA");

	theTargetRequestInput.value="ADDRESSSEARCHRETRIEVE";

	theTargetRequestDataInput.value=pafAddressId;
	theTargetForm.submit();	
}


/* Append Address To Target Address Input Fields */

function appendPAFAddress() {

	var theTargetAddressLine1Input=parent.document.getElementById("ADDRESS1");
	var theTargetAddressLine2Input=parent.document.getElementById("ADDRESS2");
	var theTargetAddressLine3Input=parent.document.getElementById("ADDRESS3");
	var theTargetAddressTownInput=parent.document.getElementById("CITY");
	var theTargetAddressCountyInput=parent.document.getElementById("COUNTY");
	var theTargetAddressPostcodeInput=parent.document.getElementById("POSTCODE");
	var theTargetAddressCountryInput=parent.document.getElementById("COUNTRY");

	theTargetAddressLine1Input.value=thisAddressLine1;
	theTargetAddressLine2Input.value=thisAddressLine2;
	theTargetAddressLine3Input.value=thisAddressLine3;
	theTargetAddressTownInput.value=thisAddressTown;
	theTargetAddressCountyInput.value=thisAddressCounty;
	theTargetAddressPostcodeInput.value=thisAddressPostcode;
	theTargetAddressCountryInput.value=thisAddressCountry;

	parent.showCCBAAddressPopUp(0);	/* Hide Address Search Div */
	self.location.hef=self.location.hef;
}

/* Append Address To Target Address Input Fields - Catalogue Request Mode */

function appendPAFAddressCatalogueRequest() {

	var theTargetAddressLine1Input=parent.document.getElementById("ADDRESS1");
	var theTargetAddressLine2Input=parent.document.getElementById("ADDRESS2");
	var theTargetAddressTownInput=parent.document.getElementById("CITY");
	var theTargetAddressCountyInput=parent.document.getElementById("COUNTY");
	var theTargetAddressPostcodeInput=parent.document.getElementById("POSTCODE");
	var theTargetAddressCountryInput=parent.document.getElementById("COUNTRY");

	theTargetAddressLine1Input.value=thisAddressLine1;
	theTargetAddressLine2Input.value=thisAddressLine2;
	theTargetAddressTownInput.value=thisAddressTown;
	theTargetAddressCountyInput.value=thisAddressCounty;
	theTargetAddressPostcodeInput.value=thisAddressPostcode;
	theTargetAddressCountryInput.value=thisAddressCountry;

	parent.showCatalogueRequestAddressPopUp(0);	/* Hide Address Search Div */
	self.location.hef=self.location.hef;
}

/**********************************************************************************/

/* Customer Account Sign In */

function customerAccountSignIn() {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetInput=document.getElementById("CUSTOMERACCOUNTREQUEST");

	theTargetInput.value="CUSTOMERACCOUNTSIGNIN";
	theTargetForm.submit();
}

/**********************************************************************************/

/* Create New Customer Account Validate Details */

function createNewCustomerAccountValidateDetails() {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetInput=document.getElementById("CUSTOMERACCOUNTREQUEST");

	theTargetInput.value="CUSTOMERACCOUNTCREATENEWACCOUNTVALIDATEDETAILS";
	theTargetForm.submit();
}


/**********************************************************************************/

/* Update Customer Account Validate Details */

function updateCustomerAccountValidateDetails() {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetInput=document.getElementById("CUSTOMERACCOUNTREQUEST");

	theTargetInput.value="CUSTOMERACCOUNTUPDATEACCOUNTVALIDATEDETAILS";
	theTargetForm.submit();

}

/**********************************************************************************/

/* Customer Account Password Hint */

function customerAccountPasswordHint(callingMode) {

	var theTargetEmailAddressInput=document.getElementById("EMAIL1");

	/* Define Calling Mode - Determines Where User Is Returned To */

	if(callingMode==1) {
		var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
		var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
		theTargetRequestInput.value="CUSTOMERACCOUNTPASSWORDHINT";	/* Define Request */
		theTargetForm.submit();						/* Submit Form */
	}

	if(callingMode==2) {
		var theTargetForm=document.getElementById("CHECKOUTCUSTOMERACCOUNTSIGNINFORM");
		var theTargetRequestInput=document.getElementById("CHECKOUTREQUEST");
		theTargetRequestInput.value="CUSTOMERACCOUNTPASSWORDHINT";	/* Define Request */
		theTargetForm.submit();						/* Submit Form */
	}

}

/**********************************************************************************/

/* Customer Account Password Reminder */

function customerAccountPasswordReminder(callingMode) {

	var theTargetEmailAddressInput=document.getElementById("EMAIL1");

	/* Define Calling Mode - Determines Where User Is Returned To */

	if(callingMode==1) {
		var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
		var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
		theTargetRequestInput.value="CUSTOMERACCOUNTPASSWORDREMINDER";	/* Define Request */
		theTargetForm.submit();						/* Submit Form */
	}

	if(callingMode==2) {
		var theTargetForm=document.getElementById("CHECKOUTCUSTOMERACCOUNTSIGNINFORM");
		var theTargetRequestInput=document.getElementById("CHECKOUTREQUEST");
		theTargetRequestInput.value="CUSTOMERACCOUNTPASSWORDREMINDER";	/* Define Request */
		theTargetForm.submit();						/* Submit Form */
	}

}

/**********************************************************************************/

/* Customer Account Password Reset */

function customerAccountPasswordReset(callingMode) {

	var theTargetEmailAddressInput=document.getElementById("EMAIL1");

	if(callingMode==1) {
		var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
		var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
		theTargetRequestInput.value="CUSTOMERACCOUNTPASSWORDRESET";	/* Define Request */
		theTargetForm.submit();						/* Submit Form */
	}

	if(callingMode==2) {
		var theTargetForm=document.getElementById("CHECKOUTCUSTOMERACCOUNTSIGNINFORM");
		var theTargetRequestInput=document.getElementById("CHECKOUTREQUEST");
		theTargetRequestInput.value="CUSTOMERACCOUNTPASSWORDRESET";	/* Define Request */
		theTargetForm.submit();						/* Submit Form */
	}
}

/**********************************************************************************/

/* Customer Account Address Book Add */

function customerAccountAddressBookAddAddress() {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");

	theTargetRequestInput.value="CUSTOMERACCOUNTADDADDRESSBOOKRECORD";
	theTargetForm.submit();
}

/**********************************************************************************/

/* Customer Account Address Book Edit */

function customerAccountAddressBookEdit(customerId) {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
	var theTargetRequestDataInput=document.getElementById("CUSTOMERACCOUNTREQUESTDATA");

	theTargetRequestDataInput.value=customerId;
	theTargetRequestInput.value="CUSTOMERACCOUNTEDITADDRESSBOOKRECORD";
	theTargetForm.submit();
}

/**********************************************************************************/

/* Customer Account Address Book Delete */

function customerAccountAddressBookDelete(customerId) {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
	var theTargetRequestDataInput=document.getElementById("CUSTOMERACCOUNTREQUESTDATA");

	if(window.confirm("Are you sure you want to delete this address from your address book?")) {
		theTargetRequestDataInput.value=customerId;
		theTargetRequestInput.value="CUSTOMERACCOUNTDELETEADDRESSBOOKRECORD";
		theTargetForm.submit();
	}
}

/**********************************************************************************/

/* Customer Account Address Book Entry Validate (Add/Edit) */

function customerAccountAddressBookEntryValidate() {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");

	theTargetRequestInput.value="CUSTOMERACCOUNTADDRESSBOOKENTRYVALIDATE";
	theTargetForm.submit();
}


/**********************************************************************************/

/* Customer Account Add New Payment Card */

function customerAccountAddNewPaymentCard() {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
	var theTargetRequestDataInput=document.getElementById("CUSTOMERACCOUNTREQUESTDATA");

	theTargetRequestInput.value="CUSTOMERACCOUNTADDNEWPAYMENTCARD";
	theTargetForm.submit();
}


/**********************************************************************************/

/* Customer Account Edit Payment Card */

function customerAccountEditPaymentCard(paymentCardId) {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
	var theTargetRequestDataInput=document.getElementById("CUSTOMERACCOUNTREQUESTDATA");

	theTargetRequestInput.value="CUSTOMERACCOUNTEDITPAYMENTCARD";
	theTargetRequestDataInput.value=paymentCardId;	
	theTargetForm.submit();
}

/**********************************************************************************/

/* Payment Card Delete */

function customerAccountDeletePaymentCard(paymentCardId) {
	
	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
	var theTargetRequestDataInput=document.getElementById("CUSTOMERACCOUNTREQUESTDATA");

	if(window.confirm("Are you sure you want to delete this payment card from your account?")) {
		theTargetRequestInput.value="CUSTOMERACCOUNTDELETEPAYMENTCARD";
		theTargetRequestDataInput.value=paymentCardId;
		theTargetForm.submit();
	}

}

/**********************************************************************************/

/* Payment Card New Card Validate */

function customerAccountPaymentCardValidate() {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");

	theTargetRequestInput.value="CUSTOMERACCOUNTPAYMENTCARDVALIDATE";
	theTargetForm.submit();
}

/**********************************************************************************/

/* View Previous Order Detail */

function customerAccountViewPreviousOrderDetail(orderId) {

	var theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	var theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
	var theTargetRequestDataInput=document.getElementById("CUSTOMERACCOUNTREQUESTDATA");

	theTargetRequestInput.value="CUSTOMERACCOUNTVIEWPREVIOUSORDERDETAIL";
	theTargetRequestDataInput.value=orderId;
	theTargetForm.submit();


}

/**********************************************************************************/

/* Carrier Parcel Tracking */

function customerAccountTrackDespatch(carrierTrackingUrl) {

	var trackDespatchWindow=window.open(carrierTrackingUrl,'trackDespatchWindow');
}

/**********************************************************************************/

/* Customer Account Copy Previous Order */

function customerAccountCopyPreviousOrder(orderId,callingSource) {

	var theTargetForm="";
	var theTargetRequestInput="";
	var theTargetRequestDataInput="";

	/* Determine Calling Mode */

	theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
	theTargetRequestDataInput=document.getElementById("CUSTOMERACCOUNTREQUESTDATA");

	if(callingSource !=1) {
		theTargetRequestInput.value="CUSTOMERACCOUNTCOPYPREVIOUSORDER0";	/* Define Request */
		theTargetRequestDataInput.value=orderId;				/* Define Order Number To View Detail */
	} else {
		theTargetRequestInput.value="CUSTOMERACCOUNTCOPYPREVIOUSORDER1";	/* Define Request */
		theTargetRequestDataInput.value=orderId;				/* Define Order Number To View Detail */
	}

	theTargetForm.submit();						/* Submit Form */
}

/**********************************************************************************/

/* Loyalty Card Update */

function loyaltyCardUpdate() {
	theTargetForm=document.getElementById("CUSTOMERACCOUNTFORM");
	theTargetRequestInput=document.getElementById("CUSTOMERACCOUNTREQUEST");
	theTargetRequestDataInput=document.getElementById("CUSTOMERACCOUNTREQUESTDATA");

	theTargetRequestInput.value="CUSTOMERACCOUNTLOYALTYCARDUPDATE";
	theTargetForm.submit();
	
}


/**********************************************************************************/

