$(document).ready(function(){zanmantou1=new Zanmantou("zanmantou");typ="p";uebung=true;loadCookie();});
/**************************************************************************************************/
function ZanmantouCallback(id, args){for(var i=0;i<ZanmantouInstance.length;i++){if(ZanmantouInstance[i][0]==id){ZanmantouInstance[i][1].callback(args);}}}
var ZanmantouInstance = new Array();
function Zanmantou(id){this.zanmantou=document.getElementById(id);this.id=id;this.isRegistered=false;this.callbackArgs="";ZanmantouInstance.push(new Array(id,this));}
Zanmantou.prototype.callback=function(args){this.callbackArgs=args+"";}
Zanmantou.prototype.register=function(){if(!this.isRegistered){this.isRegistered=true;this.zanmantou.JMAPI_init(this.id);}}
Zanmantou.prototype.start=function(position){if(this.zanmantou && this.zanmantou.JMAPI_start){this.zanmantou.JMAPI_start(position);}}
Zanmantou.prototype.stop=function(){this.zanmantou.JMAPI_stop();}
Zanmantou.prototype.halt=function(){this.zanmantou.JMAPI_halt();}
Zanmantou.prototype.next=function(){this.zanmantou.JMAPI_next();}
Zanmantou.prototype.last=function(){this.zanmantou.JMAPI_prev();}
Zanmantou.prototype.jumpAndPlay=function(index){this.zanmantou.JMAPI_jump(index);}
Zanmantou.prototype.setTransform=function(ll,lr,rr,rl){this.zanmantou.JMAPI_setTransform(ll,lr,rr,rl);}
Zanmantou.prototype.addTrack=function(name,url,index){this.zanmantou.JMAPI_addTrack(name,url,index);}
Zanmantou.prototype.removeTrack=function(index){this.zanmantou.JMAPI_removeTrack(index);}
Zanmantou.prototype.getTrackPosition=function(){this.register();this.zanmantou.JMAPI_getTrackPosition();return this.callbackArgs;}
Zanmantou.prototype.getTrackLength=function(){this.register();this.zanmantou.JMAPI_getTrackLength();return this.callbackArgs;}
Zanmantou.prototype.getID3=function(value){this.register();this.zanmantou.JMAPI_getID3(value);return this.callbackArgs;}
/**************************************************************************************************/
var zanmantou1;var typ="p";var uebung=true;var timer=null;var wechsel=0;var dauer=0;var abgelaufen=0;var meter=0;var meterziel=0;
function calculate() {var pause=0;var programm=0;var nuebung=0;if(document.forms.trainer){pause=document.forms.trainer.pause.value;for(var i=0;i<document.forms.trainer.programm.length;i++){if(document.forms.trainer.programm[i].checked){programm=document.forms.trainer.programm[i].value;break;}}nuebung=document.forms.trainer.zeit.value;if(programm==1){var zeit=10+3*pause+4*nuebung;}else if(programm==2){var zeit=10+7*pause+10*nuebung;}else if(programm==3){var zeit=10*2+7*pause+11*nuebung;}else if(programm==4){var zeit=10*6+16*pause+23*nuebung;}else if(programm==5){var zeit=10*10+25*pause+37*nuebung;}else{var zeit=0;}var min=Math.floor(zeit/60);var sek=zeit-(min*60);if(min<10){min="0"+min;}if(sek<10){sek="0"+sek;}obj=document.getElementById("calculate");obj.innerHTML=min+":"+sek;}}
function showCounter(count){var obj=document.getElementById('counter');if(typ=="p"){obj.innerHTML="Pause f&uuml;r "+count+"s";}else if(typ=="w"){obj.innerHTML="Bitte Seite wechseln "+count+"s";}else{obj.innerHTML="&Uuml;bung f&uuml;r "+count+"s";}if(count<3 && zanmantou1 && zanmantou1.start){zanmantou1.start();}if(count>0){abgelaufen++;$('#meter').css('width',(meter+Math.ceil(abgelaufen*(meterziel-meter)/dauer))+'px');timer=window.setTimeout("showCounter("+(count-1)+")",1000);}if(count==0 && !uebung){wechsel--;if(wechsel>0){typ="w";uebung=true;timer=window.setTimeout("showCounter(10)",1000);return;}}if(count==0 && !uebung && wechsel==0){window.location.reload();}if(count==0 && uebung && wechsel>0){uebung=false;typ="u";timer=window.setTimeout("showCounter(zeit)",1000);}}
function resetCounter(resetWechsel){wechsel=resetWechsel;uebung=true;typ="p";dauer=(wechsel-1)*10+pause+wechsel*zeit;abgelaufen=0;window.clearTimeout(timer);showCounter(pause);}
function loadCookie(){var list=jQuery.cookie('trainer');if(list!=undefined && list!=''){list=list.split(',');$('input[name=zeit]').val(list[0]);$('input[name=pause]').val(list[1]);$('input[name=programm][value='+list[2]+']').attr('checked','checked');calculate();}}
function saveCookie(){if($('input[name=save]:checked').length==1){var zeit=$('input[name=zeit]').val();var pause=$('input[name=pause]').val();var programm=$('input[name=programm]:checked').val();jQuery.cookie('trainer', zeit+','+pause+','+programm);}}
