$(document).ready(formInit);

function formInit() {

  var theform = $('form:first');
  var formelement = {
    'name':     {'check':'Require', 'warningparam':'name'},
    //'sex_1':    {'check':'Require', 'warningparam':'sex'},
    //'phone':    {'check':'Phone',   'warningparam':'phone'},
    'phone':    {'check':'Phone_Mobile',   'warningparam':'phone'}
    //'email':    {'check':'Email',   'warningparam':'email'},
    //'cardno':   {'check':'Require',  'warningparam':'cardno'},
    //'shop':   {'check':'Require',  'warningparam':'shop'},
    //'company':  {'check':'Require', 'warningparam':'company'},
    //'store':    {'check':'Require', 'warningparam':'store'},
    //'channel' : {'check':'Require', 'warningparam':'channel'},
    //'input_interest_0': {'check':'Require', 'warningparam':'interest'}
  };
    //alert($('#input_interest_0', theform)[0]);
  for (var e in formelement) {
    var attrs = formelement[e];
    var element = $('#'+e, theform);
    for (var attr in attrs) {
      element[0][attr] = attrs[attr];
    }
    element[0].warning=function(el){warn(el.warningparam)};
    //element.attr(attrs);
    //alert(element[0].check);
  }

}

/**
 * 提交时的处理
 */
function sent(form){
  resetformstyle();

  return CheckForm(form);
}


function warn(str) {
  var theform = $('form:first');
  //alert('#li_'+str);
  $('#li_'+str, theform).css({'border':'1px solid red','color':'red', 'background-color':'#ffeeee'});
}

function resetformstyle() {
  var theform = $('form:first');
  var lis = ['name','phone'];
  $(lis).each(function(i,e){
    $('#li_'+e, theform).css({'border':'none','color':'black', 'background-color':'#ffffff'});
  });
}

