// This is a javascript file of LOOK4OPTICS.de. 
// Please refer to the help articles:
// http://www.look4optics.de/Hilfe.aspx?leechparam:name=helpIndex
// or directly contact the developer for further information.
//
// Date:   2010-02-10
// Author: M. Viranyi (m dot viranyi at look4 dot de)
//
// Update: 2010-07-26 by M. Viranyi 
//
// Inserted onclick and onblur event handler for changing
// input field's value. (looks nicer, simple version)
//
var portalUrl         = "http://www.look4optics.de/";
var urlProductSearch  = "Suche/ProduktsucheErgebnis.aspx?";
var urlCompanySearch  = "Suche/FirmensucheErgebnis.aspx?";
var urlOpticianSearch = "Suche/FirmensucheErgebnis.aspx?companySearchCompanyTypeFlags=8&";
var urlBrandSearch    = "Suche/MarkensucheErgebnis.aspx?";
if (typeof( h1ForPage) == "undefined")
{
	var h1ForPage = "Suche in LOOK4 OPTICS";
}
if (typeof( searchPreset) == "undefined")
{
	var searchPreset = "Suchbegriff(e) eingeben ...";
}
if (typeof( submitBtnLabel) == "undefined")
{
	var submitBtnLabel = "suchen";
}
if (typeof( css) == "undefined")
{
	var css = 1;
}
//
function updateForm()
{
	var actionString = portalUrl;   
	var inpSelect = document.look4opticsSearchForm.searchLocation;    
	var selection = inpSelect.options[inpSelect.options.selectedIndex].value;
	var wordAmount = document.look4opticsSearchForm.fulltextSearchQueryTerm.value.split(" ");

	if (selection == "products")  actionString += urlProductSearch;
	if (selection == "companies") actionString += urlCompanySearch;
	if (selection == "opticians") actionString += urlOpticianSearch;
	if (selection == "brands")    actionString += urlBrandSearch;

	actionString += "fulltextSearchQueryTerm="+document.look4opticsSearchForm.fulltextSearchQueryTerm.value.toLowerCase();

	document.look4opticsSearchForm.action = actionString;
	document.look4opticsSearchForm.wordAmount.value = wordAmount.length;
	document.look4opticsSearchForm.submit();
}
//
if (css == 1)
{
	document.writeln("<style type=\"text/css\">");
	document.writeln("div#look4opticsSearchForm{");
	document.writeln("border: 1px solid #023267;");
	document.writeln("background-color: #d7d7d7;");
	document.writeln("padding: 10px;");
	document.writeln("font-family: sans-serif;");
	document.writeln("font-size: 10px;");
	document.writeln("color: #000;}");
	document.writeln("div#look4opticsSearchForm h1{");
	document.writeln("font-weight: bold;");
	document.writeln("font-size: 12px;");
	document.writeln("margin: 0px;");
	document.writeln("padding: 0px 0px 5px 0px;}");
	document.writeln("div#look4opticsSearchForm input,div#look4opticsSearchForm select{");
	document.writeln("border: 1px solid #023267;");
	document.writeln("background-color: #fff;}");
	document.writeln("div#look4opticsSearchForm input.button{");
	document.writeln("border: 1px solid #fff;");
	document.writeln("background-color: #023267;");
	document.writeln("color: #fff;}");
	document.writeln("</style>");
}
//
document.writeln("<div id=\"look4opticsSearchForm\">");
document.writeln("<form name=\"look4opticsSearchForm\" method=\"post\" action=\""+portalUrl+"\" target=\"_blank\" onsubmit=\"updateForm();\">");
document.writeln("<h1>"+h1ForPage+"</h1>");
document.writeln("<input type=\"text\" name=\"fulltextSearchQueryTerm\" value=\""+searchPreset+"\" onclick=\"if(this.value=='"+searchPreset+"')this.value='';\" onblur=\"if(this.value=='')this.value='"+searchPreset+"';\"/>");
document.writeln("<select name=\"searchLocation\" size=\"1\">");
document.writeln("<option value=\"products\">Produkte</option>");
document.writeln("<option value=\"companies\">Firmen</option>");
document.writeln("<option value=\"opticians\">Optiker</option>");
document.writeln("<option value=\"brands\">Marken</option>");
document.writeln("</select>");
document.writeln("<input type=\"submit\" value=\""+submitBtnLabel+"\" class=\"button\"/>");
document.writeln("<input type=\"hidden\" name=\"hostUrl\" value=\""+window.location.host+"\"/>");
document.writeln("<input type=\"hidden\" name=\"hostPagePath\" value=\""+window.location.pathname+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientAppCodeName\" value=\""+navigator.appCodeName+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientAppName\" value=\""+navigator.appName+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientAppVersion\" value=\""+navigator.appVersion+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientAppLang\" value=\""+navigator.language+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientAppPlatform\" value=\""+navigator.platform+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientAppUserAgent\" value=\""+navigator.userAgent+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientScreenWidth\" value=\""+screen.width+";"+screen.availWidth+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientScreenHeight\" value=\""+screen.height+";"+screen.availHeight+"\"/>");
document.writeln("<input type=\"hidden\" name=\"clientScreenDepth\" value=\""+Math.pow( 2, screen.colorDepth)+"\"/>");
document.writeln("<input type=\"hidden\" name=\"wordAmount\" value=\"0\"/>");
document.writeln("</form>");
document.writeln("</div>");