function View1(parent) {
	this.parent=parent
	this.browser=new Browser(this)
	this.infodisplayer=new InfoDisplayer(this)
	this.tabs=new Tabs(this)

	// Elements
	this.desc=null

	// Functions
	this.toggleDescription=toggleDescription_fnct
	this.toggleFontList=toggleFontList_fnct
	this.showFullSet=showFullSet_fnct
	this.showCategory=showCategory_fnct
	this.displayFontInfo=displayFontInfo_fnct
	this.addMoreInfo=addMoreInfo_fnct
	this.displayPDFInfo=displayPDFInfo_fnct
	this.displayProInfo=displayProInfo_fnct
	this.displaySetInfo=displaySetInfo_fnct

}

function toggleDescription_fnct(v) {
	this.desc.style.display=v
}

function toggleFontList_fnct(v) {
	this.browser.browserdiv.style.display=v
}

function showFullSet_fnct(name) {
	this.browser.clearBrowser()

	var msgdiv=this.browser.msgText()
	this.parent.model.settings.fullFunction(msgdiv)
	this.browser.browserdiv.appendChild(msgdiv)

	var moreinfo=this.browser.moreInfoElem()
	moreinfo.style.marginLeft='5px'
	this.browser.browserdiv.appendChild(moreinfo)

	this.parent.model.setFont(name, this.parent.model.category.category.get()[name])
	this.addMoreInfo(moreinfo)

	this.toggleDescription('none')
	this.toggleFontList('')
}

function showCategory_fnct(name, fonts) {
	this.browser.clearBrowser()
	var msgdiv=this.browser.msgText()
	this.browser.browserdiv.appendChild(msgdiv)

	for (var i=0;i<fonts.length; i++) {
		var font=fonts[i]
		var fontitem=this.browser.fontItem(font)
		this.browser.browserdiv.appendChild(fontitem)
	};

	this.toggleDescription('none')
	this.toggleFontList('')
}

function displayFontInfo_fnct() {

	with(this.parent.model.font) {
		var previewsrc=getSRC()
		var name=font.get()
		var price=getPrice()
		var licurl=getLicenseUrl()
		var pdf=getPDF()
		var orderops=getOrderOptions()
	};

	with(this.infodisplayer) {
		setPreview(previewsrc)
		setFamilyName(name)
		setPrice(price)
		setLicenseUrl(name, licurl, orderops)
	};
}

function addMoreInfo_fnct(elem) {
	elem.innerHTML=''

	this.displayPDFInfo(elem)
	this.displaySetInfo(elem)
	this.displayProInfo(elem)
	
	var nodes=this.browser.browserdiv.childNodes

	for (var i=0;i<nodes.length;i++) {
		var node=nodes[i]

		if (node.getAttribute('id')=="fontanchor") {
			node.lastChild.style.display='none'
		};
	};

	elem.style.display=''
}

function displayPDFInfo_fnct(midiv) {
        var pdf=this.parent.model.font.getPDF()
	if (pdf) {
        	this.infodisplayer.setPDFUrl(midiv, pdf)
        };
}

function displayProInfo_fnct(midiv) {
	var features=this.parent.model.font.getFeatures()
	if (features) {
		this.infodisplayer.setProFeatures(midiv, features)
	};
}

function displaySetInfo_fnct(midiv) {
	var fonts=this.parent.model.font.getFonts4Set()
	if (fonts && (fonts['p'] || fonts['s'])) {
		this.infodisplayer.setFonts4Set(midiv, fonts)
	};
}

