

function showBlock(ID){
	$(ID).show();
}
function hideBlock(ID){
	$(ID).hide();
}
function goto(href){
	document.location = href;
}

/**
function catAjaxShowOrganization(id){
	var p = {};
	p.zone = 'catalog';
	p.action = 'showOrganization';
	p.id = id;
	$.post("ajax.php", p, function(responce){
		modShowModal('Просмотр организации', responce);
	});
}
/**/


/**
function catAjaxShowDetail(mode, id){
var p = {};
p.zone = 'catalog';
p.action = 'showDetail';
p.mode = mode;
p.id = id;
$.post("ajax.php", p, function(responce){
modShowModal('Просмотр свойств', responce);
});
}
/**/

/**
function catAjaxShowDetail(mode, id){
	var p = {};
	p.zone = 'catalog';
	p.action = 'showDetail';
	p.mode = mode;
	p.id = id;
	$.post("ajax.php", p, function(responce){
		//return responce;
		modShowModal('Просмотр свойств', responce);
	});
}
/**/


function catProcessTree(strID){
	//alert('Debug: StrID = ' + strID);
	node = document.getElementById('tree'+strID);
	//alert('Debug: node.innerHTML = ' + node.innerHTML);
	//nodeClass = node.getAttribute('class');
	nodeClass = $(node).attr('class');
	//alert('Debug: nodeClass = ' + nodeClass);
	nodeID = '#tree'+strID;
	if( nodeClass == 'tree-close'){
		$(nodeID).attr('class','tree-open');
		$(nodeID+' img').attr('src','pic/m.gif');
		$(nodeID+' div').html("");
		$(nodeID+' div').load("ajax.php", {zone:"catalog", action: "ShowTreeLevel", id: strID, url: document.URL});
		$(nodeID+' div').show();
	};
	if( nodeClass == 'tree-open'){
		$(nodeID).attr('class','tree-close');
		$(nodeID+' img').attr('src','pic/p.gif');
		$(nodeID+' div').hide();
	};
}

function eachInputs(elem){
	var p = {};
	$('input', elem.form).each(
	function(){
		name = $(this).attr("name");
		value = $(this).attr("value");
		if(name){
			eval("p."+name+" = value");
		}
	}
	);

	$('select', elem.form).each(
	function(){
		name = $(this).attr("name");
		value = $(this).attr("value");
		if(name){
			eval("p."+name+" = value");
		}
	}
	);

	$('textarea', elem.form).each(
	function(){
		name = $(this).attr("name");
		value = $(this).attr("value");
		if(name){
			eval("p."+name+" = value");
		}
	}
	);
	return p;
}

/**
function ajaxSubmit(elem){
	//modCloseModal();
	$('select').css('visibility','visible');

	var p = eachInputs(elem);
	$.post("ajax.php", p, function(responce){
		modShowModal(response);
	});
	return false;
}
/**/

function ajaxChoise(elem, ID){
	keyValue = ID;
	displayValue = elem.innerText;
	$("input", elem.form).each(function()
	{
		switch( $(this).attr("name").toLowerCase() ){
			case 'ajax_key':
			keyInput = $(this).attr("value");
			break;
			case 'ajax_display':
			displayInput = $(this).attr("value");
			break;
		}
	}
	);

	$("input").each(function()
	{
		switch( $(this).attr("name").toLowerCase() ){
			case keyInput:
			$(this).attr('value', keyValue);
			break;
			case displayInput:
			$(this).attr('value', displayValue);
			break;
		}

	}
	);
	$('select').css('visibility','visible');
}

function ajaxSelect(elem, ajax_type){
	$("input", elem.parentNode).each(
	function(){
		switch( this.getAttribute('type').toLowerCase() ){
			case 'hidden':
			keyElem = this.getAttribute('name').toLowerCase();
			break;
			case 'text':
			dispElem = this.getAttribute('name').toLowerCase();
			break;
		}
	}
	);

	var p = eachInputs(elem);
	ajax_key 		= keyElem;
	ajax_display 	= dispElem;
	eval("p.ajax_key = ajax_key");
	eval("p.ajax_display = ajax_display");
	eval("p.ajax_type = ajax_type");
	eval("p.zone = 'cabinet'");

	$.post("ajax.php", p, function(responce){
		modShowModal("",responce);
	});

}

function ajaxChoiceRegion(elem, id, text){
	//modCloseModal();
	$("select").each(function(){
		if($(this).attr("name") == elem){
			opt = new Option (text);
			opt.value = id;
			opt.selected = true;
			this.options.add(opt);
			//ajaxSetOldRegion(elem, id);
		}
	})
}

function ajaxSetOldRegion(elem, old){
	$("select").each(function(){
		if($(this).attr("name") == elem){
			//var onChange = "ajaxSelectRegion('" + elem + "', '" + old + "')";
			var onChange = "return hs.htmlExpand(this, {src: '/ajax.php?zone=region&ajax_key=" + elem + "&old=" + old + "', width: 300 })";
			$(this).attr("ONCHANGE",onChange);
		}
	})
}

/**
function ajaxSelectRegion(elem, old){
	//modCloseModal();
	$("select").each(function(){
		if($(this).attr("name") == elem){
			if(! this.options[this.selectedIndex].value){
				var p = {
					zone: "region",
					ajax_key: elem,
					old: old,
				}
				$.post("ajax.php", p, function(responce){
					modShowModal("Выберите город",responce);
				});
			}
		}
	});
	//hs.close(this);
}
/**/
