/**
*	RolexDealerPlaque
*/
function RolexDealerPlaque() {

	//URL constants
	var GATEWAY_URL = 'http://www.rolex.com/gatewaydealer.aspx';
	var IMAGE_SERVICE_URL = 'http://binary.rolex.com/plaque/validate_dealer.rlx';

	//HTML for the form
	var FORM_HTML = '<form name="rolex-dealer-form" method="post" action="__GATEWAY_URL__" target="_blank">' + 
				   '<input name="lang" value="__LANG__" type="hidden" />' + 
				   '<input name="dealerDomain" value="__DOMAIN__.com" type="hidden"/>' +
				   '<input name="dealerAPIKey" value="__DEALER_API_KEY__" type="hidden" />' +
				   '<input type="image" value="Go" src="__IMAGE_SERVICE_URL__?lang=__LANG__&amp;dealerAPIKey=__DEALER_API_KEY__&amp;copy=__COPY__&amp;size=__SIZE__&amp;colour=__COLOUR__&amp;domain=__DOMAIN__&amp;ts=__TIMESTAMP__" />'+
				'</form>';

	this.getPlaque = function(config) {

	    //update the form text with new values
	    var newForm = FORM_HTML;
	    newForm = this.replaceValue(newForm, '__GATEWAY_URL__', GATEWAY_URL);
	    newForm = this.replaceValue(newForm, '__IMAGE_SERVICE_URL__', IMAGE_SERVICE_URL);
	    newForm = this.replaceValue(newForm, '__DEALER_API_KEY__', config.dealerAPIKey);
	    newForm = this.replaceValue(newForm, '__LANG__', config.lang);
	    newForm = this.replaceValue(newForm, '__COPY__', config.copy);
	    newForm = this.replaceValue(newForm, '__SIZE__', config.size);
	    newForm = this.replaceValue(newForm, '__COLOUR__', config.colour);
	    newForm = this.replaceValue(newForm, '__DOMAIN__', config.domain);
	    newForm = this.replaceValue(newForm, '__TIMESTAMP__', this.createTimeStamp());

	    //add the form to the page
	    var targetHTML = document.getElementById("rolex-dealer-plaque");
	    targetHTML.innerHTML = newForm;

	}

	this.createTimeStamp = function()
	{
		return new Date().getTime();
	}

	this.replaceValue = function(target, key, value)
	{
		return target.split(key).join(value);
	}

}