/************************************** Apple Marketing ********************************
*
* Created By:
* 		Ed Hasting-Evans, Apple Marketing, http://www.apple-marketing.co.uk/

* Description:
*       Inserts a random customer quote
*
* Dependancies:
*       - JQuery plugin v1.4.1
*       
* Usage:
*		applemarketing.randomeQuote({
*			targetElement: '#homeContent'	// ID of the div you want to replace
*		});
*          
**************************************************************************************/

/* CHECKS AND IF MISSING CREATES applemarketing NAMESPACE */ 
if(!applemarketing) {
	// Creates local $ shortcut for jQuery so will run in noConflict mode
	var applemarketing={
		jQueryNoConflict: $ = jQuery
	};
}

applemarketing.randomeQuote = function(options) {
	// Default settings can be overwritten
	var settings = {
		quotes:	[
				'<blockquote>&#8220;Ed took time to understand our business and in an innovative way has managed to reflect our business culture in the website created for us &#8230; It looks great too!&#8221;</blockquote> <p><cite>Hazel Radnor, The Market Street Gallery</cite></p>',
				'<blockquote>&#8220;A direct mailing I ran for a Storage Depot achieved sales of 6.6%. So much more than the typical 0-2% response (not sales) rate&#8221;</blockquote> <p><cite>Storage Depot</cite></p>',
				'<blockquote>&#8220;My work on tandbergtv.com led to a 29% increase in targeted traffic&#8221;</blockquote> <p><cite>TANDBERG Television</cite></p>',
				'<blockquote>&#8220Ed listened to my ideas and created a website that exceeded my expectations. He did this quickly and professionally and I would not hesitate to recommend him to potential clients. Thanks Ed.&#8221;</blockquote> <p><cite>Terry Nye, NyeTec</cite></p>',
				'<blockquote>&#8220I would recommend Apple Marketing to anyone looking for an edge in website design and marketing&#8221;</blockquote> <p><cite>Dan Barnes, Tici Box</cite></p>'
			]
		
	};
	
	var methods = {
		init: function() {
			// Generate random number
			var now=new Date();
			var random=(now.getSeconds())%settings.quotes.length;
			
			// Calls writeQuote to write the quote in
			this.writeQuote(settings.quotes[random]);
		},
		
		writeQuote: function(theQuote) {
			// Emptys the div
			$(settings.targetElement).empty();
			
			// Writes in new quote
			$(settings.targetElement).append(theQuote);
		}
	};
	
	// Overwrites the default settings with those defined in the function call (options object)
	if (options) { 
		$.extend(settings, options);
    }
	
	// Executes the code
	methods.init();
	
	// Returns 'this' so it can be used in a chain
	return this;
	
};

