loadplaceholder = "<div style=\"width: 100%; text-align: center;\"><img src=\"images/ajax-loader.gif\" /></div>";

$(document).ready(function() {





	//equalizeHeights()

	//$('#btnCustomer2').live('click', function() {loadCustomer2($(this).attr("parameter"));});
	$('.btnsearch').mouseover(function()
		{
			$(this).css('background-image', 'url("images/searchbg_hover.png")');
			//$(this).css('background-color', '#264460');
			$(this).children("img").attr('src', 'images/button_search_hover.png');
			//$('#'+$(this).attr('imageid')).attr('src', 'images/button_search_hover.png');
		});

	$('.btnsearch').mouseout(function()
		{
		$(this).css('background-image', 'url("images/searchbg.png")');
			//$(this).css('background-color', '#5a7c91');
			//$(this).children("p").children("span").children("img").attr('src', 'images/button_search_default.png');
			//$('#'+$(this).attr('imageid')).attr('src', 'images/button_search_default.png');
			$(this).children("img").attr('src', 'images/button_search_default.png');
		});


	$('.btnhelp').mouseover(function()
			{
				$(this).css('background-image', 'url("images/button_help_small_hover.png")');
			});

	$('.btnhelp').mouseout(function()
			{
				$(this).css('background-image', 'url("images/button_help_small_default.png")');
			});

	$('.btncont').mouseover(function()
			{
				$(this).css('background-image', 'url("images/button_forward_hover.png")');
			});

	$('.btncont').mouseout(function()
			{
				$(this).css('background-image', 'url("images/button_forward_default.png")');
			});

	$('.btnback').mouseover(function()
			{
				$(this).css('background-image', 'url("images/button_back_hover.png")');
			});

	$('.btnback').mouseout(function()
			{
				$(this).css('background-image', 'url("images/button_back_default.png")');
			});

	$('.btnpdf').mouseover(function()
			{
				$(this).css('background-image', 'url("images/button_pdf_hover.png")');
			});

	$('.btnpdf').mouseout(function()
			{
				$(this).css('background-image', 'url("images/button_pdf_default.png")');
			});

	$('.btnrefresh').mouseover(function()
			{
				$(this).css('background-image', 'url("images/button_reload_hover.png")');
			});

	$('.btnrefresh').mouseout(function()
			{
				$(this).css('background-image', 'url("images/button_reload_default.png")');
			});

	$('.btnclosedialog').mouseover(function()
			{
				$(this).css('background-image', 'url("images/button_close_hover.png")');
			});

	$('.btnclosedialog').mouseout(function()
			{
				$(this).css('background-image', 'url("images/button_close_default.png")');
			});

	$('.btnplus').mouseover(function()
			{
				$(this).css('background-image', 'url("images/button_plus_small_hover.png")');
			});

	$('.btnplus').mouseout(function()
			{
				$(this).css('background-image', 'url("images/button_plus_small_default.png")');
			});


	/*
	$('.btncont').live('mouseover mouseout', function(event) {
		  if (event.type == 'mouseover')
		  {
			  $(this).css('background-image', 'url("images/button_forward_hover.png")');
		  } else
		  {
		    // do something on mouseout
			  $(this).css('background-image', 'url("images/button_forward_default.png")');
		  }
		});

	$('.btnback').live('mouseover mouseout', function(event) {
		  if (event.type == 'mouseover')
		  {
			  $(this).css('background-image', 'url("images/button_back_hover.png")');
		  } else
		  {
		    // do something on mouseout
			  $(this).css('background-image', 'url("images/button_back_default.png")');
		  }
		});

	$('.btnpdf').live('mouseover mouseout', function(event) {
		  if (event.type == 'mouseover')
		  {
			  $(this).css('background-image', 'url("images/button_pdf_hover.png")');
		  } else
		  {
		    // do something on mouseout
			  $(this).css('background-image', 'url("images/button_pdf_default.png")');
		  }
		});

	$('.btnrefresh').live('mouseover mouseout', function(event) {
		  if (event.type == 'mouseover')
		  {
			  $(this).css('background-image', 'url("images/button_reload_hover.png")');
		  } else
		  {
		    // do something on mouseout
			  $(this).css('background-image', 'url("images/button_reload_default.png")');
		  }
		});

	$('.btnhelp').live('mouseover mouseout', function(event) {
		  if (event.type == 'mouseover')
		  {
			  $(this).css('background-image', 'url("images/button_help_small_hover.png")');
		  } else
		  {
		    // do something on mouseout
			  $(this).css('background-image', 'url("images/button_help_small_default.png")');
		  }
		});

	$('.btnclosedialog').live('mouseover mouseout', function(event) {
		  if (event.type == 'mouseover')
		  {
			  $(this).css('background-image', 'url("images/button_close_hover.png")');
		  } else
		  {
		    // do something on mouseout
			  $(this).css('background-image', 'url("images/button_close_default.png")');
		  }
		});
	$('.btnplus').live('mouseover mouseout', function(event) {
		  if (event.type == 'mouseover')
		  {
			  $(this).css('background-image', 'url("images/button_plus_small_hover.png")');
		  } else
		  {
		    // do something on mouseout
			  $(this).css('background-image', 'url("images/button_plus_small_default.png")');
		  }
		});
	*/

	//alert("???")


	//CookieWindow
	if($('#acceptCookies').val() == "0" && $('#showCookieWindow').val() == "1")
	{
		//alert("CookieWindow");
		try
		{
			$("#acceptcookiewindow").jqxWindow({
			    height: 250,
			    width: 600,
			   // theme: 'energyblue',
			    position: 'center',
			    closeButtonSize: 20,
			    showCloseButton: false,
			    keyboardNavigation: false,
			    isModal: true,
			    keyboardCloseKey: '',
			    draggable: false,
			    resizable: false,
			    zIndex: 99999,
			    modalZIndex: 99999//,
			    //autoOpen: false
			});
		}
		catch(err)
		{

		}

	}

	try
	{
		/*
		$("#downloaddocumentwindow").jqxWindow({
		    height: 100,
		    width: 600,
		   // theme: 'energyblue',
		    position: 'center',
		    closeButtonSize: 20,
		    showCloseButton: true,
		    keyboardNavigation: false,
		    isModal: false,
		    keyboardCloseKey: '',
		    draggable: false,
		    resizable: false,
		    zIndex: 99999,
		    modalZIndex: 99999,
		    autoOpen: true
		});
		*/
	}
	catch(err)
	{

	}


});

function initPrint()
{
	$('#frmPrintFilterDetail').submit();
}

function equalizeHeights()
{
	/*
	alert($('#contentcontainer').css('height'))
	alert($('#contentcontainer').css('min-height'))

	alert($('#navigationcontainer').css('height'))
	alert($('#navigationcontainer').css('min-height'))
	*/

	/*
	$('#contentcontainer').css('min-height', '');
	$('#navigationcontainer').css('height', '')
	$('#navigationcontainer').css('min-height', '')
	//alert('equalize')

	if($('#contentcontainer').css('height') != $('#contentcontainer').css('min-height'))
		$('#contentcontainer').css('min-height', $('#contentcontainer').css('height'))
	*/


	//$('#equalizer').equalHeights(true);

	//alert($('#contentcontainer').css('height'))
}


function getExpertSearchResult()
{
	initsearch = false;
	qs = "";

	if($("#matnr").attr("value").length > 0)
	{
		qs = "?matnr=" +  $("#matnr").attr("value");
		initsearch = true;
	}
	else if($("#typenr").attr("value").length > 0)
	{
		qs = "?typenr=" +  $("#typenr").attr("value");
		initsearch = true;
	}

	qs = qs + "&id=" + Math.ceil(Math.random()*1000000000)

	if(initsearch)
	{
		$("#divexpertsearchresult").html(loadplaceholder);
		$("#divexpertsearchresult").load("ExpertSearchResult" + encodeURI(qs), "", fadeInSearchResult);

	}
}


function fadeInSearchResult()
{
	$("#expertsearchresult").fadeIn(1000);
}


function selectLanguage(strSprachID)
{
	$.ajax
	(
		{
		  type: "POST",
		  url: "selectlanguage",
		  data: "language=" + strSprachID,
		  success: function()
		  {
			window.location.reload();
		  }
		}
	);
}



function testTextarea()
{
	$.ajax
	(
		{
		  type: "POST",
		  url: "test",
		  data: "ta=" + encodeURI($("#ta").val()),
		  success: function()
		  {
			alert("okay")
		  }
		}
	);

}


function checkForOverhead()
{
	if($("input:radio:checked[name='visko']").val() == "mms")
	{
		if(!$('#vis2').hasClass('trhidden'))
		{
			if($('#txtvisko2').val().length == 0)
			{
				$('#vis2').addClass('trhidden');
				$('#btnShowVis2').css('display', 'inline');
				$('#btnShowVis2').removeAttr('disabled');
			}
		}
		if(!$('#vis3').hasClass('trhidden'))
		{
			if($('#txtvisko3').val().length == 0)
			{
				$('#vis3').addClass('trhidden');
				$('#btnShowVis3').css('display', 'inline');
				$('#btnShowVis3').removeAttr('disabled');
			}
		}
		if(!$('#vis4').hasClass('trhidden'))
		{
			if($('#txtvisko4').val().length == 0)
			{
				$('#vis4').addClass('trhidden');
				$('#btnShowVis4').css('display', 'inline');
				$('#btnShowVis4').removeAttr('disabled');
			}
		}
		if(!$('#vis5').hasClass('trhidden'))
		{
			if($('#txtvisko5').val().length == 0)
			{
				$('#vis5').addClass('trhidden');
				$('#btnShowVis5').css('display', 'inline');
				$('#btnShowVis5').removeAttr('disabled');
			}
		}

	}
	else if($("input:radio:checked[name='visko']").val() == "med")
	{
		if(!$('#temp2').hasClass('trhidden'))
		{
			if($('#txtvisktemp2').val().length == 0)
			{
				$('#temp2').addClass('trhidden');
				$('#btnShowTemp2').css('display', 'inline');
				$('#btnShowTemp2').removeAttr('disabled');
			}
		}
		if(!$('#temp3').hasClass('trhidden'))
		{
			if($('#txtvisktemp3').val().length == 0)
			{
				$('#temp3').addClass('trhidden');
				$('#btnShowTemp3').css('display', 'inline');
				$('#btnShowTemp3').removeAttr('disabled');
			}
		}
		if(!$('#temp4').hasClass('trhidden'))
		{
			if($('#txtvisktemp4').val().length == 0)
			{
				$('#temp4').addClass('trhidden');
				$('#btnShowTemp4').css('display', 'inline');
				$('#btnShowTemp4').removeAttr('disabled');
			}
		}
		if(!$('#temp5').hasClass('trhidden'))
		{
			if($('#txtvisktemp5').val().length == 0)
			{
				$('#temp5').addClass('trhidden');
				$('#btnShowTemp5').css('display', 'inline');
				$('#btnShowTemp5').removeAttr('disabled');
			}
		}
	}
	else if($("input:radio:checked[name='visko']").val() == "dyn")
	{
		if(!$('#dynvisk2').hasClass('trhidden'))
		{
			if($('#txtviskdyn2').val().length == 0)
			{
				$('#dynvisk2').addClass('trhidden');
				$('#btnShowDynVisk2').css('display', 'inline');
				$('#btnShowDynVisk2').removeAttr('disabled');
			}
		}
		if(!$('#dynvisk3').hasClass('trhidden'))
		{
			if($('#txtviskdyn3').val().length == 0)
			{
				$('#dynvisk3').addClass('trhidden');
				$('#btnShowDynVisk3').css('display', 'inline');
				$('#btnShowDynVisk3').removeAttr('disabled');
			}
		}
		if(!$('#dynvisk4').hasClass('trhidden'))
		{
			if($('#txtviskdyn4').val().length == 0)
			{
				$('#dynvisk4').addClass('trhidden');
				$('#btnShowDynVisk4').css('display', 'inline');
				$('#btnShowDynVisk4').removeAttr('disabled');
			}
		}
		if(!$('#dynvisk5').hasClass('trhidden'))
		{
			if($('#txtviskdyn5').val().length == 0)
			{
				$('#dynvisk5').addClass('trhidden');
				$('#btnShowDynVisk5').css('display', 'inline');
				$('#btnShowDynVisk5').removeAttr('disabled');
			}
		}
	}

}

function initDiagramm(feid)
{
	$('#hddfeid').val(feid);
	loadSearchDiagramms();
	copyViskToDiagramm();
}

function loadSearchDiagramms()
{
	//if($("input:radio:checked[name='rbfeid']").val().length > 0)
	if($('#hddfeid').val().length > 0)
	{
		//feid = $("input:radio:checked[name='rbfeid']").val();
		var feid = $('#hddfeid').val()
		var vis1 = "";
		var vis2 = "";
		var vis3 = "";
		var vis4 = "";
		var vis5 = "";
		var maid = "";
		var temp1 = "";
		var temp2 = "";
		var temp3 = "";
		var temp4 = "";
		var temp5 = "";
		var mode = "";
		var arr = new Array();


		//var strvolstrom = $("#lmin").val()
		var strvolstrom = $("#volstrom").val();
		var strvoleinheit = $("#voleinheit").val();

		if(strvolstrom.length > 0)
		{
			if($("#mms:checked").val() == "mms")
			{
				if($("#txtvisko").val().length > 0)
				{
					arr.push($("#txtvisko").val())

					if($("#txtvisko2").val().length > 0)
						arr.push($("#txtvisko2").val())

					if($("#txtvisko3").val().length > 0)
						arr.push($("#txtvisko3").val())

					if($("#txtvisko4").val().length > 0)
						arr.push($("#txtvisko4").val())

					if($("#txtvisko5").val().length > 0)
						arr.push($("#txtvisko5").val())

					//arr.sort(function(a,b){return b - a})
					while(arr.length < 5)
					{
						arr.push("")
					}
					vis1 = arr[0];
					vis2 = arr[1];
					vis3 = arr[2];
					vis4 = arr[3];
					vis5 = arr[4];


					mode = "mms"

					/*
					if(bool)
					{
						$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + '&visk=' + $("#txtvisko").val() + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramm)
						loadDiagrammDetail(false);
					}
					else
						$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + '&visk=' + $("#txtvisko").val() + "&id=" + Math.ceil(Math.random()*1000000000))
					*/
					$("#pictureframe").load("SearchGraphs", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + "&voleinheit=" + strvoleinheit + '&visk=' + $("#txtvisko").val() + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramme)
				}
				else
					$("#txtvisko").focus();
			}
			else if($("#med:checked").val() == "med")
			{
				if($("#maid").val() != "-1")
				{
					maid = $("#maid").val();

					if($("#txttempmedcel1").val().length > 0)
					{
						arr.push($("#txttempmedcel1").val())

						if($("#txttempmedcel2").val().length > 0)
							arr.push($("#txttempmedcel2").val())

						if($("#txttempmedcel3").val().length > 0)
							arr.push($("#txttempmedcel3").val())

						if($("#txttempmedcel4").val().length > 0)
							arr.push($("#txttempmedcel4").val())

						if($("#txttempmedcel5").val().length > 0)
							arr.push($("#txttempmedcel5").val())

						//arr.sort(function(a,b){return b - a})
						while(arr.length < 5)
						{
							arr.push("")
						}
						temp1 = arr[0];
						temp2 = arr[1];
						temp3 = arr[2];
						temp4 = arr[3];
						temp5 = arr[4];


						mode = "med"

						/*
						if(bool)
						{
							$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&maid=" + maid + "&temp1=" + temp1 + "&temp2=" + temp2 + "&temp3=" + temp3 + "&temp4=" + temp4 + "&temp5=" + temp5 + "&volstrom=" + strvolstrom + '&temp=' + $("#txttempmedcel1").val() + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramm)
							loadDiagrammDetail(false);
						}
						else
							$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&maid=" + maid + "&temp1=" + temp1 + "&temp2=" + temp2 + "&temp3=" + temp3 + "&temp4=" + temp4 + "&temp5=" + temp5 + "&volstrom=" + strvolstrom + '&temp=' + $("#txttempmedcel1").val() + "&id=" + Math.ceil(Math.random()*1000000000))
						*/
						$("#pictureframe").load("SearchGraphs", "mode=" + mode + "&feid=" + feid + "&maid=" + maid + "&temp1=" + temp1 + "&temp2=" + temp2 + "&temp3=" + temp3 + "&temp4=" + temp4 + "&temp5=" + temp5 + "&volstrom=" + strvolstrom + "&voleinheit=" + strvoleinheit + '&temp=' + $("#txttempmedcel1").val() + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramme)
					}
					else
						$("#txttempmedcel1").focus();
				}
				else
					$("#maid").focus();
			}
			else if($("#dyn:checked").val() == "dyn")
			{
				mode = "dyn"
				if($("#txtdynvisko").val().length > 0)
				{
					if($("#txtdichte").val().length > 0)
					{
						arr.push(runden($("#txtdynvisko").val() / $("#txtdichte").val(), 2))

						if($("#txtdynvisko2").val().length && $("#txtdichte2").val().length)
							arr.push(runden($("#txtdynvisko2").val() / $("#txtdichte2").val(), 2))

						if($("#txtdynvisko3").val().length && $("#txtdichte3").val().length)
							arr.push(runden($("#txtdynvisko3").val() / $("#txtdichte3").val(), 2))

						if($("#txtdynvisko4").val().length && $("#txtdichte4").val().length)
							arr.push(runden($("#txtdynvisko4").val() / $("#txtdichte4").val(), 2))

						if($("#txtdynvisko5").val().length && $("#txtdichte5").val().length)
							arr.push(runden($("#txtdynvisko5").val() / $("#txtdichte5").val(), 2))

						//arr.sort(function(a,b){return b - a})
						while(arr.length < 5)
						{
							arr.push("")
						}
						vis1 = arr[0];
						vis2 = arr[1];
						vis3 = arr[2];
						vis4 = arr[3];
						vis5 = arr[4];

						/*
						if(bool)
						{
							//$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&txtdynvisko=" + $("#txtdynvisko").val() + "&txtdichte=" + $("#txtdichte").val() + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramm)
							$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramm)
							loadDiagrammDetail(false);

						}
						else
						{
							//$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&txtdynvisko=" + $("#txtdynvisko").val() + "&txtdichte=" + $("#txtdichte").val() + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000))
							$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000))
						}
						*/
						$("#pictureframe").load("SearchGraphs", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + "&voleinheit=" + strvoleinheit + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramme);
					}
					else
						$("#txtdichte").focus();
				}
				else
					$("#txtdynvisko").focus();
			}
		}
		else
			$("#volstrom").focus();
	}
}


function afterLoadDiagramme()
{
	$("#filtereinheitsearchdiv").fadeOut(100);
	$("#diagrammdiv").fadeIn(100);
	initTabs();

}


/*
function loadDiagramm(bool)
{
	if($("input:radio:checked[name='rbfeid']").val().length > 0)
	{
		feid = $("input:radio:checked[name='rbfeid']").val();
		vis1 = "";
		vis2 = "";
		vis3 = "";
		vis4 = "";
		vis5 = "";
		maid = "";
		temp1 = "";
		temp2 = "";
		temp3 = "";
		temp4 = "";
		temp5 = "";
		mode = "";
		arr = new Array();


		strvolstrom = $("#lmin").val()

		if(strvolstrom.length > 0)
		{
			if($("#mms:checked").val() == "mms")
			{
				if($("#txtvisko").val().length > 0)
				{
					arr.push($("#txtvisko").val())

					if($("#txtvisko2").val().length > 0)
						arr.push($("#txtvisko2").val())

					if($("#txtvisko3").val().length > 0)
						arr.push($("#txtvisko3").val())

					if($("#txtvisko4").val().length > 0)
						arr.push($("#txtvisko4").val())

					if($("#txtvisko5").val().length > 0)
						arr.push($("#txtvisko5").val())

					arr.sort(function(a,b){return b - a})
					while(arr.length < 5)
					{
						arr.push("")
					}
					vis1 = arr[0];
					vis2 = arr[1];
					vis3 = arr[2];
					vis4 = arr[3];
					vis5 = arr[4];


					mode = "mms"

					if(bool)
					{
						$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + '&visk=' + $("#txtvisko").val() + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramm)
						loadDiagrammDetail(false);
					}
					else
						$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + '&visk=' + $("#txtvisko").val() + "&id=" + Math.ceil(Math.random()*1000000000))
				}
				else
					$("#txtvisko").focus();
			}
			else if($("#med:checked").val() == "med")
			{
				if($("#maid").val() != "-1")
				{
					maid = $("#maid").val();

					if($("#txttempmedcel1").val().length > 0)
					{
						arr.push($("#txttempmedcel1").val())

						if($("#txttempmedcel2").val().length > 0)
							arr.push($("#txttempmedcel2").val())

						if($("#txttempmedcel3").val().length > 0)
							arr.push($("#txttempmedcel3").val())

						if($("#txttempmedcel4").val().length > 0)
							arr.push($("#txttempmedcel4").val())

						if($("#txttempmedcel5").val().length > 0)
							arr.push($("#txttempmedcel5").val())

						arr.sort(function(a,b){return b - a})
						while(arr.length < 5)
						{
							arr.push("")
						}
						temp1 = arr[0];
						temp2 = arr[1];
						temp3 = arr[2];
						temp4 = arr[3];
						temp5 = arr[4];


						mode = "med"

						if(bool)
						{
							$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&maid=" + maid + "&temp1=" + temp1 + "&temp2=" + temp2 + "&temp3=" + temp3 + "&temp4=" + temp4 + "&temp5=" + temp5 + "&volstrom=" + strvolstrom + '&temp=' + $("#txttempmedcel1").val() + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramm)
							loadDiagrammDetail(false);
						}
						else
							$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&maid=" + maid + "&temp1=" + temp1 + "&temp2=" + temp2 + "&temp3=" + temp3 + "&temp4=" + temp4 + "&temp5=" + temp5 + "&volstrom=" + strvolstrom + '&temp=' + $("#txttempmedcel1").val() + "&id=" + Math.ceil(Math.random()*1000000000))
					}
					else
						$("#txttempmedcel1").focus();
				}
				else
					$("#maid").focus();
			}
			else if($("#dyn:checked").val() == "dyn")
			{
				mode = "dyn"
				if($("#txtdynvisko").val().length > 0)
				{
					if($("#txtdichte").val().length > 0)
					{
						arr.push(runden($("#txtdynvisko").val() / $("#txtdichte").val(), 2))

						if($("#txtdynvisko2").val().length && $("#txtdichte2").val().length)
							arr.push(runden($("#txtdynvisko2").val() / $("#txtdichte2").val(), 2))

						if($("#txtdynvisko3").val().length && $("#txtdichte3").val().length)
							arr.push(runden($("#txtdynvisko3").val() / $("#txtdichte3").val(), 2))

						if($("#txtdynvisko4").val().length && $("#txtdichte4").val().length)
							arr.push(runden($("#txtdynvisko4").val() / $("#txtdichte4").val(), 2))

						if($("#txtdynvisko5").val().length && $("#txtdichte5").val().length)
							arr.push(runden($("#txtdynvisko5").val() / $("#txtdichte5").val(), 2))

						arr.sort(function(a,b){return b - a})
						while(arr.length < 5)
						{
							arr.push("")
						}
						vis1 = arr[0];
						vis2 = arr[1];
						vis3 = arr[2];
						vis4 = arr[3];
						vis5 = arr[4];

						if(bool)
						{
							//$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&txtdynvisko=" + $("#txtdynvisko").val() + "&txtdichte=" + $("#txtdichte").val() + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramm)
							$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagramm)
							loadDiagrammDetail(false);

						}
						else
						{
							//$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&txtdynvisko=" + $("#txtdynvisko").val() + "&txtdichte=" + $("#txtdichte").val() + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000))
							$("#diagramm").load("diagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis1=" + vis1 + "&vis2=" + vis2 + "&vis3=" + vis3 + "&vis4=" + vis4 + "&vis5=" + vis5 + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000))
						}
					}
					else
						$("#txtdichte").focus();
				}
				else
					$("#txtdynvisko").focus();
			}
		}
		else
			$("#lmin").focus();
	}
}


function afterLoadDiagramm()
{
	$("#filtereinheitsearchdiv").fadeOut(100, fadeInDiagramm);
	$("#diagrammdetail").fadeOut(100);
}
*/

function fadeInDiagramm()
{
	$("#diagrammdiv").fadeIn(100);
	$("#diagramm").fadeIn(100);
}

function openFiltereinheitSearchFromDiagram()
{
	$("#diagrammdiv").fadeOut(100, afterOpenFiltereinheitSearchFromDiagram);
}

function afterOpenFiltereinheitSearchFromDiagram()
{
	$("#filtereinheitsearchdiv").fadeIn(100);
}


/*
function loadDiagrammDetail(bool)
{
	if($("input:radio:checked[name='rbfeid']").val().length > 0)
	{
		feid = $("input:radio:checked[name='rbfeid']").val();
		maid = "";
		temp1 = "";
		mode = "";


		strvolstrom = $("#lmin").val()

		if(strvolstrom.length > 0)
		{
			if($("#mms:checked").val() == "mms")
			{
				if($("#txtvisko").val().length > 0)
				{
					vis1 = $("#txtvisko").val()

					mode = "mms"

					if(bool)
					{
						$("#diagrammdetail").load("detaildiagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis=" + vis1 + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagrammDetail)
						loadDiagramm(false);
					}
					else
						$("#diagrammdetail").load("detaildiagramm.jsp", "mode=" + mode + "&feid=" + feid + "&vis=" + vis1 + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000))
				}
				else
					$("#txtvisko").focus();
			}
			else if($("#med:checked").val() == "med")
			{
				if($("#maid").val() != "-1")
				{
					maid = $("#maid").val();

					if($("#txttempmedcel1").val().length > 0)
					{
						temp1 = $("#txttempmedcel1").val();

						mode = "med"

						if(bool)
						{
							$("#diagrammdetail").load("detaildiagramm.jsp", "mode=" + mode + "&feid=" + feid + "&maid=" + maid + "&temp=" + temp1 + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagrammDetail)
							loadDiagramm(false);
						}
						else
							$("#diagrammdetail").load("detaildiagramm.jsp", "mode=" + mode + "&feid=" + feid + "&maid=" + maid + "&temp=" + temp1 + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000))
					}
					else
						$("#txttempmedcel1").focus();
				}
				else
					$("#maid").focus();
			}
			else if($("#dyn:checked").val() == "dyn")
			{
				mode = "dyn"
				if($("#txtdynvisko").val().length > 0)
				{
					if($("#txtdichte").val().length > 0)
					{
						if(bool)
						{
							$("#diagrammdetail").load("detaildiagramm.jsp", "mode=" + mode + "&feid=" + feid + "&txtdynvisko=" + $("#txtdynvisko").val() + "&txtdichte=" + $("#txtdichte").val() + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadDiagrammDetail)
							loadDiagramm(false);
						}
						else
							$("#diagrammdetail").load("detaildiagramm.jsp", "mode=" + mode + "&feid=" + feid + "&txtdynvisko=" + $("#txtdynvisko").val() + "&txtdichte=" + $("#txtdichte").val() + "&volstrom=" + strvolstrom + "&id=" + Math.ceil(Math.random()*1000000000))
					}
					else
						$("#txtdichte").focus();
				}
				else
					$("#txtdynvisko").focus();
			}
		}
		else
			$("#lmin").focus();
	}
}



function afterLoadDiagrammDetail()
{
	$("#filtereinheitsearchdiv").fadeOut(100, fadeInDiagrammDetail);
	$("#diagramm").fadeOut(100);
}


function fadeInDiagrammDetail()
{
	$("#diagrammdiv").fadeIn(100);
	$("#diagrammdetail").fadeIn(100);
}
*/


function openFiltereinheitSearchFromDiagramDetail()
{
	$("#diagrammdetaildiv").fadeOut(100, afterOpenFiltereinheitSearchFromDiagramDetail);
}

function afterOpenFiltereinheitSearchFromDiagramDetail()
{
	$("#filtereinheitsearchdiv").fadeIn(100);
}

function clearMenu(id)
{
	$('#' + id)
    .find('option')
    .remove()
    .end()
    //.append('<option value="-1">' + $('#hdd_choose').val() + '</option>')
    .val('-1')
    .attr('disabled', 'disabled');
;

	$('#' + id)[0].options.add( new Option($('#hdd_choose').val(),'-1') )
}



function changeAnwendung(comboawid)
{
	if(comboawid.options[0].value == -1)
		comboawid.options[0] = null;

	//$("#pkidcontainer").html("&nbsp;")
	$("#pkidcontainer").load("loadproduktkategorie?awid=" + comboawid.value + "&id=" + Math.ceil(Math.random()*1000000000));
	clearMenu('df');
	clearMenu('dsid');
	clearMenu('fmid');
	hideHinweis();
	clearMenu('ffid');
	//$("#searchdetailscontainer").css("display", "none");
	$('.able2disable').attr('disabled', 'disabled');
	//$('.btnshow').attr('disabled', 'disabled');
	$("#searchresult").css("display", "none");
	$("#divviskosearch2").css("display", "none");

	$('.pflichtfeld').removeClass("pflichtfeld");

	/*
	alert('???');
	$('.btnshow').each(function(index) {
	    alert(index + ': ' + $(this).attr('id'));
	});
	*/


}

function changeProduktKategorie(combopkid)
{
	if(combopkid.options[0].value == -1)
		combopkid.options[0] = null;

	//$("#dfcontainer").html("&nbsp;");
	$("#dfcontainer").load("loaddoppelfilter", "pkid=" + $("#pkid").val() + "&id=" + Math.ceil(Math.random()*1000000000), checkAfterDoppelFilterLoad);

	$("#dfdiv").css("display", "inline");
	clearMenu('dsid');
	clearMenu('fmid');
	hideHinweis();
	clearMenu('ffid');
	//$("#searchdetailscontainer").css("display", "none");
	$('.able2disable').attr('disabled', 'disabled');
	//$('.btnshow').attr('disabled', 'disabled');
	$("#searchresult").css("display", "none");
	$("#divviskosearch2").css("display", "none");
	$('.pflichtfeld').removeClass("pflichtfeld");
}

function checkAfterDoppelFilterLoad()
{
	combodf = window.document.getElementById("df")
	if(combodf.options[0].value != -1)
		changeDoppelFilter(combodf)
}

function changeDoppelFilter(combodf)
{
	if(combodf.options[0].value == -1)
		combodf.options[0] = null;

	//$("#dsidcontainer").html("&nbsp;")
	$("#dsidcontainer").load("loaddruckstufe?pkid=" + $("#pkid").val() + "&df=" + combodf.value + "&id=" + Math.ceil(Math.random()*1000000000))
	$("#dsiddiv").css("display", "inline");
	clearMenu('fmid');
	hideHinweis();
	clearMenu('ffid');
	//$("#searchdetailscontainer").css("display", "none");
	$('.able2disable').attr('disabled', 'disabled');
	//$('.btnshow').attr('disabled', 'disabled');
	$("#searchresult").css("display", "none");
	$("#divviskosearch2").css("display", "none");
	$('.pflichtfeld').removeClass("pflichtfeld");
}

function changeDruckstufe(combodsid)
{
	if(combodsid.options[0].value == -1)
		combodsid.options[0] = null;

	//$("#fmidcontainer").html("&nbsp;")
	$("#fmidcontainer").load("loadmaterial?dsid=" + combodsid.value + "&pkid=" + $("#pkid").val() + "&df=" + $("#df").val() + "&id=" + Math.ceil(Math.random()*1000000000), "", updateDruckAbfall)
	$("#fmiddiv").css("display", "inline");
	hideHinweis();
	clearMenu('ffid');
	//$("#searchdetailscontainer").css("display", "none");
	$('.able2disable').attr('disabled', 'disabled');
	//$('.btnshow').attr('disabled', 'disabled');
	$("#searchresult").css("display", "none");
	$("#divviskosearch2").css("display", "none");
	$('.pflichtfeld').removeClass("pflichtfeld");
}

function updateDruckAbfall()
{
	druckabfall = $("#hdd_vorschlagdifferenzdruck").val().replace(/,/g, ".");
	$("#txtdruck").val(druckabfall)

}


function changeFiltermaterial(combofmid)
{
	if(combofmid.options[0].value == -1)
		combofmid.options[0] = null;

	$("#ffidcontainer").html("&nbsp;");
	$("#ffidcontainer").load("loadfeinheit?fmid=" + combofmid.value + "&dsid=" + $("#dsid").val() + "&pkid=" + $("#pkid").val() + "&df=" + $("#df").val() + "&id=" + Math.ceil(Math.random()*1000000000));
	$("#ffiddiv").css("display", "inline");
	//$("#searchdetailscontainer").css("display", "none");
	$('.able2disable').attr('disabled', 'disabled');
	//$('.btnshow').attr('disabled', 'disabled');
	$("#searchresult").css("display", "none");
	$("#divviskosearch2").css("display", "none");
	$('.pflichtfeld').removeClass("pflichtfeld");


//	TODO: Ermitteln für welche Materialien Hinweis angezeigt werden soll
	var fm = $('#fm').val();
	var fmarr = fm.split(",");

	//if(combofmid.value == "1")
	if(fmarr.indexOf(combofmid.value) != -1)
	{
		//console.log("fmhinweis");
		$('#fmhinweis').css("display", "block");
	}
	else
		hideHinweis();
}


function changeFeinheit(comboffid)
{
	if(comboffid.options[0].value == -1)
		comboffid.options[0] = null;

	$("#ddstidspan").html("&nbsp;")
	$("#ddstidspan").load("loaddifferenzdruck?fmid=" + $("#fmid").val() + "&dsid=" + $("#dsid").val() + "&pkid=" + $("#pkid").val() + "&df=" + $("#df").val() + "&ffid=" + comboffid.value + "&id=" + Math.ceil(Math.random()*1000000000), equalizeHeights)

	$("#searchdetailscontainer").css("display", "inline");
	//$("#lmin").focus();

	$("#searchresult").css("display", "none");
	$("#divviskosearch2").css("display", "none");
	$('.able2disable').removeAttr('disabled');
	$('.btnshow').attr('disabled', 'disabled');
	$("#volstrom").focus();
	checkShowButton('btnShowVis2', window.document.getElementById('txtvisko'));

	$('.pflichtfeld2').addClass("pflichtfeld");
}


function runden(zahl, stellen)
{
	zahl = String(zahl);
	zahl = zahl.replace(/,/g, ".");
	zahl = zahl.replace(/ /g, "");
	if(!isNaN(zahl) && !isNaN(stellen))
	{
		str1 = ".";
		str2 = "";
		for(i=0;i<stellen;i++)
		{
			str1 += '0';
			str2 += '0';
		}
		tmp = Math.pow(10, stellen);
		var k = (Math.round(zahl * tmp) / tmp).toString();
		if(k.indexOf('.') != -1)
		{
			k+= str2;
			ende = Number(k.indexOf('.')) + Number(stellen) + Number(1);
			k = k.substring(0, ende)
		}
		else
		{
			//k += '.00'
		}
	}
	return k;
}


function checkNumber(tf)
{
	zahl = tf.value
	zahl = zahl.replace(/,/g, ".");
	zahl = zahl.replace(/ /g, "");
	if(isNaN(zahl))
		zahl = "";
	tf.value = zahl
}

function checkFullNumber(tf)
{
	if(tf.value.length > 0)
	{
		reg = /(^[-]{0,1}[0-9]*$)/
		if(!reg.test(tf.value))
		{
			tf.value="";
		}
	}
}



function checkTemperatureInputCelsius(tf)
{

	zahl = tf.value
	zahl = zahl.replace(/,/g, ".");
	zahl = zahl.replace(/ /g, "");
	if(isNaN(zahl))
	{
		if(zahl != "-")
			zahl = "";
		else
			zahl = Math.round(zahl)
	}
	else
	{
		if(zahl < -50 || zahl > 360)
		{
			alert($("#hdd_err_celsius").val())
			zahl = "";
		}
	}
	tf.value = zahl

}


function checkTemperatureInputFahrenheit(tf)
{

	zahl = tf.value
	zahl = zahl.replace(/,/g, ".");
	zahl = zahl.replace(/ /g, "");
	if(isNaN(zahl))
	{
		if(zahl != "-")
			zahl = "";
		else
			zahl = Math.round(zahl)
	}
	else
	{
		if(zahl < -58 || zahl > 680)
		{
			alert($("#hdd_err_fahrenh").val())
			zahl = "";
		}
	}
	tf.value = zahl

}


function syncLiterToGal()
{

	zahl = $("#lmin").val()
	zahl = zahl.replace(/,/g, ".");
	zahl = zahl.replace(/ /g, "");
	if(isNaN(zahl))
		zahl = "";
	else
		zahl = Math.round(zahl)
	zahl = zahl + "";
	$("#lmin").val(zahl)
	if(zahl.length > 0)
	{
		//$("#galmin").val(runden(Number(zahl)*0.26417, 0))
		$("#galmin").val(Math.round((Number(zahl)*0.26417)))
	}
	else
		$("#galmin").val('')

}

function syncGalToLiter()
{

	zahl = $("#galmin").val()
	zahl = zahl.replace(/,/g, ".");
	zahl = zahl.replace(/ /g, "");
	if(isNaN(zahl))
		zahl = "";
	else
		zahl = Math.round(zahl)
	zahl = zahl + "";
	$("#galmin").val(zahl)

	if(zahl.length > 0)
	{
		//$("#lmin").val(runden(Number(zahl)*3.7854, 0))
		$("#lmin").val(Math.round((Number(zahl)*3.7854)))
	}
	else
		$("#lmin").val('')

}

function syncCelciusToFahrenheit(index)
{

	zahl = $("#txttempmedcel" + index).val();
	zahl = zahl.replace(/,/g, ".");
	zahl = zahl.replace(/ /g, "");
	if(isNaN(zahl) && zahl != "-")
		zahl = "";
	else if(zahl != "-")
	{
		zahl = Math.round(zahl)
		zahl = zahl + "";
	}
	$("#txttempmedcel" + index).val(zahl);

	if(zahl == "-")
	{
		$("#txttempmedfahr" + index).val('')
	}
	else
	{
		if(zahl.length > 0)
		{
			//$("#txttempmedfahr" + index).val(runden(Number(zahl)*1.8 + 32, 2))
			$("#txttempmedfahr" + index).val(Math.round((Number(zahl)*1.8 + 32)))
		}
		else
			$("#txttempmedfahr" + index).val('')

	}
	loadTempKinVisk(index);

}

function syncFahrenheitToCelcius(index)
{

	zahl = $("#txttempmedfahr" + index).val();
	zahl = zahl.replace(/,/g, ".");
	zahl = zahl.replace(/ /g, "");
	if(isNaN(zahl) && zahl != "-")
		zahl = "";
	else if(zahl != "-")
	{
		zahl = Math.round(zahl)
		zahl = zahl + "";
	}
	$("#txttempmedfahr" + index).val(zahl);

	if(zahl == "-")
	{
		$("#txttempmedcel" + index).val('')
	}
	else
	{
		if(zahl.length > 0)
		{
			//$("#txttempmedcel" + index).val(runden((Number(zahl)-32) * (5/9), 2))
			$("#txttempmedcel" + index).val(Math.round((Number(zahl)-32) * (5/9)))
		}
		else
			$("#txttempmedcel" + index).val('')
	}

	loadTempKinVisk(index);

}

function hideSearchResult()
{
	//alert("!");
	bRet = true;

	//if($("#lmin").val().length == 0)
	if($("#volstrom").val().length == 0)
	{
		$("#volstrom").focus()
		bRet = false;
	}
	else
	{
		var volstrom = $("#volstrom").val();
		//TODO:
		volstrom = volstrom.replace(",", ".");
		if(isNaN(parseFloat(volstrom)))
		{
			$("#volstrom").focus()
			bRet = false;
		}
	}

	if(bRet && $("#mms:checked").val() == "mms")
	{
		if($("#txtvisko").val().length == 0)
		{
			$("#txtvisko").focus()
			bRet = false;
		}
	}

	if(bRet && $("#med:checked").val() == "med")
	{
		if($("#maid").val() == "-1")
		{
			$("#maid").focus();
			bRet = false;
		}

		if(bRet && $("#txttempmedcel1").val().length == 0)
		{
			$("#txttempmedcel1").focus()
			bRet = false;
		}
	}

	if(bRet && $("#dyn:checked").val() == "dyn")
	{
		if($("#txtdynvisko").val().length == 0)
		{
			$("#txtdynvisko").focus()
			bRet = false;
		}

		if(bRet && $("#txtdichte").val().length == 0)
		{
			$("#txtdichte").focus()
			bRet = false;
		}

	}

	if(bRet && $("#txtdruck").val().length == 0)
	{
		$("#txtdruck").focus()
		bRet = false;
	}

	if(bRet)
	{
		$("#searchresult").css("display", "inline");
		$("#searchresult").html(loadplaceholder);
		$("#divviskosearch2").css("display", "inline");
	}

	return bRet;

}


function calcKinViskfromDynVisk(index, btnid)
{
	if($('#txtdynvisko' + index).val().length > 0 && $('#txtdichte' + index).val().length > 0)
	{
		if($('#txtdichte' + index).val() != "0" &&  $('#txtdichte' + index).val() != "0." &&  $('#txtdichte' + index).val() != "0,")
		{
			//$('#txtviskdyn' + index).val(runden($("#txtdynvisko" + index).val() / $("#txtdichte" + index).val(), 4))
			kinvisk = runden($("#txtdynvisko" + index).val() / $("#txtdichte" + index).val(), 0);
			if(!isNaN(kinvisk))
				$('#txtviskdyn' + index).val(kinvisk);

			//$('#txtviskdyn' + index).val(runden($("#txtdynvisko" + index).val() / $("#txtdichte" + index).val(), 0))
		}
		else
		{
			$('#txtviskdyn' + index).val('')
		}
	}
	else
	{
		$('#txtviskdyn' + index).val('')
	}

	if(btnid != '')
	{
		checkShowButton(btnid, window.document.getElementById('txtviskdyn' + index));
	}

}

function showSearchResult()
{
	if($("#hddanzahl").val() != "0")
	{
		$("#tblsearchresult").fadeIn(1000);
		//$("#volstrom").val("");
		//$("#volstromdetail").val("");
		//$("#rbfeid").focus();

		//Druckstufe geändert?
		if($("#hdddsidchange").val() == "1")
		{
			alert($('#hdd_andere_druckstufe').val() + " " + $("#hdddsidval").val())
		}
	}
	else
	{
		alert($("#HDD_ERR_NOTFOUND").val());
	}

	equalizeHeights();

}

function clickRadioButton(objRB)
{
	if(objRB.value != $('#rbselected').val())
	{
		//$('#topcontentcontact').html($('#rbselected').val() + ' ' +  id)
		$('#rbselected').val(objRB.value)
		$(".formlabelfieldselector").css("background-color", "white");
		//$("#" + objRB.id).parent().parent().parent().parent().parent().css("background-color", "#DFE9F4")
		//div = getParentByAttributeValue(objRB, "class", "formlabelfieldselector");


		div = getParentByAttributeValue(objRB, "class", "formlabelfieldselector");
		if(div == null)
			div = getParentByAttributeValue(objRB, "className", "formlabelfieldselector");

		$('.viskopflichtfeldmms').removeClass('pflichtfeld');
		$('.viskopflichtfeldmed').removeClass('pflichtfeld');
		$('.viskopflichtfelddyn').removeClass('pflichtfeld');

		$('.viskopflichtfeld' + objRB.value).addClass('pflichtfeld');

		if(div != null)
			div.style.backgroundColor = '#ebebeb';

			//div.style.backgroundColor = '#DFE9F4';

		resetEntries(objRB.value)
	}
}

function resetEntries(id)
{
		if(id == "mms")
		{
			resetEntriesmed();
			resetEntriesdyn();
		}
		else if(id == "med")
		{
			resetEntriesmms();
			resetEntriesdyn();
		}
		else if(id == "dyn")
		{
			resetEntriesmms();
			resetEntriesmed();
		}
}

function resetEntriesmms()
{
	$('#txtvisko').val('')
	$('#txtvisko2').val('')
	$('#txtvisko3').val('')
	$('#txtvisko4').val('')
	$('#txtvisko5').val('')
	$('.tr2hidevis').addClass('trhidden');
	$('.btnshowvis').css('display', 'inline');
	$('.btnshowvis').attr('disabled', 'disabled');
}

function resetEntriesmed()
{
	$('#txttempmedcel1').val('')
	$('#txttempmedfahr1').val('')
	$('#txtvisktemp1').val('')
	$('#txttempmedcel2').val('')
	$('#txttempmedfahr2').val('')
	$('#txtvisktemp2').val('')
	$('#txttempmedcel3').val('')
	$('#txttempmedfahr3').val('')
	$('#txtvisktemp3').val('')
	$('#txttempmedcel4').val('')
	$('#txttempmedfahr4').val('')
	$('#txtvisktemp4').val('')
	$('#txttempmedcel5').val('')
	$('#txttempmedfahr5').val('')
	$('#txtvisktemp5').val('')
	$('.tr2hidetemp').addClass('trhidden');
	$('.btnshowtemp').css('display', 'inline');
	$('.btnshowtemp').attr('disabled', 'disabled');
}


function resetEntriesdyn()
{
	$('#txtdynvisko').val('')
	$('#txtdichte').val('')
	$('#txtviskdyn').val('')
	$('#txtdynvisko2').val('')
	$('#txtdichte2').val('')
	$('#txtviskdyn2').val('')
	$('#txtdynvisko3').val('')
	$('#txtdichte3').val('')
	$('#txtviskdyn3').val('')
	$('#txtdynvisko4').val('')
	$('#txtdichte4').val('')
	$('#txtviskdyn4').val('')
	$('#txtdynvisko5').val('')
	$('#txtdichte5').val('')
	$('#txtviskdyn5').val('')
	$('.tr2hidedynvisk').addClass('trhidden');
	$('.btnshowdynvisk').css('display', 'inline');
	$('.btnshowdynvisk').attr('disabled', 'disabled');

}

function checkShowButton(id, tf)
{
	if(tf.value.length > 0)
		$('#' + id).removeAttr('disabled')
	else
		$('#' + id).attr('disabled', 'disabled')
}


function initClickRadioButton(id)
{
	if($('#rbselected').val() != id)
	{
		//window.status = $('#rbselected').val() + ' ' +  id;
		$('#topcontentcontact').html($('#rbselected').val() + ' ' +  id)

		window.document.getElementById("mms").checked = false;
		window.document.getElementById("med").checked = false;
		window.document.getElementById("dyn").checked = false;
		window.document.getElementById(id).checked = true;
		clickRadioButton(window.document.getElementById(id))
	}
}


function evalFilterSearchResult()
{
	/*
	if($('#hdd_filtersearch_count').val() == "0")
	{
		alert($('#hdd_filter_kontakt').val())
	}
	*/

	$('#hdd_submitted_before').val("1")
}

function submitFilterSearch()
{
	if($('#hdd_submitted_before').val() == "1")
	{
		$('#filtersearchform').submit();
	}
}


function showAnfrage()
{
	alert($('#hdd_filter_kontakt').val())
}


function openFilterSearch()
{
	//if($("input:radio:checked[name='rbfeid']").length > 0)
	if($("#hddfeid").val().length > 0)
	{
		$("#filtersearchresult").html("&nbsp;");
		//feid = $("input:radio:checked[name='rbfeid']").val();
		feid = $("#hddfeid").val();
		$("#filtercontainer").load("FilterSearch?feid=" + feid + "&id=" + Math.ceil(Math.random()*1000000000), afterOpenFilterSearch)
	}
}

function afterOpenFilterSearch()
{
	loadFilterBypass();
	loadSchaltElement();
	//$("#filtereinheitsearchdiv").fadeOut(100, fadeInFilterSearch);
	$("#diagrammdiv").fadeOut(1, fadeInFilterSearch);
	$('#auslkrit').css('display', 'none');

}

function fadeInFilterSearch()
{
	$("#filtersearchdiv").fadeIn(1, afterFadeInFilterSearch); //Check Bypass
}

function afterFadeInFilterSearch()
{
	$('#filtersearchform').submit();

}

function loadFilterBypass()
{
	strQuery = "feid=" + $("#feid").val()

	if($("#waaid").val() != null)
		strQuery += "&waaid=" + $("#waaid").val()
	if($("#wasdid").val() != null)
		strQuery += "&wasdid=" + $("#wasdid").val()
	if($("#did").val() != null)
		strQuery += "&did=" + $("#did").val()
	if($("#asid").val() != "-1")
		strQuery += "&asid=" + $("#asid").val()

	strQuery += "&ddstid=" + $('#ddstid').val()

	/*if($("#atex").val() != "-1")
		strQuery += "&atex=" + $("#atex").val()*/

	strQuery += "&id=" + Math.ceil(Math.random()*1000000000)

	//alert(strQuery)
	$("#bypasscontainer").load("loadbypass", strQuery)

}

function loadSchaltElement()
{
	if($("#waaid").val() != null)
	{
		//alert("waaid: " + $("#waaid").val())
		//$("#elektschalt").css("display", "none");
		$('#rowelektrschalt').addClass('trhidden');
		$("#elektschalt").load("loadschaltelement", "waaid=" + $("#waaid").val() + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadSchaltElement)
	}
}

function afterLoadSchaltElement()
{
	//alert($("#hdd_elektrschalt").val())
	if($("#hdd_elektrschalt").val() == "1")
	{
		//$("#elektschalt").css("display", "inline");
		$('#rowelektrschalt').removeClass('trhidden');
	}
}


function openDiagrammFromFilterSearch()
{
	$("#filtersearchdiv").fadeOut(100, afterOpenDiagrammFromFilterSearch);
	//$("#filtersearchresult").html("&nbsp;");
}

function afterOpenDiagrammFromFilterSearch()
{
	$("#diagrammdiv").fadeIn(100);
	$('#auslkrit').css('display', '');
}


function expSearchDiagramm(fid)
{
	$("#HDD_FID").val(fid);
	$("#searchform").fadeOut(100, afterExpSearchDiagramm);

}

function afterExpSearchDiagramm()
{
	$("#picturediv").html("&nbsp;");
	$("#picturedivdetail").html("&nbsp;");
	$("#picturediv").fadeOut(10);
	$("#picturedivdetail").fadeOut(10);
	$("#picturedivplatzhalter").fadeIn(1);
	$("#platzhaltertext").fadeIn(1);
	$('#btnExpSearchFilterDetail').attr("disabled", true);
	$("#diagramm").fadeIn(100);
	checkForOverhead();
}

function expSearchForm()
{
	$("#diagramm").fadeOut(100, afterExpSearchForm);
}

function afterExpSearchForm()
{
	$("#searchform").fadeIn(100);
}



function checkExpDiagrammSubmit()
{
	bRet = true;

	//if($("#lmin").val().length == 0)
	if($("#volstrom").val().length == 0)
	{
		//$("#lmin").focus()
		$("#volstrom").focus()
		bRet = false;
	}

	if(bRet && $("#mms:checked").val() == "mms")
	{
		if($("#txtvisko").val().length == 0)
		{
			$("#txtvisko").focus()
			bRet = false;
		}
	}

	if(bRet && $("#med:checked").val() == "med")
	{
		if($("#txttempmedcel1").val().length == 0)
		{
			$("#txttempmedcel1").focus()
			bRet = false;
		}
	}

	if(bRet && $("#dyn:checked").val() == "dyn")
	{
		if($("#txtdynvisko").val().length == 0)
		{
			$("#txtdynvisko").focus()
			bRet = false;
		}

		if(bRet && $("#txtdichte").val().length == 0)
		{
			$("#txtdichte").focus()
			bRet = false;
		}

	}

	return bRet;
}


function showMaterialText()
{
	$('#materialdiv').jOverlay({color:'#839CBA', opacity : 0.75});
	//$().jOverlay({url:'filtermaterialdetail', imgLoading : 'ajax-loader2.gif', color:'#839CBA', opacity : 0.75, bgClickToClose : true, css:{'background-color':'white', 'padding':'10px', 'width':'800px', 'overflow':'scroll', 'height':'50%;'}});
}

function showSchmutzText()
{
	$('#schmutzdiv').jOverlay({color:'#839CBA', opacity : 0.75});
	//$().jOverlay({url:'filtermaterialdetail', imgLoading : 'ajax-loader2.gif', color:'#839CBA', opacity : 0.75, bgClickToClose : true, css:{'background-color':'white', 'padding':'10px', 'width':'800px', 'overflow':'scroll', 'height':'50%;'}});
}

function showWAText()
{
	$('#waartdiv').jOverlay({color:'#839CBA', opacity : 0.75});
}

function showWEText()
{
	$('#wediv').jOverlay({color:'#839CBA', opacity : 0.75});
}

function showBypassText()
{
	$('#bypassdiv').jOverlay({color:'#839CBA', opacity : 0.75});
}


function loadMedium(combomediumart)
{
	if(combomediumart.options[0].value == -1)
		combomediumart.options[0] = null;

	$('#mediumdiv').load("loadmedium", "maid=" + combomediumart.value + "&id=" + Math.ceil(Math.random()*1000000000));
}

function loadMediumNew(combomediumart)
{
	//if(combomediumart.options[0].value == -1)
		//combomediumart.options[0] = null;

	$('#spanmedium').load("loadmedium", "maid=" + combomediumart.value + "&id=" + Math.ceil(Math.random()*1000000000), syncMediumCombo);
}

function syncMediumCombo()
{
	$('#maid').find('option').remove().end();

	$('#medium option').clone().appendTo('#maid');

	for(i = 1; i <=5 ; i++)
		$("#txtvisktemp" + i).val('')
}

function loadMediumText()
{
	if($("#txtmedium").val().length > 0)
		$('#mediumdiv').load("loadmedium", "txtmedium=" + $("#txtmedium").val() + "&id=" + Math.ceil(Math.random()*1000000000));
}

function loadMediumTextNew()
{
	//if($("#txtmedsuche").val().length > 0)
	$('#spanmedium').load("loadmedium", "txtmedium=" + escapeHtml($("#txtmedsuche").val()) + "&id=" + Math.ceil(Math.random()*1000000000), syncMediumCombo);
}

function showMediumArt()
{
	//$('#mediumartdiv').jOverlay({color:'blue', opacity : 0.5});
	$().jOverlay({url:'loadmediumart', imgLoading : 'ajax-loader2.gif', color:'#839CBA', opacity : 0.75, bgClickToClose : true, css:{'background-color':'white', 'padding':'10px', 'width':'400px'}});
}


function setMedium()
{
	$("#maid").val($("#medium").val());
	changeMedium(window.document.getElementById('maid'));
	$.closeOverlay();
}

function changeMedium(combomedium)
{
	if(combomedium.options[0].value == -1)
		combomedium.options[0] = null;

	for(i = 1; i <=5 ; i++)
		loadTempKinVisk(i)
}


function showFilterDetailsFromSearch(fid)
{
//	alert("showFilterDetails");
//	console.log("showFilterDetails");
	$("#filterdetail").load("FilterDetail", "fid=" + fid + "&source=search&id=" + Math.ceil(Math.random()*1000000000), afterShowFilterDetailsFromSearch);
}

function showFilterElementDetailsFromSearch()
{
	//alert("did=" + $('#did').val() + "&asid=" + $('#asid').val() + "&wasdid=" + $('#wasdid').val() + "&waaid=" + $('#waaid').val())
	$("#filterdetail").load("FilterDetail", "did=" + $('#did').val() + "&asid=" + $('#asid').val() + "&wasdid=" + $('#wasdid').val() + "&waaid=" + $('#waaid').val() + "&bypass=" + $('#bypass').val() + "&source=search&id=" + Math.ceil(Math.random()*1000000000), afterShowFilterDetailsFromSearch);
}

function afterShowFilterDetailsFromSearch()
{
//	console.log("afterShowFilterDetailsFromSearch");
	$("#filtersearchdiv").fadeOut(100, fadeInFilterDetailFromSearch);
}

function fadeInFilterDetailFromSearch()
{
	//$("#filterdetaildiagramm1").html($("#diagramm").html())
	//$("#filterdetaildiagramm2").html($("#diagrammdetail").html())
	$('#filterdiagramm').html($("#pictureframe").html())
	$("#filterdetail").fadeIn(100);
	syncvisktofilterdetails();
	$("#pictureframe").html('')

	updateFirefoxInnerHTML(window.document.getElementById('filterdiagramm'));
	initTabs();
}

function backToFilterSearch()
{
	$("#filterdetail").fadeOut(100, afterBackToFilterSearch);
}


function afterBackToFilterSearch()
{
	$("#filtersearchdiv").fadeIn(100, initTabs);
	$('#pictureframe').html($("#filterdiagramm").html())
	$("#filterdiagramm").html('')

	updateFirefoxInnerHTML(window.document.getElementById('pictureframe'));
	initTabs();
	//window.setTimeout("initTabs();", 1000);
}


function showFilterDetailsFromExpSearch()
{
	$("#filterdetail").load("FilterDetail", "fid=" + $("#HDD_FID").val() + "&source=expertsearch&id=" + Math.ceil(Math.random()*1000000000), afterShowFilterDetailsFromExpSearch);
}

function afterShowFilterDetailsFromExpSearch()
{
	$("#searchformpic").fadeOut(100, fadeInFilterDetailFromExpSearch);

}

function fadeInFilterDetailFromExpSearch()
{
	//$("#filterdetaildiagramm1").html($("#picturediv").html())
	//$("#filterdetaildiagramm2").html($("#picturedivdetail").html())
	$('#filterdiagramm').html($("#pictureframe").html())
	$("#pictureframe").html('');
	updateFirefoxInnerHTML(window.document.getElementById('filterdiagramm'));

	$("#filterdetail").fadeIn(100);
	syncvisktofilterdetails();

	//window.setTimeout("initTabs();", 1000);
	initTabs();
}

function backToExpFilterSearch()
{
	$('#pictureframe').html($("#filterdiagramm").html())
	$("#filterdiagramm").html('')
	updateFirefoxInnerHTML(window.document.getElementById('pictureframe'));
	initTabs();
	$("#filterdetail").fadeOut(100, afterBackToExpFilterSearch);


}

function afterBackToExpFilterSearch()
{
	$("#searchformpic").fadeIn(100, initTabs);
}


function syncvisktofilterdetails()
{
	//alert("sync");
	//$('#hdd_lmin').val($('#lmin').val())
	$('#hdd_volstrom').val($('#volstrom').val())
	$('#hdd_volstromeinheit').val($('#voleinheit').val())
	$('#hdd_rbvisko').val($("input[name='visko']:checked").val())
	$('#hdd_visko').val($('#txtvisko').val())
	$('#hdd_visko2').val($('#txtvisko2').val())
	$('#hdd_visko3').val($('#txtvisko3').val())
	$('#hdd_visko4').val($('#txtvisko4').val())
	$('#hdd_visko5').val($('#txtvisko5').val())
	$('#hdd_maid').val($('#maid').val())
	$('#hdd_tempmedcel1').val($('#txttempmedcel1').val())
	$('#hdd_tempmedcel2').val($('#txttempmedcel2').val())
	$('#hdd_tempmedcel3').val($('#txttempmedcel3').val())
	$('#hdd_tempmedcel4').val($('#txttempmedcel4').val())
	$('#hdd_tempmedcel5').val($('#txttempmedcel5').val())
	$('#hdd_dynvisko').val($('#txtdynvisko').val())
	$('#hdd_dynvisko2').val($('#txtdynvisko2').val())
	$('#hdd_dynvisko3').val($('#txtdynvisko3').val())
	$('#hdd_dynvisko4').val($('#txtdynvisko4').val())
	$('#hdd_dynvisko5').val($('#txtdynvisko5').val())
	$('#hdd_dichte').val($('#txtdichte').val())
	$('#hdd_dichte2').val($('#txtdichte2').val())
	$('#hdd_dichte3').val($('#txtdichte3').val())
	$('#hdd_dichte4').val($('#txtdichte4').val())
	$('#hdd_dichte5').val($('#txtdichte5').val())
}



function syncMedVisk()
{
	for(i = 1; i<=5; i++)
	{
		$("#txtvisktemp" + i).val($("#calculatedvisk" + i).html().replace(/,/g, "."))
	}
}

function loadTempKinVisk(index)
{
	$("#calculatedvisk" + index).load("loadexpsearchtempvisk", "maid=" + $("#maid").val() + "&tempcel=" + $("#txttempmedcel" + index).val() + "&id=" + Math.ceil(Math.random()*1000000000), syncMedVisk)
}

function showSubRow(btn, rowid)
{
	btn.style.display = 'none';
	$('#' + rowid).removeClass('trhidden');

}


function submitExpertDiagramm()
{
	var options =
	{
		url: 'ExpertSearchGraphs',
		target: '#pictureframe',
		beforeSubmit: checkExpDiagrammSubmit,
		success: afterSubmitExpertDiagramm
	};
	$('#searchformpic').ajaxForm(options);
	$("#searchformpic").submit();

}


function afterSubmitExpertDiagramm()
{
	//$('#btnExpSearchFilterDetail').attr("disabled", false);
	$('.spancontinue').css("display", "inline");
	initTabs();
}

/*
function submitExpDiagramm(bool)
{
	var options =
	{
		url: 'filterdiagramm.jsp',
		target: '#picturediv',
		beforeSubmit: checkExpDiagrammSubmit,
		success: afterExpSearchDiagrammSubmit
	};
	$('#searchformpic').ajaxForm(options);
	$("#searchformpic").submit();
	if(bool)
	{
		submitExpDiagrammDetail(false)
		$("#picturediv").fadeIn(10);
		$("#picturedivdetail").fadeOut(10);
	}

}

function submitExpDiagrammDetail(bool)
{
	var options =
	{
		url: 'filterdiagrammdetail.jsp',
		target: '#picturedivdetail',
		beforeSubmit: checkExpDiagrammSubmit,
		success: afterExpSearchDiagrammSubmit
	};
	$('#searchformpic').ajaxForm(options);
	$("#searchformpic").submit();

	if(bool)
	{
		submitExpDiagramm(false)
		$("#picturedivdetail").fadeIn(10);
		$("#picturediv").fadeOut(10);
	}
}


function afterExpSearchDiagrammSubmit()
{
	$("#picturedivplatzhalter").fadeOut(1);
	$("#platzhaltertext").fadeOut(1);
	$('#btnExpSearchFilterDetail').attr("disabled", false);
}
*/



function switchEntries()
{
	if($("#hdd_eingaben1").val() == "1")
	{
		$("#hdd_eingaben1").val("0");
		$("#eingaben1").fadeOut(10);
	}
	else
	{
		$("#hdd_eingaben1").val("1");
		$("#eingaben1").fadeIn(10);
	}
}

function switchComment()
{
	if($("#hdd_eingaben2").val() == "1")
	{
		$("#hdd_eingaben2").val("0");
		$("#eingaben2").fadeOut(10);
	}
	else
	{
		$("#hdd_eingaben2").val("1");
		$("#eingaben2").fadeIn(10);
	}
}



function triggerShowFilterDetailsFromExpSearch()
{
	refreshExpDiagramm();
}



function refreshExpDiagramm()
{
	var options =
	{
		url: 'filterdiagramm.jsp',
		target: '#picturediv',
		beforeSubmit: checkExpDiagrammSubmit,
		success: refreshExpDiagrammDetail
	};
	$('#searchformpic').ajaxForm(options);
	$("#searchformpic").submit();
}

function refreshExpDiagrammDetail()
{
	var options =
	{
		url: 'filterdiagrammdetail.jsp',
		target: '#picturedivdetail',
		beforeSubmit: checkExpDiagrammSubmit,
		success: showFilterDetailsFromExpSearch
	};
	$('#searchformpic').ajaxForm(options);
	$("#searchformpic").submit();
}

function copyViskToDiagramm()
{
	//updateFirefoxInnerHTML($('#divviskosearch'));
	$("#diagrammdetail").css("display", "none");
	//$("#sbButton").css("display", "none");
	$("#trsubmit").css("display", "none");


	updateFirefoxInnerHTML(window.document.getElementById('divviskosearch'));
	updateFirefoxInnerHTML(window.document.getElementById('divviskosearch2'));
	$('#divviskodiagramm').html($('#divviskosearch').html());
	$('#divviskosearch').html("&nbsp;");

	$('#divviskodiagramm2').html($('#divviskosearch2').html());
	$('#divviskosearch2').html("&nbsp;");

}

function copyViskToSearch()
{
	//updateFirefoxInnerHTML($('#divviskodiagramm'));
	updateFirefoxInnerHTML(window.document.getElementById('divviskodiagramm'));
	updateFirefoxInnerHTML(window.document.getElementById('divviskodiagramm2'));
	$('#divviskosearch').html($('#divviskodiagramm').html());
	$('#divviskodiagramm').html("&nbsp;");

	$('#divviskosearch2').html($('#divviskodiagramm2').html());
	$('#divviskodiagramm2').html("&nbsp;");

	//$("#sbButton").css("display", "inline");
	$("#trsubmit").css("display", "table-row");
}



function updateFirefoxInnerHTML(domObj)
{
	try
	{
//		if(typeof top.browser == 'undefined' || top.browser == null || top.browser.browser == "Firefox")
		if(true)
		{
			var arr = domObj.getElementsByTagName("INPUT");
			var len = arr.length;
			var tmpType = null;
			for(var i=0; i < len; i++)
			{
				arr[i].setAttribute("value", arr[i].value);
				tmpType = arr[i].type.toLowerCase();
				if(tmpType == "radio" || tmpType == "checkbox")
				{
					if(arr[i].checked)
						arr[i].setAttribute('checked', 'checked');
					else
						arr[i].removeAttribute('checked');
				}
			}

			arr = domObj.getElementsByTagName("TEXTAREA");
			len = arr.length;
			for(var i=0; i < len; i++)
			{
				arr[i].setAttribute("value", arr[i].value);
			}

			arr = domObj.getElementsByTagName("SELECT");
			len = arr.length;
			for(var i=0; i < len; i++)
			{
				arr[i].setAttribute("value", arr[i].value);
				//arr[i].setAttribute("selectedIndex", arr[i].selectedIndex);
			}

			arr = domObj.getElementsByTagName("OPTION");
			len = arr.length;
			for(var i=0; i < len; i++)
			{
				arr[i].setAttribute("value", arr[i].value);
				if(arr[i].selected)
					arr[i].setAttribute('selected', 'selected');
				else
					arr[i].removeAttribute('selected');
			}
		}
	}
	catch(e)
	{
		//showError("Functions", arguments, e);
	}
}

function initTabs()
{
	$("#content div").hide(); // Initially hide all content

	$("#tabs li").attr("id","");

	$("#tabs li:first").attr("id","current"); // Activate first tab
	$("#content div:first").fadeIn(); // Show first tab content

	$('#tabs b').click(function(e) {
	    e.preventDefault();
	    if ($(this).closest("li").attr("id") == "current"){ //detection for current tab
	     return
	    }
	    else{
	    $("#content div").hide(); //Hide all content
	    $("#tabs li").attr("id",""); //Reset id's
	    $(this).parent().attr("id","current"); // Activate this
	    $('#' + $(this).attr('name')).fadeIn(); // Show content for current tab
	    }
	});
}


function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

/***************************FEUS******************************/

function checkFeusSearch()
{
	bRet = true;

	if($("#txt_suche").val().length < 3)
	{
		bRet = false;
	}

	if(bRet)
		$("#feussearchresult").html("&nbsp;")
	else
		alert($("#searcherrordiv").html());

	return bRet;
}

var hasShownMoreResultsMessage = false; 

function showFeusSearchResult()
{
	$("#feussearchresult").fadeIn(10)
	$("#tblfeussearchresult").fadeIn(10)
	imagePreview();

  // Pruefen, ob die Tabelle mit Suchergebnissen existiert und mehr als 16 Zeilen hat
  var s_table = document.getElementById("tblfeussearchresult");
  if (s_table && s_table.rows.length > 16) {
    // Überprüfen, ob Hinweis bereits angezeigt wurde
    if (!hasShownMoreResultsMessage) {			
      // noch nicht da ...
      var s_form = document.getElementById("feussearchform");
      var s_pTag = document.createElement("p");
      s_pTag.id = "moreResultsMessage";
      var langValue = getCookie("sprache"); // gewählte sprache wird im cookie gespeichert
      if(langValue && langValue=="D") {			
        s_pTag.innerHTML = "<b>Es sind weitere Suchergebnisse vorhanden.</b> Bitte schr&auml;nken Sie Ihre Auswahl weiter ein!";
      } else {
        s_pTag.innerHTML = "<b>There are more search results available.</b> Please narrow down your selection further!";
      }	

      s_form.parentNode.insertBefore(s_pTag, s_form.nextSibling);
      hasShownMoreResultsMessage = true; 
    }	

    // letzte Zeile in tabelle unsichtbar setzen, damit wir wieder 15 Ergebnisse haben
    if (s_table.rows.length > 0) {
        s_table.rows[s_table.rows.length - 1].style.display = "none";
    }
  } else {
		// console.log('debug: not too much');
		if (hasShownMoreResultsMessage) {			
			// Hinweis wieder entfernen
			var s_pTagToRemove = document.getElementById("moreResultsMessage");
			if (s_pTagToRemove) {
				s_pTagToRemove.remove();
			}		
			hasShownMoreResultsMessage = false; 
		}	
	}


}

function loadFeusDetailDC(strFeid)
{
	$("#fit4filterdetail").load("Fit4FilterDetail", "feid=" + strFeid + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadFeusDetail)
}

function loadFeusDetailMapping(strMid)
{
	$("#fit4filterdetail").load("Fit4FilterDetail", "mid=" + strMid + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadFeusDetail)
}


function afterLoadFeusDetail()
{
	$('#fit4filterdetail').jOverlay({color:'#839CBA', opacity : 0.75});
}

function setFeusSearchParameters()
{
	/*
	if($("#hersteller:checked").val() == "hersteller")
		strsearchpool = "hersteller";
	else if($("#dc:checked").val() == "dc")
		strsearchpool = "dc";
	*/
	if($('#cb_hid').val() == "dcparts")
		strsearchpool = "dc";
	else
		strsearchpool = "hersteller";

	strsearchtype = $("#cb_suchart").val()

	strhid = $("#cb_hid").val()

	$("#txt_suche").setOptions({extraParams:{searchpool:strsearchpool, searchtype:strsearchtype, hid : strhid}})
}


function printFeusDetailDC(strFeid)
{
	$('#hdd_feid').val(strFeid);
	$('#hdd_mid').val('');
	$('#frmPrintFilterDetail').submit();
	//$("#feusdetail").load("FeusDetail", "feid=" + strFeid + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadFeusDetail)
}

function printFeusDetailMapping(strMid)
{
	$('#hdd_feid').val('');
	$('#hdd_mid').val(strMid);
	$('#frmPrintFilterDetail').submit();
	//$("#feusdetail").load("FeusDetail", "mid=" + strMid + "&id=" + Math.ceil(Math.random()*1000000000), afterLoadFeusDetail)
}


function printFit4FilterOnePager(feid, mid)
{

	$('#hdd_midonepager').val("");
	if(mid != null)
	{
		$('#hdd_midonepager').val(mid);
	}

	$('#hdd_feidonepager').val(feid);

	$('#frmPrintFit4FilterOnePager').submit();
}


function getParentByAttributeValue(p_obj, p_attribute_name, p_attribute_value)
{
    try
    {
        var obj = p_obj;

        while(obj != null && obj.getAttribute(p_attribute_name) != p_attribute_value)
        {
        	//alert(obj.tagName)
        	//alert(obj.getAttribute(p_attribute_name))
        	//alert(obj.getAttribute(className))
        	obj = obj.parentNode;
        }
        return obj;
    }
    catch(e)
    {
       return null;
    }
}




$(document).ready(function() {
	$("#languagespan li:has(ul)").hover(function(){
		$(this).find("ul").slideDown();
	}, function(){
		$(this).find("ul").hide();
	});
});




function hideHinweis()
{
	$('#fmhinweis').css("display", "none");
}


/*
var entityMap = {
		  '&': '&amp;',
		  '<': '&lt;',
		  '>': '&gt;',
		  '"': '&quot;',
		  "'": '&#39;',
		  '/': '&#x2F;',
		  '`': '&#x60;',
		  '=': '&#x3D;'
		};

function escapeHtml (string) {
  return String(string).replace(/[&<>"'`=\/]/g, function (s) {
    return entityMap[s];
  });
}*/


function escapeHtml (string)
{
	return string.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}


this.imagePreview = function(){
//	xOffset = -20;
//	yOffset = 40;

	xOffset = 0;
	yOffset = -400;

//	console.log("imagePreview started");

	$(".preview").hover(function(e){
	//    this.t = this.title;
	//    this.title = "";
	//     var c = (this.t != "") ? "<br/>" + this.t : "";
		//style='border: 1px solid black;'
	     $("body").append("<p id='preview'><img src='ShowFilterImage?picid="+ $(this).attr('picid') +"' width='400' alt='Image preview' /></p>");
	     $("#preview")
	        .css("top",(e.pageY - xOffset) + "px")
	        .css("left",(e.pageX + yOffset) + "px")
	        .fadeIn("slow");
//		console.log(this.picid);
//		console.log($(this).attr('picid'));
//		console.log("hover start");
	},

	function(){
	//    this.title = this.t;
	    $("#preview").remove();
//		console.log("hover end");

	});

	$(".preview").mousemove(function(e){
	    $("#preview")
	        .css("top",(e.pageY - xOffset) + "px")
	        .css("left",(e.pageX + yOffset) + "px");
	});
};



function acceptCookieSettings()
{
	$.ajax
	(
		{
		  type: "POST",
		  url: "AcceptCookieSettings",
		  data: "",
		  success: function()
		  {
			  //console.log("??????????");
			  $("#acceptcookiewindow").css("display", "none");
			  //$('.jqx-window-modal')[0].css("display", "none");

			  $(".jqx-window-modal").each(function( index ) {
				  //$(this).css("display", "none");
				  $(this).remove();
			  });



//				try
//				{
//					//$("#acceptcookiewindow").jqxWindow('close');
//					$("#acceptcookiewindow").css("display", "none")
//				}
//				catch(err)
//				{
//
//				}



		  }
		}
	);
}


function denyCookieSettings()
{
	window.location.href='https://www.hengst.com';
}


function showDocumentWindow(dldocumentid, yvalue, link)
{
	try
	{
		if($('#downloaddocumentwindow').length)
			$('#downloaddocumentwindow').remove();

		var windowcontent = '<div id="downloaddocumentwindow" name="downloaddocumentwindow">';
		windowcontent += '<div id="downloaddocumentwindowheader" name="downloaddocumentwindowheader">Download Document</div>';
		windowcontent += '<div id="downloaddocumentwindowcontent" name="downloaddocumentwindowcontent">';
//		windowcontent += '<input id="documentid" name="documentid" type="hidden" value="">';
		windowcontent += '<div><a href="javascript:downloadDocument(\'RD\')">Download Deutsch</a></div>';
		windowcontent += '<div><a href="javascript:downloadDocument(\'RE\')">Download Englisch</a></div>';
		windowcontent += '</div>';
		windowcontent += '</div>';


		$('#dldocumentid').val(dldocumentid)


		$('#downloaddocumentwindowcontainer').html(windowcontent);





		$("#downloaddocumentwindow").jqxWindow({
		    height: 90,
		    width: 600,
		   // theme: 'energyblue',
		    position: 'center',
		    closeButtonSize: 20,
		    showCloseButton: true,
		    keyboardNavigation: false,
		    isModal: false,
		    keyboardCloseKey: '',
		    draggable: false,
		    resizable: false,
		    zIndex: 99999,
		    modalZIndex: 99999,
		    autoOpen: true
		});

		/*
		var xcenter = $(window).width() / 2 - $("#downloaddocumentwindow").jqxWindow("width") / 2;
//		$("#downloaddocumentwindow").jqxWindow({position: {x: xcenter, y: yvalue}});
//		$("#downloaddocumentwindow").jqxWindow({position: {x: xcenter, y: $(link).offset().top - 20}});

		console.log("Link:")
		console.log($(link))
		console.log("Offset:")
		console.log($(link).offset())
		console.log($(link).offset().top)
		*/
	}
	catch(err)
	{
//		console.log(err);
	}

	var xcenter = $(window).width() / 2 - $("#downloaddocumentwindow").jqxWindow("width") / 2;
	$("#downloaddocumentwindow").jqxWindow({position: {x: xcenter, y: yvalue}});


	/*
	console.log("Link:")
	console.log($(link))
	console.log("Offset:")
	console.log($(link).offset())
	console.log($(link).offset().top)
	*/



}



function downloadDocument(spr)
{
	window.open('documents/' + spr + $('#dldocumentid').val() + '_2021-04.pdf');
}





