kstat=0;
var archive_open = 0;
var textlen = 0;
var isvalid = 0;

$(document).ready(function($){
	if($('#socialshareprivacy').length > 0){
		$('#socialshareprivacy').socialSharePrivacy({
			services : {
				facebook : { 'app_id' : '122903267761814', 'action' : 'like' }, 
				twitter : { 'status' : 'off' },
				gplus : { 'status' : 'off' }
			}
		}); 
	}
}); 

$(document).ready(function(){ 
    
	initialize();
     
	$(".nachricht").keyup(function(){ if(isvalid==0){ textlen++; if(textlen > 5){ make_valid(); } } });     
     
    $("#slider").easySlider({
       speed: 600,
       pause: 10000,
       auto: true,
       continuous: true, 
       esCallback: function (n, nmax)
       {
           fullbellytext = $('#btf').html();
           var bellyparts = fullbellytext.split("|");
                      
           if(bellyparts.length > n){
	           if(bellyparts[n].substring(0,5)=='</p>'){ bellyparts[n] = bellyparts[n].substring(6); }
	           if(bellyparts[n].substr((bellyparts[n].length)-3,4)=='<p>'){ bellyparts[n] = bellyparts[n].substr(0,(bellyparts[n].length)-3); }
           	
		       $('.bauchbinde').fadeOut("slow",function(){ $(".bauchbinde").empty();$('.bauchbinde').html(bellyparts[n]); });
		       $('.bauchbinde').fadeIn("slow");
           }
       }
     });
            
     e_list = $("li.error_text").size();
     m_list = $("p.message").size();
     if((e_list<1)&&(m_list<1)){
     }else{
       $("#hcform").slideToggle("slow");
       $("#kntkttoggle").html("Kontaktformular schließen");         
       kstat=1;
     }   
     
	 $(".liste_blog_boxes").hide();
     $(".liste_blog_boxes:eq(0)").show();
          
  });  
	 
  function make_valid(){ if(isvalid==0){ isvalid=1; $("#hcform").prepend('<input type="hidden" value="1" name="secid">'); } }	 
	 
  function switch_archive(index){ if(index != archive_open){ $(".liste_blog_boxes:eq("+archive_open+")").slideUp(100, function(){ $(".liste_blog_boxes:eq("+index+")").slideDown('slow',function(){ archive_open = index;	}); }); } }	
  function toggleKontakt(){ if(kstat){ $("#kntkttoggle").html("Kontaktformular öffnen"); kstat=0; }else{ $("#kntkttoggle").html("Kontaktformular schließen"); kstat=1; } $("#hcform").slideToggle("slow"); }  
  mstat = 0;
  function toggleKarte(){ if(mstat){ $("#maptoggle").html("Karte zeigen"); mstat=0; }else{ $("#maptoggle").html("Karte verbergen"); mstat=1; } $("#maphide").slideToggle("slow"); }  

  function initialize() {
     if (GBrowserIsCompatible()) {
       var map = new GMap2(document.getElementById("map_canvas"),{ size:new GSize(225,225)});
       var center = new GLatLng(50.798259,6.504207);     
      
// 50.799205,6.502715   
       
       map.setMapType(G_NORMAL_MAP);
       map.setCenter(center, 15);
       map.addControl(new GSmallMapControl());          
       map.addOverlay(new GMarker(center));          
     }
  }

