mc_menuAddons.js 13.1 KB
var var_player;
function init_audioPlayer(param_id,param_sources){

	var_player = window.document.createElement('div');
	var_player.className="js_player";

	var var_playerBar = window.document.createElement('div');
	var_playerBar.className="headmenu";

	var var_playerTitle = window.document.createElement('div');
	var_playerTitle.className="title";
	var_playerTitle.id="player_title";


	window.document.getElementById(param_id).appendChild(var_player);
	var obj_sources = new Object();
	obj_sources = param_sources;

	var_player.embed = new Object();

	var_player.songLength = obj_sources.length -1;
	var_player.number = 0;
	var_player.status = "stop";

	var_playerTitle.innerHTML = obj_sources[0].name;


	var_player.play =  function(){
		try {
			this.embed.Play();
		}
		catch (e) {
			this.embed.DoPlay();
		}
		var_buttonPlay.className="player_button player_pause";
		var_buttonPlay.href = "javascript:var_player.pause();";
		var_playerList.getElementsByTagName('li')[var_player.number].className+=" play";
		var_player.status = "play";
	};
	var_player.stop =  function(){
		try {
			this.embed.Stop();
		}
		catch (e) {
			this.embed.DoStop();
		}
		var_buttonPlay.className="player_button player_play";
		var_buttonPlay.href = "javascript:var_player.play();";
		var_playerList.getElementsByTagName('li')[var_player.number].className="selected";
		var_player.status = "stop";
	};
	var_player.pause =  function(){
		try {
			this.embed.Pause();
		}
		catch (e) {
			this.embed.DoPause();
		}
		var_buttonPlay.className="player_button player_play";
		var_buttonPlay.href = "javascript:var_player.play();";
		var_playerList.getElementsByTagName('li')[var_player.number].className+=" pause";
		var_player.status = "pause";
	};
	var_player.next =  function(){
		var_playerList.getElementsByTagName('li')[var_player.number].className="";
		if(var_player.status!="stop")
			var_player.stopCurrent();
		if(this.number == this.songLength){
			this.number = 0;
		}
		else{
			this.number += 1;
		}
		this.status = "play";
		this.setValues();
	};
	var_player.last =  function(){
		var_playerList.getElementsByTagName('li')[var_player.number].className="";
		if(var_player.status!="stop")
			var_player.stopCurrent();
		if(this.number == 0){
			this.number = this.songLength;
		}
		else{
			this.number -= 1;
		}
		this.status = "play";
		this.setValues();
	};

	var var_buttonPlay = window.document.createElement('a');
	var_buttonPlay.innerHTML = " ";
	var_buttonPlay.className="player_button player_play";
	var_buttonPlay.href = "javascript:var_player.play();";

	var var_buttonStop = window.document.createElement('a');
	var_buttonStop.innerHTML = " ";
	var_buttonStop.className="player_button player_stop";
	var_buttonStop.href = "javascript:var_player.stop();";

	var var_buttonNext = window.document.createElement('a');
	var_buttonNext.innerHTML = " ";
	var_buttonNext.className="player_button player_next";
	var_buttonNext.href = "javascript:var_player.next();";

	var var_buttonLast = window.document.createElement('a');
	var_buttonLast.innerHTML = " ";
	var_buttonLast.className="player_button player_last";
	var_buttonLast.href = "javascript:var_player.last();";

	var_playerBar.appendChild(var_buttonLast);
	var_playerBar.appendChild(var_buttonPlay);
	var_playerBar.appendChild(var_buttonNext);
	var_playerBar.appendChild(var_buttonStop);


	var_player.setValues = function(){
		this.embed = window.document.getElementById("song_"+this.number);
		var_playerTitle.innerHTML = obj_sources[this.number].name;
		if(this.status == "play"){
			this.play();
		}
	};

	var var_playerList = window.document.createElement('ul');
	var_playerList.className="smallList player_list";

	var_player.stopCurrent = function(){
		var tmp_embed = window.document.getElementById("song_"+var_player.number);
		try {
			tmp_embed.Stop();
		}
		catch (e) {
			tmp_embed.DoStop();
		}
	};

	for(var i = 0;i<obj_sources.length ; i++){
		var tmp_playerLi = window.document.createElement('li');

		tmp_playerLi.number = i;

		tmp_playerLi.innerHTML = "<object id='song_"+i+"' data='"+obj_sources[i].src+"' type=audio width=0 height=0 autostart=false enablejavascript='true'>no browser support </object>";
		tmp_playerLi.innerHTML+=obj_sources[i].name;

		var tmp_playerLiA=window.document.createElement('a');
		tmp_playerLiA.className="player_link";
		tmp_playerLiA.innerHTML=" ";
		tmp_playerLiA.href=obj_sources[i].src;
		tmp_playerLiA.title=obj_sources[i].name;
		tmp_playerLiA.target="_blank";

		tmp_playerLi.appendChild(tmp_playerLiA);

		tmp_playerLi.ondblclick = function(){
			if(var_player.status!="stop")
				var_player.stopCurrent();
			var_playerList.getElementsByTagName('li')[var_player.number].className="";
			this.className="selected";
			var_player.status="play";var_player.number = this.number; var_player.setValues();
		};
		tmp_playerLi.onclick = function(){
			if(this.number != var_player.number){
				if(var_player.status!="stop")
					var_player.stopCurrent();
				var_playerList.getElementsByTagName('li')[var_player.number].className="";
				this.className="selected";
				var_player.number = this.number; var_player.setValues();
			}
		};

		var_playerList.appendChild(tmp_playerLi);

	}

	var_playerList.getElementsByTagName('li')[var_player.number].className="selected";

	var_player.appendChild(var_playerBar);
	var_player.appendChild(var_playerTitle);
	var_player.appendChild(var_playerList);
	var_player.embed = window.document.getElementById("song_0");

}
function fnc_getCalendar(param_xml){

	var var_cal = new Object();


	if(param_xml.getElementsByTagName("BasisClipboard")[0]){

		var_cal.BCLink = param_xml.getElementsByTagName("BasisElement")[0].getElementsByTagName("Link")[0].getAttribute("host")+"/"+param_xml.getElementsByTagName("BasisElement")[0].getElementsByTagName("Link")[0].getAttribute("url")+param_xml.getElementsByTagName("BasisClipboard")[0].getAttribute("parameter");

	  	var var_DateList=param_xml.getElementsByTagName("BasisClipboard")[0].getElementsByTagName("List")[0];

		var var_LinkList=param_xml.getElementsByTagName("BasisClipboard")[0].getElementsByTagName("Menu")[0].getElementsByTagName("Link");

		for(var i = var_LinkList.length -1; i>=0; i--){
			if(var_LinkList[i].getAttribute("kind") == "nextDate"){
				var_cal.next = var_LinkList[i].getAttribute("parameter");
			}
			else if(var_LinkList[i].getAttribute("kind") == "backDate"){
				var_cal.back = var_LinkList[i].getAttribute("parameter");
			}
		}

	  	var_cal.startDate = var_DateList.getAttribute("start") * 1000;
	  	var_cal.endDate = var_DateList.getAttribute("end") * 1000;

		var_cal.month = param_xml.getElementsByTagName("Calendar")[0].getAttribute("month");

		var var_dateBE = var_DateList.getElementsByTagName("BasisElement");
		var_cal.dateBE = new Array();
		for(var i = var_dateBE.length-1; i >=0;i--){
			var_cal.dateBE[var_dateBE[i].getAttribute("ID")]=var_dateBE[i];
		}

		var_cal.entryArray = param_xml.getElementsByTagName("Calendar")[0].getElementsByTagName("Entrys")[0].getElementsByTagName("Entry");
		var_cal.dayArray = param_xml.getElementsByTagName("Calendar")[0].getElementsByTagName("CalendarDays")[0].getElementsByTagName("Day");
	}
	return var_cal;
}
function fnc_getUlfromCal(param_cal){
	var var_oneDayStamp = 86400000;
	var var_langDayArray=new Array("Su","Mo","Tu","We","Th","Fr","Sa","Su");

	var var_ul = window.document.createElement("ul");
	var_ul.className="DateBC Headline";


	/*var var_li = window.document.createElement('li');
	var_li.className="back";
	var_li.onmousedown=fnc_backMouseDown;
	var_li.innerHTML = "<<";
	var_ulHead.appendChild(var_li);

	var_li = window.document.createElement('li');
	var_li.innerHTML = obj_lang[var_langMonthArray[tmp_Date.getMonth()]]+" "+tmp_Date.getFullYear();
	var_li.className="month";
	var_ulHead.appendChild(var_li);

	var_li = window.document.createElement('li');
	var_li.className="next";
	var_li.onmousedown=fnc_nextMouseDown;
	var_li.innerHTML = ">>";
	var_ulHead.appendChild(var_li);

	var_pHead.appendChild(var_ulHead);
	var_container.appendChild(var_pHead);*/
	var tmp_Date = new Date();
	var var_todayDate = tmp_Date.getDate();
	var var_todayMonth = tmp_Date.getMonth();

	for(var i = 1; i<8;i++){
		var tmp_li = window.document.createElement('li');
		tmp_li.className = "day bold";
		tmp_li.innerHTML = obj_lang[var_langDayArray[i]];
		var_ul.appendChild(tmp_li);
	}

	for(var i = 0; i<42;i++){
		var tmp_li = window.document.createElement('li');

		tmp_li.className = "day";

		if(param_cal.month == param_cal.dayArray[i].getAttribute("month")){
			tmp_li.className += " thisMonth";
		}

		var tmp_span = window.document.createElement("span");

		if(param_cal.dayArray[i].getAttribute("day")==var_todayDate && param_cal.dayArray[i].getAttribute("month") == var_todayMonth){
			tmp_span.className = "green";
		}

		tmp_span.innerHTML = param_cal.dayArray[i].getAttribute("day");

		if(param_cal.dayArray[i].getElementsByTagName("DateHit").length > 0){
			var tmp_a = window.document.createElement("a");
			tmp_a.href = param_cal.BCLink;
			tmp_a.appendChild(tmp_span);
			tmp_li.appendChild(tmp_a);


			for(var l = 0; l<param_cal.dayArray[i].getElementsByTagName("DateHit").length;l++){
				var pop_p = window.document.createElement("p");
				pop_p.className="datePop vevent";
				var pop_span = window.document.createElement('span');
				pop_span.className="bold";
				var pop_summary = window.document.createElement('span');
				pop_summary.className="summary";

				pop_summary.innerHTML = param_cal.dateBE[param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("be_id")].getElementsByTagName("Headline")[0].getElementsByTagName("Element")[0].firstChild.nodeValue + "<br />";
				pop_span.appendChild(pop_summary);

				var pop_abbrStart = window.document.createElement('abbr');
				pop_abbrStart.className="dtstart";
				pop_abbrStart.title=param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("start");

				if(!param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("endDay")){
					pop_abbrStart.innerHTML = 	param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("startHour")
												+ ":"
												+ param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("startMinute")
												+ " "+obj_lang["time"];
				}
				else{
					var pop_abbrEnd = window.document.createElement('abbr');
					pop_abbrEnd.className="dtend";
					pop_abbrEnd.title=param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("end");
					pop_span.appendChild(pop_abbrEnd);


					if(param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("startDay")
							!= param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("endDay")
							|| param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("startMonth")
							!= param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("endMonth")
					){
						pop_abbrStart.innerHTML = param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("startDay")
						+ "."
						+ param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("startMonth")
						+ " - "
						+ param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("endDay")
						+ "."
						+ param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("endMonth");

					}
					else{
						pop_abbrStart.innerHTML = param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("startHour")
						+ ":"
						+ param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("startMinute")
						+ " - "
						+ param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("endHour")
						+ ":"
						+ param_cal.entryArray[param_cal.dayArray[i].getElementsByTagName("DateHit")[l].getAttribute("entryNr")-1].getAttribute("endMinute")
						+ " "+obj_lang["time"];
					}
				}

				pop_span.appendChild(pop_summary);
				pop_span.appendChild(pop_abbrStart);


				pop_p.appendChild(pop_span);
				tmp_li.appendChild(pop_p);
			}
		}
		else{
			tmp_li.appendChild(tmp_span);
		}

		var_ul.appendChild(tmp_li);
	}
	var tmp_span = window.document.createElement('span');
	tmp_span.className="clear";
	var_ul.appendChild(tmp_span);
	return var_ul;
}
function init_calendarAddon(param_div_id, param_id){
	var var_div =window.document.getElementById(param_div_id);
	var_div.ready = function(){
		var cal = fnc_getCalendar(var_div.xml);
		var ul = fnc_getUlfromCal(cal);
		var_div.innerHTML="";
		var_div.appendChild(ul);
	};
	getXML(var_div, param_id, "DateBC", true);
}