function selectChange(control, controlToPopulate, controlToPopulate3,ItemArray, ItemArray1, GroupArray)
{
  var myEle ;
  var x ;
  var y;

  // Empty the second drop down box of any choices
  for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
  for (var p=controlToPopulate3.options.length;p>=0;p--) controlToPopulate3.options[p]=null;

  // ADD Default Choice - in case there are no values
//  myEle = document.createElement("option") ;
//  myEle.value = '' ;
//  myEle.text = "请选择" ;
//  controlToPopulate.add(myEle) ;
  // Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0 ; x < ItemArray.length  ; x++ )
    {
      if ( GroupArray[x] == control.value )
      {
          myEle = document.createElement("option") ;
          myEle.value = ItemArray[x] ;
          myEle.text = ItemArray1[x] ;
          controlToPopulate.add(myEle) ;
     }
    }
    
  for(y = 0; y < ItemArray.length ;y++)
    {
    	
      if ( GroupArray[y] == controlToPopulate.options[0].value )
      {
      	  myEle = document.createElement("option") ;
          myEle.value = ItemArray[y] ;
          myEle.text = ItemArray1[y] ;
          controlToPopulate3.add(myEle) ;
     }
    }  
}


function selectChang2(control, controlToPopulate, ItemArray, ItemArray1, GroupArray, isAllowMulti)
{
  var myEle ;
  var x ;

  // Empty the second drop down box of any choices
  for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

  if( isAllowMulti ) {
  	
	myEle = document.createElement("option") ;
	myEle.value = control.value ;
	myEle.text = "全部" ;
	controlToPopulate.add(myEle);
  }
  if( 100 != control.value ) {
  	
  // ADD Default Choice - in case there are no values
//  myEle = document.createElement("option") ;
//  myEle.value = '' ;
//  myEle.text = "请选择" ;
//  controlToPopulate.add(myEle) ;
  // Now loop through the array of individual items
  // Any containing the same child id are added to
  // the second dropdown box
  for ( x = 0 ; x < ItemArray.length  ; x++ )
    {
      if ( GroupArray[x] == control.value )
      {
          myEle = document.createElement("option") ;
          myEle.value = ItemArray[x] ;
          myEle.text = ItemArray1[x] ;
          controlToPopulate.add(myEle) ;
     }
    }
  }
}

function initcategory(control,controlToPopulate,ItemArray,ItemArray1,GroupArray)
{
  var myEle ;
  var x ;
  
  // Empty the current drop down box of any choices
  for (var q=control.options.length;q>=0;q--) control.options[q]=null;
  
  for ( x = 0 ; x < ItemArray.length  ; x++ )
  {
  	if(GroupArray[x]== controlToPopulate.value)
  	{
          myEle = document.createElement("option") ;
          myEle.value = ItemArray[x] ;
          myEle.text = ItemArray1[x] ;
          control.add(myEle) ;  		
  	}
  }
  
}

function initcategory(control,controlToPopulate,ItemArray,ItemArray1,GroupArray,initValue, isAllowMulti)
{
  var myEle ;
  var x ;
  
  // Empty the current drop down box of any choices
  for (var q=control.options.length;q>=0;q--) control.options[q]=null;
  
  if( isAllowMulti ) {
  	
	myEle = document.createElement("option") ;
	myEle.value = controlToPopulate.value ;
	myEle.text = "全部" ;
	control.add(myEle);
  }
  for ( x = 0 ; x < ItemArray.length  ; x++ )
  {
  	if(GroupArray[x]== controlToPopulate.value)
  	{
          myEle = document.createElement("option") ;
          myEle.value = ItemArray[x] ;
          myEle.text = ItemArray1[x] ;
           
          //if(ItemArray[x]==initValue+1){
          //	myEle.selected=true;
          //} else {
          //	myEle.selected=false;
          //}		
          
		
          control.add(myEle);
          if(ItemArray1[x]==initValue){
          	myEle.selected=true;
          } else {
          	myEle.selected=false;
          }
  	}
  }  
}

function populate(yearControl,monthControl,dayControl) {
  timeA = new Date(yearControl.options[yearControl.selectedIndex].text, monthControl.options[monthControl.selectedIndex].value,1);
  timeDifference = timeA - 86400000;
  timeB = new Date(timeDifference);
  var daysInMonth = timeB.getDate();
  for (var i = 0; i < dayControl.length; i++) {
    dayControl.options[0] = null;
  }
  for (var i = 0; i < daysInMonth; i++) {
    dayControl.options[i] = new Option(i+1);
  }
  dayControl.options[0].selected = true;
}

function onSubmitCheck(form, validation) {

var messages = [];
for(var property in validation) {

if( '' == form[property].value ) {

messages[messages.length] = validation[property] + "不得为空。";
}
}
if( messages.length ) {
showMessage(messages);
return false;
} else {
return true;
}
}

function showMessage(messages) {
var message = '';
for(var i = 0, num = messages.length; i < num; i++) {
message += (i + 1) + ": " + messages[i] + "\r\n";
}

alert(message);
}


