function ViewProduct(_id, _value) {

	// Standard properties
	this.id = _id;	
	
	this.containerElementId = "C_" + this.id;
	this.containerElement = document.getElementById(this.containerElementId);
	
	// Appearance
	this.width = 0;
	this.height = 0;
	this.visible = true;
	
	// Events
	this.onclick = "";
	this.onaddtocart = "";
	
	// Extra properties
	
	// Bij meerdere apps op de pagina
	this.appName = "";
	this.appType = "";
	
	// Methods
	this.show = ViewProduct_show;
	this.hide = ViewProduct_hide;
	
	this.registerEvents = ViewProduct_registerEvents;
	this.addEvent = ViewProduct_addEvent;
	this.getEventName = ViewProduct_getEventName;
	
	this.render = ViewProduct_render;
	this.destroy = ViewProduct_destroy;
	
	this.getType = ViewProduct_getType;
	
}

function ViewProduct_getType() { return "ViewProduct"; }
function ViewProduct_destroy() {}
function ViewProduct_render() {}

function ViewProduct_hide() {
	if (this.containerElement) {
		this.visible = false;
		this.containerElement.style.display = "none";
	}
}

function ViewProduct_show() {
	if (this.containerElement) {
		this.visible = true;
		this.containerElement.style.display = "block";
	}
}

function ViewProduct_getEventName(whichevent) { return (eval("this.on" + whichevent)); }

function ViewProduct_registerEvents() {
	if (this.containerElement) {
		if (this.onclick.length > 0) {
			this.addEvent('click');
		}
	}	
}
	
function ViewProduct_addEvent(eventtype) {
	// W3C
	if(this.containerElement.addEventListener) {
		this.containerElement.addEventListener(eventtype, handle_event, false);
	}
	// Microsoft
	else if(this.containerElement.attachEvent){
		this.containerElement.attachEvent("on" + eventtype, handle_event);
	}
}

// Deze functie wordt gebruikt bij een klik op een medium size afbeelding
function ViewProduct_onMediaClicked(ev, el) {
	// Het te tonen element dient nog gemaakt te worden,
	// we kunnen dus voorlopig nog niets tonen
	if(el.needsCreate == true) {}
	else {
		// We tonen een afbeelding in een popup
		if (el.isImage) {
			openWindow(webroot + "/media?mediaid=" + el.mediaId, "win" + el.id, 800, 600);
		}
		// Alle andere bestanden gaan we gewoon downloaden
		// Niet meer nodig zie functie hieronder (ViewProduct_onSmallMediaClicked)
		//else {
		//	gotourl(el.fullPath);
		//}
		
	}
	
}

// Deze functie wordt gebruikt bij een klik op een kleine afbeelding
function ViewProduct_onSmallMediaClicked(ev, el) {
	// We tonen de 'throbber' onder de medium-afbeelding
	document.getElementById("LoadingPicture").style.visibility = "visible";
	// Kleine afbeeldingen moeten eerst getoond worden in medium size
	if (el.isImage) {
		MPreview.mediaId = el.mediaId;
		MPreview.needsCreate = true
		MPreview.init();
	}
	// Andere bestanden gaan we meteen downloaden
	else {
		gotourl(el.fullPath);
	}
	
}

