var ne = new Array();
if ('undefined' == typeof String.prototype.trim) {
    String.prototype.trim = function() {
	return this.replace(/^\s+/, '').replace(/\s+$/, '');
    }
}
if ('undefined' == typeof String.prototype.ltrim) {
    String.prototype.ltrim = function() {
        return this.replace(/^\s+/, '');
    }
}
if ('undefined' == typeof String.prototype.rtrim) {
    String.prototype.rtrim = function() {
	return this.replace(/\s+$/, '');
    }
}
		    
function showNew(){
    for(n in ne){
        var item=document.getElementById('ne'+n);
	if(!item)var item=document.getElementById('e'+n);
	if(!item)var item=document.getElementById('t'+n);
	if(item){
    	    if(fCat.adm.checked){
		item.className="expand";
	    }else{
		item.className="collaps";
	    }
	}
    }
}
function kPress(e){
    var kk = navigator.appName == 'Netscape' ? e.which : e.keyCode;
    if (kk == 13){
	document.fCat['adm'].focus();
	return false;
    }
    return true
}
function fSet(id,n){
    dl='';
    if(n=='d')dl=' class=tovar-sel';
    if(fCat.tmp.value.trim()==''){
	if(n=='n')fCat[n+'b_'+id].value='Новая группа';
	if(n=='d')fCat[n+'b_'+id].value='Отмена удаления группы';
	if(n=='')fCat[n+'b_'+id].value='Удаление группы';
    }else{
	fCat[n+'b_'+id].value=fCat.tmp.value.trim();
    }
    var item=document.getElementById(n+'e'+id);
    item.innerHTML='<a href=# OnCLick=fEdit(\"'+id+'\",\"'+n+'\")'+dl+'>'+fCat[n+'b_'+id].value+'</a>';
}
function fEdit(id,n){
    if(fCat.adm.checked){
	var item=document.getElementById(n+'e'+id);
	item.innerHTML='<input type=text name=tmp size=35 maxlength=100 value=\"'+fCat[n+'b_'+id].value+'\" OnBlur=fSet(\"'+id+'\",\"'+n+'\") onKeyPress="return kPress(event);">';
	fCat.tmp.focus();
	var r = fCat.tmp.createTextRange();
	r.collapse(false);
	r.select();
    }else{
    	if(n!='n')location.href="?a=l&e="+id;
    }
}
function sImg(name,pic) {
    var rnd = Math.round(Math.random() * 1000000000);
    document.images[name].src=pic+'?r='+rnd;
}
