/* common.js */
try{console.log('init console... done');}catch(e){console={log:function(s){}}}
jQuery.fn.wait=function(time,type){time=time||1000;type=type||"fx";return this.queue(type,function(){var self=this;setTimeout(function(){jQuery(self).dequeue();},time);});};jQuery(document).ready(function(){jQuery('a.submitForm').live('click',function(){jQuery(this).parents('form:first').submit();return false;});jQuery('.datefield').datepicker();jQuery('#dialog').dialog({autoOpen:false,modal:true,draggable:false,overlay:{backgroundColor:'#000000',opacity:0.5}});$('form input, form select').live('keypress',function(e){if($(this).parents('form').find('button[type=submit], input[type=submit]').length<=0)
return true;if((e.which&&e.which==13)||(e.keyCode&&e.keyCode==13)){$(this).parents('form').find('button[type=submit], input[type=submit]').click();return false;}else{return true;}});});function convertMeridian(hour,meridian){if(meridian=='0'){if(hour=='12'){hour='0';}}else{hour=parseInt(hour)+12;if(hour=='24'){hour='12';}}
return hour;}
function luhn_check(number){var number=number.replace(/\D/g,'');var number_length=number.length;var parity=number_length%2;var total=0;for(i=0;i<number_length;i++){var digit=number.charAt(i);if(i%2==parity){digit=digit*2;if(digit>9){digit=digit-9;}}
total=total+parseInt(digit);}
if(total%10==0){return true;}else{return false;}}
function clear_form_elements(ele){$(ele).find(':input').each(function(){switch(this.type){case'password':case'select-multiple':case'select-one':case'text':case'textarea':$(this).val('');break;case'checkbox':case'radio':this.checked=false;}});}
jQuery.fn.inputHints=function(){$(this).each(function(i){if($(this).val()==''){$(this).addClass('inputHint').val($(this).attr('title'));}});$(this).focus(function(){if($(this).val()==$(this).attr('title'))
$(this).removeClass('inputHint').val('');}).blur(function(){if($(this).val()=='')
$(this).addClass('inputHint').val($(this).attr('title'));});};
