﻿//******************************
//JS searching
//copyright ACS Solutions, Leipzig (Germany) 2007
//******************************

function Search()
{
	this.greekKeyPad = null;
	this.currInput = null;
	this.number = 1;
	this.count = 1;
}

Search.prototype.loadGreekKeypad = function()
{
	this.greekKeyPad = document.createElement("div");
	this.greekKeyPad.style.position = "absolute";
	this.greekKeyPad.style.width = "222px";
	this.greekKeyPad.style.padding = "10px";
	this.greekKeyPad.style.paddingTop = "2px";
	this.greekKeyPad.style.border = "1px solid #808080"; 
	this.greekKeyPad.style.backgroundColor = "#FFFFFF";	
	this.greekKeyPad.style.height = "59px";	
	this.greekKeyPad.style.display = "none";
	this.greekKeyPad.style.zIndex = "100";
	//this.greekKeyPad.style.overflow = "hidden";
	this.greekKeyPad.style.fontFamily = "Arial Unicode MS, Palatino Linotype, Lucida Sans, Lucida Grande, Arial";
	
	this.padContainer = document.createElement("div");
	this.padContainer.style.width = "222px";
	this.closeIcon = document.createElement("img");
	this.closeIcon.style.marginLeft = "220px";
	this.closeIcon.style.marginBottom = "3px";
	this.closeIcon.src = "../media/images/close_icon_greekKeypad.gif";
	this.closeIcon.style.cursor = "pointer";
	this.closeIcon.onclick = function(){search.hideGreekKeypad();};
	this.padContainer.appendChild(this.closeIcon);
	
	this.greekKeyPad.appendChild(this.padContainer);
	
	for(i=913;i<=937;i++)
	{
	    if (i != 930) { 
		key = document.createElement("div");
		key.style.padding = "3px";
		key.style.width = "10px";
		key.style.height = "12px";
		key.style.borderBottom = "1px solid black";
		key.style.borderRight = "1px solid black";
		if(i<926) key.style.borderTop = "1px solid black";
		if((i-913)%13 == 0)	key.style.borderLeft = "1px solid black";
		key.style.cssFloat = key.style.styleFloat = "left";

		key.innerHTML = "&#"+i+";";
		key.style.cursor = "pointer"

		key.onclick = new Function("search.addCharToInput('"+i+"')");
		this.padContainer.appendChild(key);
}
	}
	$("search").appendChild(this.greekKeyPad);
}

Search.prototype.addCharToInput = function(charCode)
{
	this.currInput.value += String.fromCharCode(charCode);
}

Search.prototype.hideGreekKeypad = function()
{
	this.greekKeyPad.style.display = 'none'; 

}

Search.prototype.showGreekKeypad = function(event)
{
	event = event || window.event;
	this.currInput = (Event.element(event)).up(".elem_rechts").down(0);
	searchMask = (Event.element(event)).up('.search_mask');
	this.number = searchMask.id.split("_")[2];
	this.greekKeyPad.style.display = "block";
	this.greekKeyPad.style.left = Event.pointerX(event) - 10 + "px";
	this.greekKeyPad.style.top = Event.pointerY(event) - 5 + "px";
}

Search.prototype.addSearch = function(obj)
{
	this.count++;
	if(this.greekKeyPad.style.display = "block")
		this.greekKeyPad.style.display = "none";
	div = document.createElement("div");
	div.id = "search_mask_"+this.count;


	lastSearchMask = obj.previousSibling;
	while(lastSearchMask.nodeName=="#text" || (lastSearchMask.nodeName.toLowerCase()!="div" && lastSearchMask.hasClassName("search_class")))
		lastSearchMask = lastSearchMask.previousSibling;
	
	div.innerHTML = lastSearchMask.innerHTML;
	obj.parentNode.insertBefore(div, obj);
	$("search_mask_"+this.count).addClassName("search_mask");
}


search = new Search();