function InfoDisplayer(parent) {
	this.parent=parent

	// Elements
	this.previewimg=null
	this.familynamediv=null
	this.pricediv=null
	this.licenseurl=null
	this.pdfurl=null


	// Functions
	this.setPreview=setPreview_fnct
	this.setFamilyName=setFamilyName_fnct
	this.setPrice=setPrice_fnct
	this.setLicenseUrl=setLicenseUrl_fnct
	this.setPDFUrl=setPDFUrl_fnct
	this.setProFeatures=setProFeatures_fnct
	this.setFonts4Set=setFonts4Set_fnct

	this.toggleCollectionInfo=toggleCollectionInfo_fnct

}

function setPreview_fnct(src) {
	this.previewimg.setAttribute('src', src)
};

function setFamilyName_fnct(name) {
	this.familynamediv.removeChild(this.familynamediv.firstChild)
	this.familynamediv.appendChild(document.createTextNode(name))
};

function setPrice_fnct(price) {
	this.pricediv.removeChild(this.pricediv.firstChild)
	this.pricediv.appendChild(document.createTextNode('-$'+price))
};

function setLicenseUrl_fnct(name, sku, orderops) {
	switch(orderops) {
		case 0:
			var licenseurl="http://www.p22.com/license.php?face="+ name +"&mac="+ sku + "M&win="+ sku +"W"
			this.licenseurl.setAttribute('href', licenseurl)
		break;
		case 1:
			var licenseurl="http://www.p22.com/license.php?face="+ name +"&mac="+ sku + "M&win="+ sku +"W&cd="+ sku +"CD"
			this.licenseurl.setAttribute('href', licenseurl)
		break;
		case 2:
			var licenseurl="http://www.p22.com/license.php?face="+ name +"&cd="+ sku +"CD"
			this.licenseurl.setAttribute('href', licenseurl)
		break;
		case 3:
			// pass
		break;
	};

	this.toggleCollectionInfo(orderops)
};

function setPDFUrl_fnct(elem, url) {
	var anchor = document.createElement('a')
	anchor.setAttribute('href', 'pdfs/'+url+'.pdf')
	anchor.setAttribute('id', 'fontpdflink')
	var name=this.parent.parent.model.getFont()[0]
	var img=document.createElement('img')
	img.setAttribute('src', '../shared/images/pdficon.gif')
	anchor.appendChild(img)
	anchor.appendChild(document.createTextNode('Download '+ name + ' PDF'))
	
	elem.appendChild(anchor)
};

function setProFeatures_fnct(elem, features) {
	var ul=document.createElement('ul')
	
	var li=document.createElement('li')
	li.setAttribute('id', 'fontultitle')
	li.appendChild(document.createTextNode('OpenType Features:'))
	ul.appendChild(li)

	for (var k in features) {
		var v=features[k]
		var li=document.createElement('li')

		var anchor=document.createElement('a')
		anchor.setAttribute('href', this.parent.parent.model.settings.otsupporturl+'#'+v)
		anchor.appendChild(document.createTextNode(k))
		
		li.appendChild(anchor)
		ul.appendChild(li)
	}

	elem.appendChild(ul)

	// Additional OpenType Info List (should probably be its own function)
	var ul=document.createElement('ul')

	var li=document.createElement('li')
	li.setAttribute('id', 'fontultitle')
	li.appendChild(document.createTextNode('Additional OpenType Info:'))
	ul.appendChild(li)

	var li=document.createElement('li')
	var anchor=document.createElement('a')
	anchor.setAttribute('href', 'http://www.p22.com/support/opentype.html#Languages')
	anchor.appendChild(document.createTextNode('Language Coverage'))
	li.appendChild(anchor)
	ul.appendChild(li)

	var li=document.createElement('li')
	var anchor=document.createElement('a')
        anchor.setAttribute('href', 'http://www.p22.com/support/opentype.html#Installation')
        anchor.appendChild(document.createTextNode('Installation'))
        li.appendChild(anchor)
	ul.appendChild(li)

	elem.appendChild(ul)
};

function setFonts4Set_fnct(elem, fonts) {
	//var ul=document.createElement('ul')
	var ctxt= {'p':"Contains these Pro Fonts:", 's':"Contains these Single Fonts:"}

	for (var n in fonts) {
		if (fonts[n].length) {
			var ul=document.createElement('ul')

			var li=document.createElement('li')
			li.setAttribute('id', 'fontultitle')
			li.appendChild(document.createTextNode(ctxt[n]))
			ul.appendChild(li)

			for (var i=0;i<fonts[n].length;i++) {
				var li=document.createElement('li')
				li.appendChild(document.createTextNode(fonts[n][i]))
				ul.appendChild(li)
			};

			elem.appendChild(ul)
		};
	};

	//elem.appendChild(ul)
};

function toggleCollectionInfo_fnct(orderops) {
	 if (orderops==3) {
		this.licenseurl.style.display='none'
		this.licenseurl.style.width='0'
		this.familynamediv.parentNode.style.width='100%' 
	} else {
		this.licenseurl.style.width='22%'
		this.familynamediv.parentNode.style.width='72%'
		this.licenseurl.style.display=''	
	};
}

