
var cfo = {
   newWindow: null,
   formName: "_c_a_q_c_f_o_r_m_",
   html: "",
   
   getReport: function(vin) {
       this.buildContent(vin);
       this.openWindow();
       this.writeContentToWindow();
   },

   getReportInThisWindow: function(vin) {
       this.buildForm(vin);
       this.writeFormToCurrentWindow();
   },
     
   buildContent: function(vin) {
      this.html = "<html><body>";
      this.buildForm(vin);
      this.html += "<script>document.forms['" + this.formName + "'].submit();</script>";
      this.html +="</body></html>";
   },
   
   buildForm: function(vin) {
	  this.html += "<form action='http://www.carfaxonline.com/AuctionCheck/display.cfx' method='post' name='" + this.formName + "'>";
	  this.html += "<input type='hidden' name='key' value='s4vPmsiLz4SzmbHysQ=='/>";
	  this.html += "<input type='hidden' name='vin' value='" + vin + "'/>";
	  this.html += "</form>";
   },
    
   openWindow: function() {
	  this.newWindow = window.open("", "_blank", "resizable=1,scrollbars=1,location=0,status=0,toolbar=0,menubar=0,width=750,height=650");
   },
   
   writeFormToCurrentWindow: function() {
      var body = document.getElementsByTagName('body')[0];
	  var div = document.createElement('div');
	  div.innerHTML = this.html;
	  body.appendChild(div);
	  setTimeout('cfo.submitForm()', 500);
   },
   
   submitForm: function() {
      document.forms[this.formName].submit();
   },
   
   writeContentToWindow: function() {
	  this.newWindow.document.write(this.html);
   }
}