added a About window
[enigma2-plugins.git] / webinterface / src / web-data / tools.js
1 var DBG = true;
2 DBG = false;
3
4 var url_getvolume = '/web/vol?set=state'; 
5 var url_setvolume = '/web/vol?set=set'; // plus new value eq. set=set15
6 var url_volumeup = '/web/vol?set=up';
7 var url_volumedown = '/web/vol?set=down';
8 var url_volumemute = '/web/vol?set=mute';
9
10 var url_epgservice = "/web/epgservice?ref="; // plus serviceRev
11 var url_epgsearch = "/web/epgsearch?search="; // plus serviceRev
12 var url_epgnow = "/web/epgnow?bref="; // plus bouqetRev
13
14 var url_fetchchannels = "/web/fetchchannels?ServiceListBrowse="; // plus encoded serviceref
15 var url_subservices = "/web/subservices"; // subservices for current service
16
17 var url_updates= "/web/updates.html";
18
19 var url_movielist= "/web/movielist";
20
21 var url_about= "/web/about";
22
23 var url_settings= "/web/settings";
24
25 var url_parentcontrol= "/web/parentcontrollist";
26
27 var url_moviefiledelete= "/web/moviefiledelete"; // plus serviceref,eventid
28
29 var url_emulist= "/web/emulist";
30 var url_emuchangestate= "/web/emuchangestate";
31
32 var url_timerlist= "/web/timerlist";
33 var url_recordnow= "/web/recordnow";
34 var url_timeradd= "/web/timeradd"; // plus serviceref,begin,end,name,description,eit,disabled,justplay,afterevent
35 var url_timerchange= "/web/timerchange"; // plus serviceref,begin,end,name,description,eit,disabled,justplay,afterevent
36 var url_timeraddbyeventid= "/web/timeraddbyeventid"; // plus serviceref,eventid
37 var url_timerdelete= "/web/timerdelete"; // plus serviceref,bedin,end
38 var url_timerlistwrite="/web/timerlistwrite?write=saveWriteNow";
39 var url_timertoggleOnOff= "/web/timeronoff"; // plus serviceref,bedin,end
40
41 var url_message = "/web/message"; // plus text,type,timeout
42
43 var url_powerstate = "/web/powerstate"; // plus new powerstate
44 var url_remotecontrol = "/web/remotecontrol"; // plus command
45
46 var bouqet_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25)FROM BOUQUET "bouquets.tv" ORDER BY bouquet';
47 var bouqet_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2)FROM BOUQUET "bouquets.radio" ORDER BY bouquet';
48 var bouqet_provider_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25) FROM PROVIDERS ORDER BY name';
49 var bouqet_provider_radio ='1:7:2:0:0:0:0:0:0:0:(type == 2) FROM PROVIDERS ORDER BY name';
50
51 var windowStyle = "alphacube";
52
53 // TimerEdit variables:
54 var addTimerEditFormObject = new Object();
55 addTimerEditFormObject["TVListFilled"] = 0;
56 addTimerEditFormObject["RadioListFilled"] = 0;
57 addTimerEditFormObject["deleteOldOnSave"] = 0;
58
59 var doRequestMemory = new Object();
60
61 // Get Settings
62 var settings = null;
63 var parentControlList = null;
64
65 // UpdateStreamReader
66 var UpdateStreamReaderNextReadPos = 0;
67 var UpdateStreamReaderPollTimer;
68 var UpdateStreamReaderPollTimerCounter = 0;
69 var UpdateStreamReaderPollTimerCounterTwisted = 0;
70 UpdateStreamReaderRequest = null;
71 function UpdateStreamReaderStart(){
72         var ua = navigator.userAgent;
73         if(navigator.userAgent.indexOf("MSIE") >=0) {
74                 debug("UpdateStreamReader IE Fix");
75
76                 var namespace = {       
77                                         'url_updates': url_updates
78                 };
79                 $('UpdateStreamReaderIEFixPanel').innerHTML = RND(tplUpdateStreamReaderIE, namespace);
80                 
81         }else {
82                 UpdateStreamReaderNextReadPos = 0;
83                 allMessages = "";
84                 UpdateStreamReaderRequest = new XMLHttpRequest();
85                 UpdateStreamReaderRequest.onload = UpdateStreamReaderOnLoad;
86                 UpdateStreamReaderRequest.onerror = UpdateStreamReaderOnError;
87                 UpdateStreamReaderRequest.open("GET", url_updates, true);
88                 UpdateStreamReaderRequest.send(null);
89                 UpdateStreamReaderPollTimer = setInterval(UpdateStreamReaderLatestResponse, 10000);
90         }
91 }
92   
93 function UpdateStreamReaderLatestResponse() {
94 // Quickhack jjbig start
95 // Its not great, but the best I could come up with to solve the 
96 // problem with the memory leak
97         UpdateStreamReaderPollTimerCounter++;
98         debug(UpdateStreamReaderPollTimerCounter);
99         if(UpdateStreamReaderPollTimerCounter > 6) {
100                 clearInterval(UpdateStreamReaderPollTimer);
101                 UpdateStreamReaderRequest.abort();
102                 UpdateStreamReaderRequest = null;
103                 UpdateStreamReaderPollTimerCounter = 0;
104                 UpdateStreamReaderStart();
105                 
106                 UpdateStreamReaderPollTimerCounterTwisted++;
107                 if(UpdateStreamReaderPollTimerCounterTwisted > 5) {
108                         UpdateStreamReaderPollTimerCounterTwisted = 0;
109                         debug("restarting twisted");
110                         debug(new Ajax.Request( "/web/restarttwisted", { method: 'get' }));
111                         debug("...twisted restart");
112                 }
113                 return;
114         }
115 // Quickhack jjbig end
116         var allMessages = UpdateStreamReaderRequest.responseText;
117         do {
118                 var unprocessed = allMessages.substring(UpdateStreamReaderNextReadPos);
119                 var messageXMLEndIndex = unprocessed.indexOf("\n");
120                 
121                 if (messageXMLEndIndex!=-1) {
122                         var endOfFirstMessageIndex = messageXMLEndIndex + "\n".length;
123                         var anUpdate = unprocessed.substring(0, endOfFirstMessageIndex);
124         
125                         var re = new RegExp("<script>parent\.(.*)</script>");
126                         anUpdate = re.exec(anUpdate);
127
128                         if(anUpdate != null){
129                                 if (anUpdate.length == 2){
130                                         eval(anUpdate[1]);
131                                 }
132                         }
133                         
134                         UpdateStreamReaderNextReadPos += endOfFirstMessageIndex;
135                 }
136                 if(UpdateStreamReaderNextReadPos > 65000){
137                         UpdateStreamReaderRequest.abort();
138                         UpdateStreamReaderRequest = null;
139                         UpdateStreamReaderPollTimerCounter = 0;
140                         UpdateStreamReaderStart();
141                         messageXMLEndIndex = -1;
142                 }
143         } while (messageXMLEndIndex != -1);
144 }
145
146 function UpdateStreamReaderOnLoad(){
147         window.clearInterval(UpdateStreamReaderPollTimer);
148         debug("UpdateStreamReaderOnLoad");
149         Dialog.confirm(
150                 "Live Update Stream ends!<br><br>You will not receive any Update from Enigma2.<br>Should I reconnect?",
151                  {windowParameters: {width:300, className: windowStyle},
152                         okLabel: "reconnect",
153                         buttonClass: "myButtonClass",
154                         cancel: function(win) {debug("cancel confirm panel")},
155                         ok: function(win) {UpdateStreamReaderStart(); return true;}
156                         }
157                 );
158 }
159 function UpdateStreamReaderOnError(){
160         // TODO: change this, because it will be called on 'PageUnload' while the request is still running
161         debug("UpdateStreamReaderOnError");
162         window.clearInterval(UpdateStreamReaderPollTimer);
163         Dialog.confirm(
164                 "Live Update Stream has an Error!<br><br>You will not receive any Update from Enigma2.<br>Should I try to reconnect?",
165                  {windowParameters: {width:300, className: windowStyle},
166                          okLabel: "reconnect",
167                          buttonClass: "myButtonClass",
168                          cancel: function(win) {debug("cancel confirm panel")},
169                          ok: function(win) {UpdateStreamReaderStart(); return true;}
170                         }
171                 );
172 }
173
174 //end UpdateStreamReader
175
176 function openWindow(title, inner, width, height, id){
177                         if(id == null) id = new Date().toUTCString();
178                         var win = new Window(id, {className: windowStyle, title: title, width: width, height: height});
179                         win.getContent().innerHTML = inner;
180                         win.setDestroyOnClose();
181                         win.showCenter();
182                         debug("opening Window: "+title);
183                         return win;
184 }
185
186 function messageBox(t, m){
187         Dialog.alert(m, {windowParameters: {title: t, className: windowStyle, width:200}, okLabel: "Close"});
188 }
189
190 //RND Template Function (http://www.amix.dk)
191
192 function RND(tmpl, ns) {
193         var fn = function(w, g) {
194                 g = g.split("|");
195                 var cnt = ns[g[0]];
196
197                 //Support for filter functions
198                 for(var i=1; i < g.length; i++) {
199                         cnt = eval(g[i])(cnt);
200                 }
201                 return cnt || w;
202         };
203         return tmpl.replace(/%\(([A-Za-z0-9_|.]*)\)/g, fn);
204 }
205
206 function debug(text){
207         if(DBG){
208                 try{
209                         debugWin.getContent().innerHTML += "DEBUG: "+text+"<br>";
210                 } catch (windowNotPresent) {}
211         }
212 }
213
214 function showhide(id){
215         o = document.getElementById(id).style;
216         o.display = (o.display!="none")? "none":"";
217 }
218
219 function set(what, value){
220         //debug(what+"-"+value);
221         element = parent.document.getElementById(what);
222         if(value.length > 550) {
223                 value = value.substr(0,550) + "[...]";
224         }
225         if (element){
226                 element.innerHTML = value;
227         }
228         if(navigator.userAgent.indexOf("MSIE") >=0) {
229                 elementscript= $('UpdateStreamReaderIEFixIFrame').document.getElementById('scriptzone');
230                 if(elementscript){
231                         elementscript.innerHTML = ""; // deleting set() from page, to keep the page short and to save memory                    
232                 }
233         }
234 }
235 function setComplete(what, value){
236         //debug(what+"-"+value);
237         element = parent.document.getElementById(what);
238         if (element){
239                 element.innerHTML = value;
240         }
241         if(navigator.userAgent.indexOf("MSIE") >=0) {
242                 elementscript= $('UpdateStreamReaderIEFixIFrame').document.getElementById('scriptzone');
243                 if(elementscript){
244                         elementscript.innerHTML = ""; // deleting set() from page, to keep the page short and to save memory                    
245                 }
246         }
247 }
248 // requestindikator
249 var requestcounter = 0;
250 function requestIndicatorUpdate(){
251         //debug(requestcounter+" open requests");
252         if(requestcounter>=1){
253                 $('RequestIndicator').style.display = "inline";
254         }else{
255                 $('RequestIndicator').style.display = "none";
256         }
257 }
258 function requestStarted(){
259         requestcounter +=1;
260         requestIndicatorUpdate();
261 }
262 function requestFinished(){
263         requestcounter -=1;
264         requestIndicatorUpdate();
265 }
266 // end requestindikator
267 function doRequest(url, readyFunction, save){
268         requestStarted();
269         //var password = "";
270         //var username = "";
271         debug(url);
272         if(save == true && typeof(doRequestMemory[url]) != "undefined") {
273                 debug("not loading");
274                 readyFunction(doRequestMemory[url]);
275         } else {
276                 debug("loading");
277                 new Ajax.Request(url,
278                         {
279                                 method: 'get',
280                                 requestHeaders: ['Pragma', 'no-cache', 'Cache-Control', 'must-revalidate', 'If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT'],
281                                 onSuccess: function (transport, json) { if(save == true) { doRequestMemory[url] = transport; }
282                                                                                                                          readyFunction(transport);},
283                                 onComplete: requestFinished 
284                         });
285         }
286 }
287
288 function getXML(request){
289         if (document.implementation && document.implementation.createDocument){
290                 var xmlDoc = request.responseXML
291         }
292         else if (window.ActiveXObject){
293                 var xmlInsert = document.createElement('xml');
294
295                 xmlInsert.setAttribute('innerHTML',request.responseText);
296                 xmlInsert.setAttribute('id','_MakeAUniqueID');
297                 document.body.appendChild(xmlInsert);
298                 xmlDoc = document.getElementById('_MakeAUniqueID');
299                 document.body.removeChild(document.getElementById('_MakeAUniqueID'));
300         } else {
301                 debug("Your Browser Sucks!");
302         }
303         return xmlDoc;
304 }
305 function parentPin(servicereference) {
306         servicereference = decodeURIComponent(servicereference);
307         if(parentControlList == null || String(getSettingByName("config.ParentalControl.configured")) != "True") {
308                 return true;
309         }
310         debug("parentPin " + parentControlList.length);
311         if(getParentControlByRef(servicereference) == servicereference) {
312                 if(String(getSettingByName("config.ParentalControl.type.value")) == "whitelist") {
313                         debug("leaving here 1");
314                         return true;
315                 }
316         } else {
317                 debug("leaving here 2");
318                 return true;
319         }
320         debug("going to ask for PIN");
321 /*
322  * The Ajax Dialog didn't work, because auf the asycnonity :(
323         Dialog.confirm(
324                 "ParentControll was switch on.<br> Please enter PIN?<br>"+
325                         '<input type="text" id="pin" name="pin" value="">',
326                  {windowParameters: {width:300, className: windowStyle},
327                         okLabel: "OK",
328                         buttonClass: "myButtonClass",
329                         cancel: function(win) { return false; },
330                         ok: function(win) {
331                                    if(String($('pin').value) == String(getSettingByName("config.ParentalControl.servicepin.0")) ) {
332                                       return true;
333                                    } else {
334                                           return parentPin(servicereference);
335                                    }
336                         }
337                         }
338                 );
339                 */
340         var userInput = prompt('ParentControll was switch on.<br> Please enter PIN','PIN');
341         if (userInput != '' && userInput != null) {
342                 if(String(userInput) == String(getSettingByName("config.ParentalControl.servicepin.0")) ) {
343                         return true;
344                 } else {
345                         return parentPin(servicereference);
346                 }
347         } else {
348                 return false;
349         }
350 }
351 function zap(servicereference){
352         if(parentPin(servicereference)) {
353                 new Ajax.Request( "/web/zap?ZapTo=" + servicereference, { method: 'get' });
354                 getSubServices(servicereference);
355         }
356 }
357
358 //++++       SignalPanel                           ++++
359 function initSignalPanel(){
360         $('SignalPanel').innerHTML = tplSignalPanelButton;
361 }
362 function openSignalDialog(){
363         openWindow("Signal Info",tplSignalPanel, 215, 75);
364 }
365
366
367 //++++ EPG functions                               ++++
368 function loadEPGBySearchString(string){
369                 doRequest(url_epgsearch+escape(string),incomingEPGrequest, false);
370 }
371 function loadEPGByServiceReference(servicereference){
372                 doRequest(url_epgservice+servicereference,incomingEPGrequest, false);
373 }
374 function incomingEPGrequest(request){
375         debug("incoming request" +request.readyState);          
376         if (request.readyState == 4){
377                 var EPGItems = new EPGList(getXML(request)).getArray(true);
378                 debug("have "+EPGItems.length+" e2events");
379                 if(EPGItems.length > 0){                        
380                         var html = tplEPGListHeader;
381                         for (var i=0; i < EPGItems.length; i++){
382                                 try{
383                                         var item = EPGItems[i];                         
384                                         //Create JSON Object for Template
385                                         var namespace = {       
386                                                         'date': item.getTimeDay(), 
387                                                         'eventid': item.getEventId(), 
388                                                         'servicereference': item.getServiceReference(), 
389                                                         'servicename': item.getServiceName(), 
390                                                         'title': item.getTitle(),
391                                                         'titleESC': escape(item.getTitle()),
392                                                         'starttime': item.getTimeStartString(), 
393                                                         'duration': Math.ceil(item.getDuration()/60000), 
394                                                         'description': item.getDescription(), 
395                                                         'endtime': item.getTimeEndString(), 
396                                                         'extdescription': item.getDescriptionExtended(),
397                                                         'number': String(i),
398                                                         'extdescriptionSmall': extdescriptionSmall(item.getDescriptionExtended(),String(i)),
399                                                         'start': item.getTimeBegin(),
400                                                         'end': item.getTimeEnd()
401                                                 };
402                                         //Fill template with data and add id to our result
403                                         html += RND(tplEPGListItem, namespace);
404                                 } catch (blubb) { debug("Error rendering: "+blubb);     }
405                         }               
406                         html += tplEPGListFooter;
407                         openWindow("Electronic Program Guide", html, 900, 500);
408                 } else {
409                         messageBox('No Items found!', 'Sorry but i could not find any EPG Content containing your search value');
410                 }
411         }
412 }
413 function extdescriptionSmall(txt,num) {
414         if(txt.length > 410) {
415                 var shortTxt = txt.substr(0,410);
416                 txt = txt.replace(/\'\'/g, '&quot;');
417                 txt = txt.replace(/\\/g, '\\\\');
418                 txt = txt.replace(/\'/g, '\\\'');
419                 txt = txt.replace(/\"/g, '&quot;');
420                 var smallNamespace = { 'txt':txt,'number':num, 'shortTxt':shortTxt};
421                 return RND(tplEPGListItemExtend, smallNamespace);
422         } else {
423                 return txt;
424         }
425 }       
426
427 /////////////////////////
428
429 function loadServiceEPGNowNext(servicereference){
430         var url = url_epgnow+servicereference;
431         doRequest(url, incomingServiceEPGNowNext, false);       
432 }
433
434 function incomingServiceEPGNowNext(request){
435         if(request.readyState == 4){
436                 var epgevents = getXML(request).getElementsByTagName("e2eventlist").item(0).getElementsByTagName("e2event");
437                 for (var c =0; c < epgevents.length;c++){
438                         var eventnow = new EPGEvent(epgevents.item(c));
439                         
440                         if (eventnow.getEventId() != 'None'){
441                                 buildServiceListEPGItem(eventnow,"NOW");
442                         }
443                 }
444         }
445 }
446 function buildServiceListEPGItem(epgevent,nownext){
447         var e = $(epgevent.getServiceReference()+'EPG'+nownext);
448                 try{
449                         var namespace = {       
450                                 'starttime': epgevent.getTimeStartString(), 
451                                 'title': epgevent.getTitle(), 
452                                 'length': Math.ceil(epgevent.duration/60) 
453                         };
454                         e.innerHTML = RND(tplServiceListEPGItem, namespace);
455                 } catch (blubb) {
456                         debug("Error rendering: "+blubb);
457                 }       
458 }
459 ///////////////////
460
461
462 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
463 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
464 //++++ GUI functions                               ++++
465 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
466 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
467
468 var currentBodyMainElement = null
469
470 function setBodyMainContent(newelementname){
471         newelement =document.getElementById(newelementname);
472         if(currentBodyMainElement != null){
473                 currentBodyMainElement.style.display = "none";
474                 
475         }
476         newelement.style.display = "";
477         currentBodyMainElement = newelement;
478 }
479
480 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
481 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
482 //++++ volume functions                            ++++
483 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
484 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
485
486 function initVolumePanel(){
487         document.getElementById('VolumePanel').innerHTML = tplVolumePanel;
488         getVolume(); 
489 }
490 function getVolume(){
491         doRequest(url_getvolume,handleVolumeRequest, false);
492 }
493 function volumeSet(newvalue){
494         doRequest(url_setvolume+newvalue,handleVolumeRequest, false);
495 }
496 function volumeUp(){
497         doRequest(url_volumeup,handleVolumeRequest, false);
498 }
499 function volumeDown(){
500         doRequest(url_volumedown,handleVolumeRequest, false);   
501 }
502 function volumeMute(){
503         doRequest(url_volumemute,handleVolumeRequest, false);
504 }
505 function handleVolumeRequest(request){
506         if (request.readyState == 4) {
507                 var b = getXML(request).getElementsByTagName("e2volume");
508                 var newvalue = b.item(0).getElementsByTagName('e2current').item(0).firstChild.data;
509                 var mute = b.item(0).getElementsByTagName('e2ismuted').item(0).firstChild.data;
510                 debug("volume"+newvalue+";"+mute);
511                 
512                 for (var i = 1; i <= 10; i++)           {
513                         if ( (newvalue/10)>=i){
514                                 $("volume"+i).src = "/webdata/gfx/led_on.png";
515                         }else{
516                                 $("volume"+i).src = "/webdata/gfx/led_off.png";
517                         }
518                 }
519                 if (mute == "False"){
520                         $("speaker").src = "/webdata/gfx/speak_on.png";
521                 }else{
522                         $("speaker").src = "/webdata/gfx/speak_off.png";
523                 }
524         }       
525 }
526
527 var bouqetsMemory = new Object();
528
529 function initChannelList(){
530         //debug("init ChannelList");    
531         var url = url_fetchchannels+encodeURIComponent(bouqet_tv);
532         doRequest(url, incomingTVBouquetList, true);
533
534         var url = url_fetchchannels+encodeURIComponent(bouqet_radio);
535         doRequest(url, incomingRadioBouquetList, true);
536
537         var url = url_fetchchannels+encodeURIComponent(bouqet_provider_tv);
538         doRequest(url, incomingProviderTVBouquetList, true);
539
540         var url = url_fetchchannels+encodeURIComponent(bouqet_provider_radio);
541         doRequest(url, incomingProviderRadioBouquetList, true);
542         
543         getSettings();
544 }
545
546 var servicereftoloadepgnow = "";
547 var loadedChannellist = new Object();
548 function loadBouquet(servicereference){ 
549         debug("loading bouquet with "+servicereference);
550         servicereftoloadepgnow = servicereference;
551         debug("loadBouquet " + typeof(loadedChannellist[servicereftoloadepgnow]));
552         if(typeof(loadedChannellist[servicereftoloadepgnow]) == "undefined") {
553                 doRequest(url_fetchchannels+servicereference, incomingChannellist, true);
554         } else {
555                 incomingChannellist();
556         }
557 }
558
559 function incomingTVBouquetList(request){
560         if (request.readyState == 4) {
561                 var list0 = new ServiceList(getXML(request)).getArray();
562                 debug("have "+list0.length+" TV Bouquet ");     
563                 $('accordionMenueBouquetContentTV').innerHTML = renderBouquetTable(list0,tplBouquetListHeader,tplBouquetListItem,tplBouquetListFooter);
564                 //loading first entry of TV Favorites as default for ServiceList
565                 loadBouquet(list0[0].getServiceReference());
566                 bouqetsMemory["bouqet_tv"] = list0;
567         }
568 }
569 function incomingRadioBouquetList(request){
570         if (request.readyState == 4) {
571                 var list1 = new ServiceList(getXML(request)).getArray();
572                 debug("have "+list1.length+" Radio Bouquet ");  
573                 $('accordionMenueBouquetContentRadio').innerHTML = renderBouquetTable(list1,tplBouquetListHeader,tplBouquetListItem,tplBouquetListFooter);
574         }       
575 }
576 function incomingProviderTVBouquetList(request){
577         if (request.readyState == 4) {
578                 var list2 = new ServiceList(getXML(request)).getArray();
579                 debug("have "+list2.length+" TV Provider Bouquet ");    
580                 $('accordionMenueBouquetContentProviderTV').innerHTML = renderBouquetTable(list2,tplBouquetListHeader,tplBouquetListItem,tplBouquetListFooter);
581         }       
582 }
583 function incomingProviderRadioBouquetList(request){
584         if (request.readyState == 4) {
585                 var list2 = new ServiceList(getXML(request)).getArray();
586                 debug("have "+list2.length+" Radio Provider Bouquet "); 
587                 $('accordionMenueBouquetContentProviderRadio').innerHTML = renderBouquetTable(list2,tplBouquetListHeader,tplBouquetListItem,tplBouquetListFooter);
588         }       
589 }
590
591 function renderBouquetTable(bouquet,templateHeader,templateItem,templateFooter){
592         debug("renderBouquetTable with "+bouquet.length+" Bouqet");     
593         var html = templateHeader;
594         for (var i=0; i < bouquet.length; i++){
595                 try{
596                         var namespace = {
597                                 'servicereference': bouquet[i].getServiceReference(), 
598                                 'bouquetname': bouquet[i].getServiceName()
599                         };
600                         html += RND(templateItem, namespace);
601                 } catch (blubb) {}
602         }
603         html += templateFooter;
604         return html;
605 }       
606
607 function incomingChannellist(request){
608         var services = null;
609         if(typeof(loadedChannellist[servicereftoloadepgnow]) != "undefined"){
610                 services = loadedChannellist[servicereftoloadepgnow];
611         } else if(request.readyState == 4) {
612                 services = new ServiceList(getXML(request)).getArray();
613                 loadedChannellist[servicereftoloadepgnow] = services;
614                 debug("got "+services.length+" Services");
615         }
616         if(services != null) {
617                 var smallNamespace = {'mainServiceRef': servicereftoloadepgnow };
618                 listerHtml = RND(tplServiceListHeader, smallNamespace);
619                 for ( var i = 0; i < services.length ; i++){
620                         var reference = services[i];
621                         var namespace = {       
622                                 'servicereference': reference.getServiceReference(),
623                                 'servicename': reference.getServiceName()
624                         };
625                         listerHtml += RND(tplServiceListItem, namespace);
626                 }               
627                 listerHtml += tplServiceListFooter;
628                 document.getElementById('BodyContentChannellist').innerHTML = listerHtml;
629                 setBodyMainContent('BodyContentChannellist');
630                 loadServiceEPGNowNext(servicereftoloadepgnow);
631 /*              alert(document.getElementById('scrollContent').style.height);
632                 document.getElementById('scrollContent').style.height = '14.5%';
633                                 alert(document.getElementById('scrollContent').style.height);*/
634                 debug("incomingChannellist " + typeof(loadedChannellist[servicereftoloadepgnow]));
635         }
636 }
637 // Movies
638 function loadMovieList(){
639         debug("loading movies");
640         doRequest(url_movielist, incomingMovieList);    
641 }
642
643 function incomingMovieList(request){
644         if(request.readyState == 4){
645                 var movies = new MovieList(getXML(request)).getArray();
646                 debug("have "+movies.length+" movies");
647                 listerHtml      = tplMovieListHeader;           
648                 for ( var i = 0; i <movies.length; i++){
649                         var movie = movies[i];
650                         var namespace = {       
651                                 'servicereference': movie.getServiceReference(),
652                                 'servicename': movie.getServiceName() ,
653                                 'title': movie.getTitle(), 
654                                 'description': movie.getDescription(), 
655                                 'descriptionextended': movie.getDescriptionExtended(),
656                                 'filelink': String(movie.getFilename()).substr(17,movie.getFilename().length),
657                                 'filename': String(movie.getFilename()),
658                                 'tags': movie.getTags().join(', ') 
659                         };
660                         listerHtml += RND(tplMovieListItem, namespace);
661                 }
662                 listerHtml += tplMovieListFooter;
663                 document.getElementById('BodyContentChannellist').innerHTML = listerHtml;
664                 setBodyMainContent('BodyContentChannellist');
665                 
666         }               
667 }
668 function delMovieFile(file) {
669                 doRequest(url_moviefiledelete+"?filename="+file, incomingDelMovieFileResult, false);    
670 }
671 function incomingDelMovieFileResult(request) {
672         debug("incomingDelMovieFileResult");
673         if(request.readyState == 4){
674                 var delresult = new SimpleXMLResult(getXML(request));
675                 if(delresult.getState()){
676                         loadMovieList();
677                 }else{
678                         messageBox("Deletion Error","Reason: "+delresult.getStateText());
679                 }
680         }               
681 }
682 // Timer
683 function addTimerByID(serviceRef,eventID,justplay){
684         if(parentPin(serviceRef)) {
685                 doRequest(url_timeraddbyeventid+"?serviceref="+serviceRef+"&eventid="+eventID+"&justplay="+justplay, incomingTimerAddResult, false);    
686         }
687 }
688 function incomingTimerAddResult(request){
689         debug("onTimerAdded");
690         if(request.readyState == 4){
691                 var addresult = new SimpleXMLResult(getXML(request));
692                 if(addresult.getState()){
693                         //timer was add
694                         loadTimerList();
695                 }else{
696                         messageBox("Timer Error","your Timer could not be added!\nReason: "+addresult.getStateText());
697                 }
698         }               
699 }
700 function loadTimerList(){
701         doRequest(url_timerlist, incomingTimerList, false);     
702 }
703
704 function incomingTimerList(request){
705         if(request.readyState == 4){
706                 var timers = new TimerList(getXML(request)).getArray();
707                 debug("have "+timers.length+" timer");
708                 listerHtml      = tplTimerListHeader;
709                 
710                 var aftereventReadable = new Array ('Nothing', 'Standby', 'Deepstandby/Shutdown');
711                 var justplayReadable = new Array('record', 'zap');
712                 var OnOff = new Array('on', 'off');
713
714                 for ( var i = 0; i <timers.length; i++){
715                         var timer = timers[i];
716                         var beginDate = new Date(Number(timer.getTimeBegin())*1000);
717                         var endDate = new Date(Number(timer.getTimeEnd())*1000);
718                         debug(timer.getDisabled());
719                         debug(OnOff[Number(timer.getDisabled())]);
720                         var namespace = {       
721                                 'servicereference': timer.getServiceReference(),
722                                 'servicename': timer.getServiceName() ,
723                                 'title': timer.getName(), 
724                                 'description': timer.getDescription(), 
725                                 'descriptionextended': timer.getDescriptionExtended(), 
726                                 'begin': timer.getTimeBegin(),
727                                 'beginDate': beginDate.toLocaleString(),
728                                 'end': timer.getTimeEnd(),
729                                 'endDate': endDate.toLocaleString(),
730                                 'state': timer.getState(),
731                                 'duration': Math.ceil((timer.getDuration()/60)),
732                                 'repeated': timer.getRepeated(),
733                                 'repeatedReadable': repeatedReadable(timer.getRepeated()),
734                                 'justplay': timer.getJustplay(),
735                                 'justplayReadable': justplayReadable[Number(timer.getJustplay())],
736                                 'afterevent': timer.getAfterevent(),
737                                 'aftereventReadable': aftereventReadable[Number(timer.getAfterevent())],
738                                 'disabled': timer.getDisabled(),
739                                 'onOff': OnOff[Number(timer.getDisabled())],
740                                 'color': colorTimerListEntry( timer.getState() )
741                         };
742                         listerHtml += RND(tplTimerListItem, namespace);
743                 }
744                 listerHtml += tplTimerListFooter;
745                 document.getElementById('BodyContentChannellist').innerHTML = listerHtml;
746                 setBodyMainContent('BodyContentChannellist');
747         }
748 }
749 function repeatedReadable(num) {
750         num = Number(num);
751         
752         if(num == 0) {
753                 return "One Time";
754         }
755         
756         var html = "";
757         
758         var Repeated = new Object();
759         Repeated["Mo-Su"] =127;
760         Repeated["Su"] =    64;
761         Repeated["Sa"] =    32;
762         Repeated["Mo-Fr"] = 31;
763         Repeated["Fr"] =    16;
764         Repeated["Th"] =     8;
765         Repeated["We"] =     4;
766         Repeated["Tu"] =     2;
767         Repeated["Mo"] =     1;
768         
769         for(rep in Repeated) {
770                 if(rep.toString() != "extend") {
771                         var check = Number(Repeated[rep]);
772                         if(check <= num) {
773                                 num -= check;
774                                 if(html == "") {
775                                         html += rep.toString();
776                                 } else {
777                                         html += "," + rep.toString();
778                                 }
779                         }
780                 }
781         }
782         return html;
783 }
784
785 function colorTimerListEntry (state) {
786         if (state == 0) {
787                 return "000000";
788         } else if(state == 1) {
789                 return "00BCBC";
790         } else if(state == 2) {
791                 return "9F1919";
792         } else {
793                 return "00BCBC";
794         }
795 }
796 function delTimer(serviceRef,begin,end){
797         debug(url_timerdelete+"?serviceref="+serviceRef+"&begin="+begin+"&end="+end);
798         doRequest(url_timerdelete+"?serviceref="+serviceRef+"&begin="+begin+"&end="+end, incomingTimerDelResult, false);
799 }
800
801 function incomingTimerDelResult(request){
802         debug("onTimerDeleted");
803         if(request.readyState == 4){
804                 var delresult = new SimpleXMLResult(getXML(request));
805                 debug("Lade liste");
806                 loadTimerList();
807         }               
808 }
809
810 // send Messages
811 function showMessageSendForm(){
812                 document.getElementById('BodyContentChannellist').innerHTML = tplMessageSendForm;
813 }
814 function sendMessage(messagetext,messagetype,messagetimeout){
815         if(!messagetext){
816                 messagetext = $('MessageSendFormText').value;
817         }       
818         if(!messagetimeout){
819                 messagetimeout = $('MessageSendFormTimeout').value;
820         }       
821         if(!messagetype){
822                 var index = $('MessageSendFormType').selectedIndex;
823                 messagetype = $('MessageSendFormType').options[index].value;
824         }       
825         doRequest(url_message+'?text='+messagetext+'&type='+messagetype+'&timeout='+messagetimeout, incomingMessageResult, false);
826 }
827 function incomingMessageResult(request){
828
829         if(request.readyState== 4){
830                 var b = getXML(request).getElementsByTagName("e2message");
831                 var result = b.item(0).getElementsByTagName('e2result').item(0).firstChild.data;
832                 var resulttext = b.item(0).getElementsByTagName('e2resulttext').item(0).firstChild.data;
833                 if (result=="True"){
834                         messageBox('message send','message send successfully! it appears on TV-Screen');
835                 }else{
836                         messageBox('message send failed',resulttext);
837                 }
838         }               
839 }
840
841 // PowerState Code
842 function showPowerStateSendForm(){
843                 document.getElementById('BodyContentChannellist').innerHTML = tplPowerStateSendForm;
844 }
845 function sendPowerState(newState){
846         doRequest(url_powerstate+'?newstate='+newState, incomingPowerStateResult, false);
847 }
848 function incomingPowerStateResult(request){
849         debug(request.readyState);
850         if(request.readyState == 4){
851                 var b = getXML(request).getElementsByTagName("e2powerstate");
852                 var result = b.item(0).getElementsByTagName('e2result').item(0).firstChild.data;
853                 var resulttext = b.item(0).getElementsByTagName('e2resulttext').item(0).firstChild.data;
854                 var tplPowerStateSendForm2 = '<h1>PowerState is changing to:'+resulttext+ '</h1>' + tplPowerStateSendForm;
855                 document.getElementById('BodyContentChannellist').innerHTML = tplPowerStateSendForm2;
856         } else {
857                 document.getElementById('BodyContentChannellist').innerHTML = "<h1>some unknown error</h1>" + tplPasswordSendForm;
858         }
859 }
860
861 // RemoteControl Code
862 function showRemoteControllSendForm(){
863                 document.getElementById('BodyContentChannellist').innerHTML = tplRemoteControlForm;
864 }
865 function sendRemoteControlRequest(command){
866         doRequest(url_remotecontrol+'?command='+command, incomingRemoteControlResult, false);
867 }
868 function incomingRemoteControlResult(request){
869         if(request.readyState == 4){
870                 var b = getXML(request).getElementsByTagName("e2remotecontrol");
871                 var result = b.item(0).getElementsByTagName('e2result').item(0).firstChild.data;
872                 var resulttext = b.item(0).getElementsByTagName('e2resulttext').item(0).firstChild.data;
873                 showRemoteControllSendForm();
874         } else {
875                 document.getElementById('BodyContentChannellist').innerHTML = "<h1>some unknown error</h1>" + tplRemoteControlForm;
876         }
877 }
878
879 function loadTimerFormNow() {
880         var now = new Date();
881         addTimerEditFormObject["syear"] = now.getFullYear();
882         addTimerEditFormObject["smonth"] = now.getMonth() + 1;
883         addTimerEditFormObject["sday"] = now.getDate();
884         addTimerEditFormObject["shour"] = now.getHours();
885         addTimerEditFormObject["smin"] = now.getMinutes();
886
887         var     plusTwoHours = new Date(now.getTime() + ((120 *60)*1000) );
888         addTimerEditFormObject["eyear"] = plusTwoHours.getFullYear();
889         addTimerEditFormObject["emonth"] = plusTwoHours.getMonth() + 1;
890         addTimerEditFormObject["eday"] = plusTwoHours.getDate();
891         addTimerEditFormObject["ehour"] = plusTwoHours.getHours();
892         addTimerEditFormObject["emin"] = plusTwoHours.getMinutes();
893                 
894         addTimerEditFormObject["justplay"] = "record";
895         addTimerEditFormObject["channel"] = "";
896         addTimerEditFormObject["channelName"] = "";
897         addTimerEditFormObject["channelSort"] = "tv";
898         addTimerEditFormObject["name"] = "";
899         addTimerEditFormObject["description"] = "";
900         addTimerEditFormObject["repeated"] = 0;
901         addTimerEditFormObject["afterEvent"] = "0";
902         addTimerEditFormObject["deleteOldOnSave"] = 0;
903         
904         addTimerEditFormObject["beginOld"] = 0;
905         addTimerEditFormObject["endOld"] = 0;
906         
907         
908         debug("loadTimerFormNow 2");
909         loadTimerFormChannels();
910 }
911
912 function loadTimerFormSeconds(justplay,begin,end,repeated,channel,channelName,name,description,afterEvent,deleteOldOnSave) {
913         debug('justplay:'+justplay+' begin:'+begin+' end:'+end+' repeated:'+repeated+' channel:'+channel+' name:'+name+' description:'+description+' afterEvent:'+afterEvent+' deleteOldOnSave:'+deleteOldOnSave);
914         var start = new Date(Number(begin)*1000);
915         addTimerEditFormObject["syear"] = start.getFullYear();
916         addTimerEditFormObject["smonth"] = start.getMonth() + 1;
917         addTimerEditFormObject["sday"] = start.getDate();
918         addTimerEditFormObject["shour"] = start.getHours();
919         addTimerEditFormObject["smin"] = start.getMinutes();
920         
921         var     stopp = new Date(Number(end)*1000);
922         addTimerEditFormObject["eyear"] = stopp.getFullYear();
923         addTimerEditFormObject["emonth"] = stopp.getMonth() + 1;
924         addTimerEditFormObject["eday"] = stopp.getDate();
925         addTimerEditFormObject["ehour"] = stopp.getHours();
926         addTimerEditFormObject["emin"] = stopp.getMinutes();
927         
928         addTimerEditFormObject["justplay"] = String(justplay);
929         addTimerEditFormObject["channel"] = decodeURIComponent(String(channel));
930         addTimerEditFormObject["channelName"] = String(channelName);
931         addTimerEditFormObject["channelSort"] = "";
932         addTimerEditFormObject["name"] = String(name);
933         addTimerEditFormObject["description"] = String(description);
934         addTimerEditFormObject["repeated"] = Number(repeated);
935         addTimerEditFormObject["afterEvent"] = Number(afterEvent);
936         
937         debug(justplay+"|"+begin+"|"+end+"|"+repeated+"|"+channel+"|"+name+"|"+description+"|"+afterEvent);
938
939         addTimerEditFormObject["deleteOldOnSave"] = Number(deleteOldOnSave);
940         addTimerEditFormObject["beginOld"] = Number(begin);
941         addTimerEditFormObject["endOld"] = Number(end);
942         
943         loadTimerFormChannels();
944 }
945
946 // startin to load for TV
947 function loadTimerFormChannels() {
948         if(addTimerEditFormObject["TVListFilled"] == 1 && addTimerEditFormObject["RadioListFilled"] == 1) {
949                 loadTimerForm();
950         } else if(addTimerEditFormObject["TVListFilled"] == 1 && addTimerEditFormObject["RadioListFilled"] == 0) {
951                 addTimerListFormatTV();
952         } else {
953                 var favorites = '1%3A7%3A1%3A0%3A0%3A0%3A0%3A0%3A0%3A0%3AFROM%20BOUQUET%20%22userbouquet.favourites.tv%22%20ORDER%20BY%20bouquet'
954                 doRequest(url_fetchchannels+favorites, addTimerListFormatTV, false);
955         }
956 }
957
958 function addTimerListFormatTV(request) {
959         if(addTimerEditFormObject["RadioListFilled"] == 0) {
960                 if(request.readyState == 4){
961                         var services = new ServiceList(getXML(request)).getArray();
962                         var tv = new Object();
963                         for ( var i = 0; i < services.length ; i++){
964                                 var reference = services[i];
965                                 tv[reference.servicereference] = reference.servicename;
966                         }
967                         addTimerEditFormObject["TVListFilled"] = 1;
968                         addTimerEditFormObject["TVList"] = tv;
969                 }
970         }
971         if(addTimerEditFormObject["RadioListFilled"] == 1) {
972                 loadTimerForm()
973         } else {
974                 var favorites = '1%3A7%3A1%3A0%3A0%3A0%3A0%3A0%3A0%3A0%3AFROM%20BOUQUET%20%22userbouquet.favourites.radio%22%20ORDER%20BY%20bouquet';
975                 doRequest(url_fetchchannels+favorites, addTimerListFormatRadio, false);
976         }
977 }
978 function addTimerListFormatRadio(request) {
979         if(request.readyState == 4){
980                 var services = new ServiceList(getXML(request)).getArray();
981                 var radio = new Object();
982                 for ( var i = 0; i < services.length ; i++){
983                         var reference = services[i];
984                         radio[reference.servicereference] = reference.servicename;
985                 }
986                 addTimerEditFormObject["RadioListFilled"] = 1;
987                 addTimerEditFormObject["RadioList"] = radio;
988         }
989         loadTimerForm();
990 }
991
992 function loadTimerForm(){
993
994         var Action = new Object();
995         Action["0"] = "Record";
996         Action["1"] = "Zap";
997         
998         var Repeated = new Object();
999         Repeated["1"] =  "mo";
1000         Repeated["2"] = "tu";
1001         Repeated["4"] =  "we";
1002         Repeated["8"] =  "th";
1003         Repeated["16"] = "fr";
1004         Repeated["32"] = "sa";
1005         Repeated["64"] = "su";
1006         Repeated["31"] = "mf";
1007         Repeated["127"] ="ms";
1008         
1009         var AfterEvent = new Object();
1010         AfterEvent["0"] = "Nothing";
1011         AfterEvent["1"] = "Standby";
1012         AfterEvent["2"] = "Deepstandby/Shutdown";
1013         
1014         addTimerEditFormObject["name"] = (typeof(addTimerEditFormObject["name"]) != "undefined") ? addTimerEditFormObject["name"] : "";
1015         addTimerEditFormObject["name"] = (addTimerEditFormObject["name"] == "") ? " " : addTimerEditFormObject["name"];
1016
1017         addTimerEditFormObject["description"] = (typeof(addTimerEditFormObject["description"]) != "undefined") ? addTimerEditFormObject["description"] : "";
1018         addTimerEditFormObject["description"] = (addTimerEditFormObject["description"] == "") ? " " : addTimerEditFormObject["description"];
1019
1020         var channelObject = addTimerEditFormObject["TVList"];
1021         if(     addTimerEditFormObject["channelSort"] == "tv") {
1022                 // already set
1023         } else if( addTimerEditFormObject["channelSort"] == "radio") {
1024                 channelObject = addTimerEditFormObject["RadioList"];
1025         } else {
1026                 var found = 0;
1027                 for( element in addTimerEditFormObject["TVList"]) {
1028                         if( element == addTimerEditFormObject["channel"]) {
1029                                 found = 1;
1030                                 break;
1031                         }
1032                 }
1033                 if(found == 0) {
1034                         for( element in addTimerEditFormObject["RadioList"]) {
1035                                 if( element == addTimerEditFormObject["channel"]) {
1036                                         channelObject = addTimerEditFormObject["RadioList"];
1037                                         found = 1;
1038                                         break;
1039                                 }
1040                         }
1041                 }
1042                 if(found == 0) {
1043                         addTimerEditFormObject["TVList"][addTimerEditFormObject["channel"]] = addTimerEditFormObject["channelName"];
1044                 }
1045         }
1046         var dashString = "------";
1047         channelObject[dashString] = "- Bouquets -";
1048         var listeNeu = new ServiceList(getXML(doRequestMemory[url_fetchchannels+encodeURIComponent(bouqet_tv)])).getArray();
1049         if(addTimerEditFormObject["channelSort"] == "radio") {
1050                 debug("weiter");
1051                 listeNeu = new ServiceList(getXML(doRequestMemory[url_fetchchannels+encodeURIComponent(bouqet_radio)])).getArray();
1052         }
1053         debug("hier" + listeNeu.length);
1054         for (i = 1; i < listeNeu.length; i++) {
1055                 var element = listeNeu[i];
1056                 channelObject[String(dashString+i)] = "---";
1057                 channelObject[element.getServiceReference()] = element.getServiceName();
1058         }
1059         debug("geklappt" + channelObject.length);
1060         var namespace = {       
1061                                 'justplay': addTimerFormCreateOptionList(Action, addTimerEditFormObject["justplay"]),
1062                                 'syear': addTimerFormCreateOptions(2007,2010,addTimerEditFormObject["syear"]),
1063                                 'smonth': addTimerFormCreateOptions(1,12,addTimerEditFormObject["smonth"]),
1064                                 'sday': addTimerFormCreateOptions(1,31,addTimerEditFormObject["sday"]),
1065                                 'shour': addTimerFormCreateOptions(0,23,addTimerEditFormObject["shour"]),
1066                                 'smin': addTimerFormCreateOptions(0,59,addTimerEditFormObject["smin"]),
1067                                 'eyear': addTimerFormCreateOptions(2007,2010,addTimerEditFormObject["eyear"]),
1068                                 'emonth': addTimerFormCreateOptions(1,12,addTimerEditFormObject["emonth"]),
1069                                 'eday': addTimerFormCreateOptions(1,31,addTimerEditFormObject["eday"]),
1070                                 'ehour': addTimerFormCreateOptions(0,23,addTimerEditFormObject["ehour"]),
1071                                 'emin': addTimerFormCreateOptions(0,59,addTimerEditFormObject["emin"]),
1072                                 'channel': addTimerFormCreateOptionList(channelObject, addTimerEditFormObject["channel"]),
1073                                 'name': addTimerEditFormObject["name"],
1074                                 'description': addTimerEditFormObject["description"],
1075                                 'repeated': addTimerFormCreateOptionListRepeated(Repeated, addTimerEditFormObject["repeated"]),
1076                                 'deleteOldOnSave': addTimerEditFormObject["deleteOldOnSave"],
1077                                 'channelOld': addTimerEditFormObject["channel"],
1078                                 'beginOld': addTimerEditFormObject["beginOld"],
1079                                 'endOld': addTimerEditFormObject["endOld"],
1080                                 'afterEvent': addTimerFormCreateOptionList(AfterEvent, addTimerEditFormObject["afterEvent"])
1081                 };
1082         var listerHtml = RND(tplAddTimerForm, namespace);
1083         document.getElementById('BodyContentChannellist').innerHTML = listerHtml;
1084
1085         // Empty some stuff, but keep others to have the performance
1086         var tmp1 = addTimerEditFormObject["RadioList"];
1087         var tmp2 = addTimerEditFormObject["TVList"];
1088         addTimerEditFormObject = new Object();
1089         addTimerEditFormObject["deleteOldOnSave"] = 0;
1090         addTimerEditFormObject["RadioList"] = tmp1;
1091         addTimerEditFormObject["TVList"] = tmp2;
1092         addTimerEditFormObject["TVListFilled"] = 1;
1093         addTimerEditFormObject["RadioListFilled"] = 1;
1094 }
1095
1096 function addTimerFormCreateOptions(start,end,number) {
1097         var html = '';
1098         for(i = start; i <= end; i++) {
1099                 var txt = (String(i).length == 1) ? "0" + String(i) : String(i);
1100                 var selected =  (i == Number(number)) ? "selected" : " ";
1101                 var namespace = {
1102                         'value': i,
1103                         'txt': txt,
1104                         'selected': selected };
1105                 html += RND(tplAddTimerFormOptions, namespace);
1106         }
1107         return html;
1108 }
1109 function addTimerFormCreateOptionList(object,selected) {
1110         html = '';
1111         var found = 0;
1112         for(var element in object) {
1113                 var txt = String(object[element]);
1114                 var sel = " ";
1115                 if(element == selected) {
1116                         found = 1;
1117                         sel = "selected";
1118                 }
1119                 var namespace = {
1120                         'value': element,
1121                         'txt': txt,
1122                         'selected': sel };
1123                 if(element != "extend") {
1124                         html += RND(tplAddTimerFormOptions, namespace);
1125                 }
1126         }
1127         if(found == 0) {
1128                 var namespace = {
1129                         'value': element,
1130                         'txt': txt,
1131                         'selected': sel };
1132         }
1133         return html;
1134 }
1135
1136 function timerFormExtendChannellist(bouqet) {
1137         var listeTV = new ServiceList(getXML(doRequestMemory[url_fetchchannels+encodeURIComponent(bouqet_tv)])).getArray();
1138         var listeRadio = new ServiceList(getXML(doRequestMemory[url_fetchchannels+encodeURIComponent(bouqet_radio)])).getArray();
1139         found = 0;
1140         for(i = 0; i < listeTV.length; i++) {
1141                 var element = listeTV[i];
1142                 if(String(element.getServiceReference()) == bouqet) {
1143                         found = 1;
1144                         break;
1145                 }
1146         }
1147         if(found == 0) {
1148                 for(i = 0; i < listeRadio.length; i++) {
1149                         var element = listeTV[i];
1150                         if(String(element.getServiceReference()) == bouqet) {
1151                                 found = 1;
1152                                 break;
1153                         }
1154                 }
1155         }
1156         if(found == 1) {
1157                 servicereftoloadepgnow = bouqet;
1158                 if(typeof(loadedChannellist[servicereftoloadepgnow]) == "undefined") {  
1159                         doRequest(url_fetchchannels+servicereftoloadepgnow, incomingTimerFormExtendChannellist, true);
1160                 } else {
1161                         incomingTimerFormExtendChannellist();
1162                 }
1163         }
1164 }
1165 function incomingTimerFormExtendChannellist(request) {
1166         var services = null;
1167         if(typeof(loadedChannellist[servicereftoloadepgnow]) != "undefined"){
1168                 services = loadedChannellist[servicereftoloadepgnow];
1169         } else if(request.readyState == 4) {
1170                 services = new ServiceList(getXML(request)).getArray();
1171                 loadedChannellist[servicereftoloadepgnow] = services;
1172                 debug("got "+services.length+" Services");
1173         }
1174         var attachLater = new Object();
1175         if(services != null) {
1176                 debug("incomingTimerFormExtendChannellist " + services.length);
1177                 var selected = $('channel').selectedIndex;
1178                 for(j = selected; j < $('channel').options.length; j++) {
1179                         if($('channel').options[j].value == servicereftoloadepgnow) {
1180                                 j++;
1181                                 for(var i = 0; i < services.length ; i++) {
1182                                         var reference = services[i];
1183                                         var newEntry = new Option(reference.getServiceName(), reference.getServiceReference(), false, true);
1184                                         if(typeof($('channel').options[j]) != "undefined") {
1185                                                 attachLater[String($('channel').options[j].value)] = $('channel').options[j].text;
1186                                         }
1187                                         $('channel').options[j] = newEntry;
1188                                         j++;
1189                                 }
1190                         }
1191                         break;
1192                 }
1193                 for(x in attachLater) {
1194                         var newEntry = new Option(attachLater[x], x, false, true);
1195                         if(x != "extend") {
1196                                 $('channel').options[$('channel').options.length] = newEntry;
1197                         }
1198                 }
1199                 $('channel').options[selected].selected = true;
1200                 
1201         }
1202 }
1203 //doRequest(url_fetchchannels+servicereference, incomingChannellist, true);
1204
1205 function addTimerFormChangeTime(which) {
1206         var start = new Date( $('syear').value, ($('smonth').value -1), $('sday').value, $('shour').value, $('smin').value, 0);
1207         var end = new Date($('eyear').value, ($('emonth').value -1), $('eday').value, $('ehour').value, $('emin').value, 0);
1208 //      debug("("+start+")(" + end+")");
1209
1210         if(start.getTime() > end.getTime()) {
1211                 opponent = (which.substr(0,1) == 's') ? 'e' +  which.substr(1, which.length -1) : 's' +  which.substr(1, which.length -1) ;
1212                 $(opponent).value = $(which).value;
1213         }
1214         var all = new Array('year','month','day','hour','min');
1215         for(i=0; i < all.length; i++) {
1216                 if(which.substr(1, which.length -1) == all[i]) {
1217                         addTimerFormChangeTime(which.substr(0,1) + all[i+1] );
1218                         break;
1219                 }
1220         }
1221 }
1222 function addTimerFormChangeType() {
1223         var selected = ($('tvradio').checked == true) ? addTimerEditFormObject["TVList"]: addTimerEditFormObject["RadioList"];
1224         for (i = $('channel').options.length; i != 0; i--) {
1225                 $('channel').options[i - 1] = null;
1226         }
1227         var i = -1;
1228         for(element in selected) {
1229                 if(element != "extend") {
1230                         i++;
1231                         $('channel').options[i] = new Option(selected[element]);
1232                         $('channel').options[i].value = element;
1233                 }
1234         }
1235 }
1236 function addTimerFormCreateOptionListRepeated(Repeated,repeated) {
1237         var num = Number(repeated);
1238         var html = "";
1239         var html2 = "";
1240         var list = new Array(127, 64, 32, 31, 16, 8, 4, 2, 1);
1241         for(i = 0; i < list.length; i++) {
1242                 var txt = String(Repeated[String(list[i])]);
1243                 if( String(Repeated[String(list[i])]) == "mf") {
1244                         txt = "Mo-Fr";
1245                 } else if( String(Repeated[String(list[i])]) == "ms") {
1246                         txt = "Mo-Su";
1247                 } else {
1248                         txt = txt.substr(0,1).toUpperCase() + txt.substr(1,1);
1249                 }
1250                 var checked = " ";
1251                 if(num >=  list[i]) {
1252                         num -= list[i];
1253                         checked = "checked";
1254                 }
1255                 var namespace = {
1256                         'id': Repeated[String(list[i])],
1257                         'name': Repeated[String(list[i])],
1258                         'value': list[i],
1259                         'txt': txt,
1260                         'checked': checked };
1261                 if(String(Repeated[String(list[i])]) == "mf" || String(Repeated[String(list[i])]) == "ms") {
1262                         html2 = RND(tplAddTimerFormCheckbox, namespace) + html2;
1263                 } else {
1264                         html = RND(tplAddTimerFormCheckbox, namespace) + html;
1265                 }
1266         }
1267         return html + html2;
1268 }
1269 function sendAddTimer() {
1270         debug("sendAddTimer" + "parentChannel:" +$('channel').value);
1271         
1272         if(parentPin($('channel').value)) {
1273                 var beginD = new Date(ownLazyNumber($('syear').value), (ownLazyNumber($('smonth').value) - 1), ownLazyNumber($('sday').value), ownLazyNumber($('shour').value), ownLazyNumber($('smin').value));
1274                 var begin = beginD.getTime()/1000;
1275                 
1276                 var endD = new Date(ownLazyNumber($('eyear').value), (ownLazyNumber($('emonth').value) - 1), ownLazyNumber($('eday').value), ownLazyNumber($('ehour').value), ownLazyNumber($('emin').value));
1277                 var end = endD.getTime()/1000;
1278
1279                 var repeated = 0;
1280                 if( $('ms').checked ) {
1281                         repeated = 127;
1282                 } else if($('mf').checked) {
1283                         repeated = 31;
1284                         if($('sa').checked) {
1285                                 repeated += ownLazyNumber($('sa').value);
1286                         }
1287                         if($('su').checked) {
1288                                 repeated += ownLazyNumber($('su').value);
1289                         }
1290                 } else {
1291                         var check = new Array('mo', 'tu', 'we', 'th', 'fr');
1292                         for(i = 0; i < check.length; i++) {
1293                                 if($(check[i]).cheked) {
1294                                         repeated += Number($(check[i]).value);
1295                                 }
1296                         }
1297                 }
1298         
1299                 var descriptionClean = ($('descr').value == " " || $('descr').value == "N/A") ? "" : $('descr').value;
1300                 var nameClean = ($('name').value == " " || $('name').value == "N/A") ? "" : $('name').value;
1301         
1302                 var repeated = 0;
1303                 if($('ms').checked) {
1304                         repeated = ownLazyNumber($('ms').value);
1305                 } else if($('mf').checked) {
1306                         repeated = ownLazyNumber($('mf').value);
1307                         if($('su').checked) {
1308                                 repeated += ownLazyNumber($('su').value);
1309                         }
1310                         if($('sa').checked) {
1311                                 repeated += ownLazyNumber($('sa').value);
1312                         }
1313                 } else {
1314                         if($('mo').checked) {
1315                                 repeated += ownLazyNumber($('mo').value);
1316                         }
1317                         if($('tu').checked) {
1318                                 repeated += ownLazyNumber($('tu').value);
1319                         }
1320                         if($('we').checked) {
1321                                 repeated += ownLazyNumber($('we').value);
1322                         }
1323                         if($('th').checked) {
1324                                 repeated += ownLazyNumber($('th').value);
1325                         }
1326                         if($('fr').checked) {
1327                                 repeated += ownLazyNumber($('fr').value);
1328                         }
1329                         if($('sa').checked) {
1330                                 repeated += ownLazyNumber($('sa').value);
1331                         }
1332                         if($('su').checked) {
1333                                 repeated += ownLazyNumber($('su').value);
1334                         }
1335                 }
1336                 doRequest(url_timerchange+"?"+"serviceref="+$('channel').value+"&begin="+begin
1337                   +"&end="+end+"&name="+escape(nameClean)+"&description="+escape(descriptionClean)
1338                   +"&afterevent="+$('after_event').value+"&eit=0&disabled=0"
1339                   +"&justplay="+ownLazyNumber($('justplay').value)+"&repeated="+repeated
1340                   +"&channelOld="+$('channelOld').value
1341                   +"&beginOld="+$('beginOld').value+"&endOld="+$('endOld').value
1342                   +"&deleteOldOnSave="+ownLazyNumber($('deleteOldOnSave').value), incomingTimerAddResult, false);       
1343         }
1344 }
1345 function getSettings(){
1346         doRequest(url_settings, incomingGetSettings, false);
1347 }
1348
1349 function incomingGetSettings(request){
1350         if(request.readyState == 4){
1351                 settings = new Settings(getXML(request)).getArray();
1352         }
1353         if(String(getSettingByName("config.ParentalControl.configured")) == "True") {
1354                 getParentControl();
1355         }
1356 }
1357 function getSettingByName(txt) {
1358         debug("getSettingByName ("+txt+")");
1359         for(i = 0; i < settings.length; i++) {
1360                 debug("("+settings[i].getSettingName()+") (" +settings[i].getSettingValue()+")");
1361                 if(String(settings[i].getSettingName()) == String(txt)) {
1362                         return settings[i].getSettingValue();
1363                 } 
1364         }
1365         return "";
1366 }
1367 function getParentControl() {
1368         doRequest(url_parentcontrol, incomingParentControl, false);
1369 }
1370 function incomingParentControl(request) {
1371         if(request.readyState == 4){
1372                 parentControlList = new ServiceList(getXML(request)).getArray();
1373                 debug("parentControlList got "+parentControlList.length + " services");
1374         }
1375 }
1376 function getParentControlByRef(txt) {
1377         debug("getParentControlByRef ("+txt+")");
1378         for(i = 0; i < parentControlList.length; i++) {
1379                 debug("("+parentControlList[i].getClearServiceReference()+")");
1380                 if(String(parentControlList[i].getClearServiceReference()) == String(txt)) {
1381                         return parentControlList[i].getClearServiceReference();
1382                 } 
1383         }
1384         return "";
1385 }
1386 function sendToggleTimerDisable(justplay,begin,end,repeated,channel,name,description,afterEvent,disabled){
1387         disabled = (ownLazyNumber(disabled) == 0) ? 1 : 0;
1388         
1389         var descriptionClean = (description == " " || description == "N/A") ? "" : description;
1390         var nameClean = (name == " " || name == "N/A") ? "" : name;
1391
1392         doRequest(url_timerchange+"?"+"serviceref="+channel+"&begin="+begin
1393          +"&end="+end+"&name="+escape(nameClean)+"&description="+escape(descriptionClean)
1394          +"&afterevent="+afterEvent+"&eit=0&disabled="+disabled
1395          +"&justplay="+justplay+"&repeated="+repeated
1396          +"&channelOld="+channel
1397          +"&beginOld="+begin+"&endOld="+end
1398          +"&deleteOldOnSave=1", incomingTimerAddResult, false);
1399 }
1400 function ownLazyNumber(num) {
1401         if(isNaN(num)){
1402                 return 0;
1403         } else {
1404                 return Number(num);
1405         }
1406 }
1407
1408 var subServicesInsertedList = new Object();
1409
1410 function getSubServices(servicereference) {
1411                 doRequest(url_subservices,incomingSubServiceRequest, false);
1412 }
1413 function incomingSubServiceRequest(request){
1414         if(request.readyState == 4){
1415                 var services = new ServiceList(getXML(request)).getArray();
1416                 listerHtml      = '';           
1417                 debug("got "+services.length+" SubServices");
1418                 if(services.length > 1) {
1419
1420                         first = services[0];
1421                         var mainChannellist = loadedChannellist[String($('mainServiceRef').value)];
1422                         
1423                         var oldEntryPosition = -1;
1424                         for(i = 0; i < mainChannellist.length; i++) {
1425                                 var service = mainChannellist[i];
1426                                 if(String(service.getServiceReference()) == String(first.getServiceReference())) {
1427                                         oldEntryPosition = i + 1;
1428                                         break;
1429                                 }
1430                         }
1431                         if(typeof(subServicesInsertedList[String(first.getServiceReference())]) != "undefined") {
1432                                 for ( var i = 1; i < subServicesInsertedList[String(first.getServiceReference())].length ; i++){
1433                                         var reference = subServicesInsertedList[String(first.getServiceReference())][i];
1434                                         document.getElementById(reference.getServiceReference()+'extend').innerHTML = "";
1435                                 }
1436                                 for(i = oldEntryPosition; i < oldEntryPosition + subServicesInsertedList[String(first.getServiceReference())].length; i++) {
1437                                         mainChannellist.splice(i);
1438                                 }
1439                         }
1440
1441                         for ( var i = 0; i < services.length ; i++){
1442                                 var reference = services[i];
1443                                 var namespace = {       
1444                                         'servicereference': reference.getServiceReference(),
1445                                         'servicename': reference.getServiceName()
1446                                 };
1447                                 listerHtml += RND(tplServiceListItem, namespace);
1448                                 if(oldEntryPosition > -1) {
1449                                         mainChannellist = mainChannellist.insert(oldEntryPosition++, reference);
1450                                 }
1451                         }
1452
1453                         document.getElementById(first.getServiceReference()+'extend').innerHTML = listerHtml;
1454                         subServicesInsertedList[String(first.getServiceReference())] = services;
1455                         loadedChannellist[$('mainServiceRef').value] = mainChannellist;
1456                 }
1457         }
1458 }
1459 // Array.insert( index, value ) - Insert value at index, without overwriting existing keys
1460 Array.prototype.insert = function( j, v ) {
1461  if( j>=0 ) {
1462   var a = this.slice(), b = a.splice( j );
1463   a[j] = v;
1464   return a.concat( b );
1465  }
1466 }
1467 // Array.splice() - Remove or replace several elements and return any deleted elements
1468 if( typeof Array.prototype.splice==='undefined' ) {
1469  Array.prototype.splice = function( a, c ) {
1470   var i = 0, e = arguments, d = this.copy(), f = a, l = this.length;
1471   if( !c ) { c = l - a; }
1472   for( i; i < e.length - 2; i++ ) { this[a + i] = e[i + 2]; }
1473   for( a; a < l - c; a++ ) { this[a + e.length - 2] = d[a - c]; }
1474   this.length -= c - e.length + 2;
1475   return d.slice( f, f + c );
1476  };
1477 }
1478 function writeTimerListNow() {
1479         new Ajax.Request( url_timerlistwrite, { method: 'get' });
1480 }
1481 function recordingPushed() {
1482         doRequest(url_timerlist, incomingRecordingPushed, false);
1483 }
1484 function incomingRecordingPushed(request) {
1485         if(request.readyState == 4){
1486                 var timers = new TimerList(getXML(request)).getArray();
1487                 debug("have "+timers.length+" timer");
1488                 
1489                 var aftereventReadable = new Array ('Nothing', 'Standby', 'Deepstandby/Shutdown');
1490                 var justplayReadable = new Array('record', 'zap');
1491                 var OnOff = new Array('on', 'off');
1492                 
1493                 listerHtml = '';
1494                 
1495                 for ( var i = 0; i <timers.length; i++){
1496                         var timer = timers[i];
1497
1498                         if(ownLazyNumber(timer.getDontSave()) == 1) {
1499                                 var beginDate = new Date(Number(timer.getTimeBegin())*1000);
1500                                 var endDate = new Date(Number(timer.getTimeEnd())*1000);
1501                                 var namespace = {
1502                                 'servicereference': timer.getServiceReference(),
1503                                 'servicename': timer.getServiceName() ,
1504                                 'title': timer.getName(), 
1505                                 'description': timer.getDescription(), 
1506                                 'descriptionextended': timer.getDescriptionExtended(), 
1507                                 'begin': timer.getTimeBegin(),
1508                                 'beginDate': beginDate.toLocaleString(),
1509                                 'end': timer.getTimeEnd(),
1510                                 'endDate': endDate.toLocaleString(),
1511                                 'state': timer.getState(),
1512                                 'duration': Math.ceil((timer.getDuration()/60)),
1513                                 'repeated': timer.getRepeated(),
1514                                 'repeatedReadable': repeatedReadable(timer.getRepeated()),
1515                                 'justplay': timer.getJustplay(),
1516                                 'justplayReadable': justplayReadable[Number(timer.getJustplay())],
1517                                 'afterevent': timer.getAfterevent(),
1518                                 'aftereventReadable': aftereventReadable[Number(timer.getAfterevent())],
1519                                 'disabled': timer.getDisabled(),
1520                                 'onOff': OnOff[Number(timer.getDisabled())],
1521                                 'color': colorTimerListEntry( timer.getState() )
1522                                 };
1523                                 listerHtml += RND(tplTimerListItem, namespace);
1524                         }
1525                 }
1526                 openWindow("Record Now", listerHtml+tplRecordingFooter, 900, 500, "Record now window");
1527         }
1528 }
1529 function inserteSizes() {
1530 /*      var screenW = 640, screenH = 480;
1531         if (parseInt(navigator.appVersion)>3) { 
1532                 screenW = screen.width;
1533                 screenH = screen.height;
1534         } else if (navigator.appName == "Netscape"
1535            && parseInt(navigator.appVersion)==3
1536            && navigator.javaEnabled() ) {
1537                 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
1538                 var jScreenSize = jToolkit.getScreenSize();
1539                 screenW = jScreenSize.width;
1540                 screenH = jScreenSize.height;
1541         }
1542         debug("screenW:"+screenW+" screenH:"+screenH);
1543         /* 640x480
1544          * 800x600
1545          * 1024x768
1546          * 1280x1024
1547          * 1600x1280
1548         if(screenH == 800) {
1549                 debug("size 1");
1550                 document.getElementById("BodyContentChannellist").style.height = '20%';
1551         } else if(screenH == 1024) {
1552                 debug("1024")
1553                 document.getElementById("BodyContentChannellist").style.height = '760px';
1554                 
1555         } else {
1556                 alert("unsupported screensize");
1557         }*/
1558         
1559 }
1560 function recordingPushedDecision(recordNowNothing,recordNowUndefinitely,recordNowCurrent) {
1561         var recordNow = recordNowNothing;
1562         recordNow = (recordNow == "") ? recordNowUndefinitely: recordNow;
1563         recordNow = (recordNow == "") ? recordNowCurrent: recordNow;
1564         if(recordNow != "nothing" && recordNow != "") {
1565                 doRequest(url_recordnow+"?recordnow="+recordNow, incomingTimerAddResult, false);
1566         }
1567 }
1568
1569 function ifChecked(rObj) {
1570         if(rObj.checked) {
1571                 return rObj.value;
1572         } else {
1573                 return "";
1574         }
1575 }
1576 function showEmuConfig() {
1577         doRequest(url_emulist, incomingEMUList, false);
1578 }
1579 function incomingEMUList(request) {
1580         if(request.readyState == 4){
1581                 var emuList = new EMUList(getXML(request)).getArray();
1582                 
1583                 debug("got " + emuList.length + " emus");
1584
1585                 listerHtml = tplEMUPageHeader;
1586                 var smallNamespace = { 'name': "EMU-name", 'file': " ", 'status': "Status", 'link': " ", 'action': "On-Off/Restart"};
1587                 listerHtml += RND(tplEMUPageItem, smallNamespace);
1588                 smallNamespace = { 'name': " ", 'file': " ", 'status': " ", 'link': " ", 'action': " "};
1589                 listerHtml += RND(tplEMUPageItem, smallNamespace);
1590                 
1591                 var OnOff = new Array('on', 'off');
1592                 
1593                 for( i = 0; i < emuList.length; i++) {
1594                         var emu = emuList[i];
1595
1596                         var statusEmu = 0;
1597                         if(emu.getStatus() == "running") {
1598                                 statusEmu = 1;
1599                         }
1600                         debug("status:"+statusEmu+emu.getStatus());
1601                         
1602                         var action = RND(tplEMUPageOnOff, {'onOff': OnOff[statusEmu], 'file': emu.getFile()});
1603                         var emuName =  emu.getName();
1604                         if(emu.getLink() != "" && emu.getLink() != " ") {
1605                                 emuName =  RND(tplEMUPageNameLink, {'name': emu.getName(), 'link': emu.getLink()});
1606                         }
1607                         var namespace = {
1608                                 'name': emuName,
1609                                 'file': emu.getFile(),
1610                                 'link': emu.getLink(),
1611                                 'status': emu.getStatus(),
1612                                 'action':  action
1613                                 };
1614                         listerHtml += RND(tplEMUPageItem, namespace);
1615                 }
1616                 listerHtml += tplEMUPageFooter;
1617                 document.getElementById('BodyContentChannellist').innerHTML = listerHtml;
1618                 setBodyMainContent('BodyContentChannellist');
1619                 
1620         }
1621 }
1622 function emuChangeStatus(state,file) {
1623         new Ajax.Request(url_emuchangestate+"?state="+state+"&file="+file, { method: 'get' });
1624 }
1625 function showAbout() {
1626         doRequest(url_about, incomingAbout, false);
1627 }
1628 function incomingAbout(request) {
1629         if(request.readyState == 4){
1630                 var aboutEntries = getXML(request).getElementsByTagName("e2abouts").item(0).getElementsByTagName("e2about");
1631                 for (var c =0; c < aboutEntries.length;c++){
1632                         var xml = aboutEntries.item(c);
1633                         try{
1634                                 var namespace = {
1635                                         'enigmaVersion': xml.getElementsByTagName('e2enigmaversion').item(0).firstChild.data
1636                                         ,'lanDHCP': xml.getElementsByTagName('e2landhcp').item(0).firstChild.data
1637                                         ,'lanIP': xml.getElementsByTagName('e2lanip').item(0).firstChild.data
1638                                         ,'lanMask': xml.getElementsByTagName('e2lanmask').item(0).firstChild.data
1639                                         ,'lanGW': xml.getElementsByTagName('e2langw').item(0).firstChild.data
1640                                         ,'lanDNS': xml.getElementsByTagName('e2landns').item(0).firstChild.data
1641                                         ,'fpVersion': xml.getElementsByTagName('e2fpversion').item(0).firstChild.data
1642                                         ,'tunerInfo': xml.getElementsByTagName('e2tunerinfo').item(0).firstChild.data
1643                                         ,'hddInfo': xml.getElementsByTagName('e2hddinfo').item(0).firstChild.data
1644                                         ,'serviceName': xml.getElementsByTagName('e2servicename').item(0).firstChild.data
1645                                         ,'serviceProvider': xml.getElementsByTagName('e2serviceprovider').item(0).firstChild.data
1646                                         ,'serviceAspect': xml.getElementsByTagName('e2serviceaspect').item(0).firstChild.data
1647                                         ,'serviceNamespace': xml.getElementsByTagName('e2servicenamespace').item(0).firstChild.data
1648                                         ,'vPID': xml.getElementsByTagName('e2vpid').item(0).firstChild.data
1649                                          ,'vPIDh': parseInt(xml.getElementsByTagName('e2vpid').item(0).firstChild.data,16)
1650                                         ,'aPID': xml.getElementsByTagName('e2apid').item(0).firstChild.data
1651                                          ,'aPIDh': parseInt(xml.getElementsByTagName('e2apid').item(0).firstChild.data,16)
1652                                         ,'pcrID': xml.getElementsByTagName('e2pcrid').item(0).firstChild.data
1653                                          ,'pcrIDh': parseInt(xml.getElementsByTagName('e2pcrid').item(0).firstChild.data,16)
1654                                         ,'pmtPID': xml.getElementsByTagName('e2pmtpid').item(0).firstChild.data
1655                                          ,'pmtPIDh': parseInt(xml.getElementsByTagName('e2pmtpid').item(0).firstChild.data,16)
1656                                         ,'txtPID': xml.getElementsByTagName('e2txtpid').item(0).firstChild.data
1657                                          ,'txtPIDh': parseInt(xml.getElementsByTagName('e2txtpid').item(0).firstChild.data,16)
1658                                         ,'tsID': xml.getElementsByTagName('e2tsid').item(0).firstChild.data
1659                                          ,'tsIDh': parseInt(xml.getElementsByTagName('e2tsid').item(0).firstChild.data,16)
1660                                         ,'onID': xml.getElementsByTagName('e2onid').item(0).firstChild.data
1661                                          ,'onIDh': parseInt(xml.getElementsByTagName('e2onid').item(0).firstChild.data,16)
1662                                         ,'sid': xml.getElementsByTagName('e2sid').item(0).firstChild.data
1663                                          ,'sidh': parseInt(xml.getElementsByTagName('e2sid').item(0).firstChild.data,16)
1664                                   };
1665                                 document.getElementById('BodyContentChannellist').innerHTML = RND(tplAbout, namespace);;
1666                                 setBodyMainContent('BodyContentChannellist');
1667                         } catch (e) {
1668                                 debug("About parsing Error");
1669                         }       
1670                 }
1671                 
1672         }
1673                 
1674         
1675 }