var Print = {
	html: [],

	ini: function() {
		this.html = [];

		this.html.push('<html><head><title>Volvo Car Configurator</title>');
		this.html.push('<meta http-equiv="content-type" content="text/html; charset=utf-8" />');
		this.html.push('<link href="/_/print.css" type="text/css" rel="stylesheet" />');
		this.html.push('</head><body>');
		this.html.push('<table width="100%" style="border: 1px solid #fff;">');

		this.header();
		this.configuration();
		this.options();
		this.totalPrice();
		this.standartOptions();
		this.footer();

		this.html.push('</table></body></html>');
		
		windows.popup('', 'Print car configurator', 800, 600, '', '', 'scrollbars', this.html.join(''));
	},

	header: function() {
		this.html.push('<tr><td align="center"><a href="" class="print_href" onclick="window.print(); window.close(); return false;">');
		this.html.push('<b>'+Interface.translate('print')+'</b></a></td></tr>');
		this.html.push('<tr><td align="center"><table width="97%">');
			this.html.push('<tr valign="bottom">');
			this.html.push('<td class="w120" align="left" rowspan="2"><img src="/_/volvo.gif" alt="Volvo logo"/></td>');
			this.html.push('<td align="center" colspan="2"><b><span style="font-size: 14px">'+Interface.translate('your_config')+'</span></b></td>');
			this.html.push('</tr><tr valign="bottom">');
			this.html.push('<td align="left">&nbsp;</td><td align="left">&nbsp;</td>');
			this.html.push('<td align="left"  class="w70"><img src="/_/volvoforlife.gif" alt=""/></td></tr>');
		this.html.push('</table></td></tr>');
		this.html.push('<tr class="h20"><td align="center"><img src="/_/separator.gif" width="97%" style="height: 2px;"></td></tr>');
	},

	configuration: function() {
		// top images
		this.html.push('<tr><td align="center"><table width="97%"><tr><td><table>');
			this.html.push('<tr><td width="103"><b>'+Interface.translate('model')+'</b></td>');
			this.html.push('<td width="80"><b><nobr>'+Interface.translate('uphols')+'</nobr></b>&nbsp;</td>');
			this.html.push('<td width="41"><b>'+Interface.translate('color')+'</b></td>');
			this.html.push('<td width="41"><b>'+Interface.translate('rims')+'</b></td></tr>');
			
			this.html.push('<tr><td><img src="/_/models/'+ Configurator.models.getModelById() +'.gif" alt=""/></td>');
			this.html.push('<td><img src="'+ Car.upholsData.pic_s +'" style="border: 1px solid black;"/></td>');
			this.html.push('<td><img src="'+ Car.colorData.pic_s +'" alt="" style="border: 1px solid black;"/></td>');
			this.html.push('<td><img src="'+ Car.rimsData.pic_s +'" style="border: 1px solid black; width: 36px; height: 36px;"/></td></tr></table>');
		this.html.push('</td></tr></table></td></tr>');

		this.html.push('<tr><td align="center"><br><table width="97%">');
			this.html.push('<tr><td>&nbsp;&nbsp;<b>'+ Interface.translate('basic') +'</b></td>');
			this.html.push('<td>&nbsp;</td><td class="w70" align="right"><b>'+ Interface.translate('price') +' '+ Price.defaultCurrency +'</b>&nbsp;&nbsp;</td></tr>');
		this.html.push('</table></td></tr>');

		this.html.push('<tr><td align="center"><table width="97%" class="b_all"><tr><td><table width="100%">');			

			this.html.push('<tr class="h20" valign="bottom">');
			this.html.push('<td class="w120">&nbsp;&nbsp;'+ Interface.translate('model') +'</td>');
			this.html.push('<td>&nbsp;&nbsp;'+ Configurator.models.getModelById() +'</td>');
			this.html.push('<td align="right" class="w70">'+ Price.getModelPrice(true) +'&nbsp;&nbsp;</td></tr>');
			
			this.html.push('<tr><td>&nbsp;&nbsp;'+ Interface.translate('engine') +'</td>');
			this.html.push('<td>&nbsp;&nbsp;'+ Configurator.matrix.getEngineById() +', CO<sup>2</sup> '+ Configurator.matrix.getCO2() +'</td>');
			this.html.push('<td align="right">&ndash;&nbsp;&nbsp;</td></tr>');

			this.html.push('<tr><td>&nbsp;&nbsp;'+ Interface.translate('trans') +'</td>');
			this.html.push('<td>&nbsp;&nbsp;'+ Configurator.matrix.getGearboxById() +'</td>');
			this.html.push('<td align="right">&ndash;&nbsp;&nbsp;</td></tr>');

			this.html.push('<tr><td>&nbsp;&nbsp;'+ Interface.translate('sv') +'</td>');
			this.html.push('<td>&nbsp;&nbsp;'+ Car.sv +'</td>');
			this.html.push('<td align="right">&ndash;&nbsp;&nbsp;</td></tr>');

			this.html.push('<tr><td>&nbsp;&nbsp;'+ Interface.translate('rims') +'</td>');
			this.html.push('<td>&nbsp;&nbsp;'+ Car.rimsData.text +'</td>');
			this.html.push('<td align="right">'+ Price.getPrice(Price.rims) +'&nbsp;&nbsp;</td></tr>');

			this.html.push('<tr><td>&nbsp;&nbsp;'+ Interface.translate('color') +'</td>');
			this.html.push('<td>&nbsp;&nbsp;'+ Car.colorData.text +'</td>');
			this.html.push('<td align="right">'+ Price.getPrice(Price.color) +'&nbsp;&nbsp;</td></tr>');

			this.html.push('<tr class="h20" valign="top">');
			this.html.push('<td>&nbsp;&nbsp;'+ Interface.translate('uphols') +'</td>');
			this.html.push('<td>&nbsp;&nbsp;'+ Car.upholsData.text +'</td>');
			this.html.push('<td align="right">'+ Price.getPrice(Price.uphols) +'&nbsp;&nbsp;</td></tr>');

		this.html.push('</table></td></tr></table></td></tr>');
	},

	totalPrice: function() {
		this.html.push('<tr><td align="center"><br /><table width="97%">');
			this.html.push('<tr><td class="b_t_b_l">&nbsp;&nbsp;<b>'+Interface.translate('dealer_total')+'</b></td>');
			this.html.push('<td align="right" class="b_t_b_r" width="100"><nobr><b>'+ Price.getTotalPrice() +'</b>&nbsp;&nbsp;</nobr></td></tr>');
		this.html.push('</table></td></tr>');
	},

	standartOptions: function() {
		this.html.push('<tr><td align="center"><br /><table width="97%">');
			try {
				eval(Configurator.standartOptions.data['xOpt']['txt']);
			} catch(e) {
				alert('Unable to load standart options data.');
				throw e;
				return;
			}
			this.html.push('<tr><td>&nbsp;&nbsp;<b>'+Interface.translate('equipment')+'</b></td></tr>');
			this.html.push('<tr><td class="b_t_b_l">');
			var so = sv_main.length;
			for(var i = 0; i < so; ++i) {
				if(i == Math.round(so/2)) this.html.push('</td><td class="b_t_b_r">');
				
				this.html.push('<table width="100%"><tr valign="top"><td class="w10" style="padding: 0 0 0 10px; margin: 0"><img src="/_/dot.gif" alt="dot" style="margin-top: 4px;"/></td>');
				this.html.push('<td style="padding: 0; margin: 0">'+sv_main[i]+'</td></tr></table>');
				
			}
			this.html.push('</td></tr></table></td></tr>');
		this.html.push('</table></td></tr>');
	},

	options: function() {
		this.html.push('<tr><td align="center"><br /><table width="97%">');
			this.html.push('<tr><td>&nbsp;&nbsp;<b>'+Interface.translate('optional_equipment')+'</b></td>');
			this.html.push('<td>&nbsp;</td><td class="w70" align="right">&nbsp;&nbsp;</td></tr>');

		so = Car.options.length;
		var so2 = 0;
		if (!so) this.html.push('<tr><td colspan="3" class="b_all">&nbsp;&nbsp;'+Interface.translate('none')+'</td></tr>');
		var temp = [];
		for (i = 0; i < so; i++) temp.push(Car.options[i].id);
		 var n = 0;
		for (el in Configurator.options.ad_options) {
			so2 = Configurator.options.ad_options[el].length;
			for (i = 0; i < so2; i++) {
				if (in_array(Configurator.options.ad_options[el][i][1], temp)) {
					this.html.push('<tr><td class="'+ (!n ? 'b_t_l' : 'b_l') +'">');
					this.html.push('<table width="100%"><tr valign="top"><td class="w10" style="padding: 0 0 0 10px; margin: 0"><img src="/_/dot.gif" alt="dot" style="margin-top: 4px;"/></td>');
					this.html.push('<td style="padding: 0; margin: 0">'+ Configurator.options.ad_options[el][i][0] +'</td></tr></table>');
					this.html.push('</td><td '+ (!n ? 'class="b_t"' : '') +'>&nbsp;</td>');
					this.html.push('<td class="'+ (!n ? 'b_t_r' : 'b_r') +'" align="right">'+ Configurator.options.ad_options[el][i][2] +'&nbsp;&nbsp;</td></tr>');
					n++;
				}
			}
		}
		this.html.push('<tr><td class="b_t_b_l">&nbsp;&nbsp;<b>'+ Interface.translate('total_eq_cost') +'</b></td>');
		this.html.push('<td class="b_t_b">&nbsp;</td><td class="b_t_b_r" align="right"><b>'+ Price.getPrice(Price.options) +'</b>&nbsp;&nbsp;</td></tr>');

		this.html.push('</table></td></tr>');
	},

	footer: function() {
		// dealer information
		this.html.push('<tr><td align="center"><br /><table width="97%" cellpadding="10">');
		var h = 1, w = 1, img = '';
		
		switch(parseInt(Configurator.dealerID, 10)) {
			case 3: // Sostena
				w = 200;
				h = 28;
				img = '/_/logos/Sostena_logo_be_uzraso.jpg';
				break;
			case 4: // MMG
				w = 200;
				h = 50;
				img = '/_/logos/musamotors_id.jpg';
				break;
			case 6: // Elite Auto
				img = '/_/_.gif';
				break;
			case 7: // Info Auto
				w = 160;
				h = 70;
				img = '/_/logos/IA_logo_w.gif';
				break;
			case 8: // Winner
				w = 203;
				h = 52;
				img = '/_/logos/Winner Logo.gif';
				break;
			case 9: // Signals
				w = 174;
				h = 34;
				img = '/_/logos/signaals.jpg';
				break;
		}
		
		this.html.push('<tr><td width="1%"><img src="'+ img +'" style="height: '+ h +'px; width: '+ w +'px;" alt="dealer_logo"/></td>');
		this.html.push('<td><b>'+ Configurator.dealers.getName() +'</b><br>'+ Interface.translate('phone') +': '+ Configurator.dealers.getPhone() +'<br>');
		this.html.push(Configurator.dealers.getStreet() +', '+ Configurator.dealers.getCity() +', '+ Configurator.dealers.getPostalCode() +', ');
		this.html.push(Configurator.dealers.getCountry() +'</td></tr>');
		this.html.push('</table></td></tr>');

		// disclaimers text
		this.html.push('<tr><td align="center"><br /><table width="97%">');
		this.html.push('<tr><td>&nbsp;&nbsp;<span class="small">'+ Interface.translate('disc1_'+ Configurator.market) +'</span></td></tr>');
		this.html.push('</table></td></tr>');
	}
}
