﻿// --- Klasse partitur --- PS 10.3.08 ---

function partitur( node )
{
	this.node				= node;
	this.node.partitur	= this;
	this.partitur			= this;

	this.create				= partiturCreate;
	this.init				= partiturInit;
	this.play				= partiturPlay;
	this.set_trackmode	= partiturSetTrackMode;
	this.set_sn				= partiturSetSn;
	this.set_tab			= partiturSetTab;
	this.set_all			= partiturSetAll;
	this.set_aktiv			= partiturSetAktiv;
	this.set_passiv		= partiturSetPassiv;
	this.vollbild			= partiturVollbild;
	
	// --- Parameter zerlegen ---
	
	var para = node.title.split("|");
	
	this.titel		= para[0];
	this.trackmode	= para[1];
	this.height		= para[2];
	this.src			= "media/" + para[3] + ".tb2";
	this.mp3			= "media/" + para[3] + ".mp3";
	this.png			= "media/" + para[3] + ".png";
	this.width		= para[4];
	
	this.create()
}

function partiturCreate()
{
	var plugin = getPlugin();
	
	if( plugin == pluginNP )
	{
		this.partitur.node.innerHTML = '<div id="canvas_' + this.partitur.src + '">' + this.partitur.titel + '<embed id="' + this.src + '" width="100%" height="' + this.partitur.height + 'px" src="' + this.partitur.src + '" backcolor="#ffffff" title="FALSE" showtitle="FALSE" trackmode="' + this.partitur.trackmode + '" scorewidth="' + this.partitur.width + '"></embed></div>';
		
		menu = document.createElement("div");
		menu.id = "menu_" + this.partitur.src;
		menu.style.borderTop = "solid 1px #d0d0d0";
		menu.style.backgroundColor = "#eed";
		menu.style.textAlign = "left";
		menu.style.padding = "5px";

		btn1 = document.createElement( "input" );
		btn1.type = "Button";
		btn1.value = "Start/Stop";
		btn1.style.width = "90px";
		btn1.style.marginRight = "20px";
		btn1.partitur = this;
		btn1.onclick = this.play;

		btn2 = document.createElement( "input" );
		btn2.type = "Button";
		btn2.value = "Noten";
		btn2.style.width = "90px";
		btn2.partitur = this;
		btn2.onclick = this.set_sn;

		btn3 = document.createElement( "input" );
		btn3.type = "Button";
		btn3.value = "Tabulatur";
		btn3.style.width = "90px";
		btn3.partitur = this;
		btn3.onclick = this.set_tab;

		btn4 = document.createElement( "input" );
		btn4.type = "Button";
		btn4.value = "Beides";
		btn4.style.width = "90px";
		btn4.partitur = this;
		btn4.onclick = this.set_all;

		btn5 = document.createElement( "input" );
		btn5.type = "Button";
		btn5.value = "Vollbild";
		btn5.style.marginLeft = "20px";
		btn5.style.width = "90px";
		btn5.partitur = this;
		btn5.onclick = this.vollbild;

		menu.appendChild( btn1 );
		menu.appendChild( btn2 );
		menu.appendChild( btn3 );
		menu.appendChild( btn4 );
		menu.appendChild( btn5 );
		
		this.partitur.node.appendChild( menu );
	}
	else if( plugin == pluginAX )
	{
		var html = "";
		
		html = '<div id="canvas_' + this.partitur.src + '">' + this.partitur.titel;
		html += '<object id="' + this.partitur.src + '" classid="clsid:89468B2B-B784-49BA-BFD5-2B70A1A6B014" codebase="/bin/Tb2AXCtrl.ocx" border="0" width="100%" height="' + this.partitur.height + '" align="center">';
		html += '<param name="backcolor" value="#ffffff">';
		html += '<param name="showtitle" value="FALSE">';
		html += '<param name="trackmode" value="' + this.partitur.trackmode + '">';
		html += '<param name="scorewidth" value="' + this.partitur.width + '">';
		html += '<param name="tb2" value="' + this.partitur.src + '">';
		html += '</object>';
		html += '</div>'
		
		this.partitur.node.innerHTML = html;
				
		menu = document.createElement("div");
		menu.id = "menu_" + this.partitur.src;
		menu.style.borderTop = "solid 1px #d0d0d0";
		menu.style.backgroundColor = "#f0f0f0";
		menu.style.textAlign = "left";
		menu.style.padding = "5px";

		btn1 = document.createElement( "input" );
		btn1.type = "Button";
		btn1.value = "Start/Stop";
		btn1.style.width = "90px";
		btn1.style.marginRight = "20px";
		btn1.partitur = this;
		btn1.onclick = this.play;

		btn2 = document.createElement( "input" );
		btn2.type = "Button";
		btn2.value = "Noten";
		btn2.style.width = "90px";
		btn2.partitur = this;
		btn2.onclick = this.set_sn;

		btn3 = document.createElement( "input" );
		btn3.type = "Button";
		btn3.value = "Tabulatur";
		btn3.style.width = "90px";
		btn3.partitur = this;
		btn3.onclick = this.set_tab;

		btn4 = document.createElement( "input" );
		btn4.type = "Button";
		btn4.value = "Beides";
		btn4.style.width = "90px";
		btn4.partitur = this;
		btn4.onclick = this.set_all;

		btn5 = document.createElement( "input" );
		btn5.type = "Button";
		btn5.value = "Vollbild";
		btn5.style.marginLeft = "20px";
		btn5.style.width = "90px";
		btn5.partitur = this;
		btn5.onclick = this.vollbild;

		menu.appendChild( btn1 );
		menu.appendChild( btn2 );
		menu.appendChild( btn3 );
		menu.appendChild( btn4 );
		menu.appendChild( btn5 );
		
		this.partitur.node.appendChild( menu );
	}
	else
	{
		noten = document.createElement("div");
		noten.style.width = "750px";
		noten.style.overflow = "scroll";
		
		text = document.createElement("span");
		text.innerHTML = this.partitur.titel;
		
		img = document.createElement("img");
		img.src = this.partitur.png;
		img.style.marginTop = "20px";		
		img.style.marginBottom = "20px";		

		player = document.createElement("span");
		player.innerHTML = '<object type="application/x-shockwave-flash" data="/bin/emff_silk.swf" width="84" height="32"><param name="movie" value="/bin/emff_silk.swf" /><param name="FlashVars" value="src=' + this.partitur.mp3 + '"/></object>';
		player.style.padding = "0px 0px 5px 5px";
		
		getit = document.createElement("a");
		getit.href="/tabazar/index.php?lang=0&page=1";
		getit.style.height = 16;
		getit.innerHTML = "TaBazar-Plugin nicht installiert! Download?";
		getit.style.fontSize = "12px";
		getit.style.padding = "0px 0px 5px 10px";
		
		noten.appendChild( text );
		noten.appendChild( img );
		noten.style.textAlign = "center";
		
		this.partitur.node.appendChild( noten );
		this.partitur.node.appendChild( player );
		this.partitur.node.appendChild( getit );
		this.partitur.node.style.textAlign = "left";
	}

	this.partitur.node.title = "";
}

function partiturInit()
{
	var player = document.getElementById( this.partitur.src );
	
	if( player )
		player.init();
}

function partiturPlay()
{
	var player = document.getElementById( this.partitur.src );
	
	if( player )
	{
		player.play();
	}
}

function partiturSetTrackMode( trackmode )
{
	if( this.partitur.trackmode != trackmode )
	{
		var player = document.getElementById( this.partitur.src );
		
		if( player )
		{
			height = player.settrackmode( trackmode );
			
			this.partitur.trackmode = trackmode;
			player.style.height = height + 20;
		}
	}
}

function partiturSetSn()
{
	this.partitur.set_trackmode(1);
}

function partiturSetTab()
{
	this.partitur.set_trackmode(2);
}

function partiturSetAll()
{
	this.partitur.set_trackmode(3);
}

function partiturSetAktiv()
{
	this.style.border = "solid 1px #000";
}

function partiturSetPassiv()
{
	this.style.borderLeft = "solid 1px #ccc";
	this.style.borderTop = "solid 1px #ccc";
	this.style.borderRight = "solid 1px #888";
	this.style.borderBottom = "solid 1px #888";
}

function partiturVollbild()
{
	document.location.href = PartiturVollbild( this.partitur.src );
}