Ext.define('TradePortal.view.products.ProductImageView', {
	extend: 'Ext.view.View',
	loadMask: false,
	alias: 'widget.productimageview',
	tpl: new Ext.XTemplate(
		'<tpl for=".">',
		'<div class="thumb-wrap"><img src="{productFiles:this.renderImage}" width="200" height="200" /></div></tpl>',
		{
			renderImage: function (images) {
				del = images.indexOf("|");
				first = images.indexOf("http");
				file = images.indexOf("S:");
				last = images.lastIndexOf("http");
				jpg = images.indexOf(".jpg");
				pdf = images.indexOf(".pdf");

				if (file != -1 || images == '') {
					TradePortal.view.products.pdfLink = '';
					Ext.getCmp('view_spec_sheet').hide();
				} else if (del == -1) {
					TradePortal.view.products.pdfLink = '';
					Ext.getCmp('view_spec_sheet').hide();
				} else if (pdf > del) {
					TradePortal.view.products.pdfLink = images.substr(last,
						pdf + 4);
					TradePortal.view.products.pdfLink = TradePortal.view.products.pdfLink.replace('|', '');
					Ext.getCmp('view_spec_sheet').show();
				} else {
					TradePortal.view.products.pdfLink = images.substr(0,
						pdf + 4);
					TradePortal.view.products.pdfLink = TradePortal.view.products.pdfLink.replace('|', '');
					Ext.getCmp('view_spec_sheet').show();
				}

				if (file != -1 || images == '') {
					return "noImage.gif";
				} else if (del == -1) {
					return images;
				} else if (jpg > del) {
					images = images.substr(last, jpg + 4);
					return images;
				} else {
					images = images.substr(0, jpg + 4);
					return images;
				}
			}
		}),
	store: 'showProductDetails',
	itemSelector: 'div.thumb-wrap',
	emptyText: 'No image',
	initComponent: function () {
		this.callParent(arguments);
	}
});