function winopen(url){
   window.open(url,'','width=640, height=480,resizable=1,scrollbars=1');
   return;
}


//2008-05-19
//1. form with id '_rqd' focus on first element
//2. element with id '_rqd' will validate;
//3. in IE, rel attribute is used a alert information.
function formProcess(){
   
   var frms = document.getElementsByTagName('form');
   
   $each(frms, function(frm){

      if(frm.id.test(/_rqd/i)) {

         //using the ID as a mark, because some browsers don't support rel or any other arbitrary attributes
         //after the id is used, store the infor to el.rqd, and recover back to a 'normal' one (without the affix '_rqd', etc.)         
         var els = $(frm).getFormElements();
         var focused = false;
         
         $each(els, function(el){
            if(el.id.test(/_rqd$/i)){
               el.rqd=true; 
               el.id.replace(/_rqd$/i,'');   //????
            }
            if(!el.getValue() && !focused) {
               el.focus();
               focused = true;
            }
         });
      
         //same thing to the form id.
         frm.id = frm.id.replace(/_rqd$/i,'');
         frm.rqd = true;
         
         
         $(frm).addEvent('submit', function(e){
            
            var e = new Event(e);         

            for(var i=0; i<$A(els).length; i++){
               
               //an invalidate entry found
               if(!els[i].getValue() && els[i].rqd == true) {
                  
                  //invalidate the form submit action.
                  e.stop();
                  
                  //IE supports 'rel' attribute
                  alert(els[i].rel ? els[i].rel : 'Please fill the highlighted field!');
                  
                  els[i].focus();
                  
                  $(els[i]).addClass('required');
                  $(els[i]).addEvent('change', function(){
                                                   if(this.getValue()){
                                                      this.removeClass('required');
                                                   }
                                                });                  
                  break;
               }
            }
         });
      }
   })
}

