﻿// Mainmenu

// Dict
var lang  = document.getElementsByTagName('html')[0].lang;
var dict = "";

switch (lang) {
	case "de":
		dict = "Suche";
		break;
	case "en":
		dict = "Search";
		break;
	case "fr":
		dict = "Recherche";
		break;
	case "es":
		dict = unescape("B%FAsqueda");
		break;
	case "pt":
		dict = "Procurar";
		break;
	case "ru":
		dict = unescape("%u041F%u043E%u0438%u0441%u043A");
		break;
	case "zh-CN":
		dict = unescape("%u641C%u7D22");
		break;
	default:
		break;
}
// alert(escape("из"))
// Events
document.forms.menusearch.elements.q.onfocus = function() {
	if (this.value == dict) {
		this.value = ""; 
	}
	this.style.color = "#000"; // css too
	this.parentNode.parentNode.parentNode.style.backgroundPosition = "0 -42px";
}
document.forms.menusearch.elements.q.onblur = function() {
	if (this.value == "") {
		 this.value = dict;
		 this.style.color = "#999";
	}
	else {
		 this.style.color = "#000";
	}
	this.parentNode.parentNode.parentNode.style.backgroundPosition = "0 0";
}
document.forms.menusearch.onsubmit = function() {
	if (this.elements.q.value.search(/^\s*$/) != -1 || this.elements.q.value == dict) {
		return false;
	}
}
document.getElementsByTagName('button')[0].onclick = function() {
	var query = document.forms.menusearch.elements.q.value;
	if (query == dict || query == "") {
		window.location.href = document.forms.menusearch.action ;
	}
}


