<?php

/**
* @version 2.7.16
* @package Joomla 1.7/2.5
* @subpackage DT Register
* @copyright Copyright (C) 2006 DTH Development
* @copyright contact dthdev@dthdevelopment.com
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

global $Itemid;

?>
<form name="adminForm" method="post" action="index.php" enctype="multipart/form-data">
  
  <table>
   <tr>

         <td>

           <?php echo JText::_( 'DT_DISCOUNT_CODE'); ?>

         </td>

         <td>

           <input type="text" id="discountcode_id" name="User[discount_code]" value="" class="inputbox" />

         </td>

         <td> </td>

      </tr>
 <tr >

		<td colspan="3" align="left" ><strong>Member <?php echo $this->currentMember; ?> Information</strong></td>

		</tr>
 <?php
       echo $this->form;
	  
	 ?>
  
  </table>
   <input type="hidden" name="option" value="com_dtregister" />
   <input type="hidden" name="controller" value="user" />
   <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
   <input type="hidden" name="task" value="member" />
   <input type="hidden" name="formsubmit" value="1" />
</form>
<div id="debug">
</div>
<script type="text/javascript">
 
 DTjQuery(function(){
   //DTjQuery.validator.messages.required = " ";

    DTjQuery(document.adminForm).validate({
	        success: function(label) {
				label.addClass("success");
			}

	});
	
	DTjQuery("#discountcode_id").change(function(){
		
		update_discountcode_fields();
		
	})
	
 })
 function update_discountcode_fields() {
  	  var element_class = "";
	  if(DTjQuery("#discountcode_id").size()){
	  DTjQuery.each(DTjQuery(".discountcode_show"),function(k,v){
	  		 element_class = "code_"+DTjQuery("#discountcode_id").val().toLowerCase() ;
			if( DTjQuery(v).hasClass(element_class) ){
				if(navigator.appName.indexOf("Micro") >=0){

					display = 'block';

				}else{

					display = 'table-row';

				}
				DTjQuery(v).css({display:display});
			} else {
				DTjQuery(v).hide();
			}
			
	  })
	  }
	  
  }
  
    update_discountcode_fields();
	
 function submitbutton(pressbutton){
    
	if(DTjQuery(document.adminForm).valid()){
		 DTjQuery.each(DTjQuery(".discountcode_show"),function(k,v){
				  
				  if( DTjQuery(v).is(':visible') ){
					 
				  } else {
					  DTjQuery(v).remove();
				  }
				  
			})
	  	submitform(pressbutton);
	}
	
	return false;

}

</script>