$(document).ready(function(){

/* ###########ie 8 bugfixing ########## */

if(navigator.appVersion.match(/MSIE 8.0/)){

$("#container").css("overflow","hidden");
$("#righto").css("width","775px");
//alert($("#lefto").offset().left);
//$("#era").css("left",$("#lefto").offset().left);

}else{


}






	/* ################################### Menue ################################### */

	var speed="normal";
	var bColorBg = "#B3002A";
	var bColorFg = "#ffffff";
	
// safari bugfix	
	if(navigator.appName.match(/Microsoft Internet Explorer/)){
		
	}else{
			
		if(agentsmith=="safari"){
//			mache scrollbalken
//			$("#righto").css("background-color","green");
			$("#container").css("overflow-x","hidden");
			$("#righto").css("overflow-x","hidden");

			$("#container").css("overflow-y","scroll");		
		}
		

	
	
	
	function doSomething() {
		
		if(agentsmithversion=="4"){
			$("#container").css("height", (window.innerHeight-35) + "px");
			
		}else if(agentsmithversion=="3"){
			$("#container").css("height", (window.innerHeight-35) + "px");
			
		}else{			
			$("#container").css("height", (window.innerHeight-35) + "px");
		}
		
	};
		
	var resizeTimer = null;
	$(window).bind('resize', function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(doSomething, 100);
	});
	
		
	
	}
	
	// end::safaribugfix
	
	
	/* TeamBild */




	if(navigator.appName.match(/Microsoft Internet Explorer/) && !navigator.appVersion.match(/MSIE 7.0/)){
		$("#teambild").css("margin-left", "-18px");
		$("#teambild").replaceWith($("#tehflash"));
		$("#tehflash").css("margin-left", "-18px");
		$(".page_display > p > #tehflash").show();
	}else{
		$("#teambild").css("margin-left", "-19px");
		$("#teambild").replaceWith($("#tehflash"));
		$("#tehflash").css("margin-left", "-19px");
		$(".page_display > p > #tehflash").show();
	}
		/* End::TeamBild */

	/* Menue */	
	var urlbase="http://www.lukasundpartner.de";

	
	
	
	
	if(navigator.appName.match(/Microsoft Internet Explorer/)){
		$(".menu, .menuoben").hover(
		  function () {
			  
			if($(this).css("background-color")=="rgb(179, 0, 42)" || $(this).css("background-color")=="#b3002a"){
				merker= "#b3002a";
				border= "#b3002a";
				schrift= "#ffffff";
			}else{
				merker= "#e9e9e9";
				border= "#ffffff";
				schrift= "#21057C";
			}
			
			$(this).children("a").children("span").css("color", "#21057C");
	//		$(this).css("background-color", "#ffffff");
	//		$(this).css("border-color", "#ffffff");
		  }, 
		  function () {

			$(this).css("background-color", merker);
			$(this).css("border-color", border);
			$(this).children("a").children("span").css("color", schrift);
			$(this).css("background-color", "#e9e9e9");
		  }
		);
	}else{
		$(".menu, .menuoben").hover(
				function () {
					
					if($(this).css("background-color")=="rgb(179, 0, 42)" || $(this).css("background-color")=="#b3002a"){
						merker= "#b3002a";
						border= "#b3002a";
						schrift= "#ffffff";
					}else{
						merker= "#e9e9e9";
						border= "#ffffff";
						schrift= "#21057C";
					}
					
					$(this).children("a").children("span").css("color", "#21057C");
							$(this).css("background-color", "#ffffff");
							$(this).css("border-color", "#ffffff");
				}, 
				function () {
					
					$(this).css("background-color", merker);
					$(this).css("border-color", border);
					$(this).children("a").children("span").css("color", schrift);
				}
		);	
	}
		
	if(tehselection=="haus"){
		$("#lhaus").css("background-color", bColorBg).css("border-color", bColorBg);
		$("#ahaus").css("color", bColorFg);
		$("#ehaus").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_haeuser_head.jpg"});
		$("#uberliste").html("Angebote H&auml;user");
		$("#uberbeschreibung").html("<p>Sie suchen ein neues Dach &uuml;berm Kopf? Schauen Sie doch gleich in unsere aktuelle Angebotsliste:</p>");

	}else if(tehselection=="wohnung"){
		$("#lwohnung").css("background-color", bColorBg).css("color", bColorFg).css("border-color", bColorBg);
		$("#awohnung").css("color", bColorFg);
		$("#ewohnung").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_wohnungen_head.jpg"});
		$("#uberliste").html("Angebote Wohnungen");
		if(navigator.appName.match(/Microsoft Internet Explorer/) && !navigator.appVersion.match(/MSIE 8.0/)){
			$("#uberbeschreibung").html("<p>Verwirklichen Sie Ihre individuellen Wohn-Tr&auml;ume.<br/>&nbsp;&nbsp;Die geeigneten R&auml;umlichkeiten hierf&uuml;r finden sie bei uns:</p>");
		}else{
			$("#uberbeschreibung").html("<p>Verwirklichen Sie Ihre individuellen Wohn-Tr&auml;ume.<br/>Die geeigneten R&auml;umlichkeiten hierf&uuml;r finden sie bei uns:</p>");
		}	
		
	}else if(tehselection=="home"){
		$("#lhome").css("background-color", bColorBg).css("border-color", bColorBg);
		$("#ahome2").css("color", bColorFg);
		$("#ehome2").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/startanimation.gif"});

	}else if(tehselection=="grundstueck"){
		$("#lgrundstueck").css("background-color", bColorBg).css("color", bColorFg).css("border-color", bColorBg);
		$("#agrundstueck").css("color", bColorFg);
		$("#egrundstueck").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_grundstuecke_head.jpg"});
		$("#uberliste").html("Angebote Grundst&uuml;cke");
		if(navigator.appName.match(/Internet Explorer/) && !navigator.appVersion.match(/MSIE 8.0/)){
			$("#uberbeschreibung").html("<p>Platz f&uuml;r neue Ideen! Wenn Sie etwas erschaffen wollen, sollten Sie sich diese Grundst&uuml;cke einmal &nbsp;&nbsp;anschauen:</p>");
		}else{
			$("#uberbeschreibung").html("<p>Platz f&uuml;r neue Ideen! Wenn Sie etwas erschaffen wollen, sollten Sie sich diese Grundst&uuml;cke einmal anschauen:</p>");
		}

	}else if(tehselection=="mietobjekt"){
		$("#lmietobjekt").css("background-color", bColorBg).css("color", bColorFg).css("border-color", bColorBg);
		$("#amietobjekt").css("color", bColorFg);
		$("#emietobjekt").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_grundstuecke_head.jpg"});
		$("#uberliste").text("Angebote Mietobjekte");
		$("#uberbeschreibung").html("<p>Hier k&ouml;nnen Sie ein Objekt mieten!</p>");
		if(navigator.appName.match(/Microsoft Internet Explorer/)){
			$("#uberliste").text("Angebote Mietobjekte");
			$("#uberbeschreibung").html("<p>Hier k&ouml;nnen Sie ein Objekt mieten!</p>");
		}else{
			$("#uberliste").text("Angebote Mietobjekte");
			$("#uberbeschreibung").html("<p>Hier k&ouml;nnen Sie ein Objekt mieten!</p>");
		}

	}else if(tehselection=="hausverwaltung"){
		$("#lhausverwaltung").css("background-color", bColorBg).css("color", bColorFg).css("border-color", bColorBg);
		$("#ahausverwaltung").css("color", bColorFg);
		$("#ehausverwaltung").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_haeuser_head.jpg"});
	
	}else if(tehselection=="vorstellen"){
		$("#lvorstellen").css("background-color", bColorBg).css("color", bColorFg).css("border-color", bColorBg);
		$("#avorstellen").css("color", bColorFg);
		$("#evorstellen").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_wir_head.jpg"});
	
	}else if(tehselection=="era"){
		$("#luera").css("background-color", bColorBg).css("color", bColorFg).css("border-color", bColorBg);
		$("#auera").css("color", bColorFg);
		$("#euera").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_wir_head.jpg"});
	
	}else if(tehselection=="service"){
		$("#lservice").css("background-color", bColorBg).css("color", bColorFg).css("border-color", bColorBg);
		$("#aservice").css("color", bColorFg);
		$("#eservice").css("color", bColorFg);

		$("#content").load("include/kontactForm.inc.php");

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_service_head.jpg"});	

	}else if(tehselection=="impressum"){
		$("#limpressum").css("background-color", bColorBg).css("color", bColorFg).css("border-color", bColorBg);
		$("#aimpressum").css("color", bColorFg);
		$("#eimpressum").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_impressum_head.jpg"});
	
	}else if(tehselection=="meinung"){
		$("#lmeinung").css("background-color", bColorBg).css("color", bColorFg).css("display", "block").css("border-color", bColorBg);
		$("#ameinung").css("color", bColorFg);
		$("#emeinung").css("color", bColorFg);

		$("#kopfbild").attr({src: urlbase + "/template/rounded_boxes/images/lukas_kundenmeinung_head.jpg"});
	}else{
	}
	/* End::Menue */

	/* ################################### Listing Results ################################### */

//	$(".form_main > tbody > tr > td > form > table > tbody > tr > td:eq(1) > select > option:first").text("Alle");

	$(".listThumb > a > img").css("height","115px");
	$('.zentriert > a').jTruncate({
		length: 25,
		minTrail: 25,
		moreText: ''
	});
	
	if(navigator.appName.match(/Microsoft Internet Explorer/)){

		$(".listleft ul li, .listright ul li").each(function (i) {
			$(this).css("list-style-type","none");
			$(this).css("list-style-position","inside");
			
			if ($(this).attr("title")!="") {
				$(this).jTruncate({
					length: 15,
					minTrail: 15,
					ellipsisText: '',
					moreText: ''
			}).prepend("- ");
			} else {
				$(this).css("display","none");
			}
		});

	}else{
		$(".listleft > ul > li, .listright > ul > li").each(function (i) {
			$(this).css("list-style-type","none");
			if ($(this).attr("title")!=""){
				$(this).jTruncate({
					length: 15,
					minTrail: 15,
					ellipsisText: '',
					moreText: ''
			}).prepend("- ");
			} else {
				$(this).css("display","none");
			}
      		});

	}

	
$(".listThumb a img").each(function (i) { $(this).attr("title", ""); });

/* End::Listing Results */

/* ################################### ImageGallerie ################################### */

$("#imagerows > tbody > tr:eq(0)").append($("#imagerows > tbody > tr:gt(0) > td"));

$("#imgliste > hr").remove();
	$("#main").css("height", "225px");
	$("#main").css("cursor", "pointer");
	$("#main").attr("title", "Zur Gallerie");


$("#main").click(function(){
	
	$(".thickbox").each(function(i){

		if($(this).attr("href")==$("#main").attr("src")){
			tb_show( $(this).attr("title"),$(this).attr("href"), 'mygroup');
		}
	});
});

$("#imagerows tbody tr td a img").click(function(){
	$("#main").attr("title", $("#main").attr("alt"));
});

$("#imagerows tbody tr td a img").each(function(i){
	$(this).attr("title", $(this).attr("alt"));
});



$("#imgliste > a > img").each(function(i){
	//	alert($(this).attr("longdesc"));

	$("#detailRechts").append("<span class=\"tehlist\" style=\"display: none;\"><a class=\"thickbox\" rel=\"mygroup\" href=\""+this.src.replace(/listing_photos\/thumb_/,"listing_photos/")+"\" title=\"" + $(this).attr("alt") + "\" ></a>");


});




// /* End::ImageGallerie */


/* ################################### Kundenmeinungen ################################### */
$(".mehr > p").css("color","#b3002a");
$(".mehr > p").css("font-weight","bold");
$(".mehr > p").mouseover(function(){$(this).css("cursor","pointer");});

$(".meinmein").css('margin-left','10px');


var meinungsflag=false;

$(".mehr > p").click(function(){

$(".rest").slideUp();
$(".mehr > p").html("&gt; mehr...");

	if($(this).parents(".meinmein").children(".rest").is(":visible")){
		$(this).parents(".meinmein").children(".rest").slideUp();
		$(this).html("&gt; mehr...");
	}else{
		$(this).parents(".meinmein").children(".rest").slideDown();
		$(this).html("&gt; weniger...");
	}
});

/* End::Kundenmeinungen */

/* ################################### Searchfield ################################### */
/*
$(".form_main > tbody > tr > td > form > table > tbody > tr:eq(1) > td:eq(1)").appendTo($(".form_main > tbody > tr > td > form > table > tbody > tr:eq(0)"));
$(".form_main > tbody > tr > td > form > table > tbody > tr:eq(1)").remove();
$(".form_main > tbody > tr > td > form > table").removeAttr("width");
*/
/* End::Searchfield */

/* ################################### HausDetails ################################### */

$("#detailLinks > ul > li").each(function (i) {
        if ($(this).attr("title")!="") {
         // $(this).prepend("- ");
          $(this).append("<br/>");
        } else {  $(this).remove(); }
});


$(".resultatliste .status").each(function (i) {	
	if($(this).html()=="verkauft"){
		$(this).parent().append('<div class="over" style="clear:both; z-index: 20; position: absolute; top: 0; left: 0;"><a href="'+
				$(this).parent().children(".listtop").children(".zentriert").children("a").attr("href")+'"><img src="'+ 
				urlbase + '/template/rounded_boxes/images/diagonal/verkauft_gr.gif" width="613" height="118" /></a></div>');
	}else if($(this).html()=="reserviert"){
		$(this).parent().append('<div class="over" style="clear:both; z-index: 20; position: absolute; top: 0; left: 0;"><a href="'+
				$(this).parent().children(".listtop").children(".zentriert").children("a").attr("href")+'"><img src="'+ 
				urlbase + '/template/rounded_boxes/images/diagonal/reserviert_gr.gif" width="613" height="118" /></a></div>');
	}else if($(this).html()=="vermietet"){
		$(this).parent().append('<div class="over" style="clear:both; z-index: 20; position: absolute; top: 0; left: 0;"><a href="'+
				$(this).parent().children(".listtop").children(".zentriert").children("a").attr("href")+'"><img src="'+ 
				urlbase + '/template/rounded_boxes/images/diagonal/vermietet_gr.gif" width="613" height="118" /></a></div>');
	}else{	
	}
});


if($(".status2").html()=="verkauft"){
	$(".status3").append('<img src="'+ urlbase + '/template/rounded_boxes/images/diagonal/verkauft_kl.gif" width="255" height="74" />');
}else if($(".status2").html()=="reserviert"){
	$(".status3").append('<img src="'+ urlbase + '/template/rounded_boxes/images/diagonal/reserviert_kl.gif" width="255" height="74" />');
}else if($(".status2").html()=="vermietet"){
	$(".status3").append('<img src="'+ urlbase + '/template/rounded_boxes/images/diagonal/vermietet_kl.gif" width="255" height="74" />');
}else{	
}


if(document.getElementById("zurueckbutton") == null){

}else if(document.getElementById("zurueckbutton").className == "Häuser"){
	$("#zurueckbutton > a").attr('href', urlbase+'/index.php?action=searchresults&amp;pclass[]=1');
}else if(document.getElementById("zurueckbutton").className == "Wohnung"){
	$("#zurueckbutton > a").attr('href', urlbase+'/index.php?action=searchresults&amp;pclass[]=2');
}else if(document.getElementById("zurueckbutton").className == "Grundstäcke"){
	$("#zurueckbutton > a").attr('href', urlbase+'/index.php?action=searchresults&amp;pclass[]=3');
}else if(document.getElementById("zurueckbutton").className == "MietObjekte"){
	$("#zurueckbutton > a").attr('href', urlbase+'/index.php?action=searchresults&amp;pclass[]=4');
}else{
}

/* End::HausDetails */

/* ################################### browse tool ################################### */
/*
$(".form_main > tbody > tr > td > form > table > tbody > tr").append($(".browse_tool_table > tbody > tr:eq(1) > td"));

$(".form_main > tbody > tr > td > form > table > tbody > tr > td:eq(3)").attr("align","right").attr("width","315px");
$(".form_main > tbody > tr > td > form > table > tbody > tr > td:eq(3)").remove();
*/
/* End::browse tool */

/* Mitarbeiter */

$(".mitarbeiterimg > img").css({'height':'130px', 'width':'95px'});
$(".mitarbeiterinfo > p").css("margin-top","6px");


/* End::Mitarbeiter */

/* Kontakt */


/* End::Kontakt */


if(navigator.appName.match(/Microsoft Internet Explorer/)){

$(".menuoben a, .menu a").css({ 'line-height':'20px', 'color':'#21057c' });
var aktuellecssbg = "";
var aktuellecssbo = "";

$(".menu, .menuoben").hover(
	function () {
		aktuellecssbg = $(this).css("background-color");
		aktuellecssbo = $(this).css("border-color");
		$(this).css({ 'background-color':'#ffffff', 'border-color':'#ffffff' });
	},
	function () {
		$(this).css( 'background-color', aktuellecssbg );
		$(this).css( 'border-color', aktuellecssbo );
	}
);




$(".page_display_spezial > ul > li").css({ 'margin': '5px 0 0 0' });
$("#imagerows > tbody > tr > td").css({ 'padding': '0' });
$(".form_main > tbody > tr > td > form, .form_main > tbody > tr > td").css({ 'padding': '0', 'margin': '0' });

}else{

}

if(agentsmithversion=="4"){
	$("#righto").css("width","800px");
	$("#container").css("height", (window.innerHeight-35) + "px");
}else if(agentsmithversion=="3"){
	$("#righto").css("width","800px");
	$("#container").css("height", (window.innerHeight-35) + "px");		
	//$(".page_display > p").css("background-color", "green");
	$(".page_display > p").css("margin-left", "0");
	$(".mitarbeiterinfo > p").css("margin-left", "0");
	$(".meinmein > p").css("margin-left", "0");
	$(".meinhead").css("padding-top", "3px");
	$(".mehr > p").css("margin-left", "0");
	$(".rest > p").css("margin-left", "0");
	$("#eralist").css("margin-left", "2px");
	$("#detailLinks p").css("font:", "13px Helvetica, Arial, Sans-Serif");
	$("#detailLinks p").css("margin", "0 ");
	$("#detailLinks ul li").css("margin", "0 0 5px 0");
	$("#detailLinks > ul > li > strong > .field_caption").css("font", "13px Helvetica, Arial, Sans-Serif");
	$("#detailLinks > ul > li > strong > .field_caption").css("font-weight", "bold");
	$("#detailUnten > p > strong > .field_caption").css("font", "13px Helvetica, Arial, Sans-Serif");
	$("#detailUnten > p > strong > .field_caption").css("font-weight", "bold");

	$(".listleft > ul > li > .field_caption").css("font", "13px Helvetica, Arial, Sans-Serif");
	$(".listright > ul > li > .field_caption").css("font", "13px Helvetica, Arial, Sans-Serif");
	
	
	$("#zurueckbutton").css("margin", "0 0 0 0");
	$("#detailUnten p").css("margin", "0 0 0 0");
	$("#uberbeschreibung p").css("margin-left", "0");
	
	
	
}else{			
}





});