<?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('hint.js'); ?>
<script language="javascript" type="text/javascript">
function chk(){
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	with(document.State)
	{ 	
		//if (StateName.value == "") { errorstr += "- Please enter State Name.\n"; StateName.focus();}
		//if (StateCode.value == "") { errorstr += "- Please enter State Code.\n"; StateCode.focus();}
	}	
	
	if (errorstr != '')
	{
		msgstr = msgstr + errorstr;
		alert(msgstr);
		return false;
	}
	else
	{
		return true;
	}
} 
$(document).ready(function() 
{
  $('#StateName').val(''); $('#StateCode').val('');$('#StateTaxName').val('');$('#StateTaxRate').val('');
 var dflt_state=$.trim($('#StateCountryId').val());
 showHide(dflt_state);
});

function showHide(arg)
{
   $('#StateName').val(''); $('#StateCode').val('');$('#StateTaxName').val('');$('#StateTaxRate').val('');
  if(arg=='US')
  {
     $('#us_states').show();
	 $('#other_states').hide(); $('#other_codes').hide();
  }
  else
  {
    $('#us_states').hide();	
	$('#other_states').show(); $('#other_codes').show();
  }
}  
</script>
            <div align="center" class="subheading">
              <div align="left">Tax Settings</div>
            </div>
            <br />
            <div align="left" id="item_details_admin">
			<?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#446423"><?php $session->flash(); ?></font></div><?php } ?>			
              <div align="center" id="items_display_area_admin">
                <div align="left" class="inner_content_area_admin">
                <?php echo $form->create('State', array('name' =>'State')); ?>
                  <div id="admin_heading">Add Tax Rate</div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Country</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     
                        <span class="toplinks">
						<?php echo $form->input('country_id', array('label' => ' ','options' => $countrylist,'selected' => 'US', 'class' =>'box2_admin' ,'onchange' => 'javascript:showHide(this.value)')); ?>
                        </span>
                      
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
				  
				  
				   <div  id="us_states" "style=display:none;">
				   <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">US State name <span class="required_field">*</span>					 
					</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<select class="box2_admin" name="us_state" id="us_state">
						<option value="All">All States</option>
						<?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>
				  
				  <div  id="other_states" "style=display:none;">
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">State name <span class="required_field">*</span>					 
					</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php echo $form->input('name', 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>
				  
				   <div  id="other_codes" "style=display:none;">
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent">
                      <p class="maintext_inner">Code (Enter 'All' for All states of country)<span class="required_field">*</span></p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php echo $form->input('code', 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>
				  
				  
                  <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">Tax Name </p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                      <span class="toplinks">
						<?php echo $form->input('tax_name', 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">Tax Rate &nbsp;(%)</p>
                    </div>
                    <div align="right" id="inner_rightcontent">
                     <span class="toplinks">
						<?php echo $form->input('tax_rate', 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="submit" value="Add Tax" onClick="return chk();" class="buttn_admin">
					<input type="button" value="Cancel" onClick="window.location.href='<?php echo $sitebase.$sitefolder;?>/states/index/'" 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>