function openWnd(url,wnd_name,width,height,scrollbars){		
	var stScrollBar = (scrollbars ? 'yes' : 'no');
	newWnd = window.open(url,wnd_name,'width='+width+',height='+height+',status=yes,menubar=no,resizable=yes,scrollbars='+stScrollBar+',left='+String((screen.width-width)/2)+',top='+String((screen.height-height)/2));
	newWnd.focus();
	return false;
}

function set_location(str){
	document.location = str;
	return false;
}

function setplace(s_id, cur_id){
	var val = document.getElementById(s_id).value;
	var place = 0;
	if(document.getElementById('country' + cur_id).value > 0) place = document.getElementById('country' + cur_id).value;
	if(document.getElementById('region' + cur_id).value > 0) place = document.getElementById('region' + cur_id).value;
	if(document.getElementById('city' + cur_id).value > 0) place = document.getElementById('city' + cur_id).value;
	if(document.getElementById('metro' + cur_id).value > 0) place = document.getElementById('metro' + cur_id).value;
	document.getElementById('place' + cur_id).value = place;
	if(s_id == 'country' + cur_id){
		arr = get_regions_array(val);
		change_list('region', cur_id, arr);
		setplace('region' + cur_id, cur_id);
	}
	if(s_id == 'region' + cur_id){
		arr = get_cities_array(val);
		change_list('city', cur_id, arr);
		setplace('city' + cur_id, cur_id);
	}
	if(s_id == 'city' + cur_id){
		arr = get_metro_array(val);
		change_list('metro', cur_id, arr);
		setplace('metro' + cur_id, cur_id);
	}
}

function change_list(listType, listID, arr){
	list = document.getElementById(listType + listID);
	var i = 1;
	var j = 0;
	list.length = arr.length;
	newline = new Option;
	newline.value = '0';
	if(listType == 'region' || listType == 'city'){ newline.text = 'не выбран'; } else { newline.text = 'не выбрана'; }
	list.options[0] = newline;
	for(var n = 0; n < arr.length; n++){
	    newline = new Option;
	    j = arr[n].search(';');
	    newline.value = arr[n].slice(j + 1);
	    newline.text = arr[n].slice(0, j);
		list.options[i] = newline;
	    i++;
	}
	list.value = list.options[0].value;
}

function setSalesCurrents(branch, item){
	document.salesAddCatalog.branch.value = branch;
	document.salesAddCatalog.item.value = item;
	document.salesAddCatalog.submit();
	return false;
}

function showComment(num){
	var oDiv = document.getElementById('comment_' + num);
	if(oDiv.style.display == 'none'){
		oDiv.style.display = '';
	} else {
		oDiv.style.display = 'none';
	}
}

function shure(message){
	return confirm(message);
}

function showImageContainers(sToDo, iItem, iFrom, iTo, bWithDesc){
	oContainer = document.getElementById('container' + iItem);
	if(oContainer){
		if(sToDo == 'add'){
			var iCur = iFrom;
			while(oCur = document.getElementById('image' + iCur)){
				iCur++;
			}
			if(iCur <= iTo){
				var oItem = document.createElement('input');
				oItem.setAttribute('type', 'hidden');
				oItem.setAttribute('id', 'item' + iCur);
				oItem.setAttribute('name', 'item' + iCur);
				oItem.setAttribute('value', iItem);

				var oImage = document.createElement('input');
				oImage.setAttribute('type', 'file');
				oImage.setAttribute('id', 'image' + iCur);
				oImage.setAttribute('name', 'image' + iCur);

				if(bWithDesc){
					var oName = document.createElement('input');
					oName.setAttribute('type', 'text');
					oName.setAttribute('id', 'name' + iCur);
					oName.setAttribute('name', 'name' + iCur);
					oName.setAttribute('size', '30');
					oName.setAttribute('maxlength', '255');

					var oBreak1 = document.createElement('br');
					oBreak1.setAttribute('id', 'br1_' + iCur);
					var oBreak2 = document.createElement('br');
					oBreak2.setAttribute('id', 'br2_' + iCur);

					oContainer.appendChild(oBreak1);
					oContainer.appendChild(oBreak2);
				}
				oContainer.appendChild(oItem);
				oContainer.appendChild(oImage);
				if(bWithDesc){
					oContainer.appendChild(oName);
				}
				oContainer.style.height = oImage.offsetHeight * (iCur - iFrom + 1) * (1 + bWithDesc * 1.6);
			}
		}

		if(sToDo == 'del'){
			var iCur = iTo;
			while(!(oImage = document.getElementById('image' + iCur))){
				iCur--;
			}
			if(iCur > iFrom){
				oContainer.style.height = oImage.offsetHeight * (iCur - iFrom) * (1 + bWithDesc * 1.6);
				oItem = document.getElementById('item' + iCur);
				oName = document.getElementById('name' + iCur);
				oBreak1 = document.getElementById('br1_' + iCur);
				oBreak2 = document.getElementById('br2_' + iCur);
				oContainer.removeChild(oImage);
				oContainer.removeChild(oItem);
				if(bWithDesc){
					oContainer.removeChild(oName);
					oContainer.removeChild(oBreak1);
					oContainer.removeChild(oBreak2);
				}
			}
		}
	}
}

function showObject(sID){
	if(oObject = document.getElementById(sID)){
		if(oObject.style.display == 'none'){
			oObject.style.display = '';
		} else {
			oObject.style.display = 'none';
		}
	}
}