var baselink = 'http://www.warendorf.eu/';
var bla = false;
function hover_aktiv(id, what, merk){
    if(what == "inhalt" && merk == "short"){
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_inaktiv.png")!=-1){
		document.getElementById("inhaltbild_gr"+id).style.display ="none";
		document.getElementById("zumerkliste_"+what+"_"+id).style.display ="block";
        document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_hover.png");
        }
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
            document.getElementById("inhaltbild_gr"+id).style.display ="none";
            document.getElementById("merklisteent_"+what+"_"+id).style.display ="block";
        }
    }
    if(what == "inhalt" && merk == "big"){
        if (document.getElementById("harken_"+what+"_big_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_inaktiv.png")!=-1){
            document.getElementById("inhaltbild_"+id).style.display ="none";
            document.getElementById("zumerkliste_"+what+"_big_"+id).style.display ="block";
            document.getElementById("harken_"+what+"_big_"+id).setAttribute("src","fileadmin/system/image/harken_hover.png");
        }
        if (document.getElementById("harken_"+what+"_big_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
           // $("#inhaltbild_"+id).fadeOut(400);
           // $("#zumerkliste_"+what+"_big_"+id).fadeIn(400); 
            document.getElementById("inhaltbild_"+id).style.display ="none";
            document.getElementById("merklisteent_"+what+"_big_"+id).style.display ="block";
        }
    }    
    if(merk == "merk"){
           // $("#merklisteent_"+what+"_"+id).fadeIn(400);
         
            $('#haendlerbild_'+id).css('visibility','hidden');
            $('#kuechebild_'+id).css('visibility','hidden');
            $('#hotspotbild_'+id).css('visibility','hidden');
            $('#inhaltbild_'+id).css('visibility','hidden');
            $('#bighotspotbild_'+id).css('visibility','hidden');
            
            document.getElementById('merklisteent_'+what+'_'+id).style.display ="block";
    }
    if(what == "kuechen" && merk != "merk"){
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_inaktiv.png")!=-1){
           // $("#zumerkliste_"+what+"_"+id).fadeIn(400); 
           $("#kuech_"+id).css("display","none");
           document.getElementById("zumerkliste_"+what+"_"+id).style.display ="block";
           document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_hover.png");
        }
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
           // $("#merklisteent_"+what+"_"+id).fadeIn(400);
           $("#kuech_"+id).css("display","none"); 
            document.getElementById("merklisteent_"+what+"_"+id).style.display ="block";
        }
    }
    if(what == "haendler" && merk != "merk"){
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_inaktiv.png")!=-1){
           // $("#zumerkliste_"+what+"_"+id).fadeIn(400); 
            document.getElementById("zumerkliste_"+what+"_"+id).style.display ="block";
            document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_hover.png");
        }
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
           //$("#merklisteent_"+what+"_"+id).fadeIn(400); 
            document.getElementById("merklisteent_"+what+"_"+id).style.display ="block";
        }
    }
    if(what == "hotspot" && merk != "merk"){
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_inaktiv.png")!=-1){
           //$("#zumerkliste_"+what+"_"+id).fadeIn(400); 
            document.getElementById("zumerkliste_"+what+"_"+id).style.display ="block";
            document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_hover.png");
        }
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
            //$("#merklisteent_"+what+"_"+id).fadeIn(400); 
            document.getElementById("merklisteent_"+what+"_"+id).style.display ="block";
        }
    }
}

      
function hover_inaktiv(id, what, merk){
 //   alert(id);
    if(what == "inhalt" && merk == "short"){
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_hover.png")!=-1){
           // $("#inhaltbild_gr"+id).fadeIn(400); 
           // $("#zumerkliste_"+what+"_"+id).fadeOut(400);
            //$("#zumerkliste_"+what+"_"+id).stop();
            document.getElementById("inhaltbild_gr"+id).style.display ="block";
            document.getElementById("zumerkliste_"+what+"_"+id).style.display ="none";
            document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
        }
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
           // $("#inhaltbild_gr"+id).fadeIn(400); 
           // $("#zumerkliste_"+what+"_"+id).fadeOut(400);
           if(bla == false){
            document.getElementById("inhaltbild_gr"+id).style.display ="block";
            }
            document.getElementById("merklisteent_"+what+"_"+id).style.display ="none";
        }
    }
    if(what == "inhalt" && merk == "big"){
        if (document.getElementById("harken_"+what+"_big_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_hover.png")!=-1){
           // $("#inhaltbild_"+id).fadeIn(400); 
           // $("#zumerkliste_"+what+"_big_"+id).fadeOut(400);
            document.getElementById("inhaltbild_"+id).style.display ="block";
            document.getElementById("zumerkliste_"+what+"_big_"+id).style.display ="none";
            document.getElementById("harken_"+what+"_big_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
        }
        if (document.getElementById("harken_"+what+"_big_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
           // $("#inhaltbild_"+id).fadeIn(400); 
           // $("#zumerkliste_"+what+"_big_"+id).fadeOut(400);
           if(bla == false){
            document.getElementById("inhaltbild_"+id).style.display ="block";
            }
            document.getElementById("merklisteent_"+what+"_big_"+id).style.display ="none";
            //document.getElementById("harken_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
        }
    }
    if(merk == "merk"){
           // $("#merklisteent_"+what+"_"+id).fadeOut(400);
            $('#haendlerbild_'+id).css('visibility','visible');
            $('#kuechebild_'+id).css('visibility','visible');
            $('#hotspotbild_'+id).css('visibility','visible');
            $('#inhaltbild_'+id).css('visibility','visible');
            $('#bighotspotbild_'+id).css('visibility','visible');
           document.getElementById('merklisteent_'+what+'_'+id).style.display ="none";
    }
    if(what == "kuechen" && merk != "merk"){
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_hover.png")!=-1){
           //$("#zumerkliste_"+what+"_"+id).fadeOut(400);
            $("#kuech_"+id).css("display","block");
            document.getElementById("zumerkliste_"+what+"_"+id).style.display ="none";
            document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
        }
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
            //$("#merklisteent_"+what+"_"+id).fadeOut(400);
            $("#kuech_"+id).css("display","block");
            document.getElementById("merklisteent_"+what+"_"+id).style.display ="none";
           //document.getElementById("harken_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
        }
    }  
    if(what == "haendler" && merk != "merk"){
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_hover.png")!=-1){
           //$("#zumerkliste_"+what+"_"+id).fadeOut(400);           
            document.getElementById("zumerkliste_"+what+"_"+id).style.display ="none";
            document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
        }
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
           // $("#merklisteent_"+what+"_"+id).fadeOut(400); 
            document.getElementById("merklisteent_"+what+"_"+id).style.display ="none";
        }
    } 
    if(what == "hotspot" && merk != "merk"){
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_hover.png")!=-1){
           //$("#zumerkliste_"+what+"_"+id).fadeOut(400); 
            document.getElementById("zumerkliste_"+what+"_"+id).style.display ="none";
            document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
        }
        if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/merken_aktiv.png")!=-1){
          // $("#merklisteent_"+what+"_"+id).fadeOut(400); 
            document.getElementById("merklisteent_"+what+"_"+id).style.display ="none";
        }
    }      
}

function Eintrag_Suchen(lang)
{
  //var Titel = document.getElementById("kueche").value
  var Preis = document.getElementById("preis").value;
  var Land = document.getElementById("land").value;
  var lang = document.getElementById("language").value;
  //var url = "fileadmin/system/php/musterkuechen.php?ajax=on&kueche=" + Titel + "&preis=" + Preis + "&land=" + Land+"&L="+lang;
 var url = "fileadmin/system/php/musterkuechen.php?ajax=on&preis=" + Preis + "&land=" + Land+"&L="+lang;
  
 req = XMLobject();
  if(req)
  {    req.onreadystatechange = antwort;
   req.open("GET", url, true);
   req.send(null);
  }
}


function antwort()
{
  if (req.readyState == 4)
  {
    document.getElementById('gefunden').innerHTML = req.responseText;
  }
}

function XMLobject() {
  var req = false;
  if(window.XMLHttpRequest) {
   try {
   req = new XMLHttpRequest();
  } catch(e) {
  req = false;
  }
  } else if(window.ActiveXObject) {
    try {
   req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e) {
  try {
   req = new ActiveXObject("Microsoft.XMLHTTP");
  } catch(e) {
   req = false;
    }
   }
  }

return req;
}
var request = false;
var request_to_typo3_session = false;
	// Request senden
	function setRequest(id, what, khaendler, merk ,link) {
		
		// Request erzeugen
		if (window.XMLHttpRequest) {
			request = new XMLHttpRequest(); // Mozilla, Safari, Opera
		} else if (window.ActiveXObject) {
			try {
				request = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
			} catch (e) {
				try {
					request = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
				} catch (e) {}
			}
		}

		// überprüfen, ob Request erzeugt wurde
		if (!request) {
			alert("Kann keine XMLHTTP-Instanz erzeugen");
			return false;
		} else {
		
			var url = "fileadmin/system/php/add_to_merkliste.php";
			// Request öffnen
			request.open('post', url, true);
			// Requestheader senden
			request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			// Request senden
			if(what == "merkinfo")
            		{
            		request.send('merkinfo=1');
            		}else{
            		
			if (document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_hover.png")!=-1 || document.getElementById("harken_"+what+"_"+id).getAttribute("src").indexOf("fileadmin/system/image/harken_inaktiv.png")!=-1 ){
			 var status = 1;
            		}else{
			 var status = 0;
            		}
            		
            		if(what == "haendler" && merk == "merkliste")
			{
			 request.send('h_id='+id+'&status='+status+'&all=true');
			}
            else if(what == "haendler")
			{
			 request.send('h_id='+id+'&status='+status);
            }            
            else if(what == "kuechen")
			{
			 request.send('k_id='+id+'&status='+status+'&hzuk='+khaendler);
			}
	        else if(what == "inhalt")
			{
			 request.send('i_id='+id+'&status='+status);
			}
		            else if(what == "bighotspot")
			{
			 request.send('hsuid='+id+'&link='+link+'&hsstatus='+status);
             $.ajax({
                type: "POST",
                url: baselink + "index.php?id=96",
                data: "unlink=" + link + '&hsuid=' + id + '&hsstatus=' + status,
                success: function(data){
                    //
                }
             });             
			}
            else if(what == "hotspot")
			{
			 request.send('hsuid='+id+'&link='+link+'&hsstatus='+status);
             $.ajax({
                type: "POST",
                url: baselink + "index.php?id=96",
                data: "unlink=" + link + '&hsuid=' + id + '&hsstatus=' + status,
                success: function(data){
                    //
                }
             });             
			}
            }
			// Request auswerten
			request.onreadystatechange = function ()
	{
	interpretRequest(id, what, merk, status,khaendler);
	}  
		}
	}
    
    	// Request auswerten
        function unsichtbar(){
                document.getElementById('hinzu_kuechen_157').style.display ='none';
      
        }
    	function interpretRequest(id, what, merk, status,khaendler) {
		switch (request.readyState) {
			// wenn der readyState 4 und der request.status 200 ist, dann ist alles korrekt gelaufen
			case 4:
				if (request.status != 200) {
					alert("Der Request wurde abgeschlossen, ist aber nicht OK\nFehler:"+request.status);
				} else {
					var content = request.responseText;
					// den Inhalt des Requests in das <div> schreiben
					document.getElementById('merkid_'+what+'_'+ id).innerHTML = content;
					
                    if(merk== "normal"){
                        if(status == 1){
                            document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/merken_aktiv.png");
                            document.getElementById("zumerkliste_"+what+"_"+id).style.display ="none";
                                document.getElementById("hinzu_"+what+"_"+id).style.display ="block";
                                bla = true;
                                window.setTimeout(function(){
bla = false;
document.getElementById('hinzu_'+what+'_'+id).style.display ='none'; 
$("#inhaltbild_gr"+id).css("display","block");
}, 500);
                                
                            if(what=="inhalt"){
                            $('#inhaltbild_'+id).css('display','none');
//                                document.getElementById("inhaltbild_"+id).style.display ="none";
                                window.setTimeout(function(){document.getElementById('inhaltbild_'+id).style.display ='block';}, 500);
                            }                            
                        }else{
                            document.getElementById("harken_"+what+"_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
                            document.getElementById("merklisteent_"+what+"_"+id).style.display ="none";
                            if(what=="kuechen"){
                                    $('#kuech_'+id).css('display','block');
                                } 
                            if(what=="inhalt"){
                                $('#inhaltbild_'+id).css('display','block');
                                //document.getElementById("inhaltbild_gr"+id).style.display ="block";
                            }                                                        
                        }
                        if(khaendler == "big"){
                            if(status == 1){
                                document.getElementById("harken_"+what+"_big_"+id).setAttribute("src","fileadmin/system/image/merken_aktiv.png");
                                document.getElementById("zumerkliste_"+what+"_big_"+id).style.display ="none";
                                    document.getElementById("hinzu_"+what+"_big_"+id).style.display ="block";
                                      window.setTimeout(function(){document.getElementById('hinzu_'+what+'_big_'+id).style.display ='none';}, 500);
    
                                if(what=="inhalt"){
                                    document.getElementById("inhaltbild_"+id).style.display ="none";
                                    window.setTimeout(function(){document.getElementById('inhaltbild_'+id).style.display ='block';}, 500);
                                }                            
                            }else{
                                document.getElementById("harken_"+what+"_big_"+id).setAttribute("src","fileadmin/system/image/harken_inaktiv.png");
                                document.getElementById("merklisteent_"+what+"_big_"+id).style.display ="none";
                                if(what=="kuechen"){
                                    document.getElementById("kuech_"+id).style.display ="block";
                                } 
                                if(what=="inhalt"){
                                    document.getElementById("inhaltbild_"+id).style.display ="block";
                                }                                                        
                            }
                        }
                    }
                    
                    
                    if(merk == "merkliste" && what == "kuechen"){
					document.getElementById('erg_' + id).style.display = "none";
				
                    }
                    if(merk == "merkliste" && what == "inhalt"){
					document.getElementById('inhalt_' + id).style.display = "none";
					
                    }
                    if(merk == "merkliste" && what == "hotspot"){
					document.getElementById('hotspot_' + id).style.display = "none";
					
                    }
                    if(merk == "merkliste" && what == "bighotspot"){
					document.getElementById('bighotspot_' + id).style.display = "none";
					
                    }
		   if(merk == "merkliste" && what == "haendler"){
	
             var divs = document.getElementsByTagName('div');
                 for(var i = 0; i < divs.length; i++){
                    var div = divs[i];
                    if(div.getAttribute('class') == "erg_"+ id){
                          div.style.display='none';}
                          if(div.className == "erg_"+ id){
                          div.style.display='none';}
                 } 
 			document.getElementById('haendler_' + id).style.display = "none";
 			document.getElementById('sendeform' + id).style.display = "none";
					//document.getElementById('haendler_' + id).style.display = "none";
		                    }          
				}
				break;
			default:
				break;
		}
	}
