

function checkBrowserName(name){  
   var agent = navigator.userAgent.toLowerCase();  
   if (agent.indexOf(name.toLowerCase())>-1) {  
     return true;  
   }  
   return false;  
 }  


function pageselectCallback(page_index, jq){
        var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone(); 
        $('#Searchresult').empty().append(new_content);
        return false;
}
function initPagination() {

        var num_entries = $('#hiddenresult div.result').length;

        // Create pagination element
        $("#Pagination").pagination(num_entries, {
                num_edge_entries: 2,
                num_display_entries: 20,
                callback: pageselectCallback,
                items_per_page:1
        });
 }

function show_doku_ausdauer(datum) 
{
	
		var kalenderart        =          document.form_save_ausdauer.kalenderart.value;
		var inhalt = $.ajax({
		  url: 'module/controllcenter/ajax_doku_ausdauer.php?datum='+datum+'&kalenderart='+kalenderart,
		  success: function(data){
				var inhalt = data;
				var cp=datum.split('-');
				var jahr=cp[0];
				var monat=cp[1];
				var tag=cp[2];
				var ebene = 'doku_'+jahr+'_'+monat+'_'+tag;
				document.getElementById(ebene).innerHTML=inhalt;
		  }
		});
}

function auswerten_garmin(datei)
{

       var datum= document.form_save_ausdauer.datum.value ;


		
       var sportart= document.form_save_ausdauer.save_einheit_sportart.value;
       var inhalt = $.ajax({
       url: 'hfdatei_verarbeiten.php?ausgabe='+datei+'&art=tcx&datum='+datum+'&sportart='+sportart,
       success: function(data){
           var inhalt = data;


                 show_doku_ausdauer(datum);

                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;
				 
				 

                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
								
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();

                          }
                        });



         }
       });

}

function auswerten_powertap(datei)
{

       var datum= document.form_save_ausdauer.datum.value ;

		
       var sportart= document.form_save_ausdauer.save_einheit_sportart.value;
       var inhalt = $.ajax({
       url: 'hfdatei_verarbeiten.php?ausgabe='+datei+'&art=powertap&datum='+datum+'&sportart='+sportart,
       success: function(data){
           var inhalt = data;
			show_doku_ausdauer(datum);

                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;
				 
				 
						
                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
					
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();

                          }
                        });
         }
       });

}


function auswerten_polar()
{
	var datum= document.form_save_ausdauer.datum.value ;
	var sportart= document.form_save_ausdauer.save_einheit_sportart.value;
	var filespeicher=$('#polar_files_uploaded').html();
	
	var burl = 'hfdatei_verarbeiten.php?art=polar&datum='+datum+'&sportart='+sportart+'&filespeicher='+filespeicher;
 	var inhalt = $.ajax({
       url: burl,
       success: function(data){
           var inhalt = data;

			show_doku_ausdauer(datum);
                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;

                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
					
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();
                          }
                        });	
         }
      });
}



function auswerten_timex(datei)
{

       var datum= document.form_save_ausdauer.datum.value ;

		
       var sportart= document.form_save_ausdauer.save_einheit_sportart.value;
       var inhalt = $.ajax({
       url: 'hfdatei_verarbeiten.php?ausgabe='+datei+'&art=timex&datum='+datum+'&sportart='+sportart,
       success: function(data){
           var inhalt = data;
		
			show_doku_ausdauer(datum);

                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;
				 
				 
						
                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
					
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();

                          }
                        });
         }
       });

}
 

function auswerten_daum(datei)
{
       var datum= document.form_save_ausdauer.datum.value ;
       var sportart= 8;
	   var url = 'hfdatei_verarbeiten.php?ausgabe='+datei+'&art=daum&datum='+datum+'&sportart='+sportart;
     
	   var inhalt = $.ajax({
       url: url,
       success: function(data ){ 
           var inhalt = data;
		
			show_doku_ausdauer(datum);

                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;
				 
				 
						
                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
					
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();

                          }
                        });
         }
       });

}

function auswerten_sigma(datei)
{
       var datum= document.form_save_ausdauer.datum.value ;
       var sportart= document.form_save_ausdauer.save_einheit_sportart.value;
	   var url = 'hfdatei_verarbeiten.php?ausgabe='+datei+'&art=sigma&datum='+datum+'&sportart='+sportart;
     
	   var inhalt = $.ajax({
       url: url,
       success: function(data ){ 
           var inhalt = data;
		
			show_doku_ausdauer(datum);

                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;
				 
				 
						
                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
					
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();

                          }
                        });
         }
       });

}

function auswerten_suunto(datei)
{
       var datum= document.form_save_ausdauer.datum.value ;
        var sportart= document.form_save_ausdauer.save_einheit_sportart.value;
	   var url = 'hfdatei_verarbeiten.php?ausgabe='+datei+'&art=suunto&datum='+datum+'&sportart='+sportart;
     
	   var inhalt = $.ajax({
       url: url,
       success: function(data ){ 
           var inhalt = data;
		
			show_doku_ausdauer(datum);

                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;
				 
				 
						
                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
					
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();

                          }
                        });
         }
       });

}

function auswerten_hac(datei)
{
       var datum= document.form_save_ausdauer.datum.value ;
        var sportart= document.form_save_ausdauer.save_einheit_sportart.value;
	   var url = 'hfdatei_verarbeiten.php?ausgabe='+datei+'&art=hac&datum='+datum+'&sportart='+sportart;
     
	   var inhalt = $.ajax({
       url: url,
       success: function(data ){ 
           var inhalt = data;

			show_doku_ausdauer(datum);

                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;
				 
				 
						
                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
					
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();

                          }
                        });
         }
       });

}

function auswerten_nike(datei)
{
       var datum= document.form_save_ausdauer.datum.value ;
        var sportart= document.form_save_ausdauer.save_einheit_sportart.value;
	   var url = 'hfdatei_verarbeiten.php?ausgabe='+datei+'&art=nike&datum='+datum+'&sportart='+sportart;
     
	   var inhalt = $.ajax({
       url: url,
       success: function(data ){ 
           var inhalt = data;

			show_doku_ausdauer(datum);

                 $('#hinweis_save_ausdauer').hide();
                 $('#hinweis_save_ausdauer_warten').hide();
                 var nummer=inhalt;
				 
				 
						
                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
					
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');
                                $('#hinweis_save_hf_datei').show();

                          }
                        });
         }
       });

}


function change_athletik(dat,wert)
{
	 var inhalt = $.ajax({
	  url: 'module/controllcenter/ajax_change_athletik.php?dat='+dat+'&wert='+wert,
	  success: function(data){
			var inhalt = data;
		 }
     });
}



$(document).ready(function(){


	//alert($('#div_login_block').width());
	$('#div_login_block').css('left', (1000 - $('#div_login_block').width())+'px'  )  ;
	

	window.alert = function(text) {
        $("<div id='alertfenster'>" + text + "</div>").dialog({
            modal: true,
            autoOpen: true,
            buttons: {
                close: function() {
                    $(this).dialog('close');
                }
            }
        });
    };
	window.confirm = function(text) {
        $("<div id='alertfenster'>" + text + "</div>").dialog({
            modal: true,
            autoOpen: true,
            buttons: {
                'nein': function() {
                    $(this).dialog('close');
				},
				'ja': function() {
					$(this).dialog('close');
					$('#link_training_aktualisieren').hide();
					calculate();
					
                }
            }
        });
    };
	
	
	
	
	
	
	$("#dialog_confirm_delete").dialog({
      autoOpen: false,
      modal: true
    });
	$(".confirm_del").click(function(e) {
	
		e.preventDefault();
		var targetUrl = $(this).attr("href");
	
		$("#dialog_confirm_delete").dialog({
		  buttons : {
			"ja" : function() {
			  window.location.href = targetUrl;
			},
			"abbrechen" : function() {
			  $(this).dialog("close");
			}
		  }
		});
	
		$("#dialog_confirm_delete").dialog("open");
	  });
	  
	  
	  
	 $(".confirm_del_ausdauer").livequery(function() {
	 	$(this).click(function(e) {
			e.preventDefault();
			var targetUrl = $(this).attr("dat");
		
			$("#dialog_confirm_delete").dialog({
			  buttons : {
				"ja" : function() {
				  //window.location.href = targetUrl;
				  del_doku_ausdauer(targetUrl);
				  $(this).dialog("close");
				},
				"abbrechen" : function() {
				  $(this).dialog("close");
				}
			  }
			});
		
			$("#dialog_confirm_delete").dialog("open");
		  });
	});		

	
	
	$('.athletik_uebung_ok').click(function() {
		var dat=$(this).attr('dat');
		change_athletik(dat,'2');
		$("#athletik_uebung_"+dat).css('border' , '4px solid #00cc00');
	});
	$('.athletik_uebung_nok').click(function() {
		var dat=$(this).attr('dat');
		change_athletik(dat,'1');
		$("#athletik_uebung_"+dat).css('border' , '4px solid #FFFF00');
	});
	$('.athletik_uebung_nicht').click(function() {
		var dat=$(this).attr('dat');
		change_athletik(dat,'0');
		$("#athletik_uebung_"+dat).css('border' , '4px solid #FF3300');
	});
	
	
	
	
	
	
	
	
	$('#link_training_aktualisieren').click(function() {
		var frage = $('#div_frage_alles_dokumentiert').html();
		confirm(frage);
	});


	$('#drucken_ausdauer_tagesuebersicht').click(function() {
		$('#tabelle_ausdauer_tagesuebersicht').printElement({
			overrideElementCSS:['style_druck.css', { href:'style_druck.css',media:'print'}],
			leaveOpen:false,
            printMode:'popup'
		});
	});


	if ($('#ebene_neuling').length > 0) alert( $('#ebene_neuling').html()  );  //

	$('.anleitungsoeffner').click(function() {
		$('#alertfenster').dialog('close'); 
		$('#anleitungen_ausdauer').dialog('open');
		
	});
	
	$("#div_anleitung").dialog({
			autoOpen: false,
			show: 'blind',
			position: 'center',
			closeText: 'zumache',
			height: 570,
			width: 990
	});
	$('.anleitung_clicker_plan_erstellen').click(function() {
		var video=$(this).attr('dat');
		$('#iframe_anleitung').attr('src','http://www.youtube.com/embed/'+video+'?rel=0&showinfo=0&autohide=1&controls=1&fs=0&hd=1&showsearch=0&fmt=22');
		$('#div_anleitung').dialog('open');
	});
	
	
	
	
	

	var marker = new Array();
	
	
	$('#ebene_facebook').fbWall({ id:'195497893821125',accessToken:'AAAC7gAoWDQ0BAOb9W1hfS6VO8kN43s3gGozOghFuZAQQF8ZAo4XKzXhyK0GHXG5PySsjCFIpwe5vAk1Sq6tLoufirUYJp5eo5QSWRQ1AZDZD'}); 
	//206158599425293|409961bb9cd96f963c03fa01.1-100000090177706|hxe2esazEJczWO0cd-lKnTesQgc

	$('#file_upload_polar').uploadify({
		  'uploader'       : 'uploadify.swf',
		  'script'         : 'uploadify_polar.php',
		  'cancelImg'      : 'cancel.png',
		  'folder'         : 'uploads',
		  'multi'          : true,
		  'auto'           : false,
		  'fileExt'        : '*.hrm;*.gpx;',
		  'fileDesc'       : 'hrm und gpx',
		  'queueID'        : 'upload_polar_ausgabe',
		  'queueSizeLimit' : 2,
		  'simUploadLimit' : 2,
		  'removeCompleted': true,
		  'onComplete'  : function(event, ID, fileObj, response, data) {
			 	var cp=$('#polar_files_uploaded').html();
				if (cp=='') cp=response;
					else cp=cp + '|' + response;
				
				$('#polar_files_uploaded').html(cp);
				
					
			},
		  'onSelect'    : function(event,ID,fileObj) {
		  	var ty = fileObj.type;
			if (ty !='.hrm' && ty !='.gpx')
				{
					$('#hinweis_polar_fehler').show();
					$('#file_upload_polar').uploadifyClearQueue();
				}
				else
					{
						$('#hinweis_polar_fehler').hide();
						$('#upload_polar_ausgabe_link_ebene').show();
					}
			},
			'onAllComplete': function(event, data){
				$('#hinweis_save_ausdauer_warten').show();
				
				auswerten_polar();
			}
      });

	$('#upload_polar_ausgabe_link').click(function() {
		$('#polar_files_uploaded').html('');
		$('#file_upload_polar').uploadifyUpload();
	});
	

    $('#file_upload_garmin').uploadify({
        'uploader'  : 'uploadify.swf',
        'script'    : 'uploadify.php',
        'cancelImg' : 'images/cancel.png',
        'folder'    : 'uploads',
        'auto'      :  true,
        'buttonText': $('#file_upload_garmin').attr('title'),
        'simUploadLimit' : 1,
        'onComplete': function(event, queueID, fileObj, response, data){
			$('#hinweis_save_ausdauer_warten').show();
            auswerten_garmin(response);
        }

      });
	 $('#file_upload_powertap').uploadify({
        'uploader'  : 'uploadify.swf',
        'script'    : 'uploadify_powertap.php',
        'cancelImg' : 'images/cancel.png',
        'folder'    : 'uploads',
        'auto'      :  true,
        'buttonText': $('#file_upload_powertap').attr('title'),
        'simUploadLimit' : 1,
        'onComplete': function(event, queueID, fileObj, response, data){
			$('#hinweis_save_ausdauer_warten').show();
            auswerten_powertap(response);
        }

      });
	  
	   $('#file_upload_timex').uploadify({
        'uploader'  : 'uploadify.swf',
        'script'    : 'uploadify_timex.php',
        'cancelImg' : 'images/cancel.png',
        'folder'    : 'uploads',
        'auto'      :  true,
        'buttonText': $('#file_upload_timex').attr('title'),
        'simUploadLimit' : 1,
        'onComplete': function(event, queueID, fileObj, response, data){
			$('#hinweis_save_ausdauer_warten').show();
            auswerten_timex(response);
        }

      });
	  
	  $('#file_upload_daum').uploadify({
        'uploader'  : 'uploadify.swf',
        'script'    : 'uploadify_daum.php',
        'cancelImg' : 'images/cancel.png',
        'folder'    : 'uploads',
        'auto'      :  true,
        'buttonText': $('#file_upload_daum').attr('title'),
        'simUploadLimit' : 1,
        'onComplete': function(event, queueID, fileObj, response, data){
			$('#hinweis_save_ausdauer_warten').show();
            auswerten_daum(response);
        }

      });
	  
	  $('#file_upload_sigma').uploadify({
        'uploader'  : 'uploadify.swf',
        'script'    : 'uploadify_sigma.php',
        'cancelImg' : 'images/cancel.png',
        'folder'    : 'uploads',
        'auto'      :  true,
        'buttonText': $('#file_upload_sigma').attr('title'),
        'simUploadLimit' : 1,
        'onComplete': function(event, queueID, fileObj, response, data){
			$('#hinweis_save_ausdauer_warten').show();
            auswerten_sigma(response);
        }

      });
	  
	   $('#file_upload_suunto').uploadify({
        'uploader'  : 'uploadify.swf',
        'script'    : 'uploadify_suunto.php',
        'cancelImg' : 'images/cancel.png',
        'folder'    : 'uploads',
        'auto'      :  true,
        'buttonText': $('#file_upload_suunto').attr('title'),
        'simUploadLimit' : 1,
        'onComplete': function(event, queueID, fileObj, response, data){
			$('#hinweis_save_ausdauer_warten').show();
            auswerten_suunto(response);
        }

      });
	  
	  $('#file_upload_hac').uploadify({
        'uploader'  : 'uploadify.swf',
        'script'    : 'uploadify_hac.php',
        'cancelImg' : 'images/cancel.png',
        'folder'    : 'uploads',
        'auto'      :  true,
        'buttonText': $('#file_upload_hac').attr('title'),
        'simUploadLimit' : 1,
        'onComplete': function(event, queueID, fileObj, response, data){
			$('#hinweis_save_ausdauer_warten').show();
            auswerten_hac(response);
        }

      });
	  
	  $('#file_upload_nike').uploadify({
        'uploader'  : 'uploadify.swf',
        'script'    : 'uploadify_nike.php',
        'cancelImg' : 'images/cancel.png',
        'folder'    : 'uploads',
        'auto'      :  true,
        'buttonText': $('#file_upload_nike').attr('title'),
        'simUploadLimit' : 1,
        'onComplete': function(event, queueID, fileObj, response, data){
			$('#hinweis_save_ausdauer_warten').show();
            auswerten_nike(response);
        }

      });


        initPagination();

        function in_array(suche, mein_array)
        {

          var j=0;
            for (i=0; i<mein_array.length; i++)
                 {
                         if(mein_array[i]==suche)
                         {j++;}
                 }
            return j;
        }







        hide_hf_upload();



        function hide_hf_upload()
                {
						$('#infobutton_upload_garmin').hide();
						$('#infobutton_upload_polar').hide();
						$('#infobutton_upload_powertap').hide();
						$('#infobutton_upload_timex').hide();
						$('#infobutton_upload_daum').hide();
						$('#infobutton_upload_suunto').hide();
						$('#infobutton_upload_hac').hide();
						$('#infobutton_upload_nike').hide();
						$('#infobutton_upload_sigma').hide();
				
                        $('#ebene_upload_polar').hide();
                        $('#ebene_upload_garmin').hide();
						$('#ebene_upload_powertap').hide();
						$('#ebene_upload_timex').hide();
						$('#ebene_upload_daum').hide();
						$('#ebene_upload_suunto').hide();
						$('#ebene_upload_hac').hide();
						$('#ebene_upload_nike').hide();
						$('#ebene_upload_sigma').hide();
                }

        $('#dateiart_upload_hf').change(function(event) {
       		 var dateiart        = document.form_save_ausdauer.dateiart_upload_hf.value;

                hide_hf_upload();
				

                if (dateiart==1) {$('#ebene_upload_polar').show();		$('#infobutton_upload_polar').show(); }		
                if (dateiart==2) {$('#ebene_upload_garmin').show();		$('#infobutton_upload_garmin').show(); }
				if (dateiart==3) {$('#ebene_upload_powertap').show();	$('#infobutton_upload_powertap').show(); }
				if (dateiart==4) {$('#ebene_upload_timex').show();		$('#infobutton_upload_timex').show(); }
				if (dateiart==5) {$('#ebene_upload_daum').show();		$('#infobutton_upload_daum').show(); }
				if (dateiart==6) {$('#ebene_upload_suunto').show();		$('#infobutton_upload_suunto').show(); }
				if (dateiart==7) {$('#ebene_upload_hac').show();		$('#infobutton_upload_hac').show(); }
				if (dateiart==8) {$('#ebene_upload_nike').show();		$('#infobutton_upload_nike').show(); }
				if (dateiart==9) {$('#ebene_upload_sigma').show();		$('#infobutton_upload_sigma').show(); }
			
				

    }); 

        function calculate()
        {

                var startdatum = document.form_datum.datum_von.value;
                var enddatum = document.form_datum.datum_bis.value;
                var kalenderart        = $("input[name=kalenderart]:checked").val();

                $('#ebene_bitte_warten_aktualisierung').dialog('open');
                var inhalt = $.ajax({
                  url: 'module/controllcenter/ajax_calculate_plan.php?kalenderart='+kalenderart+'&startdatum='+startdatum+'&enddatum='+enddatum,
                  success: function(data){
                        var inhalt = data;
						
                        var cp=inhalt.split('~~');
                        var anz = cp.length;
                        var feld_vgl = new Array();
                        for (var i=0; i < anz; i++)
                         {
                                     var cp2=cp[i].split('|');
                                     var tag                                =        cp2[0];
                                     var monat                        =        cp2[1];
                                     var jahr                        =        cp2[2];
                                     var html                        =        cp2[3];


                                     if (in_array(jahr+'-'+monat+'-'+tag, feld_vgl) == 0)
                                        {
                                         feld_vgl.push(jahr+'-'+monat+'-'+tag);

                                              if (tag != '' && monat !='' && jahr !='')
                                                     {
                                                             if ( $('#plan_'+jahr+'_'+monat+'_'+tag).length > 0) $('#plan_'+jahr+'_'+monat+'_'+tag).html(html); // document.getElementById('plan_'+jahr+'_'+monat+'_'+tag).innerHTML= html;
                                                     }
                                        }
                                     else
                                         {
                                           if (tag != '' && monat !='' && jahr !='')
                                                     {
													 		
                                                           if ( $('#plan_'+jahr+'_'+monat+'_'+tag).length > 0) 
														   	{
																var zw=$('#plan_'+jahr+'_'+monat+'_'+tag).html();
																$('#plan_'+jahr+'_'+monat+'_'+tag).html(zw + html);
																 //document.getElementById('plan_'+jahr+'_'+monat+'_'+tag).innerHTML= document.getElementById('plan_'+jahr+'_'+monat+'_'+tag).innerHTML +  html;
                                                     		}
													 }
                                         }




                             }

                        //$('#zeitbalken').slider( 'option', 'min', parseInt(inhalt[2]) );
                        $('#ebene_bitte_warten_aktualisierung').dialog('close');
                  },
                  error: function(data){
                          $('#ebene_bitte_warten_aktualisierung').dialog('close');
                  }
                });

        }

        $('#go_del_wk').click(function() {
                var datum        =        document.form_wettkampf_loeschen.loeschen_datum.value;
                var auswahl        = $("input[name=auswahl_loeschen]:checked").val();

                if (auswahl==1)
                        {
                                var inhalt = $.ajax({
                                  url: 'module/controllcenter/ajax_delete_wettkaempfe.php?datum='+datum,
                                  success: function(data){
                                        var inhalt = data;
                                        var cp=inhalt.split("||");
                                        var element=cp[0];
                                        var wochentag=cp[1];
                                        var plantag=cp[2];
                                        var wochentagtext=cp[3];
                                        var headline=cp[4];

                                        if (wochentag==0) var style='tabelle_zeile_dunkel';
                                                else var style='tabelle_zeile_hell'

                                        document.getElementById(element).className=style;


                                        var cp=element.split('_');
                                                var cp_plan='plan_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_doku='doku_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_taganker='taganker_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_rand_links='rand_links_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_rand_rechts='rand_rechts_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var save_spalte='save_spalte_'+cp[1]+'_'+cp[2]+'_'+cp[3];


                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_plan).className=style;
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_doku).className=style;
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_taganker).className=style;
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_rand_links).className=style;
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_rand_rechts).className=style;
                                                if (document.getElementById(cp_taganker)) document.getElementById(save_spalte).className=style;



                                        document.getElementById(plantag).innerHTML='';


                                        document.getElementById(wochentagtext).title=headline;
                                        document.getElementById(wochentagtext).className='link_darkgreen tooltip_standard link_planungseinstellungen';






                                        //$('#zeitbalken').slider( 'option', 'min', parseInt(inhalt[2]) );


                                  }
                                });
                        }

                $('#ebene_wettkampf_loeschen').dialog('close');

                calculate();

        });

        function del_doku_ausdauer(nummer)
                {
                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_del_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
                                show_doku_ausdauer(inhalt)
                          }
                        });
                }
       // $('.del_doku_einheit').livequery(function() {
         //       $(this).click(function(){
			//		var nummer=$(this).attr('dat');
              //      del_doku_ausdauer(nummer);
				
                       // if (confirm('Wirklich löschen?'))
                         //       {
                                        
                           //     }

                //});
        //});

        $('.edit_doku_einheit').livequery(function() {
                $(this).click(function(){
                        $('#hinweis_save_ausdauer').hide();
                        $('#hinweis_save_ausdauer_warten').hide();
                        $('#hinweis_save_hf_datei').hide();
						$('#hinweis_polar_fehler').hide();
						


                        var nummer=$(this).attr('dat');

                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_hole_doku_ausdauer.php?nummer='+nummer,
                          success: function(data){
                                var inhalt = data;
                                var cp=inhalt.split('|~');

                                document.form_save_ausdauer.ausdauernummer.value                        = nummer;
                                document.form_save_ausdauer.datum.value                                                = cp[0];
                                document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + cp[19] + '</strong>';
                                document.form_save_ausdauer.save_einheit_sportart.value          = cp[1];
                                document.form_save_ausdauer.save_einheit_intensitaet.value         = cp[2];
                                document.form_save_ausdauer.save_einheit_art.value                        = cp[3];
                                document.form_save_ausdauer.save_einheit_std.value                        = cp[4];
                                document.form_save_ausdauer.save_einheit_min.value                        = cp[5];
                                document.form_save_ausdauer.save_einheit_beginn_std.value        = cp[6];
                                document.form_save_ausdauer.save_einheit_beginn_min.value        = cp[7];
                                document.form_save_ausdauer.save_einheit_puls.value                        = cp[8];
                                document.form_save_ausdauer.save_einheit_hoehenmeter.value        = cp[9];
                                document.form_save_ausdauer.save_einheit_kcal.value                        = cp[10];
                                document.form_save_ausdauer.save_einheit_vgl.value                        = cp[11];
                                document.form_save_ausdauer.save_einheit_beurteilung.value        = cp[12];
                                document.form_save_ausdauer.save_einheit_bemerkung.value        = cp[13];
                                document.form_save_ausdauer.save_einheit_laenge.value                = cp[14];
                                document.form_save_ausdauer.save_einheit_material.value                = cp[15];

                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=        cp[16];
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=                        cp[17];
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=                                cp[18];

                                $('#ebene_save_ausdauer').dialog('open');

                          }
                        });
                });
        });



        $('#save_ausdauer').livequery(function() {
                $(this).click(function(){

                         $('#hinweis_save_ausdauer').hide();
                         $('#hinweis_save_hf_datei').hide();
						 $('#hinweis_polar_fehler').hide(); 

                        $('#hinweis_save_ausdauer_warten').show();


                        var ausdauernummer                =        document.form_save_ausdauer.ausdauernummer.value;
                        var datum                =        document.form_save_ausdauer.datum.value;
                        var sportart         =        document.form_save_ausdauer.save_einheit_sportart.value;
                        var intensitaet =         document.form_save_ausdauer.save_einheit_intensitaet.value;
                        var art                 =          document.form_save_ausdauer.save_einheit_art.value;
                        var stunden         =          document.form_save_ausdauer.save_einheit_std.value;
                        var minuten         =          document.form_save_ausdauer.save_einheit_min.value;
                        var start_std         =          document.form_save_ausdauer.save_einheit_beginn_std.value;
                        var start_min         =          document.form_save_ausdauer.save_einheit_beginn_min.value;

                        var puls                 =          document.form_save_ausdauer.save_einheit_puls.value;
                        var hoehenmeter =         document.form_save_ausdauer.save_einheit_hoehenmeter.value;
                        var kcal                 =          document.form_save_ausdauer.save_einheit_kcal.value;
                        var vgl                 =          document.form_save_ausdauer.save_einheit_vgl.value;
                        var beurteilung =          document.form_save_ausdauer.save_einheit_beurteilung.value;
                        var bemerkung        =          document.form_save_ausdauer.save_einheit_bemerkung.value;
                        var laenge                =          document.form_save_ausdauer.save_einheit_laenge.value;
                        var material        =          document.form_save_ausdauer.save_einheit_material.value;



                        var inhalt = $.ajax({
                          url: 'module/controllcenter/ajax_save_ausdauer.php?datum='+datum+'&sportart='+sportart+'&intensitaet='+intensitaet+'&art='+art+'&stunden='+stunden+'&minuten='+minuten+'&start_std='+start_std+'&start_min='+start_min+'&puls='+puls+'&bemerkung='+bemerkung+'&kcal='+kcal+'&beurteilung='+beurteilung+'&hoehenmeter='+hoehenmeter+'&start_std='+start_std+'&start_min='+start_min+'&vgl='+vgl+'&laenge='+laenge+'&material='+material+'&ausdauernummer='+ausdauernummer,
                          success: function(data){
                                var inhalt = data;
                                var cp=inhalt.split("|~");
                                var nummer = cp[0];
                                var pace = cp[1];
                                var schnitt_hoehenmeter = cp[2];
                                var schnitt_energie = cp[3];

                                document.form_save_ausdauer.ausdauernummer.value = nummer;
                                document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML=pace;
                                document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML=schnitt_hoehenmeter;
                                document.getElementById('save_einheit_schnitt_energie').innerHTML=schnitt_energie;


                                $('#hinweis_save_ausdauer').show();
                                $('#hinweis_save_ausdauer_warten').hide();

                                show_doku_ausdauer(datum);
                          }
                        });





                });
        });


        $('#planeinstellungen_go').livequery(function() {
                $(this).click(function(){
                        var datum        =        document.form_planungseinstellungen.planung_datum.value;
                        var auswahl        = $("input[name=auswahl]:checked").val();
                        if (auswahl==1)
                                {
                                        var sportart=document.form_planungseinstellungen.planung_sportart_hoehepunkt.value;
                                        var stunden=document.form_planungseinstellungen.planung_hoehepunkt_std.value;
                                        var minuten=document.form_planungseinstellungen.planung_hoehepunkt_min.value;
                                        var bemerkung=document.form_planungseinstellungen.planung_sportart_hoehepunkt_bemerkung.value;
                                        var inhalt = $.ajax({
                                          url: 'module/controllcenter/ajax_save_hoehepunkt.php?datum='+datum+'&sportart='+sportart+'&stunden='+stunden+'&minuten='+minuten+'&bemerkung='+bemerkung,
                                          success: function(data){
                                                var inhalt = data;
                                                var cp=inhalt.split("||");
                                                var element=cp[0];
                                                var wochentag=cp[1];
                                                wochentagtext=cp[2];
                                                var headline=cp[3];
                                                //$('#zeitbalken').slider( 'option', 'min', parseInt(inhalt[2]) );
                                                document.getElementById(element).className='zeile_hoehepunkt';

                                                                      var cp=element.split('_');
                                                var cp_plan='plan_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_doku='doku_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_taganker='taganker_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_rand_links='rand_links_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_rand_rechts='rand_rechts_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var save_spalte='save_spalte_'+cp[1]+'_'+cp[2]+'_'+cp[3];


                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_plan).className='zeile_hoehepunkt';
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_doku).className='zeile_hoehepunkt';
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_taganker).className='zeile_hoehepunkt';
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_rand_links).className='zeile_hoehepunkt';
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_rand_rechts).className='zeile_hoehepunkt';
                                                if (document.getElementById(cp_taganker)) document.getElementById(save_spalte).className='zeile_hoehepunkt';




                                                $('#'+wochentagtext).attr('class','link_darkgreen tooltip_standard link_wettkampf_loeschen');
                                                //$('#'+wochentagtext).attr('title',headline);


                                          }
                                        });
                                        $('#ebene_planungseinstellungen').dialog('close');
                                        calculate();
                                }
                        if (auswahl==2)
                                {
                                        var sportart=document.form_planungseinstellungen.planung_sportart_wettkampf.value;
                                        var stunden=document.form_planungseinstellungen.planung_wk_std.value;
                                        var minuten=document.form_planungseinstellungen.planung_wk_min.value;
                                        var bemerkung=document.form_planungseinstellungen.planung_sportart_wettkampf_bemerkung.value;
                                        var wochentagtext="";
                                        var inhalt = $.ajax({
                                          url: 'module/controllcenter/ajax_save_wettkaempfe.php?datum='+datum+'&sportart='+sportart+'&stunden='+stunden+'&minuten='+minuten+'&bemerkung='+bemerkung,
                                          success: function(data){
                                                var inhalt = data;

                                                var cp=inhalt.split("||");
                                                var element=cp[0];
                                                var wochentag=cp[1];
                                                wochentagtext=cp[2];
                                                var headline=cp[3];


                                                document.getElementById(element).className='zeile_wettkampf';


                                                var cp=element.split('_');
                                                var cp_plan='plan_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_doku='doku_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_taganker='taganker_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_rand_links='rand_links_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var cp_rand_rechts='rand_rechts_'+cp[1]+'_'+cp[2]+'_'+cp[3];
                                                var save_spalte='save_spalte_'+cp[1]+'_'+cp[2]+'_'+cp[3];


                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_plan).className='zeile_wettkampf';
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_doku).className='zeile_wettkampf';
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_taganker).className='zeile_wettkampf';
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_rand_links).className='zeile_wettkampf';
                                                if (document.getElementById(cp_taganker)) document.getElementById(cp_rand_rechts).className='zeile_wettkampf';
                                                if (document.getElementById(cp_taganker)) document.getElementById(save_spalte).className='zeile_wettkampf';

                                                //document.getElementById(wochentagtext).title=headline;
                                                $('#'+wochentagtext).attr('class','link_darkgreen tooltip_standard link_wettkampf_loeschen');

                                                //$('#'+wochentagtext).attr('title',headline);
                                                //document.getElementById(wochentagtext).className='';


                                          }
                                        });
                                        $('#ebene_planungseinstellungen').dialog('close');

                                        calculate();

                                }
                        if (auswahl==3)
                                {
                                        var sportart=document.form_planungseinstellungen.planung_sportart_training.value;
                                        var stunden=document.form_planungseinstellungen.planung_std.value;
                                        var minuten=document.form_planungseinstellungen.planung_min.value;

                                        var option_woechentlich=document.form_planungseinstellungen.option_woechentlich.checked;
                                        var planung_tage_wiederholung=document.form_planungseinstellungen.planung_tage_wiederholung.value;
                                        var option_zusaetzlich=document.form_planungseinstellungen.option_zusaetzlich.checked;





                                        var inhalt = $.ajax({
                                          url: 'module/controllcenter/ajax_save_planeinheit.php?datum='+datum+'&sportart='+sportart+'&stunden='+stunden+'&minuten='+minuten+'&option_woechentlich='+option_woechentlich+'&planung_tage_wiederholung='+planung_tage_wiederholung+'&option_zusaetzlich='+option_zusaetzlich,
                                          success: function(data){
                                                var inhalt = data;

                                                //$('#zeitbalken').slider( 'option', 'min', parseInt(inhalt[2]) );

                                          }
                                        });
                                        $('#ebene_planungseinstellungen').dialog('close');
                                        calculate();
                                }
                        if (auswahl==4)
                                {
                                        var inhalt = $.ajax({
                                          url: 'module/controllcenter/ajax_delete_trainingstag.php?datum='+datum,
                                          success: function(data){
                                                var inhalt = data;
                                                document.getElementById(inhalt).innerHTML='';
                                                $('#ebene_planungseinstellungen').dialog('close');
                                          }
                                        });


                                        calculate();
                                }
                        if (auswahl==5)
                                {
                                        $('#ebene_planungseinstellungen').dialog('close');
                                        $('#ebene_bitte_warten_aktualisierung').dialog('open');
                                        var inhalt = $.ajax({
                                          url: 'module/controllcenter/ajax_delete_training_gesamt.php?datum='+datum,
                                          success: function(data){
                                                var inhalt = data;
                                                var cp=inhalt.split('-');
                                                var jahr=cp[0];
                                                var monat=cp[1];
                                                var tag=cp[2];

                                                //document.location.href='index.php?modul=controllcenter&op=ausdauer&kalenderart=2&jahr='+jahr+'&monat='+monat+'&tag='+tag;
                                                document.form_datum.submit();
                                                //$('#zeitbalken').slider( 'option', 'min', parseInt(inhalt[2]) );

                                          }
                                        });
                                }
                        if (auswahl==6)
                                {
                                        $('#ebene_planungseinstellungen').dialog('close');

										var beschreibung=document.form_planungseinstellungen.tl_beschreibung.value;
                                        var tl_dauer=document.form_planungseinstellungen.tl_dauer.value;
                                        var inhalt = $.ajax({
                                          url: 'module/controllcenter/ajax_save_trainingslager.php?datum='+datum+'&beschreibung='+beschreibung+'&tl_dauer='+tl_dauer,
                                          success: function(data){
                                                var inhalt = data;

                                                if (inhalt=='')
                                                        {
                                                                $('#ebene_planungseinstellungen').dialog('close');
                                                                calculate();
                                                                $('#ebene_bitte_warten_aktualisierung').dialog('open');
                                                                //document.location.href='index.php?modul=controllcenter&op=ausdauer&kalenderart=2';
                                                                document.form_datum.submit();

                                                        }
                                                        else
															{
																
																alert(inhalt);
																
															}




                                  }

                                });





                                }


                        if (auswahl==7)
                                 {
                                         var krankheit        = $("input[name=option_krankheit]:checked").val();

                                        $('#ebene_planungseinstellungen').dialog('close');

                                        var inhalt = $.ajax({
                                          url: 'module/controllcenter/ajax_save_krankheit.php?datum='+datum+'&krankheit='+krankheit,
                                          success: function(data){
                                                var inhalt = data;

                                                alert(inhalt);
                                                document.form_datum.submit();
                                          //        document.location.href='index.php?modul=controllcenter&op=ausdauer&kalenderart=2';


                                          },
                                          error: function(data){
                                                  alert(data);
                                                  }
                                        });



                                 }


                });



        });

        $('.link_planungseinstellungen').livequery(function(){
                $(this).click(function(){
                        document.form_planungseinstellungen.planung_datum.value=$(this).attr('dat');
                        document.getElementById('planungseinstellungen_datum').innerHTML='<strong>' + $(this).attr('datformat') + '</strong>';

                        var heute = new Date();
                        var jahr = heute.getFullYear();
                        var monat = heute.getMonth()+1;
                        var tag = heute.getDate();

                        if(tag<10) tag = "0" + tag;
                        if(monat<10) monat= "0" + monat;

                        var dat= tag+'.'+monat+'.'+jahr;

                        if (dat == $(this).attr('datformat'))
                                {
                                        $('#zeile_krank_1').show();
                                        $('#zeile_krank_2').show();
                                }
                        else
                                {
                                        $('#zeile_krank_1').hide();
                                        $('#zeile_krank_2').hide();
                                }

                        $('#ebene_planungseinstellungen').dialog('open');
                        $('#ebene_wettkampf_loeschen').dialog('close');
                });
        });


        $('.link_save_ausdauer').livequery(function(){
                $(this).click(function(){
                        $('#hinweis_save_ausdauer').hide();
                        $('#hinweis_save_ausdauer_warten').hide();
                        $('#hinweis_save_hf_datei').hide();
						$('#hinweis_polar_fehler').hide();

                        document.form_save_ausdauer.datum.value=$(this).attr('dat');
                        document.form_save_ausdauer.ausdauernummer.value='';
                        document.getElementById('dokueinstellungen_datum').innerHTML='<strong>' + $(this).attr('datformat') + '</strong>';

						//Zurücksetzen
						document.form_save_ausdauer.save_einheit_puls.value='130';
						document.form_save_ausdauer.save_einheit_hoehenmeter.value='0';
						document.getElementById('save_einheit_schnitt_hoehenmeter').innerHTML='';
						
						document.form_save_ausdauer.save_einheit_kcal.value='0';
						document.getElementById('save_einheit_schnitt_energie').innerHTML='';
						
						document.form_save_ausdauer.save_einheit_laenge.value='0';
						document.getElementById('save_einheit_durchschnittsgeschwindigkeit').innerHTML='';
						
						
						document.form_save_ausdauer.save_einheit_vgl.value='1';
						document.form_save_ausdauer.save_einheit_bemerkung.value='';
						document.form_save_ausdauer.save_einheit_beginn_std.value='17';
						document.form_save_ausdauer.save_einheit_beginn_min.value='30';
						
						document.form_save_ausdauer.save_einheit_std.value='0';
						document.form_save_ausdauer.save_einheit_min.value='0';
						


                        $('#ebene_save_ausdauer').dialog('open');
                });
        });
		
		
		


        /*
        $('.link_planungseinstellungen').click(function() {
                document.form_planungseinstellungen.planung_datum.value=$(this).attr('dat');
                document.getElementById('planungseinstellungen_datum').innerHTML='<strong>' + $(this).attr('datformat') + '</strong>';

                $('#ebene_planungseinstellungen').dialog('open');
        });
        */


        $("#ebene_bitte_warten_aktualisierung").dialog({
                autoOpen: false,
                show: 'blind',
                position: 'center',
                closeText: 'zumache',
                height: 220,
                width: 400
        });


        $("#ebene_planungseinstellungen").dialog({
                autoOpen: false,
                show: 'blind',
                position: 'center',
                closeText: 'zumache',
                height: 480,
                width: 940,
                resizable: false
        });

        $("#ebene_save_ausdauer").dialog({
                autoOpen: false,
                show: 'blind',
                position: 'center',
                closeText: 'zumache',
                height: 500,
                width: 940,
                resizable: false,
				close: function(event, ui) {
					if(checkBrowserName('MSIE')){  
					  form_datum.submit();  
					}
					
				}
        });
		
		$("#ebene_save_athletik").dialog({
                autoOpen: false,
                show: 'blind',
                position: 'center',
                closeText: 'zumache',
                height: 110,
                width: 640, 
                resizable: false
        });
		
		$('.link_save_kraft').livequery(function(){
                $(this).click(function(){
					var dat=$(this).attr('dat');
					
					var ok1=$('#link_athletik_zusaetzlich_ok_1').attr('href') + dat + '#taganker_'+dat;
					var ok2=$('#link_athletik_zusaetzlich_ok_2').attr('href') + dat + '#taganker_'+dat;
					var ok3=$('#link_athletik_zusaetzlich_ok_3').attr('href') + dat + '#taganker_'+dat;
					var ok4=$('#link_athletik_zusaetzlich_ok_4').attr('href') + dat + '#taganker_'+dat;
					var ok5=$('#link_athletik_zusaetzlich_ok_5').attr('href') + dat + '#taganker_'+dat;
					
					var nok1=$('#link_athletik_zusaetzlich_nok_1').attr('href') + dat + '#taganker_'+dat;
					var nok2=$('#link_athletik_zusaetzlich_nok_2').attr('href') + dat + '#taganker_'+dat;
					var nok3=$('#link_athletik_zusaetzlich_nok_3').attr('href') + dat + '#taganker_'+dat;
					var nok4=$('#link_athletik_zusaetzlich_nok_4').attr('href') + dat + '#taganker_'+dat;
					var nok5=$('#link_athletik_zusaetzlich_nok_5').attr('href') + dat + '#taganker_'+dat;
             
					$('#link_athletik_zusaetzlich_ok_1').attr('href',ok1);
					$('#link_athletik_zusaetzlich_ok_2').attr('href',ok2);
					$('#link_athletik_zusaetzlich_ok_3').attr('href',ok3);
					$('#link_athletik_zusaetzlich_ok_4').attr('href',ok4);
					$('#link_athletik_zusaetzlich_ok_5').attr('href',ok5);
				
					$('#link_athletik_zusaetzlich_nok_1').attr('href',nok1);
					$('#link_athletik_zusaetzlich_nok_2').attr('href',nok2);
					$('#link_athletik_zusaetzlich_nok_3').attr('href',nok3);
					$('#link_athletik_zusaetzlich_nok_4').attr('href',nok4);
					$('#link_athletik_zusaetzlich_nok_5').attr('href',nok5);
					

                        $('#ebene_save_athletik').dialog('open');
                });
        });



        $('.link_tl_loeschen').click(function() {
                document.form_tl_loeschen.loeschen_tl_nummer.value=$(this).attr('tl_loesch');

                $('#ebene_tl_loeschen').dialog('open');
        });



        $('.link_wettkampf_loeschen').livequery(function(){
                $(this).click(function(){

                        document.form_wettkampf_loeschen.loeschen_datum.value=$(this).attr('dat');
                        document.getElementById('div_loeschen_datum').innerHTML='<strong>' + $(this).attr('datformat') + '</strong>';

                        $('#ebene_wettkampf_loeschen').dialog('open');
                        $('#ebene_planungseinstellungen').dialog('close');
                });
        });


        /*
        $('.link_wettkampf_loeschen').click(function() {
                document.form_wettkampf_loeschen.loeschen_datum.value=$(this).attr('dat');
                document.getElementById('div_loeschen_datum').innerHTML='<strong>' + $(this).attr('datformat') + '</strong>';

                $('#ebene_wettkampf_loeschen').dialog('open');
        });
        */

	$("#menue_mapping").dialog({
                autoOpen: false,
                show: 'blind',
                position: 'center',
                closeText: 'zumache',
                height: 400,
                width: 500
        });
		
	$("#mapping_liste").dialog({
                autoOpen: true,
                show: 'blind',
                position: 'left',
                closeText: 'zumache',
                height: 300,
                width: 240,
				close: function(event, ui) { $('#mapping_liste').dialog('open');  }
        });


        $("#ebene_wettkampf_loeschen").dialog({
                autoOpen: false,
                show: 'blind',
                position: 'center',
                closeText: 'zumache',
                height: 380,
                width: 800
        });

        $("#ebene_tl_loeschen").dialog({
                autoOpen: false,
                show: 'blind',
                position: 'center',
                closeText: 'zumache',
                height: 140,
                width: 260
        });





        $('#kopfmenue').click(function() {
                                        $('#ebene_kopfmenue').dialog('open');
                                });
$('#menue_mapping_button').click(function() {
                                        $('#menue_mapping').dialog('open');
                                });






        $("#ebene_kopfmenue").dialog({
                                        autoOpen: false,
                                       
                                        position: 'center',
                                        closeText: 'zumache',
                                        height: 300,
                                        width: 500,
										zIndex:90000
                                });

		$("#anleitungen_ausdauer").dialog({
				autoOpen: false,
				show: 'blind',
				hide: 'explode',
				position: 'center',
				closeText: 'zumache',
				height: 200,
				width: 350
		});



        $("#form_neuer_benutzer").validate();




        $('#slider').nivoSlider({
                effect:'random', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:1000, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
        });

        $('.trainingtime').timepicker({
                timeSeparator: ':',
                showLeadingZero: true,
                showMinutesLeadingZero: true,
                showPeriod: false,
                defaultTime: '17:30',
                showOn: 'focus',
                hours: {
                        starts: 0,
                        ends: 23
                },
                minutes: {
                        starts: 0,
                        ends: 55,
                        interval: 5
                },
                rows: 4
        });


         $(".draggable").draggable();

        if ($("#zeitfenster").length > 0)
                {
                        $("#zeitfenster").dialog({
                                        autoOpen: false,
                                        show: 'blind',
                                        hide: 'explode',
                                        position: 'center',
                                        closeText: 'zumache',
                                        height: 480
                                });
                        $('.show_neue_einheit').click(function() {
                                        $('#zeitfenster').dialog('open');

                                        var dat=$(this).attr('id');
                                        var cp=dat.split('_');
                                        var cp2=cp[1].split('-');

                                        document.form_neue_einheit.jahr.value=cp2[0];
                                        document.form_neue_einheit.monat.value=cp2[1];
                                        document.form_neue_einheit.tag.value=cp2[2];

                                        document.getElementById('zeitfenster_datum').innerHTML=cp2[2]+'.'+cp2[1]+'.'+cp2[0];

                                        var inhalt = $.ajax({
                                          url: 'module/controllcenter/ajax_vorschlag_einheit.php?start=1&dauer=60&tag='+cp2[2]+'&monat='+cp2[1]+'&jahr='+cp2[0],
                                          success: function(data){
                                                  var inhalt = data.split('[SCHNIEDELWUTZ]');
                                                $('#vorgeschlagene_einheiten').html(inhalt[0]);
                                                if ( parseInt($('#amount' ).val()) > parseInt(inhalt[1])) $('#amount' ).val( inhalt[1] );

                                                $('#zeitbalken').slider( 'option', 'min', parseInt(inhalt[2]) );
                                                $('#zeitbalken').slider( 'option', 'max', parseInt(inhalt[3]) );
                                                $('#zeitbalken').slider( 'option', 'value', parseInt(inhalt[4]) );

                                                $('#slidermin').html(inhalt[2]);
                                                $('#slidermax').html(inhalt[3]);
                                                $('#amount').val(inhalt[4]);
                                          }
                                        });

                                        return false;
                                });


                        $( "#zeitbalken" ).slider({
                                'value': 60,
                                'min': 20,
                                'max': 240,
                                'step':5,
                                'slide': function(event, ui)
                                        {
                                                $('#amount' ).val( ui.value );
                                        },
                                'change': function(event, ui)
                                        {
                                                var tag=document.form_neue_einheit.tag.value;
                                                var monat=document.form_neue_einheit.monat.value;
                                                var jahr=document.form_neue_einheit.jahr.value;

                                                var inhalt = $.ajax({
                                                  url: 'module/controllcenter/ajax_vorschlag_einheit.php?dauer='+ui.value+'&tag='+tag+'&monat='+monat+'&jahr='+jahr,
                                                  success: function(data){
                                                        $('#vorgeschlagene_einheiten').html(data);
                                                        var inhalt = data.split('[SCHNIEDELWUTZ]');
                                                        $('#vorgeschlagene_einheiten').html(inhalt[0]);
                                                        if ( parseInt($('#amount' ).val()) > parseInt(inhalt[1]))
                                                                {
                                                                        $('#amount' ).val( inhalt[1] );
                                                                        $('#zeitbalken').slider( 'option', 'value', parseInt(inhalt[1]) );
                                                                }
                                                  }
                                                });
                                        }
                        });

                        $( "#amount" ).val(  $( "#zeitbalken" ).slider( "value" ) );
                }



        $("#dialog_gewicht").dialog({
                        autoOpen: false,
                        show: 'blind',
                        hide: 'explode',
                        position: 'center',
                        closeText: 'zumache',
                        height: 80
                });
        $("#menue_controllcenter").dialog({
                        autoOpen: false,
                        show: 'blind',
                        hide: 'explode',
                        position: 'center',
                        closeText: 'zumache',
                        height: 300,
                        width:370
                });
        $('#dialog_menue_controllcenter_opener').click(function() {
                        $('#menue_controllcenter').dialog('open');
                        return false;
                });



        $('.gewicht_opener').click(function() {
                        $('#dialog_gewicht').dialog('open');
                        return false;
                });


        $("#trackliste").dialog({
                        autoOpen: false,
                        show: 'blind',
                        hide: 'explode',
                        position: [10,200]
                });
        $('#trackopener').click(function() {
                        $('#trackliste').dialog('open');
                        return false;
                });



        $("#acco").livequery(function(){
				$(this).accordion({
						fillSpace: true,
						collapsible: true,
						autoHeight: false,
						clearStyle: true,
						active: parseInt($('#form_datum_aktive').val()),
						change: function(event, ui)
							{
								var active = $( this ).accordion( "option", "active" );
								$('#form_vgl_aktive').val(active);
								$('#form_datum_aktive').val(active);
							}
				});
			});

	
	
	
	$('#accordion_moeglichkeiten').accordion({
		fillSpace: false,
		collapsible: true,
		autoHeight: true,
		clearStyle: true,
		active:false
	});


        $("#dialog").dialog({
                width:500
        });




        $.datepicker.regional['de'] = {clearText: 'löschen', clearStatus: 'aktuelles Datum löschen',
                closeText: 'schließen', closeStatus: 'ohne Änderungen schließen',
                prevText: '&#x3c;zurück', prevStatus: 'letzten Monat zeigen',
                nextText: 'Vor&#x3e;', nextStatus: 'nächsten Monat zeigen',
                currentText: 'heute', currentStatus: '',
                monthNames: ['Januar','Februar','März','April','Mai','Juni',
                'Juli','August','September','Oktober','November','Dezember'],
                monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
                'Jul','Aug','Sep','Okt','Nov','Dez'],
                monthStatus: 'anderen Monat anzeigen', yearStatus: 'anderes Jahr anzeigen',
                weekHeader: 'Wo', weekStatus: 'Woche des Monats',
                dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
                dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
                dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
                dayStatus: 'Setze DD als ersten Wochentag', dateStatus: 'Wähle D, M d',
                dateFormat: 'dd.mm.yy', firstDay: 1,
                initStatus: 'Wähle ein Datum', isRTL: false};
      $.datepicker.setDefaults($.datepicker.regional['de']);

        $('.datepicker').datepicker();
        $('#menue_controllcenter').css('z-index', 880);



        $("#hinweisfenster").dialog({
			autoOpen:false,
			width:300,
			position: 'right',
			height:$(window).height()-20		
				
		});




        $('.tooltip_standard').livequery(function(){
                $(this).tooltip({
                        track: true,
                        delay: 0,
                        showURL: false,
                        opacity: 1,
                        showBody: ";"
                });
        });



        $("a[rel^='prettyPhoto']").livequery(function(){
                $(this).prettyPhoto({
                        animationSpeed: 'fast'
                });
        });


        $("a[rel^='li_grunddaten']").prettyPhoto();



        $("a[rel^='li_tagebuch']").prettyPhoto({
                callback: function()
                        {
                                document.location.href='index.php?modul=meineteamseite&audauid='+(Math.random())+'#tagebuch';
                        }
                });
				
		 $("a[rel^='trainingsanpassungen']").livequery(function(){
                $(this).prettyPhoto({
                        animationSpeed: 'fast',
						opacity: 0.50,
						callback: function()
                        {
                             //alert('fertig');
							  
							 $('#link_training_sollte_angepasst_werden').hide();
							 $('#link_training_sollte_angepasst_werden_info').hide();
							 
							 calculate();
                        }
                });
       });

        $("a[rel^='li_sponsoren']").prettyPhoto({
                callback: function()
                        {
                                document.location.href='index.php?modul=meineteamseite&audauid='+(Math.random())+'#sponsoren';
                        }
                });

        $("a.ausdauerdoku").prettyPhoto({
                animationSpeed: 'normal', /* fast/slow/normal */
                padding: 40, /* padding for each side of the picture */
                opacity: 0.9, /* Value betwee 0 and 1 */
                showTitle: false, /* true/false */
                allowresize: false, /* true/false */
                counter_separator_label: '/', /* The separator for the gallery counter 1 of 2 */
                theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
                prev_next_on: '', /* '' ODER '1'*/
                callback: function(opener)
                        {
                                $("#hinweisfenster").html('Bitte warten! Die Daten werden neu geladen.');
                                $("#hinweisfenster").dialog('open');

                                var monat=document.form_datum.monat.value;
                                var jahr=document.form_datum.jahr.value;
                                var modul=document.form_datum.modul.value;
                                var op=document.form_datum.op.value;
                                var ansicht=document.form_datum.ansicht.value;

                                document.location.href='index.php?modul='+modul+'&op='+op+'&monat='+monat+'&jahr='+jahr+'&ansicht='+ansicht+'&clean=1&audauid='+(Math.random())+'#'+opener;
                        }
                });
				
				
		$("a.ernaehrungdoku").prettyPhoto({
                animationSpeed: 'normal', /* fast/slow/normal */
                padding: 40, /* padding for each side of the picture */
                opacity: 0.9, /* Value betwee 0 and 1 */
                showTitle: false, /* true/false */
                allowresize: false, /* true/false */
                counter_separator_label: '/', /* The separator for the gallery counter 1 of 2 */
                theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
                prev_next_on: '', /* '' ODER '1'*/
                callback: function(opener)
                        {
                                document.form_datum.submit();
                        }
                });
			
		$("a.nachrichtsenden").prettyPhoto({
                animationSpeed: 'normal', /* fast/slow/normal */
                padding: 40, /* padding for each side of the picture */
                opacity: 0.9, /* Value betwee 0 and 1 */
                showTitle: false, /* true/false */
                allowresize: false, /* true/false */
                counter_separator_label: '/', /* The separator for the gallery counter 1 of 2 */
                theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
                prev_next_on: '', /* '' ODER '1'*/
                callback: function(opener)
                        {
                                document.form_messages.submit();
                        }
                });
		
				
		 


function show_info_window(i)
		{
			alert(i);
			infowindow.setContent("<span style='color:#000000'>"+marker_lat[i]+"</span>" );
			infowindow.setPosition(marker_po[i]);
			infowindow.open(map);
		}


if ( $('#mapping_karte').length > 0 )
	{
		var map = new google.maps.Map(document.getElementById('mapping_karte'), {
		  zoom: 12,
		  center: new google.maps.LatLng(    $('#mapping_karte_home_lat').html(), $('#mapping_karte_home_long').html()   ),
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		});
		
		var infowindow = new google.maps.InfoWindow();
		
		//Die Umkreisadresse hinzufügen
		var homepos = new google.maps.LatLng($('#mapping_karte_home_lat').html(),$('#mapping_karte_home_long').html() );
		var homeimage = 'http://maps.google.com/mapfiles/arrow.png';

		var home_marker = new google.maps.Marker({
			  position: homepos,
			  title: $('#mapping_karte_startadresse').html(),
			  icon: homeimage,
			 
		  });
  		home_marker.setMap(map);  

		//Event-Listerner einfügen
		google.maps.event.addListener(home_marker, 'click', function(event) {
		
			infowindow.setContent("<span style='color:#000000'>"+$('#mapping_karte_startadresse').html()+"</span>" );
					infowindow.setPosition(event.latLng);
					infowindow.open(map);
		});
			
		   
  
		
		
		
		//Jetzt alle Punkte raussuchen

		var track_lat=new Array();
		var track_long=new Array();
		var mapping_track;

		var markerimage = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
		var gorte=$('#mappingdaten').html();
		var orte=gorte.split("|");
		
		var anz=orte.length;
		
		var marker_nummer= new Array();
		var marker_lat= new Array();
		var marker_long= new Array();
		var marker_laenge= new Array();
		var marker_hoehe= new Array();
		var marker_beschreibung= new Array();
		var marker_anspruch_ausdauer= new Array();
		var marker_anspruch_kraft= new Array();
		var marker_anspruch_koordination= new Array();
		var marker_po = new Array();
		
		for (var i=0; i < anz; i++)
			{
				details=orte[i].split('~');
				marker_nummer[i]=details[0];
				marker_lat[i]=details[1];
				marker_long[i]=details[2];
				marker_laenge[i]=details[3];
				marker_hoehe[i]=details[4];
				marker_beschreibung[i]=details[5];
				marker_anspruch_ausdauer[i]=details[6];
				marker_anspruch_kraft[i]=details[7];
				marker_anspruch_koordination[i]=details[8];
				marker_po[i] = new google.maps.LatLng(details[1],details[2]);
			}
			
			
		function createMarker(pos, t, nummer,id) {
			var marker = new google.maps.Marker({       
				position: pos, 
				map: map,  // google.maps.Map 
				icon: markerimage     
			}); 
			
			google.maps.event.addListener(marker, 'click', function() { 
			    
				//Infos per Ajax holen
				var inhalt = $.ajax({
				  url: 'module/controllcenter/ajax_hole_strecke.php?id='+id,
				  success: function(data){
						var cp = data;
						var cp1=cp.split('|~|~');
						var inhalt=cp1[0];
						infowindow.setContent("<span style='color:#000000'>"+inhalt+"</span>" );
						infowindow.setPosition(pos);
						infowindow.open(map);
						
						//Strecke einblenden
						var st = cp1[1].split('|');
						var laenge=st.length;
						
						//Erst mal die Felder löschen
						track_lat=[];
						track_long=[];
						
						if (mapping_track) mapping_track.setMap(null);
						
						for (var i=0; i < laenge; i++)
							{
								var ko=st[i].split('~');
								track_lat.push(ko[0]);
								track_long.push(ko[1]);
							}
						if (track_lat.length > 5)
							{
								var coord = new Array();
								for (var i =0; i < laenge; i++)
									{
										coord.push(new google.maps.LatLng(track_lat[i], track_long[i]));
									}
								
								  mapping_track = new google.maps.Polyline({
									path: coord,
									strokeColor: "#0000ff",
									strokeOpacity: 1.0,
									strokeWeight: 2
								  });
								
								  mapping_track.setMap(map);
							}
						
				  }
				 			  
				});

				
				
				
				
				
				
			}); 
			
						
			return marker;  
		}	
			
		for (var i=0; i < anz; i++)
			{
				marker[i] = createMarker(new google.maps.LatLng(marker_lat[i],marker_long[i]), "marker_"+i,i,marker_nummer[i]);
				
				// {
					
				//});
			
			}
					
	
			
			

	}

	

	$('.markerclick').click(function(){
	  var wo=$(this).attr('val');
	  google.maps.event.trigger(marker[wo], 'click');
	 // map.setCenter(new google.maps.LatLng(marker_lat[wo],marker_long[wo]));
	});
		
		
		
		
		
		
		
		
		
	

$('.piediagramm').livequery(function() 
	{
		var data = new Array();
		var farben = new Array();
		var cp=$(this).attr('dat');
				
		var sportarten=cp.split('|');
		for (var i=0; i< sportarten.length; i++)
			{
				var cp1=sportarten[i].split('~');
				var anzahl=cp1[0]*10;
				var spo=cp1[1];
				var farbe=cp1[2];
				
				data.push({ label: spo, data:anzahl});
				farben.push(farbe);
			}

		
		 $.plot($(this), data, 
			{
				series: {
					pie: { 
						show: true
					}
				},
				colors: farben,
				 legend: {
					show: false
				}
			});		
	});	
		

$('.diagramm_timeline').livequery(function() 
{	
	var data = new Array();
	var cp=$(this).attr('dat');
	
	var dat=cp.split("++");
	var mindat=dat[0];
	var maxdat=dat[1];
	var labelname=dat[2];	
			
	var zeitpunkte=dat[3].split('|');
	for (var i=0; i< zeitpunkte.length; i++)
		{
			var cp1=zeitpunkte[i].split('~');
			var time=cp1[0];
			var wert=cp1[1];
			data.push([time,wert]);
		}

	var dataset={ data: data, label: labelname };
	
	var plot=$.plot($(this), [dataset], {
			xaxis: {mode: "time", min: mindat, max:maxdat, color: '#ffffff'},
			yaxis: {color: '#ffffff'},
			legend:{backgroundColor: '#cccccc', position: 'nw'}
		});
});









		
		
		
});




