function $(id) {
	if(typeof(id)=='object')
		return id;
    return document.getElementById(id);
}

function getval(obj) {
     switch(obj.type) {
     case 'select-one':
		 return obj.options[obj.selectedIndex].value;
     default:
     return obj.value;
     }
}

function show(obj, s) {
	if(s==null)
		s = true;
	$(obj).style.display = s?'':'none';
}

function hide(obj) {
	$(obj).style.display = 'none';
}


// custom


function extract_lang(name) {
	 var p = name.indexOf('[');
	 var r = name.indexOf(']');
	 var lang = name.substr(p+1, r-p-1);
	 return lang;
 }



function afis_limba(obj) {
	var lang = extract_lang(obj.name);
	var div = get('afis_'+lang);
	if(obj.value) {
		div.style.display = '';
	}
	else {
		div.style.display = 'none';
	}
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function classname_append(obj, name) {
	if(!obj.className)
	    obj.className = '';
	var a = obj.className.split(' ');
	for(i in a) {
	  if(a[i]==name)
		  return;
    }
	obj.className += ' '+name;
}

function classname_remove(obj, name) {
	if(!obj.className)
	    obj.className = '';
	var a = obj.className.split(' ');
	for(i in a) {
		if(a[i]==name)
			a[i]=null;
	}
	obj.className = a.join(' ');
}