//============================================================================================================
//Script:		CustomerComments.js
//Description:	Prints random customer testimonial.
//------------------------------------------------------------------------------------------------------------
//History:		01/11/07	CHT		Initial version.
//				xx/xx/xx	SJB		Changed to declare literal.
//				10/07/08	XXX		Refactored to allow different types of comment depending on the product
//									and stage in the quoting process (CRF-1122).
//============================================================================================================

//------------------------------------------------------------------------------------------------------------
//Declare array of all customer testimonials.  Each array element is an object with the following attributes:
//	Comment - The customer's comment.
//	Name - The customer's name.
//	Product - Type of product (e.g. "Motor", "Travel", "Any").
//	Stage - The stage of the quoting process (e.g. "Quote", "Buy", "Any").
//------------------------------------------------------------------------------------------------------------
var Comments = [
        {
            Comment:"Very easy only took me a couple of minutes to arrange my travel insurance",
            Name:"Helen Purvis, Corbridge",
            Product:"Travel",
            Stage:"Welcome"
        },
        {
            Comment:"My travel insurance was half the price of the cheapest quote",
            Name:"Elisa Carter, Streatham",
            Product:"Travel",
            Stage:"Welcome"
        },
        {
            Comment:"I must say that the home guard cover option is brilliant. It gives peace of mind while we are on holiday",
            Name:"Richard McHugh, Leeds",
            Product:"Travel",
            Stage:"Welcome"
        },
        {
            Comment:"A fast, competitive and efficient way of arranging travel insurance. The easiest travel insurance I've ever taken out",
            Name:"Andy, Poulten Le Fylde",
            Product:"Travel",
            Stage:"Welcome"
        },
        {
            Comment:"Very good, and most of all cheap",
            Name:"Lee, Wolverhampton",
            Product:"Motor",
            Stage:"Welcome"
        },
        {
            Comment:"Swiftcover saved me an amazing &pound;275",
            Name:"G Wynn, Newton Abbot",
            Product:"Motor",
            Stage:"Welcome"
        },
        {
            Comment:"I finally found a company that lives up to its promises",
            Name:"A Hughes, Pontypridd",
            Product:"Motor",
            Stage:"Welcome"
        },
        {
            Comment:"Surprisingly quick and easy to set up",
            Name:"P Horbury, Barnsley",
            Product:"Motor",
            Stage:"Welcome"
        },
        {
            Comment:"The service I have received is excellent.  Thank you very much",
            Name:"Lee, Wolverhampton",
            Product:"Motor",
            Stage:"Welcome"
        },
		{
			Comment:"I must compliment you on your quality of service. Having had occasion to make a claim, I would, recommend your company without hesitation as one which looks after your customers and offers great value for money and excellent service.",
			Name:"David Price, Rugby",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"Using swiftcover.com was fast, easy and very good value.  I saved over &pound;150 on my renewal by going to swiftcover.com.",
			Name:"Tony Hudspith",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"A quick easy way to get very competitive insurance cover.  In total I have saved over &pound;450 over my two cars.",
			Name:"Ramon Allan, Dorking",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"I saved myself &pound;400 by using Swiftcover and cut my premium in half.",
			Name:"Yvonne Winstanley, Cheshire",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"You were recommended to me by my son who said that he had heard lots of comments regarding how much money could be saved. This I have definitely proved.",
			Name:"Mrs Corns, Brixham",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"Swiftcover is just that, cover in the most straight forward way, swift cover and it\'s great how they even text your mobile to confirm, also it\'s good for you to tailor make your policy yourself.",
			Name:"Paul Anderson, Sunderland",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"I completed the proposal form, arranged the payment and printed it off in half an hour, whilst watching TV - brilliant\! Not like the old days.",
			Name:"Keith Walsh, Canterbury",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"Getting a quote from you was much quicker, easier \& cheaper (by over &pound;100) then it was through my broker.  And it\'s ace accessing the policy via the web - saves all the hunting around for misplaced insurance certificate\!",
			Name:"Dave Arthur, Shipley",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"I found Swiftcover very easy to use and they offered me an excellent quote, the site is easy to navigate \& it\'s a pleasant change not to have to listen to scripted insurance jargon from a salesperson.",
			Name:"G Morgan, Mitcham",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"Swiftcover saved me almost &pound;300, your quote was half my renewal quote from Elephant.",
			Name:"Izabela Mazaraki, Reading",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"Keep doing what you are doing - keep it simple, people get fed up with spending ages inputting and I was able to secure a straight forward policy.",
			Name:"Mrs East, Chelmsford",
			Product:"Motor",
			Stage:"Quote"
		},
		{
			Comment:"This was my second policy from yourselves, I insured my partners car through you earlier this year, and both times I was impressed. I love being able to access my insurance document online, I\'ll never need to lose it again\!\!",
			Name:"Bill Blackburn, Bournemouth",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"Previously with Elephant.co.uk - and you saved me nearly &pound;170 against their quote which was amazing",
			Name:"Darren Berwick, Horsham",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"I saved over &pound;200 and that was with a lower voluntary excess than my previous insurer. The cover is totally comparable, if not better.",
			Name:"Anne Tully, Pontefract",
			Product:"Motor",
			Stage:"Quote"
		}, 
		{
			Comment:"I was a little worried about getting a quote on line, confirming on line and paying on line, but I need not have been concerned. It went well.",
			Name:"M. Jones",
			Product:"Motor",
			Stage:"Buy"
		}, 
		{
			Comment:"Excellent website, I was worried about paying on the internet but I needn\'t have.",
			Name:"Mr J Baxter, Kettering",
			Product:"Motor",
			Stage:"Buy"
		}, 
		{
			Comment:"I was very pleased with the quote. It was the lowest I\'d received and having access to my documents online is great! They even texted me the claims number to add to my phone\!",
			Name:"Mark Frost, Stanford-le-Hope",
			Product:"Motor",
			Stage:"Buy"
		}, 
		{
			Comment:"I must compliment you on your quality of service. Having had occasion to make a claim, I would, recommend your company without hesitation as one which looks after your customers and offers great value for money and excellent service.",
			Name:"David Price, Rugby",
			Product:"Motor",
			Stage:"Buy"
		}, 
		{
			Comment:"It was great to be able to print the certificate myself there and then instead of waiting 10 days for it to be posted.",
			Name:"Sarah Fenner, Seaton",
			Product:"Motor",
			Stage:"Buy"
		}, 
		{
			Comment:"I completed the proposal form, arranged the payment and printed it off in half an hour, whilst watching TV - brilliant! Not like the old days.",
			Name:"Keith Walsh, Canterbury",
			Product:"Motor",
			Stage:"Buy"
		}
	]
var whichComment = Comments[0] ;
commentInitialize("Motor", "Quote");

//------------------------------------------------------------------------------------------------------------
//Function: CommentInitialize()
//Description: Initialize "whichComment" to a random comment within the list of available comments.
//------------------------------------------------------------------------------------------------------------
function commentInitialize(strProduct, strStage) {
	//Create a list of the relevent subset of customer comments.
	var tempList = new Array();
	for (var i = 0 ; i<Comments.length; i++) {
		if ((Comments[i].Product == strProduct || strProduct == "" || Comments[i].Product == "Any") &&
				(Comments[i].Stage == strStage || strStage == "") || Comments[i].Stage == "Any") {
			tempList.push(Comments[i]) ;
		}
	}
	
	//Set "whichComment" to point to a random comment within the list.
	if (tempList.length > 0) {
		whichComment = tempList[Math.round((tempList.length-1) * Math.random())] ;
	}
}

//------------------------------------------------------------------------------------------------------------
//Function: showComment()
//Description: Display the comment from the selected customer quotation.
//------------------------------------------------------------------------------------------------------------
function showComment() {
	document.write(whichComment.Comment) ;
}

//------------------------------------------------------------------------------------------------------------
//Function: showName()
//Description: Display the name from the selected customer quotation.
//------------------------------------------------------------------------------------------------------------
function showName() {
	document.write(whichComment.Name) ;
}
