<?php

/**
* @version 2.8.0
* @package Joomla 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?option=com_dtregister&Itemid=<?php echo $Itemid ?>" enctype="multipart/form-data">

   <dl>

         <dt class="dtlabel" valign="top">

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

         </dt>

         <dd class="dtfield">

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

         </dd>

   </dl>
   <dl>

		<dt class="dtlabel" valign="top"><strong><?php echo JText::_( 'DT_MEMBER'); ?> <?php echo $this->currentMember; ?> <?php echo JText::_( 'DT_INFORMATION'); ?></strong></td>

   </dl>
 <?php
       echo $this->form;
	  
	 ?>
  
   <input type="hidden" name="option" value="com_dtregister" />
   <input type="hidden" name="controller" value="usermanage" />
   <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>