/*

		AutoCheck.js
		
		AutoCheck report functionality
		
		Written by:		Ken Kolodziej
		Created on:		September 29, 2009
		
*/

var AutoCheck = new Class({
	options: {
		CID: ''
	},
	initialize: function(options) {
		this.setOptions(options);
		
		// Get target element
		this.targetElement = $(this.options.CID);
	},
	returnReport: function(DID, VIN, returnScore) {
		var ajax = new Request({
			url: '/index.cl/event/ws/cmd/returnAutocheckReport/DID/' + DID + '/VIN/' + VIN + '/returnScore/' + returnScore,
			onSuccess: this.injectReport.bind(this)
		}).send();
	},
	injectReport: function(html) {
		/*
		if(document.querySelectorAll && Browser.Engine.trident) {
			var newEl = new Element('div', {
				'html': '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="75" height="75">' + JSON.decode(html).responseText + '</td></tr></table>'
			});
		}
		else {
			var newEl = document.createElement('div');
			newEl.innerHTML = JSON.decode(html).responseText;
		}
		this.targetElement.parentNode.appendChild(newEl, this.targetElement);
		*/
		this.targetElement.innerHTML = JSON.decode(html).responseText;
	}
});
AutoCheck.implement(new Options, new Events);