function CreateObForm(ob){
	var params = {};
	var name;
	var counter = 0;
	params["r"] = Math.random();

	$('input', $(ob)).each(function(){
		if(!$(this).attr('disabled')){
			if($(this).attr('type') == 'checkbox'){
				
				if($(this).attr('name').indexOf("[]") != -1){
					name = $(this).attr('name').split("[")
					name = name[0] + "["+$(this).attr('value')+"]";
					
					if($(this).attr('checked') == true)
						params[name] = true;
					else
						params[name] = false;
				}else{
					if($(this).attr('checked') == true)
						params[$(this).attr('name')] = true;
					else
						params[$(this).attr('name')] = false;
				}
			}else if($(this).attr('type') == 'radio'){
				
				if($(this).attr('name').indexOf("[]") != -1){
					name = $(this).attr('name').split("[")
					name = name[0] + "["+$(this).attr('value')+"]";
					
					if($(this).attr('checked') == true)
						params[name] = true;
					else
						params[name] = false;
				}else{
					if($(this).attr('checked') == true)
						params[$(this).attr('name')] = true;
					else
						params[$(this).attr('name')] = false;
				}
			}else{
				if($(this).attr('value') == undefined)
					params[$(this).attr('name')] = '';
				else
					params[$(this).attr('name')] = $(this).attr('value');
			}
		}
	});
	
	$('textarea', $(ob)).each(function(){
		if(!$(this).attr('disabled')){
			var value = $(this).attr('value');
			if(value == undefined)
				value = '';
			params[$(this).attr('name')] = value;
		}
	});
	
	$('select', $(ob)).each(function(){
		if(!$(this).attr('disabled')){
			var nameSelect = $(this).attr('name');
			if($(this).attr('multiple')){
				if($(this).attr('name').indexOf("[]") != -1){					
					var name = $(this).attr('name').split("[")
					$('option:selected',$(this)).each(function(i){
						params[name[0]+"["+i+"]"] = $(this).attr('value');
					});
				}else{
					$('option:selected',$(this)).each(function(i){
						params[nameSelect+"["+i+"]"] = $(this).attr('value');
					});
				}
				
			}else{
				params[nameSelect] = $(this).attr('value');
			}
			/*$('option:selected',$(this)).each(function(i){
				if(i == 0){
					if($(this).attr('value') == undefined)
						params[nameSelect] = '';
					else
						params[nameSelect] = $(this).attr('value');
				}else{
					params[nameSelect] += ', '+$(this).attr('value');
				}
			});*/
		}
	});
	
	return params;
}




function ProgressShow(ob, name){
	$(ob).css('position','relative');
	//$(ob).css('overflow','hidden');
	var width = $(ob).width();
	var height = $(ob).height();
	$(ob).append('<div class="Progress"><div class="ProgressFon">&nbsp;</div><div class="ProgressBar"><img src="/core/templates/admin/images/loading_indicator.gif" alt="" /> '+name+'</div>');
	$('.Progress', $(ob)).css('width',width);
	$('.Progress', $(ob)).css('height',height);
	$('.ProgressFon', $(ob)).css('width',width);
	$('.ProgressFon', $(ob)).css('height',height);
	//$('.ProgressBar', $(ob)).css('left',width/2 - $('.ProgressBar', $(ob)).width()/2);
	//$('.ProgressBar', $(ob)).css('top',height/2 - $('.ProgressBar', $(ob)).height()/2);
}

function ProgressClose(ob){
	$('.Progress',$(ob)).remove();
	$(ob).removeAttr('style');
}

function ClearObForm(ob){
	
	$('input', $(ob)).each(function(){
		if($(this).attr('type') == 'checkbox'){
			$(this).attr('checked', false)
		}else if($(this).attr('type') == 'text'){
			$(this).attr('value', '');
		}
	});
	
	$('textarea', $(ob)).each(function(){
		$(this).attr('value', '');
	});
	
	$('select', $(ob)).each(function(){
		$('option:selected',$(this)).each(function(){
			$(this).attr('selected', false);
		});
	});
}


function getStrJSOb(ar){
	var params;

	if(typeof(ar) == "object"){
		params = '{';
		var c = 0;
		for (var key in ar){
			c++;
			if(c != 1)
				params += ',';
				
			if(typeof(ar[key]) == "object"){
				var t = getStrJSOb(ar[key]);
				params += '"'+key+'":'+t;
			}else{
				params += '"'+key+'":"'+ar[key]+'"';
			}
		}
		params += '}';
	}
	return params;
}