<?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'); 
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($ship["country"])) { ?>
  var dflt_shipcntry='<?php echo $ship["country"];?>';
  <?php } ?>
  
   var dflt_billstate='';
  <?php if(isset($bill["state"])) { ?>
  var dflt_billstate='<?php echo $bill["state"];?>';
  <?php } ?>
  var dflt_shipstate='';
  <?php if(isset($ship["state"])) { ?>
  var dflt_shipstate='<?php echo $ship["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);			
  }

});
</script>
<script language="javascript" type="text/javascript">
function chk(thisform){
	    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 msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";	
				
		if ($.trim($('#bemail').val()) == '') { errorstr += "- Please enter  Email Address.\n";  fcs_fld[i]='bemail'; i++;}
		if ($.trim($('#bemail').val())!='') 
		{
		 if(reg.test($.trim($('#bemail').val())) == false) { errorstr += "- Invalid Email Address.\n";   fcs_fld[i]='bemail'; i++;}
		}		
		
		
		if ($.trim($('#bfname').val()) == '') { errorstr += "- Please enter Billing First name.\n";  fcs_fld[i]='bfname'; i++;}
		if(chkname($.trim($('#bfname').val()))==false) { errorstr += "- Billing First name should contain only characters. \n"; fcs_fld[i]='bfname'; i++;}
		//if ($.trim($('#blname').val()) == '') { errorstr += "- Please enter Billing Last name.\n";  fcs_fld[i]='bfname'; i++;}
		
		if ($.trim($('#blname').val()) != '') { 
		if(chkname($.trim($('#blname').val()))==false) { errorstr += "- Billing Last name should contain only characters. \n"; fcs_fld[i]='blname'; i++;}
		}

			
		if ($.trim($('#baddress').val()) == '') { errorstr += "- Please enter Billing Address.\n";  fcs_fld[i]='baddress'; i++;}
		var bcntry=$('#bcountry').val();		
		if(bcntry != 'US')
		{
		  if ($.trim($('#bstate').val()) == '') { errorstr += "- Please enter Billing State.\n";  fcs_fld[i]='bstate'; i++;}		
		}  
	    if ($.trim($('#bcity').val()) == '') { errorstr += "- Please enter Billing City.\n";  fcs_fld[i]='bcity'; i++;}		
		if ($.trim($('#bzip').val()) == '') { errorstr += "- Please enter Billing Postal Code.\n";  fcs_fld[i]='bzip'; i++;}	
		if(bcntry == 'US' && $.trim($('#bzip').val()) !='')
		{
		  var bzipval=$.trim($('#bzip').val());
		  if(bzipval.length < 5 || bzipval.length > 5 )
		   {   errorstr += "- Billing Zip code should contain 5 numeric digits.\n"; fcs_fld[i]='bzip'; i++; }	
		}   
		
		if($.trim($('#bphone').val()) =='')
		{
		  errorstr += "- Please enter Billing Phone .\n";  fcs_fld[i]='bfname'; i++;
		}else{
                   var bphoneval=$.trim($('#bphone').val());
		   if(verify(bphoneval)==false)
              { errorstr += "- Billing Phone number should contain only numbers, spaces, (, ), - and + \n";fcs_fld[i]='bphone'; i++;    }
                }
		
		if($.trim($('#bmobile').val()) !='')
		{
		  var bmobileval=$.trim($('#bmobile').val());
		   if(verify(bmobileval)==false)
              { errorstr += "- Billing Mobile number number should contain only numbers, spaces, (, ), - and + \n";fcs_fld[i]='bmobile'; i++; }
		}  
		
		if($.trim($('#bfax').val()) !='')
		{
		  var bfaxval=$.trim($('#bfax').val());
		   if(verify(bfaxval)==false)
              { errorstr += "- Billing Fax number should contain only numbers, spaces, (, ), - and + \n";fcs_fld[i]='bfax'; i++; }
		}   
		
		
	<?php if($prodtype <> 'Digital') { ?>	
			
		if ($.trim($('#sfname').val()) == '') { errorstr += "- Please enter Shipping First Name.\n";  fcs_fld[i]='sfname'; i++;}		
		if(chkname($.trim($('#sfname').val()))==false) { errorstr += "- Shipping First name should contain only characters. \n"; fcs_fld[i]='sfname'; i++;}
		//if ($.trim($('#slname').val()) == '') { errorstr += "- Please enter Shipping Last Name.\n";  fcs_fld[i]='sfname'; i++;}		
		if ($.trim($('#slname').val()) != '') { 	
		if(chkname($.trim($('#slname').val()))==false) { errorstr += "- Shipping Last name should contain only characters. \n"; fcs_fld[i]='slname'; i++;}		
		}	
		//if ($.trim($('#slname').val()) == '') { errorstr += "- Please enter Shipping Last Name.\n";  fcs_fld[i]='slname'; i++;}
		if ($.trim($('#saddress').val()) == '') { errorstr += "- Please enter Shipping Address.\n";  fcs_fld[i]='saddress'; i++;}
		

		var scntry=$('#scountry').val();		
		if(scntry != 'US')
		{
		  if ($.trim($('#sstate').val()) == '') { errorstr += "- Please enter Shipping State.\n";  fcs_fld[i]='sstate'; i++;}
		}  
		if ($.trim($('#scity').val()) == '') { errorstr += "- Please enter Shipping City.\n";  fcs_fld[i]='scity'; i++;}		
		if ($.trim($('#szip').val()) == '') { errorstr += "- Please enter Shipping Postal Code.\n";  fcs_fld[i]='szip'; i++;}			
		if(scntry == 'US' && $.trim($('#szip').val()) !='')
		{
		  var szipval=$.trim($('#szip').val());
		  if(szipval.length < 5 || szipval.length > 5)
		   {   errorstr += "- Shipping Zip code should contain only 5 numeric digits.\n"; fcs_fld[i]='szip'; i++; }	
		} 
		
		
		if($.trim($('#sphone').val()) !='')
		{
		  var sphoneval=$.trim($('#sphone').val());
		   if(verify(sphoneval)==false)
              { errorstr += "- Shipping Phone number should contain only numbers, spaces, (, ), - and + \n";fcs_fld[i]='sphone'; i++; }
		}  
		
		if($.trim($('#smobile').val()) !='')
		{
		  var smobileval=$.trim($('#smobile').val());
		   if(verify(smobileval)==false)
              { errorstr += "- Shipping Mobile number number should contain only numbers, spaces, (, ), - and + \n";fcs_fld[i]='smobile'; i++; }
		}  
		
		if($.trim($('#sfax').val()) !='')
		{
		  var sfaxval=$.trim($('#sfax').val());
		   if(verify(sfaxval)==false)
              { errorstr += "- Shipping Fax number should contain only numbers, spaces, (, ), - and + \n";fcs_fld[i]='sfax'; i++; }
		}   
		
    <?php } ?>
	
	if (errorstr != '')
	{
		msgstr = msgstr + errorstr;
		alert(msgstr);
		$('#'+fcs_fld[0]+'').focus();$('#'+fcs_fld[0]+'').select();
		return false;
	}
	else
	{
		thisform.submit();
		return true;
	}
} 
function same(){
	
	if($('#sameas').prop('checked')==true)
	{
	  $('#sfname').val($('#bfname').val());	
	  $('#slname').val($('#blname').val());
	  $('#saddress').val($('#baddress').val());
	  $('#scountry').val($('#bcountry').val());

	  if($('#bcountry').val() == 'US')
	  {
	    $('#ship_us_states').show();
		$('#ship_otherstates').hide();
	    $('#us_sstate').val($('#us_bstate').val());
	  }
	  else
	  {	  
	    $('#ship_otherstates').show();$('#ship_us_states').hide();
	    $('#sstate').val($('#bstate').val());
	  }
	
	  $('#scity').val($('#bcity').val());
	  $('#szip').val($('#bzip').val());
	  $('#sphone').val($('#bphone').val());
	  $('#smobile').val($('#bmobile').val());
	  $('#sfax').val($('#bfax').val());
	}
	else
	{
	  /*
	  $('#sfname').val('');
	  $('#slname').val('');
	  $('#saddress').val('');
	  $('#scountry').val('US');
	  $('#scity').val('');
	  $('#szip').val('');
	  $('#sphone').val('');
	  $('#smobile').val('');
	  $('#sfax').val('');
	  $('#ship_us_states').show();
	  $('#ship_otherstates').hide();
	  $('#us_sstate').val('AL');
	 
	  
	  var shipfname='';var shiplname='';var shipaddr='';
			var shipcity='';var shipcity='';var shipstate='';var shipcntry='';var shipzip='';
			var shipphone='';var shipfax='';var shipmobile='';
			
			<?php if(isset($ship["fname"])) { ?>
			shipfname='<?php echo $ship["fname"];?>';
			<?php } ?>
			<?php if(isset($ship["lname"])) { ?>
			shiplname='<?php echo $ship["lname"];?>';
			<?php } ?>
			<?php if(isset($ship["address"])) { ?>
			shipaddr='<?php echo $ship["address"];?>';
			<?php } ?>
			<?php if(isset($ship["city"])) { ?>
			shipcity='<?php echo $ship["city"];?>';
			<?php } ?>
			<?php if(isset($ship["state"])) { ?>
			shipstate='<?php echo $ship["state"];?>';
			<?php } ?>
			<?php if(isset($ship["country"])) { ?>
			shipcntry='<?php echo $ship["country"];?>';
			<?php } ?>
			<?php if(isset($ship["zip"])) { ?>
			shipzip='<?php echo $ship["zip"];?>';
			<?php } ?>
			<?php if(isset($ship["phone"])) { ?>
			shipphone='<?php echo $ship["phone"];?>';
			<?php } ?>
			<?php if(isset($ship["fax"])) { ?>
			shipfax='<?php echo $ship["fax"];?>';
			<?php } ?>
			<?php if(isset($ship["mobile"])) { ?>
			shipmobile='<?php echo $ship["mobile"];?>';
			<?php } ?>
			
			  $('#sfname').val(shipfname);
			  $('#slname').val(shiplname);
			  $('#saddress').val(shipaddr);
			  $('#scountry').val(shipcntry);
			  $('#scity').val(shipcity);
			  $('#szip').val(shipzip);
			  $('#sphone').val(shipphone);
			  $('#smobile').val(shipmobile);
			  $('#sfax').val(shipfax);
			
			
			  $('#ship_us_states').show();
			  $('#ship_otherstates').hide();
			  $('#us_sstate').val('AL');
			  
			   */
	}	
}

function chkname(str) 
{
    return /^[A-Za-z\s]{1,}$/.test(str);
}
function verify(str) 
{
    return /^[0-9\-\s\)\(\+]{1,}$/.test(str);
}
</script>
            <div align="center">
            	<h2 class="title text-center mainhd">Checkout</h2>
            </div>
            <br />
            <div align="left" id="billing_address">
              <!--items display area start -->
              <div align="center" id="items_display_area_admin" style="border:none">
                <div align="left" class="inner_content_area_admin">
				<?php $session->flash(); ?>
                <form name="bill_ship" action="<?php echo $html->url('/carts/checkout');?>" method="post">
                <div class="row">
                <div class="col-md-6">
				<div class="billing-pnl left">
                  <div id="admin_heading" style="margin-bottom:15px ">Billing Address</div>
                  <div id="grid_admin" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Email <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                     
                        <span class="toplinks">
						
                      <input type="text" value="<?php  if(!empty($email)) echo $email; ?>" name="bemail" id="bemail" 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" style="background:none "class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">First Name <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                     <span class="toplinks">
						<input type="text" value="<?php  if(!empty($bill["fname"])) echo $bill["fname"]; ?>" name="bfname"  id="bfname" class="box2_admin" size="27" onKeyup="return 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" style="background:none "class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Last Name</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php if(!empty($bill["lname"])) echo $bill["lname"]; ?>" name="blname" id="blname" class="box2_admin" size="27" onKeyup="return 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" style="background:none "class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Address <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                     <span class="toplinks">
		<input type="text" value="<?php if(!empty($bill["address"])) echo $bill["address"]; ?>" name="baddress" id="baddress"  class="box2_admin" size="27" onKeyup="return 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" style="background:none" class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Country <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                     <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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">State <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                    <span class="toplinks">
						<select class="box2_admin" name="us_bstate" id="us_bstate" onChange="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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">State <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                    <span class="toplinks">
                                 												<input type="text" value="<?php if(!empty($bill["state"])) echo $bill["state"]; ?>" name="bstate" id="bstate"  size="27" onKeyup="return same();" class="box2_admin">
         
                        </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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">City <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php if(!empty($bill["city"])) echo $bill["city"]; ?>" name="bcity" id="bcity" class="box2_admin" size="27" onKeyup="return 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" style="background:none" class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Zip code <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php if(!empty($bill["zip"])) echo $bill["zip"]; ?>" name="bzip" id="bzip" class="box2_admin" size="27" onKeyup="return 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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Phone<span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php if(!empty($bill["phone"])) echo $bill["phone"]; ?>" name="bphone" id="bphone" class="box2_admin" size="27" onKeyup="return 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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Mobile</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php if(!empty($bill["mobile"])) echo $bill["mobile"]; ?>" name="bmobile"  id="bmobile" class="box2_admin" size="27" onKeyup="return 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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Fax</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php if(!empty($bill["fax"])) echo $bill["fax"]; ?>" name="bfax" id="bfax"  class="box2_admin" size="27" onKeyup="return 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>
				   <?php if($prodtype <> "Digital"){ ?>
				   <div id="grid_admin" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner"></p>
                    </div>
                    
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
				  <?php }?>
				  
				  
				  
				  
				  
				  
				  
				  <?php if($prodtype <> 'Digital') { ?>		
				  
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
				  <div class="clear"></div>
				 </div>
				 </div>
				  <!--shipping-->
				  <div class="col-md-6">
				  <div class="shipping-pnl right">
				   <div id="admin_heading" style="margin-bottom:15px ">Shipping Address </div>
								
					 <div id="grid_admin" style="background:none" class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner"></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                     <span class="toplinks">
						<input type="checkbox"  name="sameas" id="sameas" onClick="javascript:same(this.value);" style="float:left "> <p class="maintext_inner" style="float:left; line-height:20px; margin:0px">Same as Billing Address</p> 
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
				  
				  
					
				  <div id="grid_admin" style="background:none;" class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">First Name <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                     <span class="toplinks">
						<input type="text" value="<?php  if(!empty($ship["fname"])) echo $ship["fname"]; ?>" name="sfname"   id="sfname" 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" style="background:none;" class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Last Name</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php  if(!empty($ship["lname"])) echo $ship["lname"]; ?>" name="slname"  id="slname"  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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Address <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                     <span class="toplinks">
						<input type="text" value="<?php  if(!empty($ship["address"])) echo $ship["address"]; ?>" name="saddress"  id="saddress"   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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Country <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                     <span class="toplinks">
						<?php  if(!empty($ship["country"])) { ?>
													<?php echo $form->input('scountry', array('options' => $countrylist,'label' => '', 'selected' => $ship["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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">State <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                    <span class="toplinks">
						<select class="box2_admin"  name="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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">State <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                    <span class="toplinks">
					<input type="text" value="<?php  if(!empty($ship["state"])) echo $ship["state"]; ?>" name="sstate"   id="sstate"  size="27"  class="box2_admin" >
                      
                        </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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">City <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php  if(!empty($ship["city"])) echo $ship["city"]; ?>" name="scity"  id="scity" 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" style="background:none" class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Zip code <span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php  if(!empty($ship["zip"])) echo $ship["zip"]; ?>" name="szip"   id="szip" 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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Phone</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php  if(!empty($ship["phone"])) echo $ship["phone"]; ?>" name="sphone" id="sphone" 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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Mobile</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php  if(!empty($ship["mobile"])) echo $ship["mobile"]; ?>" name="smobile" id="smobile" 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" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Fax</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<input type="text" value="<?php  if(!empty($ship["fax"])) echo $ship["fax"]; ?>" name="sfax" id="sfax" 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>
				  
				  <?php if(trim($prodtype) <> "Digital"){ ?>
				  <div id="grid_admin" style="background:none " class="grid-adm">
                    <div align="left" id="inner_leftcontent" class="lft-cell">
                      <p class="maintext_inner">Shipping Method</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
                      <span class="toplinks">
						<select name="shipmeth" class="box2_admin">
							<?php foreach($shipmethods as $smeth){
							if(trim($smeth) <> '') {
							 ?>
							<option value="<?php echo $smeth; ?>"><?php echo $smeth; ?></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>
				  <?php }  ?>
				  
				<?php } ?>  
				
                 <div id="admin_bottom" class="padding-10px-sides">
				<div align="left" id="inner_leftcontent" class="lft-cell">
				  <p class="maintext_inner">&nbsp;</p>
				</div>
				<div align="right" id="inner_rightcontent" class="ryt-cell" style="width:330px!important">
					<span class="toplinks">
                                         <input type="button" value="Cancel" onClick="javascript:history.go(-1);" class="btn-gry01" >
					<input type="button" value="Checkout" onClick="return chk(document.bill_ship);" class="btn-usr01" >
					
					
					</span>
				</div>
				<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
			</div>
			</div>
            </div>
            </div> 
                <!--form area end -->
				</form>
                </div>
			<div class="clear"></div>
				 </div>
              <div align="left" class="float_clear1"></div>
            </div>
            <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
			
			<?php if($prodtype == "Digital"){ ?>
<script language="javascript" type="text/javascript">
same();

</script>
<?php } ?>

<script type="text/javascript">
/*
$('#bzip').numeric();
$('#szip').numeric();
$('#bfname').alpha();
$('#blname').alpha();
$('#sfname').alpha();
$('#slname').alpha();

$('#bphone').numeric({allow:"(,),-,+"});
$('#bmobile').numeric({allow:"(,),-,+"});
$('#bfax').numeric({allow:"(,),-,+"});
$('#sphone').numeric({allow:"(,),-,+"});
$('#smobile').numeric({allow:"(,),-,+"});
$('#sfax').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();
  }	
  
}
</script>