// JavaScript Document


$(document).ready(function(){

  var ajaxloader = "./pics/icons/ajax-loader.gif";
  var strTMP = "";
 
 
 ShowGemerkteAnzeigen();
 
 
 $(".CheckboxKlickText").click(function() {
        var $checkbox = $(this).parent();

        if ($checkbox.find("input").attr("checked")) {
            $checkbox.find("input").attr("checked", "")
        }
        else {
            $checkbox.find("input").attr("checked", "checked")
        }
        
      
  });
 
 //Anzeigen (view.anzeigen.php)
 if ($('.anzeige_small_image').length > 0) {
    $('.anzeige_small_image').slideshow({
                  width:100,      // width in px
                  height:100,
                  index:0,
                  time:800,      // time out beetwen slides
                  title:false,     // show title
                  panel:false,
                  effecttime:0,
                  playhover:true,
                  playframe:false,
                  controls :{'hide':true,
                  'prev':true,
                  'next':true} 
    });
    $('.anzeige_small_image_no_evect').slideshow({
                  width:100,      // width in px
                  height:100,
                  index:0,
                  time:1000,      // time out beetwen slides
                  title:false,     // show title
                  panel:false,
                  effecttime:500,
                  playhover:false,
                  playframe:false,
                  controls :{'hide':true} 
    });
 }
  

/*  $('.anzeige_small_image').hover(function() {
                                    $(this).animate({
                                              "opacity": "0.6"
                                            }, { "duration": "slow" }
                                            );
                                  },
                                  function() {
                                    $(this).animate({
                                              "opacity": "1.0"
                                            }, { "duration": "slow" }
                                            );
                                  }
  );
*/  
 

    //Tooltip Box
      if ($('a.title').length > 0) $('a.title').cluetip({width: '200px', showTitle: false, arrows: true});
	    if ($('a#search').length > 0) $('a#search').cluetip({width: '200px', showTitle: false, positionBy: 'bottomTop'});
      if ($('a.jt').length > 0) {
        $('a.jt').cluetip({
            cluetipClass: 'jtip', 
            arrows: true, 
            dropShadow: false,
            hoverIntent: false,
            sticky: true,
            activation: 'click',
            closePosition: 'title',
            closeText: '<img src="http://'+document.domain+'/kbl/pics/icons/cross.png" alt="close" />'
        });
      }
      if ($('a.contact').length > 0) {
        $('a.contact').cluetip({
            cluetipClass: 'jtip', 
            width:"600px",
            arrows: true, 
            dropShadow: false,
            hoverIntent: false,
            sticky: true,
            activation: 'click',
            closePosition: 'title',
            closeText: '<img src="http://'+document.domain+'/kbl/pics/icons/cross.png" alt="close" />'      
        });
      }
      if ($('a.kontodaten').length > 0) {
        $('a.kontodaten').cluetip({
            cluetipClass: 'jtip', 
            arrows: true, 
            dropShadow: false,
            hoverIntent: false,
            sticky: true,
            activation: 'click',
            closePosition: 'title',
            closeText: '<img src="http://'+document.domain+'/kbl/pics/icons/cross.png" alt="close" />'      
        });
      }
      if ($('a.helpbox').length > 0) {
        $('a.helpbox').cluetip({
            width: '300px', cluetipClass: 'rounded_c002', dropShadow: false, ajaxCache: false
        });
      }




    

    
  
    
    
    // Startseite
     

     
     // Neue Anzeigen
    //$("#NeueAnzeigenEntries").hide();
    
    
    $("#NeueAnzeigen").click(function () {
      if ($("#NeueAnzeigenEntries").is(":hidden")) {
      
          $("#NeueNews img").attr("src", "./pics/icons/right2.gif");
          $("#bestKlicks img").attr("src", "./pics/icons/right2.gif");
          $("#NeueBilder img").attr("src", "./pics/icons/right2.gif");
          $("#NeueAnzeigen img").attr("src", "./pics/icons/down.gif");
      
          $("#NeueAnzeigenEntries").animate({
                                              "height": "toggle", "opacity": "show"
                                            }, { "duration": "slow" }
                                            );
                                            
          $("#NeueBilderEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          $("#NeueNewsEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
                                            
          $("#bestKlicksEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
                                  
      }
      
      else {
          $("#NeueAnzeigen img").attr("src", "./pics/icons/right2.gif");
          $("#NeueAnzeigenEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" });
      }
      
    });


        


    // Neue Bilder
    //$("#NeueBilderEntries").hide();
    
    $("#NeueBilder").click(function () {
      if ($("#NeueBilderEntries").is(":hidden")) {

          $("#NeueNews img").attr("src", "./pics/icons/right2.gif");
          $("#bestKlicks img").attr("src", "./pics/icons/right2.gif");
          $("#NeueAnzeigen img").attr("src", "./pics/icons/right2.gif");
          $("#NeueBilder img").attr("src", "./pics/icons/down.gif");

          $("#NeueBilderEntries").animate({
                                              "height": "toggle", "opacity": "show"
                                            }, { "duration": "slow" }
                                            );
                                            
          $("#NeueNewsEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          $("#NeueAnzeigenEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          $("#bestKlicksEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
      } 
      
      else {
          $("#NeueBilder img").attr("src", "./pics/icons/right2.gif");
          $("#NeueBilderEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" });
      }
      
    });
    
    
    
        // Neue News
    //$("#NeueNewsEntries").hide();
    
    $("#NeueNews").click(function () {
      if ($("#NeueNewsEntries").is(":hidden")) {
          $("#NeueNews img").attr("src", "./pics/icons/down.gif");
          $("#bestKlicks img").attr("src", "./pics/icons/right2.gif");
          $("#NeueBilder img").attr("src", "./pics/icons/right2.gif");
          $("#NeueAnzeigen img").attr("src", "./pics/icons/right2.gif");
          
          $("#NeueNewsEntries").animate({
                                              "height": "toggle", "opacity": "show"
                                            }, { "duration": "slow" }
                                            );
                                            
          $("#NeueBilderEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          $("#NeueAnzeigenEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          $("#bestKlicksEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          
      } 
      
      else {
          $("#NeueNews img").attr("src", "./pics/icons/right2.gif");
          $("#NeueNewsEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" });
      }
      
    });


        // Best KLicks
    //$("#bestKlicksEntries").hide();
    
    $("#bestKlicks").click(function () {
      if ($("#bestKlicksEntries").is(":hidden")) {
      
          $("#NeueNews img").attr("src", "./pics/icons/right2.gif");
          $("#bestKlicks img").attr("src", "./pics/icons/down.gif");
          $("#NeueBilder img").attr("src", "./pics/icons/right2.gif");
          $("#NeueAnzeigen img").attr("src", "./pics/icons/right2.gif");
      
          $("#bestKlicksEntries").animate({
                                              "height": "toggle", "opacity": "show"
                                            }, { "duration": "slow" }
                                            );
                                            
          $("#NeueBilderEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          $("#NeueAnzeigenEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          $("#NeueNewsEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" }
                                            );
          
      } 
      
      else {
          $("#bestKlicks img").attr("src", "./pics/icons/right2.gif");
          $("#bestKlicksEntries").animate({
                                              "height": "toggle", "opacity": "hide"
                                            }, { "duration": "slow" });
      }
      
    });

  
    
    // SearchForm
 
  $('#SCategory').change(function () { ShowTreffer() });
  $('#SVorlieben').change(function () { ShowTreffer() });
  $('#SAgeVon').change(function () { ShowTreffer() });
  $('#SAgeBis').change(function () { ShowTreffer() });
  $('#SName').blur(function () { ShowTreffer() });
  $('#SHaarfarbe').change(function () { ShowTreffer() });
  $('#SGoodLuck').focus(function () { ShowTreffer() });
  $('#SGoodLuck').keyup(function () { ShowTreffer() });
  $('#SGoodLuck').blur(function () { ShowTreffer() });
  if ($('#SGoodLuck').length > 0) {
  $("#SGoodLuck").autocomplete('http://'+document.domain+'/kbl/php/public/ajax/search_autocomplete.php', {
     extraParams: {
         country: function() { return $("#country").val(); }
     }                  
  }); 
  }


  
  $('#btnGT').click(function() {
  	
    var R = $("#CapRegion").text();
		var G = $("#SGebiet").val();
		
		if (R == null) R = "";
		if (G == null) G = "";
  		Ziel = "http://"+document.domain+"/Anzeigen/"+R+"/";
  		if (G.length > 0) Ziel = Ziel +G+"/";
      /*alert(Ziel);*/
  		window.location.href = Ziel;
  });
  
  $(".DIVSearchListBoxEntry").click(function(){
  
  	var Box = $(this).parent().attr("id");
  	var SelectedIDs = [];
  	//var it = $("#S"+Box).val();
		//var id = $(this).attr("id");
		//id = id.substring(id.indexOf("_"), id.length);
		//strrep = id;

		//it = it.replace(strrep, "");
  	
  	if ($(this).css("marginLeft") == "10px") {
  	
			$(this).css({"marginLeft": "0px", "backgroundColor": "transparent"});
			$(this).find("img").remove(); 
			
		}
		else {
		
		  $("#Cap_"+Box+" img").attr("src", "http://"+document.domain+"/kbl/pics/icons/bottom_10x10.gif");
			$(this).css({"marginLeft": "10px", "backgroundColor": "#FBDF7B"});
			
			$(this).prepend("<img style='border: none; width: 10px; height: 10px;' src='http://"+document.domain+"/kbl/pics/icons/right_10x10.gif' alt='keinBild' />");
			
		}

  	$("#" + Box + " div").each(function (e) {
        if ($(this).css("marginLeft") == "10px") {
           var tmp_id = $(this).attr("id");
           SelectedIDs.push(tmp_id.substring(tmp_id.indexOf("_")+1, tmp_id.length)); 
        }
    });
  	$("#S"+Box).val(SelectedIDs.join(","));
		//alert($("#S"+Box).val());
		
		if ($("#"+Box+" img").length == 0) {
        $("#Cap_"+Box+" img").attr("src", "http://"+document.domain+"/kbl/pics/icons/right_10x10.gif");
    }
		
		ShowTreffer();

		
		
  });
  

  $('.DIVSearchListBoxEntry').hover(
    function() {
      $('.DIVSearchListBoxEntry').css({"borderBottom":"none", "paddingBottom":"1px"});
      $(this).css({"borderBottom":"1px solid black", "paddingBottom":"0px"});
    }, 
    function() {
      $(this).css({"borderBottom":"none", "paddingBottom":"1px"});
    }
  );

  
	
	/*
  if ($('#SGebiet').val()) {
  
    $.getJSON("http://" + document.domain + "/kbl/php/inc/get.region.gebiet.search.php?id="+$('#SGebiet').val()+"&Col=Region&Where=Gebiet",
        function(data){
     
        				for (p in data) {

        					$("#SRegion").selectOptions(data[p]);
                  
        				}
        				
        ShowTreffer();

    });
    
  }
  */        

  $('#SRegion').change(function(){
  
    $.post("http://" + document.domain + "/kbl/php/inc/get.region.gebiet.search.php", { id: $(this).val(), Col: "Gebiet", Where: "Region" },
        function(data){
                var output = '';
                output += '<option value=\"\">alle</option>\n';
        				for (p in data) {
        					output += '<option value="' + HtmltoAsci(data[p]) + '">' + HtmltoAsci(data[p]) + '</option>\n';
        				}
  
        				$('#SGebiet').html(output);
        				ShowTreffer();
          }, 'json');
  });
  
  $('#SGebiet').change(function(){
      
    if ($('#SGebiet').val()) {
      
      $.post("http://" + document.domain + "/kbl/php/inc/get.region.gebiet.search.php", { id: $(this).val(), Col: "Region", Where: "Gebiet" },
        function(data){
     
        				for (p in data) {

        					$("#SRegion").selectOptions(HtmltoAsci(data[p]));
                  
        				}
                ShowTreffer();

          }, 'json');
          
      
          
    } 
  });
  
  
  


  
  
  
    // Konto Anzeigen (MeinKonto)
    


  $('#KRegion').change(function(){

    var BL = $(this).val();
    $.post("http://" + document.domain + "/kbl/php/inc/get.region.gebiet.search.php", { id: BL, Col: "Gebiet", Where: "Region" },
        function(data){

                var output = '';

        				for (p in data) {
        					output += '<option value="' + HtmltoAsci(data[p]) + '">' + HtmltoAsci(data[p]) + '</option>\n';
        				}
  
        				$('#KRaum').html(output);
          }, 'json');
  });
  
  $('#KRaum').change(function(){
      
    
    $.post("http://" + document.domain + "/kbl/php/inc/get.region.gebiet.search.php", { id: $(this).val(), Col: "Region", Where: "Gebiet" },
        function(data){
                
        				for (p in data) {

        					$("#KRegion").selectOptions(HtmltoAsci(data[p]));
   
        				}
	
          }, 'json');
          
          
  });
  
  
  

  
  // Guestbook freischalten
  
  
  $('#Guestbook_FS').click(function(){
  
    var GBFS = $('#Guestbook_FS').attr("checked");
    if (GBFS==true) {
        $GBFS = true;
        
    }
    else {
        GBFS = false;
    }
    
  
    $.get("http://" + document.domain + "/kbl/php/inc/set.guestbook.freischaltung.php?GBFS="+GBFS);
  });
  
  // Link Corsor
  $('a').css({cursor:"pointer"});
  
  // INPUT Text Box
  $('input[type=text], textarea').css({backgroundColor:"#FFFFFF", cursor:"pointer"});
  $('input[type=text], input[type=password], textarea').focus(function () {
         $(this).css({backgroundColor:"#F9F3D8"})
    });
  $('input[type=text], input[type=password], textarea').blur(function () {
         $(this).css({backgroundColor:"#FFFFFF"})
    });
  
  
  $('input[type=text], input[type=password], textarea').hover( 
      function() {
        //alert($(this).css("backgroundColor")); 
        if ($(this).css("backgroundColor") != "rgb(249, 243, 216)") {
            $(this).css("backgroundColor", "#CCCCFF");  
        }
      },
      function() {
        if ($(this).css("backgroundColor") != "rgb(249, 243, 216)") {
          $(this).css("backgroundColor", "#FFFFFF");   
        }
      }
   );
  

  $("#logout").hover(function(){
  	$(this).attr("src", "http://"+document.domain+"/kbl/pics/bg_main_navi/logout_Mouseover.gif");
  }, function(){
  	$(this).attr("src", "http://"+document.domain+"/kbl/pics/bg_main_navi/logout.gif");
  })





  $(".DIVVisitenKartenBox").hover(
        function(){ 
            $(this).find(".MerkenBtn").show();

        }, 
        function(){
            $(this).find(".MerkenBtn").hide();
  
        }
   );

  $(".MerkenBtn").hover(
      function(){
          $(this).find("img").attr("src", "http://"+document.domain+"/kbl/pics/bg_merk_button_hover.gif");
      },
      function(){
          $(this).find("img").attr("src", "http://"+document.domain+"/kbl/pics/bg_merk_button.gif");
      }
  )


  
ShowGalerie = function(AID, Pos) { 
          var GalTitle = $(".DetailAnzeigeName").html();
          $('#g1').css("z-index", "0");
          $('#g1').mbGallery({maskBgnd:'#ccc', 
         overlayOpacity:.9, startFrom: Pos, galleryTitle: GalTitle, fullScreen:false, minWidth:200, minHeight:200, slideTimer: 3500 });
}


});


//function ShowGalerie(AID, Pos) {
//function ShowGalerie(AID, Pos) {



function CheckEMailAdress(EMAIL) {
    alert(EMAIL);
    $.get("http://" + document.domain + "/kbl/php/inc/check.email.php?eMail="+EMAIL, function(text){
      alert(text);
      if (text == "OK") {
          return (true);
      }
      else return (false);
    });
}


function HideClueTip() {
    $('#cluetip').hide();
}

function SendAlert() {

  
  
      var KontaktAlertInfo = $('#cluetip').find("#AlertInfo").val();
      var KontaktEMail = $('#cluetip').find("#AlertEMail").val();

      KontaktAlertInfo = KontaktAlertInfo.replace (/^\s+/, '').replace (/\s+$/, '');
      
      if (KontaktAlertInfo) {
      
          $.get("http://" + document.domain + "/kbl/php/inc/check.email.php?eMail="+KontaktEMail, function(text){
            //alert(text)
              if (text == "OK") {
                  var AZ = $("[name=ViewAnzeige]").val();
                  //alert("AZ: "+AZ+" eMail: "+KontaktEMail+" AZAlert: "+KontaktAlertInfo);
                  $.post("http://" + document.domain + "/kbl/php/inc/alert.anzeige.php", { AZID: AZ, eMail: KontaktEMail, AZAlert: KontaktAlertInfo } );
                  $('#cluetip').find("#AlertForm").html("<div style='font-size:12px;'>Deine Anfrage wurde weitergeleitet!<br /></div>");
                  window.setTimeout("HideClueTip()", 2000);
                  
              }
              else alert('Deine eMail-Adresse ist ungÃŸltig!');
          });
      }
      else { alert('Bitte gib einen Kommentar mit an!'); }
   
      
  

}












function ShowTreffer() {

	var SGebiet 	= '';
	var SRegion 	= '';
	var SName 		= '';
	var SCategory = '';
	var SHaarfarbe= '';
	var SAgeGroup = ''
	var SAgeVon 	= '';
	var SAgeBis 	= '';
	var SVorlieben= '';
  var SGoodLuck = '';

	if ($('#SGebiet').val()) { 
	    SGebiet     =  $('#SGebiet').val() ;
	    SGebiet     = SGebiet.replace("/ /g", "");
	}
	if ($('#SRegion').val()) {
    	SRegion     =  $('#SRegion').val() ;
    	SRegion     = SRegion.replace("/ /g", "");
  }
	if ($('#SName').val())
	    SName       =  $('#SName').val() ;
	if ($('#SCategory').val()) {
		SCategory = $('#SCategory').val();

		var repstr = "||";
		//SCategory = SCategory.replace(repstr, "','");
		//SCategory = SCategory.replace(/\|/g, "'");
	    SCategory   =  SCategory ;
		
		
	}
	if ($('#SHaarfarbe').val()) {
		SHaarfarbe = $('#SHaarfarbe').val();
		//var repstr = "||";
		//SHaarfarbe = SHaarfarbe.replace(repstr, "','");
		//SHaarfarbe = SHaarfarbe.replace(/\|/g, "'");
	    //SHaarfarbe   = escape( SHaarfarbe );

	}	
	
	if ($('#SAgeGroup').val()) {
      SAgeGroup = $('#SAgeGroup').val();
  }
	
	if ($('#SAgeVon').val())
		SAgeVon     =  $('#SAgeVon').val() ;
		
	if ($('#SAgeBis').val())
	    SAgeBis     =  $('#SAgeBis').val() ;
		
	if ($('#SVorlieben').val()) {
		SVorlieben = $('#SVorlieben').val();
		//var repstr = "||";
		//SVorlieben = SVorlieben.replace(repstr, "','");
		//SVorlieben = SVorlieben.replace(/\|/g, "'");
	    //SVorlieben   = escape( SVorlieben );

	}
	if ($('#SGoodLuck').val()) {
	  SGoodLuck = $('#SGoodLuck').val(); 
	}
    
    Link = "SAnzeigen[Haarfarbe]="+SHaarfarbe
    +"&SAnzeigen[Raum]="+SGebiet
    +"&SAnzeigen[Region]="+SRegion
    +"&SAnzeigen[Name]="+SName
    +"&SAnzeigen[AgeGroup]="+SAgeGroup
    +"&SAnzeigen[AgeVon]="+SAgeVon
    +"&SAnzeigen[AgeBis]="+SAgeBis
    +"&SAnzeigen[Category]="+SCategory
    +"&SAnzeigen[Vorlieben]="+SVorlieben
    +"&SAnzeigen[GoodLuck]="+SGoodLuck
    +"&SAjax=Yes";
    
    
//alert(Link);
    $.ajax({
              type: "POST",
             url: "http://"+document.domain+"/kbl/php/content.anzeigen.search.string.php",
             processData: true,
             data: Link,
             beforeSend: function() {
                //$("#btnSearch").hide();
                //$("#btnSearch").prepend("<img src='./pics/icons/ajax-loader.gif' id='ajaxloader' alt='keinBild' border='0' />");
                //$("#DIVSearchSumitBox").append("<img src='./pics/icons/ajax-loader.gif' id='ajaxloader' alt='keinBild' border='0' />");
                //$("#btnSearch").val("<img src='"+ajaxloader+"' border='0' />");
             },
             success: function(msg){
               $("#btnSearch").val("Anzeigen ("+msg+")");
               $("#btnSearch").fadeIn("slow");
               //$("#ajaxloader").remove();
                //alert(msg);
                //alert(Link);
                //alert(msg);
             }
    });

}










function ShowPic(Src) {

    document.getElementById("MainPic").src = Src;

}


function dateDiff(strDate1,strDate2){ /*Parmeterformat mm/dd/yyy */
     datDate1= Date.parse(strDate1);
     datDate2= Date.parse(strDate2);
     var diff = ((datDate2-datDate1)/(24*60*60*1000));
     return diff;
     
}


function ShowBgTrans() {

var x=0;
var y=0;

//x = document.getElementById("frame_top_left").offsetWidth; //+ document.getElementById("frame_top_right").offsetWidth;
//y = document.getElementById("frame_top_left").offsetHeight; // + document.getElementById("frame_top_right").offsetHeight;


//x=x;
//y = y + document.getElementById("content").offsetHeight;
y = document.body.scrollHeight;
x = document.body.offsetWidth;

//alert(x+":"+y);


//var bgtrans = document.getElementById("bg_trans");
//var left = document.getElementById("frame_top_left").offsetLeft;
//left = left;
//bgtrans.style.left = left+"px"; //3;
//bgtrans.style.top = 3;
//bgtrans.style.display = "inline";
//bgtrans.style.position = "absolute";
//alert(y+" x"+x);
$("#bg_trans").css({ "text-align":"center", height:y+"px", width:x+"px", position:"absolute", top: "0px", left: "0px", opacity:"0.8"});
$("#bg_trans").fadeIn("slow");

//$("#bg_trans").height(y);
//$("#bg_trans").width(x);



}





function AjaxRequest(Link, ID) {

        if (ID) {
              $.get(Link, function(text){
      
                if (text != "") {
                  document.getElementById(ID).innerHTML = text;
                }
              });
      
        }
        else {
              $.get(Link);        
        }

}






function ShowGermany() {

ShowBgTrans();

//var login = document.getElementById("pic_germany");
//login.style.display = "inline";

$("#pic_germany").css({ position:"absolute", left:"200px", top:"30px" });
$("#pic_germany").show();
//login.style.left = 200;
//login.style.top = 30;


}



function CloseGermany() {



var login = document.getElementById("pic_germany");
login.style.display = "none";


var bgtrans = document.getElementById("bg_trans");
bgtrans.style.display = "none";
bgtrans.style.width = 0;
bgtrans.style.height = 0;

}





function CloseGalerie() {

var login_element = document.getElementById("pic_galerie_element");
login_element.style.display = "none";

var login = document.getElementById("pic_galerie");
login.style.display = "none";
login.style.width = 0;
login.style.height = 0;

var bgtrans = document.getElementById("bg_trans");
bgtrans.style.display = "none";
bgtrans.style.width = 0;
bgtrans.style.height = 0;

}








function CloseBgTrans() {

  var bgtrans = document.getElementById("bg_trans");
  $("#bg_trans").empty();
  bgtrans.style.display = "none";
  bgtrans.style.width = 0;
  bgtrans.style.height = 0;

}





function DateAdd(timeU,byMany,dateObj) {
	var millisecond=1;
	var second=millisecond*1000;
	var minute=second*60;
	var hour=minute*60;
	var day=hour*24;
	var year=day*365;

	var newDate;
	var dVal=dateObj.valueOf();
	switch(timeU) {
		case "ms": newDate=new Date(dVal+millisecond*byMany); break;
		case "s": newDate=new Date(dVal+second*byMany); break;
		case "mi": newDate=new Date(dVal+minute*byMany); break;
		case "h": newDate=new Date(dVal+hour*byMany); break;
		case "d": newDate=new Date(dVal+day*byMany); break;
		case "y": newDate=new Date(dVal+year*byMany); break;
	}
	return newDate;
}





function AnzeigeMerken(AZ) {

    $.get("http://" + document.domain + "/kbl/php/inc/setcookie.merken.php?AZ="+AZ, function() {
        ShowGemerkteAnzeigen();
    }) ;

}


function ShowGemerkteAnzeigen() {

    var form = "";
    
  //$(document).ready(function(){
      $.getJSON("http://" + document.domain + "/kbl/php/inc/anzeigen.gemerkt.php?Show=True", function(data) {
                  if (data) {
                      $("#AnzeigenAssistent").text("");
                      $("#AnzeigenAssistent").show();
                      form="<div class='content_box_01_middle' style='clear:both;'>";
                      form+="<div class='content_box_01_top'><div>Favoriten</div></div>";
                      form+="<div id='delAllFavorites' onClick=\"javascript:DeleteGemerkteAnzeige('', 'All')\">";
                      form+="<img style='border: none; width: 10px; height: 10px;' src='http://"+document.domain+"/kbl/pics/icons/right_10x10.gif' alt='l&ouml;schen' title='alle Favoriten l&ouml;schen' />&nbsp;...alle Favoriten l&ouml;schen</div>";
                      
                      for (p in data) {
                              //alert(data[p].Anzeigen_Name+data[p].Anzeigen_ID+data[p].Anzeigen_Treffpunkt+data[p].Anzeigen_Pic);
                              form+= "<div class='favorite_entries' style='border-top:1px solid #666; padding:5px 5px; text-align:left; white-space: nowrap'>";
                              form+= "<a class='title' href='http://"+document.domain+data[p].Anzeigen_SeoLink+"' rel='http://"+document.domain+"/kbl/php/tooltip/tt.pic.zoom.php?AZID="+data[p].Anzeigen_ID+"'>"+data[p].Anzeigen_Name+"</a> <span style='font-weight:lighter;'>- "+data[p].Anzeigen_Treffpunkt+"</span>";
                              form+= "</div>";
                              
                      }
                      
                      form+="</div>";
                      form+="<div class='content_box_01_bottom' style='margin-bottom:0px;'></div>";
                      $("#AnzeigenAssistent").append(form);
                      
                      $('a.title').cluetip({width: '200px', showTitle: false, arrows: true});
                      $(".favorite_entries").hover(
                        function(){ $(this).css("backgroundColor", "#fff"); }, 
                        function(){ $(this).css("backgroundColor", "transparent"); }
                      );
                      //alert($(".favorit_entries a").attr("class"));
                      //alert(form);
                  }
                  else {
                              $("#AnzeigenAssistent").hide();//css("display","none");
                              
                  }
                  
                 
      });
      /*
      $.get("http://" + document.domain + "/kbl/php/inc/anzeigen.gemerkt.in.navi.php?Show=True", function(text) {
                  if (text) {
                              $("#naviGemerkteAZ").text("");
                              $("#AnzeigenAssistent").show();
                              $("#naviGemerkteAZ").append(text);
                  }
                  else {
                              $("#AnzeigenAssistent").css("display","none");
                  }
      });*/
  //})

}

function DeleteGemerkteAnzeige(AZ, All) {

  $(document).ready(function(){
      $.get("http://" + document.domain + "/kbl/php/inc/anzeigen.gemerkt.php?Delete=True&AZ="+AZ+"&All="+All, function(text) {
                              ShowGemerkteAnzeigen();
                              });
  })

}



function AddGuestbookEntry() {

  $(".addguestbookentry").slideDown(1000);

}


function SaveGuestbookEntry(AZ) {

          var pseudo_text = $(".addguestbookentry input[type=text]").val();
          var gb_text = $(".addguestbookentry textarea").val();
          if (gb_text == "Hier Erlebnisbericht eintragen...") gb_text = "";
          if (pseudo_text == "Von...") pseudo_text = "(Anomym)";
          //alert(gb_text);
          
          if (gb_text) {
            $.post("http://" + document.domain + "/kbl/php/inc/save.guestbook.entry.php", {AZID: AZ, pseudo: pseudo_text, guestbook_text: gb_text }, function(text) {
                                $(".addguestbookentry").fadeOut(5000);//, function() {
                                
                                  if (text) {
                                    $("#guestbookaddinfo").css({ "border":"2px solid green", "color":"green" });
                                    $("#guestbookaddinfo").fadeIn(2000).text("Dein Erlebnisbericht liegt zur PrÃŸfung vor!!").fadeOut(3000);
                                    //$("#guestbookaddinfo").show(3, function() {
                                        
                                        //$("#guestbookaddinfo").slideUp(2000);
                                    //}) ;
                                  }  
                                //});
                                
                                });
          
        }
        else {
            $("#guestbookaddinfo").css({ "border":"2px solid red", "color":"red" });
            $(".addguestbookentry textarea").css({ "border":"1px solid red" });
            $("#guestbookaddinfo").fadeIn(2000).text("Du musst noch einen Erlebnisbericht hinterlassen!").fadeOut(3000);
        }
}



/*
function SaveGuestbookEntry(AZ) {

          var pseudo_text = escape ($(".addguestbookentry input[type=text]").val() );
          var gb_text = escape ( $(".addguestbookentry textarea").val() );
          

          
          

          $.post("http://" + document.domain + "/kbl/php/inc/save.guestbook.entry.php", {AZID: AZ, pseudo: pseudo_text, guestbook_text: gb_text }, function(text) {
                              $(".addguestbookentry").slideUp("slow", function() {
                              
                                if (text) {
                                  $("#guestbookaddinfo").text("Ihr GÃ¤stebucheintrag liegt zur PrÃŸfung vor!!")
                                  $("#guestbookaddinfo").show(3, function() {
                                      
                                      
                                  }) ;
                                }  
                              });
                              
                              });
        

}
*/




function ResetDIVSearchListBox (id) {
  	var	hiddentxt = "#S"+id;		
		var obj = "#"+id +"";
		
		$(obj).find("div").css({"marginLeft": "0px", "backgroundColor": "transparent"});
		$(obj).find("img").remove();
		//alert(id);		
		$(hiddentxt).val("");
		$("#Cap_"+id).find("img").attr("src", "http://www."+document.domain+"/kbl/pics/icons/right_10x10.gif");
		ShowTreffer();
}




function GetOnlineStatus(obj, clear) {
  
    $.get("http://" + document.domain + "/kbl/php/konto/message/ajax/get.user.getonlinestatus.php", function(msg) {
      if (clear.length == 0) $(obj).append("<img src='./pics/konto/online.png' style='float:left;' />&nbsp;"+msg);
      else $(obj).html("<img src='./pics/konto/online.png' />&nbsp;"+msg);
    })
}



function HtmltoAsci(HtmlString)
{
  var chars = new Array ('&','Ã ','Ã¥','Ã¢','Ã£','Ã¤','Ã¼','ÃŒ','Ã§','Ã¨','ÃŠ',
                         'Ãª','Ã','Ã','Ã­','ÃŽ','Ã¯','Ã°','Ã¹','Ã²','Ã³','Ã´',
                         'Ã¾','Ãœ','Ã¸','Ãš','Ãº','Ã','ÃŸ','Ã½','Ãž','Ã¿','Ã€',
                         'Ã','Ã‚','Ãƒ','Ã„','Ã…','Ã†','Ã‡','Ãˆ','Ã‰','Ã¦','Ã‹',
                         'Ã©','Ã«','Ã¬','Ã®','Ã','Ã‘','Ã’','Ã“','Ã”','Ã•','Ã–',
                         'Ã˜','Ã™','Ã±','Ã›','Ãµ','Ã¶','Ã·','â‚','\"','Ã»','<',
                         '>','Â¢','Â£','Â¤','Â¼','ÂŒ','Â§','Â¨','ÂŠ','Âª','Â',
                         'Â','Â­','ÂŽ','Â¯','Â°','Â¹','Â²','Â³','Â´','Â¾','Âœ',
                         'Â¡','Â¸','Âš','Âº','Â','ÂŸ','Â½','Âž');

  var entities = new Array ('amp','agrave','aacute','acirc','atilde','auml','aring',
                            'aelig','ccedil','egrave','eacute','ecirc','euml','igrave',
                            'iacute','icirc','iuml','eth','ntilde','ograve','oacute',
                            'ocirc','otilde','ouml','oslash','ugrave','uacute','ucirc',
                            'uuml','yacute','thorn','yuml','Agrave','Aacute','Acirc',
                            'Atilde','Auml','Aring','AElig','Ccedil','Egrave','Eacute',
                            'Ecirc','Euml','Igrave','Iacute','Icirc','Iuml','ETH','Ntilde',
                            'Ograve','Oacute','Ocirc','Otilde','Ouml','Oslash','Ugrave',
                            'Uacute','Ucirc','Uuml','Yacute','THORN','euro','quot','szlig',
                            'lt','gt','cent','pound','curren','yen','brvbar','sect','uml',
                            'copy','ordf','laquo','not','shy','reg','macr','deg','plusmn',
                            'sup2','sup3','acute','micro','para','middot','cedil','sup1',
                            'ordm','raquo','frac14','frac12','frac34');

  newString = HtmlString;
  for (var i = 0; i < chars.length; i++)
  {
    myRegExp = new RegExp();
    myRegExp.compile('&' + entities[i] + ';','g')
    newString = newString.replace (myRegExp, chars[i]);	
	/*
    myRegExp.compile(chars[i],'g')
    newString = newString.replace (myRegExp, '&' + entities[i] + ';');
	*/
  }
  return newString;
}


function strip_px(vari){
    var vari = (vari == null) ? "0px" : vari;
    var ret = vari.substr(0,(vari.length-2));
    return parseInt(ret);
}



/* Print_R-Function Begin */
function padding(laenge) {
result = '';
for (i = 0; i < laenge; i++)
result = result + '___';
return result;
}

function print_r(das_array, ebene) {
var result = '';
for (var wert in das_array)
if (typeof das_array[wert] == "object")
result = result + ' ' + padding(ebene) + wert + "\n" + print_r(das_array[wert], ebene + 1);
else
result = result + ' ' + padding(ebene) + wert + ' = ' + das_array[wert] + "\n";

return result;
}
/* Print_R-Function END */
