function trim(s) {
	return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}
var oldColor = "";
function coloriseBlock(obj){
	oldColor = obj.style.backgroundColor;
	obj.style.backgroundColor = "#EEEEEE";
};
function restoreColor(obj){
	obj.style.backgroundColor = oldColor;
};
function turnMenuOn(obj){
	obj.style.border = "1px solid #044368";
	obj.style.backgroundColor = "#E7F4FB";
};
function turnMenuOff(obj){
	obj.style.border = "1px solid #FFFFFF";
	obj.style.backgroundColor = "";
};
function turnItemOn(obj){
	if(obj != null){
		obj.style.backgroundColor = "#F0F7FB";
		return;
	}
	this.style.backgroundColor = "#F0F7FB";
};
function turnItemOff(obj){
	if(obj != null){
		obj.style.backgroundColor = "";
		return;
	}
	this.style.backgroundColor = "";
};

function person(id, name, rectype){
	this.id = id;
	this.name = name;
	this.rectype = rectype;
}
var pDB = new Array();

function sortHash(hash){
	var names = new Array();
	
	for(var i = 0; i < hash.length; i++){		
		names[i] = trim(hash[i].name) + "_" + hash[i].id + "_" + hash[i].rectype;
	}
	return names.sort();
};
function setSeparator(colspan){
	var tr = document.createElement("tr");
	var td = document.createElement("td");
		td.setAttribute('colspan', 2);
		td.setAttribute('height', 1);
	td.innerHTML = "<img src='../img/line.gif' width='2' height='2'>";
	tr.appendChild(td);	
	return tr;
};
function showLinks(target, names){
	var nest = document.getElementById(target);
	for(var i = 0; i < names.length; i++){
		var tmp = names[i].split("_");
		if(recordUnitExists == false){			
			var tr = document.createElement("tr");
				tr.onmouseover = turnItemOn;
				tr.onmouseout = turnItemOff;
			var td1 = document.createElement("td");
			var td2 = document.createElement("td");
				td1.setAttribute("width", "55%");
				td1.setAttribute("height", "35");
			var a1 = document.createElement("a");
				a1.setAttribute("target", "_self");
				a1.setAttribute("title", tmp[0]);
				a1.setAttribute("href", "search.pl?oaction=show&id=" + tmp[1]);
				a1.setAttribute("hidefocus", "true");
				a1.innerHTML = "<div class='items'>" + tmp[0];
				a1.className = "items1";
				
			var a2 = document.createElement("a");
				a2.setAttribute("target", "_self");
				a2.setAttribute("title", units[tmp[2]]);
				a2.setAttribute("href", "search.pl?oaction=show&rectype=" + tmp[2]);
				a2.setAttribute("hidefocus", "true");
				a2.innerHTML =  "<div class='items'>" + units[tmp[2]];
				a2.className = "items2";
			td1.appendChild(a1);
			td2.appendChild(document.createTextNode(" "));
			td2.appendChild(a2);
			tr.appendChild(td1);
			tr.appendChild(td2);
			td1.className = "items1";
			td2.className = "items2";
			nest.appendChild(tr);							
			nest.appendChild(setSeparator(2));		
		}
		else{
			var tr = document.createElement("tr");
				tr.onmouseover = turnItemOn;
				tr.onmouseout = turnItemOff;
			var td = document.createElement("td");			
			var a = document.createElement("a");
				a.setAttribute("target", "_self");
				a.setAttribute("title", tmp[0]);
				a.setAttribute("href", "search.pl?oaction=show&id=" + tmp[1]);
				a.setAttribute("hidefocus", "true");
				a.innerHTML = "<div style='width=100%; cursor: hand'>" + tmp[0];
				a.className = "items1";
			td.appendChild(a);			
			tr.appendChild(td);		
			td.className = "items2";	
			td.setAttribute("height", 20);
			nest.appendChild(tr);			
			nest.appendChild(setSeparator(1));		
		}
	}
};

function oaction(action, id, page){
	switch(action){		
		case 'mail': document.location.href = 'mailto:<Получатель>?subject=Биография.RU&body=' + id;
			break;
		case 'main': document.location.href = 'index.pl';
			break;
		case 'print': window.open('save.pl?id=' + id + '&page=' + page + '&oaction=print', 'MMM', 'height=480,width=640,status=no,toolbar=yes,resizable=yes,menubar=no,location=no,scrollbars=yes');
			break;
		case 'save': document.location.href = 'save.pl?id=' + id + '&page=' + page + '&oaction=save'; 
			break;
		
		default:;
	}
};

function qaction(action, id){
	switch(action){		
		case 'mail': document.location.href = 'mailto:<Получатель>?subject=Биография.RU&body=' + id;
			break;
		case 'main': document.location.href = '../quotes.html';
			break;
		case 'print': window.open('qsave.pl?name=' + id + '&oaction=print', 'MMM', 'height=480,width=640,status=no,toolbar=yes,resizable=yes,menubar=no,location=no,scrollbars=yes');
			break;
		case 'save': document.location.href = 'qsave.pl?name=' + id + '&oaction=save'; 
			break;
		
		default:;
	}
};

function action(action, href){
	switch(action){ 
		case 'mail': document.location.href = 'mailto:<Получатель>?subject=Биография.RU&body=' + escape(href);
			break;		
		case 'print': window.open(href, 'MMM', 'height=480,width=640,status=no,toolbar=yes,resizable=yes,menubar=no,location=no,scrollbars=yes');
			break;
		case 'save': document.location.href = href; 
			break;
		
		default:;
	}
};

function SetBanners(url){
	
	
return;
var ifr = document.frames["bannerHost"].location.replace(url);
};
