function $(id){
	return document.getElementById(id);
}

function byId(id){
	return document.getElementById(id);
}

function clearVal(obj,title){
	if(obj.value==title){
		obj.value='';
	}
}

function writeVal(obj,title){
	if(obj.value==''){
		obj.value=title;
	}
}

function goToCat(id,cat){
	document.location = "/catalog/"+id+"/"+cat;
}

function goToPath(path,id){
	document.location = path+id;
}

function goToShop(id,cat){
	document.location = "/shop/"+id+"/"+cat;
}

function selectCity(val){
	document.getElementById('city2').style.display = val=='1000' ? 'block' : 'none';
}

function hideIt(name){
	byId('row_'+name).style.display='none';
	byId('sel_'+name).selectedIndex = 0;
}
function showIt(name){
	byId('row_'+name).style.display='table-row';
}
function hideAll(){
	hideIt('region');hideIt('reg_organ');hideIt('department');hideIt('organ');
}
function docCatView(doccat){
	hideAll();
	switch(doccat){
		case '1' : showIt('organ');break;
		case '2' : showIt('region');showIt('reg_organ');break;
		case '3' : showIt('department');break;
		default  : hideALL();
	}
}

function cityChange(id){
	document.getElementById('ancity').style.display = id==0 ? 'inline' : 'none';
}


alert_str = 'Вы должны заполнить поле';

val_fields = new Array();
val_fields['addresume'] = new Array("fio", "age","experience", "salary", "edu_descr","exp_descr","skill_descr");
val_fields['addvacancy'] = new Array("age_from","age_to","experience","salary","descr","org_name","fio","phone","email");

val_fieldnames = new Array();
val_fieldnames['addresume'] = new Array("ФИО","Возраст","Опыт","Зар. плата","Образование","Описание опыта работы","Описание профессиональных навыков");
val_fieldnames['addvacancy'] = new Array("Возраст от","Возраст до","Опыт работы","Заработная плата","Требования","Название организации","Ф.И.О. контактного лица","Телефон","E-mail");


function Validate(forma,level){
	fields = val_fields[level];
	cnt = fields.length;
	for(i=0;i<cnt;i++){
		field = fields[i];
		if (forma.elements[field].value == ""){
			alert(alert_str+":  \""+val_fieldnames[level][i]+"\"");
			forma.elements[field].focus();
			return false;
		}
	}
return true;
}


function checkRadio(){
	var isSelected = false;
	for(counter = 0;counter < document.getElementById('voteForm').voteq.length;counter++){
		if(document.getElementById('voteForm').voteq[counter].checked) isSelected = true; 
	}
	if(!isSelected){
		alert("Выберите ответ!");
		return false;
	}
return true;
}

function tb(url){
	window.open(url);
	return false;
}
