<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2010 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts VistaCart                     |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<?php	echo $javascript->link('jquery.js'); ?>
<?php echo $javascript->link('alphanumeric.js'); ?>
<script>
$(document).ready(function() 
{
  var dflt_billcntry='';
  <?php if(isset($bill["country"])) { ?>
  var dflt_billcntry='<?php echo $bill["country"];?>';
  <?php } ?>
  var dflt_shipcntry='';
  <?php if(isset($shipp["country"])) { ?>
  var dflt_shipcntry='<?php echo $shipp["country"];?>';
  <?php } ?>
  
   var dflt_billstate='';
  <?php if(isset($bill["state"])) { ?>
  var dflt_billstate='<?php echo $bill["state"];?>';
  <?php } ?>
  var dflt_shipstate='';
  <?php if(isset($shipp["state"])) { ?>
  var dflt_shipstate='<?php echo $shipp["state"];?>';
  <?php } ?>
  
  if(dflt_billcntry != '')
   {
       setBillStates(dflt_billcntry); 
	   $('#bstate').val(dflt_billstate);	
	   $('#us_bstate').val(dflt_billstate);		     
   }
  else 
  {
       setBillStates('US');	  
	   $('#us_bstate').val(dflt_billstate);		  
  }
  
  if(dflt_shipcntry != '') {
      setShipStates(dflt_shipcntry);
      $('#bstate').val(dflt_shipstate);	
	  $('#us_sstate').val(dflt_shipstate);		
   }
  else {
     setShipStates('US'); 
     $('#us_sstate').val(dflt_shipstate);
     $('#us_sstate').val(dflt_billstate);			
  }

});




function chk(thisform){
	var errorstr = '';
        var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	var i=0;
	var fcs_fld=new Array();	
	var errorstr = '';
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;   /* For Email Address*/
        var regfloat = /^[-]?[0-9]*.?[0-9]+$/;
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";		
	
	if ($.trim($('#UserEmail').val()) == '') { errorstr += "- Please enter Email Address.\n";  fcs_fld[i]='UserEmail'; i++;}	
	if ($.trim($('#UserEmail').val())!='') 
		{
		 if(reg.test($.trim($('#UserEmail').val())) == false) { errorstr += "- Invalid Email Address.\n";   fcs_fld[i]='UserEmail'; i++;}
		}	
	if ($.trim($('#UserPassword').val())!='') 
		{
         if ($.trim($('#UserPassword').val()).length < 6) { errorstr += "- Password should contain atleast 6 characters.\n";   fcs_fld[i]='UserPassword'; i++;}
		}

         if ($.trim($('#UserUserCredit').val())!='')
		{
                   
		 if(regfloat.test($.trim($('#UserUserCredit').val())) == false) { errorstr += "- Invalid User Credit.\n";   fcs_fld[i]='UserUserCredit'; i++;}
		}
		
		if ($.trim($('#UserBzip').val())!='' )
		 {
		   var bcntry=$.trim($('#UserBcountry').val());
		   var bzip=$.trim($('#UserBzip').val());
		   if(bcntry=='US') 
		   {
			   if(bzip.length < 5 || bzip.length > 5)
			   {   errorstr += "- Billing Zip code should contain only 5 numeric digits.\n";fcs_fld[i]='UserBzip'; i++; }		
		   }	   			
		}
		
		var usrbphone=$.trim($('#UserBphone').val());
		  var usrbmobile=$.trim($('#UserBmobile').val());
		  var usrbfax=$.trim($('#UserBfax').val());
		  
		  if(usrbphone!='' )
		   {		  
		      if(verify(usrbphone)==false)
              { errorstr += "- Billing Phone number should contain only numbers, spaces, (, ), - and + \n";fcs_fld[i]='UserBphone'; i++;}
		   }	  
			if(usrbmobile!='' )
		   {
			  if(verify(usrbmobile)==false)
              { errorstr += "- Billing Mobile number should contain only numbers, spaces, (, ), - and + \n"; fcs_fld[i]='UserBmobile'; i++;}
		   }
		   
		   if(usrbfax!='' )
		   {	  
			  if(verify(usrbfax)==false)
              { errorstr += "- Billing Fax number should contain only numbers, spaces, (, ), - and + \n"; fcs_fld[i]='UserBfax'; i++;}
			}  

		
		if ($.trim($('#UserSzip').val())!='' )
		 {
		   var scntry=$.trim($('#UserScountry').val());
		   var szip=$.trim($('#UserSzip').val());
		   if(scntry=='US') 
		   {
			   if(szip.length < 5 && szip.length > 5 )
			   {   errorstr += "- Shipping Zip code should contain only 5 numeric digits.\n";fcs_fld[i]='UserSzip'; i++; }		
		   }	   			
		}
		
		
		 var usrsphone=$.trim($('#UserSphone').val());
		  var usrsmobile=$.trim($('#UserSmobile').val());
		  var usrsfax=$.trim($('#UserSfax').val());
		  
		  if(usrsphone!='' )
		   {		  
		      if(verify(usrsphone)==false)
              { errorstr += "- Shipping Phone number should contain only numbers, spaces, (, ), - and + \n";fcs_fld[i]='UserSphone'; i++;}
		   }	  
			if(usrsmobile!='' )
		   {
			  if(verify(usrsmobile)==false)
              { errorstr += "- Shipping Mobile number should contain only numbers, spaces, (, ), - and + \n"; fcs_fld[i]='UserSmobile'; i++;}
		   }
		   
		   if(usrsfax!='' )
		   {	  
			  if(verify(usrsfax)==false)
              { errorstr += "- Shipping Fax number should contain only numbers, spaces, (, ), - and + \n"; fcs_fld[i]='UserSfax'; i++;}
			}  


			
	if (errorstr != '')
	{
		msgstr = msgstr + errorstr;
		alert(msgstr);
		$('#'+fcs_fld[0]+'').focus();$('#'+fcs_fld[0]+'').select();
		return false;
	}
	else
	{
		thisform.submit();
		return true;
	}
} 

function verify(str) 
{
    return /^[0-9\-\s\)\(\+]{1,}$/.test(str);
}

function same(){
	
	if($('#sameas').attr('checked')==true)
	{
	  $('#UserSfname').val($('#UserBfname').val());	
	  $('#UserSlname').val($('#UserBlname').val());
	  $('#UserSaddress').val($('#UserBaddress').val());
	  $('#UserScountry').val($('#UserBcountry').val());

	  if($('#UserBcountry').val() == 'US')
	  {
	    $('#ship_us_states').show();
		$('#ship_otherstates').hide();
	    $('#us_sstate').val($('#us_bstate').val());
	  }
	  else
	  {	  
	    $('#ship_otherstates').show();$('#ship_us_states').hide();
	    $('#UserSstate').val($('#UserBstate').val());
	  }
	
	  $('#UserScity').val($('#UserBcity').val());
	  $('#UserSzip').val($('#UserBzip').val());
	  $('#UserSphone').val($('#UserBphone').val());
	  $('#UserSmobile').val($('#UserBmobile').val());
	  $('#UserSfax').val($('#UserBfax').val());
	}
	else
	{
	          $('#UserSfname').val('');
			  $('#UserSlname').val('');
			  $('#UserSaddress').val('');
			  $('#UserScountry').val('US');
			  $('#UserScity').val('');
			  $('#UserSzip').val('');
			  $('#UserSphone').val('');
			  $('#UserSmobile').val('');
			  $('#UserSfax').val('');			
			  $('#ship_us_states').show();
			  $('#ship_otherstates').hide();
			  $('#us_sstate').val('AL');
	}
	//alert("not");
}

</script>
            <div align="center" class="subheading">
              <div align="left">Users</div>
            </div>
            <br />
          <?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#446423"><?php $session->flash(); ?></font></div><?php } ?>
            <div align="left" id="item_details_admin">           
              <div align="center" id="items_display_area_admin">
                <div align="left" class="inner_content_area_admin">
                 <?php echo $form->create('User', array('name' =>'User')); ?>
                  <div id="admin_heading">Edit User</div>
                  <div align="center">
                      <h3>User Details</h3>
                  </div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">UserName  </p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     
                        <span class="toplinks">
						<?php if(isset($usrdet["User"]["uname"])){ echo $form->input('uname', array('label' => '', 'value' => $usrdet["User"]["uname"], 'readonly' => 1, 'class' =>'box2_admin', 'size' => 27)); }else{echo $form->input('uname', array('label' => '', 'class' =>'box2_admin', 'size' => 27));} ?>
                      
                        </span>
                      
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
				  
				     <div id="grid_admin">
									<div align="left" id="inner_leftcontent">
									  <p class="maintext_inner">User Type<span class="required_field">*</span></p>
									</div>
									<div align="right" id="inner_rightcontent">
										<span class="toplinks">
											<?php 
															$utypes['wholesale']='wholesale';
															$utypes['retail']='retail';
															echo $form->input('usertype', array('options' => $utypes,'label' => '','class' => 'box2_admin')); ?>
										</span>							
									</div>
									<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
					  </div>
				
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Email </p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php if(isset($usrdet["User"]["email"])){ echo $form->input('email', array('label' => '', 'value' => $usrdet["User"]["email"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('email', array('label' => '', 'class' =>'box2_admin', 'size' => 27));} ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
				  
				   <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Password </p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php echo $form->input('password', array('label' => '', 'type' => 'password', 'value' => '', 'class' =>'box2_admin', 'size' => 27 , 'maxlength' => 25)); ?>
						<input type="checkbox" name="notify" id="notify" /><label class="maintext_inner"> Notify By Email</label>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="center">
                      <h3><a onclick="return false;" name="User Credit">User Credit Point</a></h3>
                  </div>
                  <div id="grid_admin">
                      <div>

                          <div align="left" id="inner_leftcontent">
                              <p class="maintext_inner">User Credit Point</p>
                          </div>
                          <div align="right" id="inner_rightcontent">
                              <span class="toplinks">
                                                            <?php
                                                            if(isset($usrdet["User"]["user_credit"])) {
                                                                echo $form->input('user_credit', array('label' => '', 'value' => $usrdet["User"]["user_credit"], 'class' =>'box2_admin', 'size' => 27 ,'onkeyup' => "setCreditAmount(this)"));
                                                            }
                                                            else {
                                                                echo $form->input('user_credit', array('label' => '','value' =>0, 'class' =>'box2_admin', 'size' => 27 ,'onkeyup' => "setCreditAmount(this)"));
                                                            }
                                                            $usrdet["User"]["user_credit"]
                                  ?>


                              </span>
                          </div>

                          <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>


                      </div>
                  </div>
                  <div id="grid_admin">
                      <div>
                          <div align="left" id="inner_leftcontent">
                              <p class="maintext_inner">User Credit Amount</p>
                          </div>
                          <div align="right" id="inner_rightcontent">
                              <span class="toplinks" id="creditamount">
                                  <?php echo $curlogo?><?php echo ($usrdet["User"]["user_credit"] * $userCreditAmount);?>

                              </span>
                          </div>
                          <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>

                      </div>
                  </div>
                 <div align="center">
                      <h3>Billing Address</h3>
                  </div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing First Name</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php if(isset( $bill["fname"])){ echo $form->input('bfname', array('label' => '', 'value' => $bill["fname"], 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); }else{ echo $form->input('bfname', array('label' => '', 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()'));} ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing Last name</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset( $bill["fname"])){ echo $form->input('blname', array('label' => '', 'value' => $bill["lname"], 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')) ;}else{ echo $form->input('blname', array('label' => '', 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()'));} ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing Address</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php if(isset($bill["address"])){ echo $form->input('baddress',array('rows' => '3','label' => '', 'value' => $bill["address"], 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); }else{ echo $form->input('baddress',array('rows' => '3','label' => '', 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()'));}?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  
				  
				  
				  
				                     
				  
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing Country</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
					 <?php if(!empty($bill["country"])) { ?>
					 <?php echo $form->input('bcountry', array('options' => $countrylist,'label' => '', 'selected' => $bill["country"],'class' => 'box2_admin','onchange' => 'javascript:setBillStates(this.value)'));?>
					 <?php }else{?>
					 <?php echo $form->input('bcountry', array('options' => $countrylist,'label' => '', 'selected' => 'US','class' => 'box2_admin','onchange' => 'javascript:setBillStates(this.value)'));?>
					 <?php } ?>					                   
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  
				  
				  
				 <div id="bill_us_states" style="display:none;">   
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing State </p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                    <span class="toplinks">
						<select class="box2_admin" name="data[User][us_bstate]" id="us_bstate" onKeyup="return same();">
													<?php
													foreach($us_states as $stval) { ?>
													<option value="<?php echo $stval["Statecode"]["code"];?>"><?php echo $stval["Statecode"]["name"];?></option>
													<?php } ?>
													</select>  
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  </div>
				  
				  
				  
				    <div id="bill_otherstates" style="display:none;">      
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing State </p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                    <span class="toplinks">                                 												
		           <?php				
					 if(!empty($bill["state"])) {
					echo $form->input('bstate', array('label' => '', 'class' =>'box2_admin', 'size' => 27 ,
					'value' => $bill["state"] , 'onKeyUp'=>'same()'));
					}
					else
					{
					echo $form->input('bstate', array('label' => '', 'class' =>'box2_admin', 'size' => 27 ,
					'value' => '', 'onKeyUp'=>'same()'));
					}
					?>
					
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  </div>
				  
				  
				  
				  
				  
				    
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing City</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($bill["city"])){ echo $form->input('bcity',array('label' => '', 'value' => $bill["city"], 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); }else{ echo $form->input('bcity',array('label' => '', 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()'));}?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
					
					
				  
				  

				  
				  
				  
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing Zip code</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($bill["zip"])){ echo $form->input('bzip',array('label' => '', 'value' => $bill["zip"], 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); }else{ echo $form->input('bzip',array('label' => '', 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()'));}?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing Phone</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($bill["phone"])){ echo $form->input('bphone',array('label' => '', 'value' => $bill["phone"], 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); }else{ echo $form->input('bphone',array('label' => '', 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); } ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing Mobile</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($bill["mobile"])){ echo $form->input('bmobile',array('label' => '', 'value' => $bill["mobile"], 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); }else{ echo $form->input('bmobile',array('label' => '', 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()'));} ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Billing Fax</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($bill["fax"])){ echo $form->input('bfax',array('label' => '', 'value' => $bill["fax"], 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); }else{ echo $form->input('bfax',array('label' => '', 'class' =>'box2_admin', 'size' => 27,'onKeyUp'=>'same()')); } ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				   <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner"></p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<input type="checkbox" name="sameas" id="sameas" onClick="same();" class="box2_admin" style="float:left; width:auto;">  <p class="maintext_inner" style="margin-top:0">Same as Billing Address</p> 
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>

                  <div align="center">
                      <h3>Shipping Address</h3>
                  </div>
		<div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping First Name</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php if(isset( $shipp["fname"])){ echo $form->input('sfname', array('label' => '', 'value' => $shipp["fname"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('sfname', array('label' => '', 'class' =>'box2_admin', 'size' => 27));} ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping Last name</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset( $shipp["lname"])){ echo $form->input('slname', array('label' => '', 'value' => $shipp["lname"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('slname', array('label' => '', 'class' =>'box2_admin', 'size' => 27));} ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping Address</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php if(isset($shipp["address"])){ echo $form->input('saddress',array('rows' => '3','label' => '', 'value' => $shipp["address"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('saddress',array('rows' => '3','label' => '', 'class' =>'box2_admin', 'size' => 27)); } ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  
				  
				  
				  
			
			
				  
				  

				  
				  
				  	  
				  
				    <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping Country</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php  if(!empty($shipp["country"])) { ?>
													<?php echo $form->input('scountry', array('options' => $countrylist,'label' => '', 'selected' => $shipp["country"],'class' => 'box2_admin','onchange' => 'javascript:setShipStates(this.value)'));?>
												<?php }else{ ?>
													<?php echo $form->input('scountry', array('options' => $countrylist,'label' => '', 'selected' => 'US','class' => 'box2_admin','onchange' => 'javascript:setShipStates(this.value)'));?>
												<?php } ?>								
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  
				  
				  
				    <div id="ship_us_states" style="display:none;">   
				   <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping State</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                    <span class="toplinks">
						<select class="box2_admin"  name="data[User][us_sstate]"   id="us_sstate" >
												<?php
												foreach($us_states as $stval) { ?>
												<option value="<?php echo $stval["Statecode"]["code"];?>"><?php echo $stval["Statecode"]["name"];?></option>
												<?php } ?>
												</select> 
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  </div>
				  
				    
					
					 <div id="ship_otherstates" style="display:none;">   
					<div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping State</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                    <span class="toplinks">
					
					<?php
					 if(!empty($shipp["state"])) {
					echo $form->input('sstate', array('label' => '', 'class' =>'box2_admin', 'size' => 27 ,
					'value' => $shipp["state"]));
					}
					else
					{
					echo $form->input('sstate', array('label' => '', 'class' =>'box2_admin', 'size' => 27 ,
					'value' => ''));
					}
					?>
					
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				    </div>
				  
				  
				  	  
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping City</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($shipp["city"])){ echo $form->input('scity',array('label' => '', 'value' => $shipp["city"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('scity',array('label' => '', 'class' =>'box2_admin', 'size' => 27)); }?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  
				  
				  
                 
				  
				  
				  
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping Zip code</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($shipp["zip"])){ echo $form->input('szip',array('label' => '', 'value' => $shipp["zip"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('szip',array('label' => '', 'class' =>'box2_admin', 'size' => 27)); }?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  
				  
				  
				  
				  
				  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping Phone</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($shipp["phone"])){ echo $form->input('sphone',array('label' => '', 'value' => $shipp["phone"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('sphone',array('label' => '', 'class' =>'box2_admin', 'size' => 27)); } ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping Mobile</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($shipp["mobile"])){ echo $form->input('smobile',array('label' => '', 'value' => $shipp["mobile"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('smobile',array('label' => '', 'class' =>'box2_admin', 'size' => 27)); } ?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Shipping Fax</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php if(isset($shipp["fax"])){ echo $form->input('sfax',array('label' => '', 'value' => $shipp["fax"], 'class' =>'box2_admin', 'size' => 27)); }else{ echo $form->input('sfax',array('label' => '', 'class' =>'box2_admin', 'size' => 27)); }?>
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                 <div id="admin_bottom">
				<div align="left" id="inner_leftcontent">
				  <p class="maintext_inner">&nbsp;</p>
				</div>
				<div align="right" id="inner_rightcontent">
					<span class="toplinks">		
					<input type="button" value="Update" onClick="return chk(document.User);" class="buttn_admin" >
					<input type="button" value="Cancel" onClick="javascript:history.go(-1);" class="buttn_admin" >
					
					</span>
				</div>
				<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
			</div>
                </div>
                <!--form area end -->
				<?php echo $form->end(); ?>
              </div>
              <div align="left" class="float_clear1"></div>
            </div>
            <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
            </div>
			
<script type="text/javascript">
/*
$('#UserBphone').numeric({allow:"(,),-,+"});
$('#UserBmobile').numeric({allow:"(,),-,+"});
$('#UserBfax').numeric({allow:"(,),-,+"});
$('#UserSphone').numeric({allow:"(,),-,+"});
$('#UserSmobile').numeric({allow:"(,),-,+"});
$('#UserSfax').numeric({allow:"(,),-,+"});
*/


function setBillStates(val)
{
  if(val=='US')
  {
    $('#bill_us_states').show();
	$('#bill_otherstates').hide(); 
  }	
  else
  {
    $('#bill_otherstates').show(); 
	$('#bill_us_states').hide();
  }	
}

function setShipStates(val)
{
  if(val=='US')
  {
    $('#ship_us_states').show();
	$('#ship_otherstates').hide(); 
  }	
  else
  {
    $('#ship_otherstates').show(); 
	$('#ship_us_states').hide();
  }	
  
}
function setCreditAmount(txtPoint){
    var userCreditAmount = <?php echo $userCreditAmount;?>;
    if(userCreditAmount == "")
        userCreditAmount = 0;
    var creditAmount = 0;
    //if(txtPoint.value.match(/^[0-9]+$/)){
        
   // }
    if(txtPoint.value.match(/^[0-9]+(\.([0-9]{1,2})?)?$/)){
    creditAmount = parseFloat(txtPoint.value * userCreditAmount).toFixed(2);
    $("#creditamount").html('<?php echo $curlogo?>'+creditAmount);
    }else{
        //alert("Please enter valid user credit point.")
    }
    
    
}
</script>