
function galery_complete(){var opt={half:true,path:'/img/rating',space:false,hintList:['оч.плохо','плохо','средне','хорошо','отлично'],readOnly:true,cancel:false,noRatedMsg:''};$('.rating').each(function(){opt.start=$(this).data('average');$(this).raty(opt);});}
function removeGalleryWork(g_id){if(confirm('Вы действительно хотите удалить все файлы, относящиеся к работе с кодом '+g_id+' ?')){var url=get_webroot()+'/user/works/?delete&work_id='+g_id;$.get(url,function(data){$('#main_content').html(data);evalCompleteFunction(data);});}}
function choose_currency(param,mode){var $obj=$(param);var g_id=getKey($obj);var position=$obj.position();var top=0;var left=position.left;var $select=new Object();if(mode=='gallery'){$select=$('<select></select>').insertAfter($obj).attr('id','currency_'+g_id).html($('#currency').html()).css('position','absolute').attr('onblur','$(this).empty().remove()').attr('onchange','sele_currency_change(this,"gallery")');top=position.top+15;}else if(mode=='edit_form'){$select=$('#currency').css('position','absolute');top=$('#price_'+g_id).position().top;}else if(mode=='show_work'){$select=$('#currency').css({'margin-top':'-10px','position':'relative'});left+=10;}
$select.addClass('select_curr').data('g_id',g_id).css('top',top).css('left',left).css('z-index',1000).show().focus();}
function sele_currency_change(obj,mode){var curr_id=$(obj).val();if(curr_id){if(mode=='gallery'||mode=='show_work'){var url='/ajax/?mode=set_currency&curr_id='+curr_id;var data={};var _tmp=new Array();var g_id=0;$('a.currency').each(function(index){g_id=getKey($(this));_tmp.push(g_id);});data.g_code=_tmp;$.ajax({url:url,dataType:'xml',data:data,type:'POST',beforeSend:function(){$.blockUI();},error:function(){$(obj).empty().hide();try{$(obj).remove();}catch(e){}
$.unblockUI();},complete:function(res,status){var xmldoc=res.responseXML;var g_id='';var val='';if(xmldoc){var $tmp=$('currency',xmldoc);if($tmp){var curr_name=$tmp.eq(0).attr('name');if(curr_name){$('a.currency').each(function(){$(this).text(curr_name);});}
if(mode=='gallery'){$('#currency').html('');$('#currency').html($(obj).html());$('option','#currency').removeAttr('selected');$('#currency [value="'+curr_id+'"]').attr('selected','selected');}
$('work',xmldoc).each(function(){g_id=$(this).attr('g_id');val=$(this).attr('val');if(g_id){$('#price_'+g_id).text(val);}});}}
$(obj).hide();if(mode=='gallery'){$(obj).empty();try{$(obj).remove();}catch(e){}}
$.unblockUI();}});}else{var g_id=$(obj).data('g_id');var url='/ajax/?mode=get_cur_name&cur_id='+curr_id;$.ajax({url:url,beforeSend:function(){$.blockUI();},error:function(){$(obj).hide();$.unblockUI();},complete:function(res,status){var data=res.responseText;if(status=="success"||status=="notmodified"){$('#a_'+g_id).text(data);}
$(obj).hide();$.unblockUI();}});}}}
