function openWin(link,id){
	window.open(link,"w"+id,"width=420px,height=600px,status=no,toolbar=no,menubar=no,scrollbars=yes");
}

function catalog_hide(fid){
	
	var cnt = document.getElementById("cat_hide_"+fid);
	var control = document.getElementById("cat_hide_"+fid+"_control");
	if(cnt.style.display == 'none'){
		cnt.style.display = 'block';
		control.className = control.className + " close";
		control.innerHTML = 'свернуть';
	}else{
		cnt.style.display = 'none';
		control.className = control.className.replace(" close","");
		control.innerHTML = 'показать все';
	}
	
}

function hideCalcBlock(id){
	
	var cnt = document.getElementById("cnt_"+id);
	var control = document.getElementById("control_"+id);
	if(!cnt.style.display || cnt.style.display == 'none'){
		cnt.style.display = 'block';
		control.className = control.className.replace("calc_tit","calc_tit opened");
	}else{
		cnt.style.display = 'none';
		control.className = control.className.replace(" opened","");
	}
	
	/* hide all opened */
	var divs = document.getElementsByTagName("div");
	for(var i=0; i<divs.length; i++){
		if(divs[i].className == "cnt" && divs[i].getAttribute("id") != "cnt_"+id && divs[i].style.display == "block"){
			divs[i].style.display = 'none';
			var tid = divs[i].getAttribute("id").substr(3);
			document.getElementById("control"+tid).className = document.getElementById("control"+tid).className.replace(" opened","");
			break;
		}
	}
	
}

function getSelectValue(form_name, field_name, withtext){
	
	var elm = document.forms[form_name].elements[field_name];
	
	if (!elm || elm.options == null || elm.options.length == 0)
		return "";
		
	return withtext?new Array(elm.options[elm.selectedIndex].value,elm.options[elm.selectedIndex].text):elm.options[elm.selectedIndex].value;
	
}

function clearOptions(form_name, field_name){	
	var sel = document.forms[form_name].elements[field_name];
	while(sel.options.length)
		sel.removeChild(sel.options[0]);
	//addOption(form_name,field_name,"","--");
}

function addOption(form_name, field_name, val, txt){
	
	var s_obj = document.forms[form_name].elements[field_name];	
	var o_obj = document.createElement("option");
	o_obj.value = val;
	o_obj.text = txt;
	if(navigator.appName == "Microsoft Internet Explorer")
		s_obj.add(o_obj);
	else
		s_obj.add(o_obj,null);
	
}
