function mod_voorstelling() 
{
	this.mod_id = 'mod_voorstelling';
	this.rel_window;
} 

mod_voorstelling.prototype.doAction = function(pAction, pId)
{
	var action 	= document.getElementById(this.mod_id + '_action');
	var id 		= document.getElementById(this.mod_id + '_id');
	var form 	= document.getElementById(this.mod_id + '_form');

	if (action && pAction) action.value = pAction;
	if (id && pId)	       id.value 	  = pId;
	if (form)              form.submit();
}

mod_voorstelling.prototype.doVandaag = function(pId, pUrl)
{
	var action  = document.getElementById('vandaag_action');
	var id  	= document.getElementById('vandaag_id');
	var form   	= document.getElementById('vandaag_form');

	if (action && pId) action.value = "details-" + pId;
	if (id && pId) id.value = pId
	if (form)      
	{
		form.action = pUrl;
		form.submit();
	}
}

mod_voorstelling.prototype.showRelation = function()
{
	if (this.rel_window && !this.rel_window.closed) this.rel_window.close();
	var a = '';
	for (var i=0; i<arguments.length; i++) a += '-' + arguments[i];	
	//this.rel_window = window.open('http://localhost/toneelschuur/cms/toneelschuur/modules/voorstelling/voorstelling_relation.asp?action=relation-list' + a, 'relations', 'width=500, height=600, status=no, toolbar=no, scrollbars=yes, resizable=yes');
	this.rel_window = window.open('modules/voorstelling/voorstelling_relation.asp?action=relation-list' + a, 'relations', 'width=500, height=600, status=no, toolbar=no, scrollbars=yes, resizable=yes');
	// this.rel_window = window.open('modules/voorstelling/voorstelling_relation.asp?table=' + pTable + '&id=' + pId, 'relations', 'width=500, height=600, status=0, toolbar=0');
	if (!this.rel_window) alert("Kan het venster niet openen. Heeft u misschien een popup-blocker aanstaan?");
}

mod_voorstelling.prototype.addHomepageSlideshowCaptions = function(vo_naam, vo_maker, vo_kop, vo_id, vo_ty_id, vo_jeugd, fo_omschrijving, fo_data, fo_fotograaf)
{
	var htm = "<span style='font-size:14px'>";
	if (vo_naam != "") htm += "<strong>" + vo_naam + "</strong>";
	if (vo_maker != "") htm += " <em>" + vo_maker + "</em>";
	htm += "</span>";
	if (vo_naam != "" && vo_maker != "") htm += "<br /><br />";
	if (vo_kop != "") htm += vo_kop + "<br /><br />";
	if (fo_data != "") htm += "Data: " + fo_data + "<br /><br />";
	if (fo_omschrijving != "") htm += fo_omschrijving;
	//if (vanaf != "") htm += vanaf;
	//if (sp_tijd_van != "") htm += ", " + sp_tijd_van + " uur";	
	
	if (htm != "")
	{
		var id = 0;
		if (vo_ty_id == "1") id = 2;
		if (vo_ty_id == "2") id = 32;
		if (vo_ty_id == "3") id = 5;
		if (vo_jeugd == "true") id = 3;
		htm = htm + "<a href='index.asp?id=" +  id + "&vo_id=" + vo_id + "' class='homemeerinfo'>Meer info >></a>";	
	}
	return htm;
}

mod_voorstelling.prototype.addMedia = function(fi_pad, fi_url, fi_width, fi_height)
{
	fi_pad = (fi_url != "") ? fi_url : fi_pad ;
	if (fi_pad.indexOf(".swf") > 0)
	{
		this.addFlash(fi_pad.replace(".swf", ""), fi_width, fi_height);
	}
	else if (fi_pad.indexOf(".mov") > 0 || fi_pad.indexOf(".qt") > 0)
	{
		this.addQuicktime(fi_pad, fi_width, fi_height);
	}
	else if (fi_pad.indexOf(".r") > 0)
	{
		this.addRealMedia(fi_pad, fi_width, fi_height);
	}
	else
	{
		this.addWindowsMedia(fi_pad, fi_width, fi_height);
	}	
}

mod_voorstelling.prototype.addFlash = function(fi_pad, fi_width, fi_height)
{
	AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', fi_width,
			'height', fi_height,
			'src', fi_pad,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', fi_pad,
			'bgcolor', '#ffffff',
			'name', fi_pad,
			'menu', 'false',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', fi_pad,
			'salign', ''
			)
}

mod_voorstelling.prototype.addQuicktime = function(fi_pad, fi_width, fi_height)
{
	QT_WriteOBJECT_XHTML(fi_pad, fi_width, parseInt(fi_height, 10) + 15, '', 'autoplay', 'false', 'emb#bgcolor', 'black', 'align', 'middle'); 
}

mod_voorstelling.prototype.addWindowsMedia = function(fi_pad, fi_width, fi_height)
{
	var htm = "" + 
				"<OBJECT ID='MediaPlayer' WIDTH='" + fi_width + "' HEIGHT='" + fi_height + "' CLASSID='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' STANDBY='Loading Windows Media Player components...' TYPE='application/x-oleobject'>" +
				"<PARAM NAME='FileName' VALUE='" + fi_pad + "'>" + 
				"<PARAM name='autostart' VALUE='false'>" +
				"<PARAM name='ShowControls' VALUE='true'>" + 
				"<param name='ShowStatusBar' value='true'>" +
				"<PARAM name='ShowDisplay' VALUE='true'>" + 
				"<PARAM name='stretchToFit' VALUE='true'>" + 				
				"<EMBED TYPE='application/x-mplayer2' SRC='" + fi_pad + "' NAME='MediaPlayer' WIDTH='" + fi_width + "' HEIGHT='" + fi_height + "' ShowControls='1' ShowStatusBar='1' ShowDisplay='1' stretchToFit='1' autostart='0'>" +
				"</EMBED></OBJECT>";
				
	document.write(htm);
}

mod_voorstelling.prototype.addRealMedia = function(fi_pad, fi_width, fi_height)
{
	var htm = "" + 
				"<OBJECT id='rvocx' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='" + fi_width + "' height='" + fi_height + "'>" + 
        		"<param name='src' value='" + fi_pad + "'>" +
       			"<param name='autostart' value='false'>" + 
       			"<param name='controls' value='imagewindow'>" +
				"<param name='console' value='video'>" + 
        		"<param name='loop' value='false'>" + 
       			"<EMBED src='" + fi_pad + "' width='" + fi_width + "' height='" + fi_height + "'loop='false' type='audio/x-pn-realaudio-plugin' controls='imagewindow' console='video' autostart='false'>" + 
       		 	"</EMBED></OBJECT>" + 
				"<OBJECT id='rvocx' classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='" + fi_width + "' height='30'>" +
         		"<param name='src' value='" + fi_pad + "'>" +
         		"<param name='autostart' value='false'>" + 
         		"<param name='controls' value='ControlPanel'>" + 
         		"<param name='console' value='video'>" + 
          		"<EMBED src='http://servername/path/to/media.file' width='" + fi_width + "' height='30' controls='ControlPanel' type='audio/x-pn-realaudio-plugin' console='video' autostart='false'>" + 
				"</EMBED></OBJECT>";
				
	document.write(htm);	
}

mod_voorstelling.prototype.writeSpeelschema = function(pId, pData, pTmp, pType_Id, pJeugd, pPremiere)
{	
	if (pData.length > 0)
	{
		var htm = "<div id='speelschemas_" + pId + "'><table class='speelschemas'>";
		var pDataMax = pData.length;
		if (pData.length > 10)
		{ 
			pDataMax = 10;
		}
		
		for (var i=0; i<pDataMax; i++)
		{			
			var a = pData[i];
			var h = pTmp;
			for (var j=0; j<a.length; j++) h = h.replace("a[" + j + "]", a[j]);	
			htm += h;
			
		}		
		if (pData.length > 10)
		{
			var id = 0;
			if (pType_Id == "1") id = 2;
			if (pType_Id == "2") id = 32;
			if (pType_Id == "3") id = 5;
			if (pJeugd == true) id = 3;
			htm += "<tr><td colspan=2><a href='index.asp?id=" ;
			htm += id ;
			htm += "&vo_id=" ;
			htm += pId ;
			htm += "' class='meerinfo' >Meer data &raquo;</a></td></tr>";
		}
		htm += "</table></div>";
	
		document.write(htm);
		
	}
}

mod_voorstelling.prototype.writeFoto = function(pData, pWidth)
{	
	//if (pData.length > 0) pData = pData[0]; // use first image in array
	if (!pWidth) pWidth = 120;
  document.write("<img src='upload/" + pData + "' align='left' style='margin: 0 10px 10px 0; width:" + pWidth + "px; border: 0;' />");
}

mod_voorstelling.prototype.writeSlideshow = function(pImg, pId, pSize)
{
  if (!pSize) pSize = 250;
	if (pImg.length > 1)
	{
	  document.write("<div id='slideshow_" + pId + "' class='slideshow'><img src='img/pixel.gif' />/div>");
    new Slideshow('slideshow_" + pId + "', {width: pSize, height: pSize, hu: 'upload/', images: pImg});
	}
	else
	{
    this.writeFoto(pImg, pSize);
  }		
}

var mVo = new mod_voorstelling();