var EntryPageMaterialSearch =
{
	LanguageIso: 'DE',
	
	ShowInformationTimeout: -1,
	ShowInformationItemDiv: null,
	ShowInformationItemValue: '',
	
	LabelIdentifier: '',
	LabelHardness: '',
	LabelFirmness: '',
	LabelStrech: '',
	
	RollOver: function(divItem, sItemValue)
	{
		//--- Keep div & value ---
		this.ShowInformationItemDiv = divItem;
		this.ShowInformationItemValue = sItemValue;
		//--- Wait before info is shown ---
		this.ShowInformationTimeout = window.setTimeout('EntryPageMaterialSearch.ShowInfo();', 333);
	},
	
	RollOut: function()
	{
		this.Hide();
	},
	
	Hide: function()
	{
		//---- Check if there is a show-timeout running ---
		if(this.ShowInformationTimeout>-1)
		{
			//--- Stop timeout ---
			window.clearTimeout(this.ShowInformationTimeout);
			this.ShowInformationTimeout = -1;
		}
		var oDivMaterialSearchRollover = document.getElementById("divMaterialSearchRollover");
		oDivMaterialSearchRollover.style.display = 'none';
	},
	
	ShowInfo: function()
	{
		//--- Clear timout cursor ---
		this.ShowInformationTimeout = -1;
		//--- Get item position ---
		var iMenuItemX = jsfGetObjectX(this.ShowInformationItemDiv, 'boxContent');
		var iMenuItemY = jsfGetObjectY(this.ShowInformationItemDiv, 'boxContent');
		//--- Get divs ---
		var oDivMaterialSearchRollover = document.getElementById("divMaterialSearchRollover");
		var oDivMaterialSearchLoading = document.getElementById("divMaterialSearchLoading");
		var oDivMaterialSearchResult = document.getElementById("divMaterialSearchResult");
		//--- Show loading div and hide content ---
		oDivMaterialSearchLoading.style.display = 'block';
		oDivMaterialSearchResult.style.display = 'none';
		//--- Position & show box ---
		oDivMaterialSearchRollover.style.left = (iMenuItemX + this.ShowInformationItemDiv.offsetWidth) + 'px';
		oDivMaterialSearchRollover.style.top = iMenuItemY + 'px';
		oDivMaterialSearchRollover.style.display = 'block';
		//--- Do AJAX request ---
		var sRequestUrl = '/dcswiss/AjaxHandlers/MaterialSearch.aspx?lang=' + this.LanguageIso + '&search=' + encode_utf8(this.ShowInformationItemValue);
		AjaxHandler.StartRequest(sRequestUrl, EntryPageMaterialSearch.InfoReceived);
	},
	
	InfoReceived: function(jsonData)
	{
		//--- Get divs ---
		var oDivMaterialSearchLoading = document.getElementById("divMaterialSearchLoading");
		var oDivMaterialSearchResult = document.getElementById("divMaterialSearchResult");
		//--- Compose HTML ---
		var sInfoHtml = '';
		for(var i=0; i<Number(jsonData.RecordCount); i++)
		{
			var currentRecord = eval('jsonData.Record' + i);
			sInfoHtml += '<strong>' + EntryPageMaterialSearch.LabelIdentifier + currentRecord.Identifier + '</strong><br />';
			sInfoHtml += '<strong>' + currentRecord.Text + '</strong><br />';
			sInfoHtml += EntryPageMaterialSearch.LabelHardness + currentRecord.Hardness + '<br />';
			sInfoHtml += EntryPageMaterialSearch.LabelFirmness + currentRecord.Firmness + '<br />';
			sInfoHtml += EntryPageMaterialSearch.LabelStrech + currentRecord.Strech;
			if(i+1<Number(jsonData.RecordCount))
			{
				sInfoHtml += '<br /><br />';
			}
		}
		//--- Set HTML ---
		oDivMaterialSearchResult.innerHTML = sInfoHtml;
		//--- Hide loading div and show content ---
		oDivMaterialSearchLoading.style.display = 'none';
		oDivMaterialSearchResult.style.display = 'block';
	},
	
	ShowStaticInfo: function()
	{
		this.Hide();
		/*
		var oDivPositionOfStaticInfo = document.getElementById('divPositionOfStaticInfo');
		this.ShowInformationItemDiv = oDivPositionOfStaticInfo;
		this.ShowInfo();
		*/
	}
}
