function isNumeric(){if((window.event.keyCode>=48&&window.event.keyCode<=57)||window.event.keyCode==13||window.event.keyCode==27){return true}else{alert('خطا: در این قسمت فقط می‌توانید عدد وارد کنید.‏');return false}}function getPlainNumber(sValue){sValue=""+sValue;return sValue.replace(/\,/gi,'')}function get_persian_num(str){numbers=new Array('۰','۱','۲','۳','۴','۵','۶','۷','۸','۹');retval="";str=""+str;for(var i=0;i<str.length;i++){num=str.charCodeAt(i);if((num<=57)&&(num>=48)){retval+=numbers[str.charAt(i)]}else{retval+=str.charAt(i)}}return retval}function addCommas(sValue){sValue=sValue+"";var sRegExp=new RegExp('(-?[0-9]+)([0-9]{3})');while(sRegExp.test(sValue)){sValue=sValue.replace(sRegExp,'$1,$2')}return sValue}function in_array(needle,my_array){for(var i=0;i<my_array.length;i++){if(my_array[i]==needle){return true}}return false}function resetComboBox(id){obj=document.getElementById(id);obj.selectedIndex=0;for(i=obj.options.length;i>=1;i--){obj.remove(i)}}function fillComboBox(id,options){obj=document.getElementById(id);obj.selectedIndex=0;for(i=obj.options.length;i>=1;i--){obj.remove(i)}for(i=0;i<options.length;i++){if(typeof options=='Object'){obj.options[obj.options.length]=new Option(options[i][1],options[i][0])}else{obj.options[obj.options.length]=new Option(options[i],options[i])}}obj.selectedIndex=0}jQuery.fn.DisableElement=function(status,autofocus){return this.each(function(){var $this=$(this);var element_type=document.getElementById($this.attr('id')).type;if(status==true){if(element_type=='text'){$this.addClass('element-disabled')}$this.attr('disabled','true');$('label[@for='+$this.attr('id')+']').addClass('label-disabled');if(element_type=='select'||element_type=='select-one'){document.getElementById($this.attr('id')).selectedIndex=0}}else{$this.removeClass('element-disabled').removeAttr('disabled');$('label[@for='+$this.attr('id')+']').removeClass('label-disabled');if(autofocus!=undefined){if(autofocus){}}}})};jQuery.fn.ElementFocus=function(){return this.each(function(){var $this=$(this);$this.focus(function(){$this.addClass('element-focus')}).blur(function(){$this.removeClass('element-focus')})})};jQuery.fn.ElementHint=function(){return this.each(function(){var $this=$(this);$this.focus(function(){$this.parent('dd').find('ul').hide().end().find('.element-hint').fadeIn('normal')}).blur(function(){$this.parent('dd').find('.element-hint').hide().end().find('ul.errors').show().end()})})};jQuery.fn.ElementValidation=function(options){return this.each(function(){var $this=$(this);$this.change(function(){$this.removeClass('element-error');var post_data=$this.serialize();if($this.is("input:password")&&$this.attr('name')=='password_confirm'){var post_data=$this.parents('form').find('input:password').serialize()}$.ajax({type:'POST',url:options.url,data:post_data,dataType:'json',timeout:15000,beforeSend:function(xhr){$this.parent('dd').find('ul').remove().end().find('.element-hint').hide().end().append('<ul class="errors"></ul>').find('ul').html('<li class="loading"></li>').find('.loading').fadeIn('normal')},success:function(data){$this.parent('dd').find('.loading').remove().end();if(true==data){$this.parent('dd').find('ul').html('<li class="ok"></li>').find('li').fadeIn('slow').animate({opacity:1.0},1000).fadeOut('slow')}else{jQuery.each(data,function(elementName){jQuery.each(data[elementName],function(errorName,errorText){$this.parent('dd').find('ul').html('<li>'+errorText+'</li>').find('li').fadeIn('slow');$this.addClass('element-error')})})}return true}})})})};$(document).ready(function(){var preloadImages=new Array(staticHost+'/img/common/icon-info.gif',staticHost+'/img/common/icon-ok.gif',staticHost+'/img/common/icon-error.gif',staticHost+'/img/common/icon-loading.gif',staticHost+'/img/common/icon-error-big.gif',staticHost+'/img/common/icon-success-big.gif');for(i=0;i<preloadImages.length;i++){new Image().src=preloadImages[i]}});
