	<?php echo $header; ?>

<style> 
input[type=text] {
  width: 30px;
  font-size:11px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: white;
  background-image: url('searchicon.png');
  background-position: 2px 2px; 
  background-repeat: no-repeat;
  padding-top: 1px;
  padding-bottom: 1px;
}
.list .left{
  text-align:left;
  padding:2px;
}


input[class=currency] {
  text-align:right;
}

input[class=GemCounts] {
  width: 20px;
  text-align:center;
  padding-left:2px;
  padding-right:2px;
}
select{
    box-sizing: border-box;
    margin: 0;
    border: 1px solid #aaa;
    box-shadow: 0 1px 0 1px rgba(0,0,0,.04);
    border-radius: .5em;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    background-color: #fff;
    background-position: right .7em top 50%, 0 0;
    background-size: .65em auto, 100%;
}
</style>

<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/order.png" alt="" /> Shipment & Costs </h1>
      <div class="buttons" id="newProductButton">	  
		<!-- <a onclick="SHIPNOW();$('#form').submit();"  value="Update"  id="Update"  name="Update" class="button">Ship Now</a> -->
		<a onclick="$('#form').attr('action', '<?php echo $updateShipAll; ?>'); $('#form').attr('onsubmit', 'return SHIPNOW()'); $('#form').submit();"  value="Update"  id="Update"  name="Update" class="button">Ship Now</a>
		
		

	  </div>
    </div>
    <div class="content">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form"  onsubmit="return validateForm()">
            <?php if ($orders) { ?>
			

						
        <table class="list oldProduct" >
          <thead>
            <tr>
              <!-- <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td> 
              <td class="right"><?php if ($sort == 'o.order_id') { ?>
                <a href="<?php echo $sort_order; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_order_id; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_order; ?>"><?php echo $column_order_id; ?></a>
                <?php } ?></td>   -->
				<td class="center">Order ID  <br> Product</td>
				
              <td class="center">M1</td>
              <td class="center">M2</td>
              <td class="center">G1</td>
              <td class="center">G2</td>
              <td class="center">G3</td>
              <td class="center">G4</td>
              <td class="center">G5</td>			  
			  <td class="center oldProduct">Sett</td>
			  <td class="center oldProduct">FilPol</td>
			  <td class="center oldProduct">Rhod</td>
			  <td class="center oldProduct">Cast</td>
			  <td class="center oldProduct">Plat</td>
			  <td class="center oldProduct">Oth Codes /<br>Cost</td>
			  <td class="center oldProduct">ShipQty</td>	
			  <td class="center oldProduct">Ship Ready</td>	
			  
            </tr>
          </thead>
          <tbody>			
			
            <?php foreach ($orders as $order) { ?>
            <tr > <!--
              <td style="text-align: center;"><?php if ($order['selected']) { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $order['order_id']; ?>" checked="checked" />
                <?php } else { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $order['order_id']; ?>" />
                <?php } ?></td> -->
              <td class="center"><?php echo $order['order_id']; ?><br><?php echo $order['name']; ?></td>
			  
			  <td class="center">
				<?php echo $order['M1']; ?><br>
				<?php if($order['M1'] != "" ){ ?>			
					<input type="text" name="M1Weight<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['M1Wt'],2)); ?>" class="currency" />
				<?php } ?>
			  </td>				  
			  <td class="left">
				<?php echo $order['M2']; ?><br>
				<?php if($order['M2'] != "" ){ ?> 				
					<input type="text" name="M2Weight<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['M2Wt'],2)); ?>" class="currency" />
				<?php } ?>
			  </td>
			  
			  <?php if($order['G1'] != "" ){ ?>
			  <td class="center">
					<?php echo $order['G1']; ?>
					<input type="text" name="G1Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G1#'],2); ?>" class="GemCounts" />
					<input type="text" name="G1Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G1Wt'],2)); ?>" class="currency" />
					<br>
					<select name="G1SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G1SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code'] ; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
					<br>
					<select name="G1ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G1ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
			  </td>
			  <?php }else{ ?>
					<td></td>
			  <?php } ?>
			  
			  <?php if($order['G2'] != "" ){ ?>
			  <td class="center">
					<?php echo $order['G2']; ?>
					<input type="text" name="G2Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G2#'],2); ?>" class="GemCounts" />
					<input type="text" name="G2Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G2Wt'],2)); ?>" class="currency" />
					<br>
					<select name="G2SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G2SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>				
					<br>
					<select name="G2ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G2ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>

			  </td>
			  <?php }else{ ?>
					<td></td>
			  <?php } ?>
			  <?php if($order['G3'] != "" ){ ?> 
			  <td class="center">
					<?php echo $order['G3']; ?>
					<input type="text" name="G3Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G3#'],2); ?>" class="GemCounts" />
					<input type="text" name="G3Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G3Wt'],2)); ?>" class="currency" />
					<br>
					<select name="G3SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G3SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>				
					<br>
					<select name="G3ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G3ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
			  </td>
			  <?php }else{ ?>
					<td></td>
			  <?php } ?>
			  <?php if($order['G4'] != "" ){ ?> 
			  <td class="center">
					<?php echo $order['G4']; ?>
					<input type="text" name="G4Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G4#'],2); ?>" class="GemCounts" />
					<input type="text" name="G4Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G4Wt'],2)); ?>" class="currency" />
					<br>
					<select name="G4SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G4SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>				
					<br>
					<select name="G4ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G4ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
			  </td>
			  <?php }else{ ?>
					<td></td>
			  <?php } ?>
			  <?php if($order['G5'] != "" ){ ?> 
			  <td class="center">
					<?php echo $order['G5']; ?>
					<input type="text" name="G5Count<?php echo $order['order_id']; ?>" value="<?php echo round($order['G5#'],2); ?>" class="GemCounts" />
					<input type="text" name="G5Wt<?php echo $order['order_id']; ?>" value="<?php printf("%.2f", round($order['G5Wt'],2)); ?>" class="currency" />
					<br>
					<select name="G5SizeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemSizes as $gemsize) { ?>
							<?php if ($gemsize['size_code'] == $order['G5SizeId']) { ?>
								<option value="<?php echo $gemsize['size_code']; ?>" selected="selected"><?php echo $gemsize['size_code']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemsize['size_code']; ?>"><?php echo $gemsize['size_code']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>				
					<br>
					<select name="G5ShapeId<?php echo $order['order_id']; ?>">
						<option value="0" selected="selected"><?php echo $text_none; ?></option>
						<?php foreach ($gemShapes as $gemShape) { ?>
							<?php if ($gemShape['shape_id'] == $order['G5ShapeId']) { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>" selected="selected"><?php echo $gemShape['shape']; ?></option>
							<?php } else { ?>
								<option value="<?php echo $gemShape['shape_id']; ?>"><?php echo $gemShape['shape']; ?></option>
							<?php } ?>
						<?php } ?>
					</select>
			  </td>
			  <?php }else{ ?>
					<td></td>
			  <?php } ?>

			  <!-- <td class="right"><input type="text" name="<?php echo $order['order_id']; ?>Setting" value="<?php  printf("%.2f", round($order['Setting'],2)); ?>" class="currency" /></td> -->
			  <td class="right"><select name="Setting<?php echo $order['order_id']; ?>">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($settingCodes as $settingCode) { ?>
                  <?php if ($settingCode['Id'] == $order['Setting']) { ?>
                  <option value="<?php echo $settingCode['Id']; ?>" selected="selected"><?php echo $settingCode['Code']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $settingCode['Id']; ?>"><?php echo $settingCode['Code']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
			  </td>
			  <td class="right"><input type="text" name="FilingPolishing<?php echo $order['order_id']; ?>" value="<?php printf("%.2f",  round($order['FilingPolishing'],2)); ?>" class="currency" /></td>
			  <td class="right"><select name="Rhodium<?php echo $order['order_id']; ?>">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($rhodiumCodes as $rhodiumCode) { ?>
                  <?php if ($rhodiumCode['Id'] == $order['Rhodium']) { ?>
                  <option value="<?php echo $rhodiumCode['Id']; ?>" selected="selected"><?php echo $rhodiumCode['Code']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $rhodiumCode['Id']; ?>"><?php echo $rhodiumCode['Code']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
			  </td>
			  <td class="right"><select name="Casting<?php echo $order['order_id']; ?>">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($castingCodes as $castingCode) { ?>
                  <?php if ($castingCode['Id'] == $order['Casting']) { ?>
                  <option value="<?php echo $castingCode['Id']; ?>" selected="selected"><?php echo $castingCode['Code']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $castingCode['Id']; ?>"><?php echo $castingCode['Code']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
			  </td>	
			  <td class="right"><select name="Plating<?php echo $order['order_id']; ?>">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($platingCodes as $platingCode) { ?>
                  <?php if ($platingCode['Id'] == $order['Plating']) { ?>
                  <option value="<?php echo $platingCode['Id']; ?>" selected="selected"><?php echo $platingCode['Code']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $platingCode['Id']; ?>"><?php echo $platingCode['Code']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
			  </td>		  
			  <td class="right">
			  	<select name="OtherCode<?php echo $order['order_id']; ?>">  
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($otherCodes as $otherCode) { ?>
                  <?php if ($otherCode['Id'] == $order['otherCode']) { ?>
						<option value="<?php echo $otherCode['Id']; ?>" selected="selected"><?php echo $otherCode['Code']; ?></option>
                  <?php } else { ?>
						<option value="<?php echo $otherCode['Id']; ?>"><?php echo $otherCode['Code']; ?></option>
                  <?php } } ?>  
                </select><br><br>	
				
				<input type="text" name="OtherCost<?php echo $order['order_id']; ?>" value="<?php printf("%.2f",  round($order['OtherCost'],2)); ?>" class="currency" />
			  </td>			  
			  <td class="right">				
				Ship Qty :<input type="text" name="ShipQty<?php echo $order['order_id']; ?>" value="<?php echo $order['ShipQty']; ?>" class="currency" /></br>
				Prod Qty :<input type="text" name="OrdProdQty<?php echo $order['order_id']; ?>" value="<?php echo $order['OrdProdQty']; ?>" class="currency" readonly/>
			  </td>
			  <td style="text-align: center;">
                <input type="checkbox" name="orderids[]" value="<?php echo $order['order_id']; ?>" checked="checked" />
			    <div class="buttons">	  
					<a onclick="SetUpdate('Update','<?php echo $order['order_id']; ?>' );$('#form').submit();"  value="Update"  id="Update"  name="Update" class="button">Update</a>
				</div>				
			  </td>
<!--			  
              <td style="text-align: center;"><?php if ($order['selected']) { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $order['order_id']; ?>" checked="checked" />
                <?php } else { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $order['order_id']; ?>" />
                <?php } ?>				

			    <div class="buttons">	  
					<a onclick="SetUpdate('Update','<?php echo $order['order_id']; ?>' );$('#form').submit();"  value="Update"  id="Update"  name="Update" class="button">Update</a>
				</div>
				
			  </td>	
			  -->
            </tr>
            <?php } ?>
			
            <?php } else { ?>
            <tr>
              <td class="center" colspan="15"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>			
			
          </tbody>
        </table>
		   <input type="hidden" name="InsertUpdateFlag" value="Update" />
		   <input type="hidden" name="processOrderId" value="Update" />

      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>

  </div>
</div>
<script type="text/javascript"><!--

function SetUpdate(action,order_id){
	document.forms["form"]["InsertUpdateFlag"].value =  action;
	document.forms["form"]["processOrderId"].value =  order_id;
	
}
function SHIPNOW(){
	checkedCount = 0;
	validation = true;
	list = document.getElementsByTagName('input');
	error="";
	for (index = 0; index < list.length; ++index) {
		item = list[index];
		if (item.getAttribute('type') === "checkbox" && item.checked && item.name === "orderids[]") {
			//validateOrder(item.value);			
			validation = validateOrder(item.value,"Order ID #"+item.value + " - ");			
			if(validation){}else{
				error=item.value;
			}			
			++checkedCount;
		}
	}
	if(error==""){
		alert('All selected OrderIds (' + checkedCount + ') are good.');
	}else{
		// alert('Order Id ' + error + ' is errored');
		return false;
	}	
    return true;	 
}
function newproductshow(){  
  
}

function filter() {
	url = 'index.php?route=sale/orderstockist&token=<?php echo $token; ?>';
	
	var filter_order_id = $('input[name=\'filter_order_id\']').attr('value');
	
	if (filter_order_id) {
		url += '&filter_order_id=' + encodeURIComponent(filter_order_id);
	}
	
	var filter_customer = $('input[name=\'filter_customer\']').attr('value');
	
	if (filter_customer) {
		url += '&filter_customer=' + encodeURIComponent(filter_customer);
	}
	
	var filter_order_status_id = $('select[name=\'filter_order_status_id\']').attr('value');
	
	if (filter_order_status_id != '*') {
		url += '&filter_order_status_id=' + encodeURIComponent(filter_order_status_id);
	}	

	var filter_total = $('input[name=\'filter_total\']').attr('value');

	if (filter_total) {
		url += '&filter_total=' + encodeURIComponent(filter_total);
	}	
	
	var filter_date_added = $('input[name=\'filter_date_added\']').attr('value');
	
	if (filter_date_added) {
		url += '&filter_date_added=' + encodeURIComponent(filter_date_added);
	}
	
	var filter_date_modified = $('input[name=\'filter_date_modified\']').attr('value');
	
	if (filter_date_modified) {
		url += '&filter_date_modified=' + encodeURIComponent(filter_date_modified);
	}
				
	location = url;
}
//--></script>  
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
});
//--></script> 
<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});
//--></script> 
<script type="text/javascript"><!--
$.widget('custom.catcomplete', $.ui.autocomplete, {
	_renderMenu: function(ul, items) {
		var self = this, currentCategory = '';
		
		$.each(items, function(index, item) {
			if (item.category != currentCategory) {
				ul.append('<li class="ui-autocomplete-category">' + item.category + '</li>');
				
				currentCategory = item.category;
			}
			
			self._renderItem(ul, item);
		});
	}
});

$('input[name=\'filter_customer\']').catcomplete({
	delay: 0,
	source: function(request, response) {
		$.ajax({
			url: 'index.php?route=sale/customer/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request.term),
			dataType: 'json',
			success: function(json) {		
				response($.map(json, function(item) {
					return {
						category: item.customer_group,
						label: item.name,
						value: item.customer_id
					}
				}));
			}
		});
	}, 
	select: function(event, ui) {
		$('input[name=\'filter_customer\']').val(ui.item.label);
						
		return false;
	}
});
//--></script> 
<script>
function validateForm() {
  formAction = $('input[name=\'InsertUpdateFlag\']').attr('value');
  OrderId = document.forms["form"]["processOrderId"].value ;
  return validateOrder(OrderId, "") ;
  /*
  if(OrderId != "NONE"){
	alert("vaidating " + OrderId);
	return validateOrder(OrderId, "") ;
  }else{
	return true;
  }
  */
}
function alertMe(Prefix,alertText){
	alert(Prefix + alertText);
}
function validateOrder(OrderId,AlertText) { 

  // Update Section
  var OrdProdQty = document.forms["form"]["OrdProdQty"+OrderId].value;
  var ShipQty = document.forms["form"]["ShipQty"+OrderId].value;
  if (ShipQty == "" || ShipQty == 0 ) {
    alertMe(AlertText,"Ship quantity must be filled out");
    return false;
  }else{
	if ( ShipQty > OrdProdQty ) {
		alertMe(AlertText,"Ship quantity must be less than order quantity");
		return false;
	}	  
  }
  
  var M1Weight = document.forms["form"]["M1Weight"+OrderId].value;
  if (M1Weight == "") {
    alertMe(AlertText,"Metal 1 - Weight must be filled out");
    return false;
  } 
  
  if (document.contains(document.getElementById("M2Weight"+OrderId))) {
		var M2Weight = document.forms["form"]["M2Weight"+OrderId].value;
		if (M2Weight == "") {
			alertMe(AlertText,"Metal 2 - Weight must be filled out");
			return false;
		}
  }

  
  if (document.contains(document.getElementById("G1ShapeId"+OrderId))) {
   
		var G1ShapeId = document.forms["form"]["G1ShapeId"+OrderId].value;
		if (G1ShapeId == 0) {
			alertMe(AlertText,"Gem 1 Shape must be selected");
			return false;
		}	 
		var G1SizeId = document.forms["form"]["G1SizeId"+OrderId].value;
		if (G1SizeId == 0) {
			alertMe(AlertText,"Gem 1 Size must be selected");
			return false;
		}
		var G1Count = document.forms["form"]["G1Count"+OrderId].value;
		if (G1Count == "") {
			alertMe(AlertText,"Gem 1 Count must be filled out");
			return false;
		}	
		var G1Wt = document.forms["form"]["G1Wt"+OrderId].value;
		if (G1Wt == "") {
			alertMe(AlertText,"Gem 1 Weight must be filled out");
			return false;
		}	  
	}
	
	if (document.contains(document.getElementById("G2ShapeId"+OrderId))) {
  
   
		var G2ShapeId = document.forms["form"]["G2ShapeId"+OrderId].value;
		if (G2ShapeId == 0) {
			alertMe(AlertText,"Gem 1 Shape must be selected");
			return false;
		}	 
		var G2SizeId = document.forms["form"]["G2SizeId"+OrderId].value;
		if (G2SizeId == 0) {
			alertMe(AlertText,"Gem 1 Size must be selected");
			return false;
		}
		var G2Count = document.forms["form"]["G2Count"+OrderId].value;
		if (G2Count == "") {
			alertMe(AlertText,"Gem 1 Count must be filled out");
			return false;
		}	
		var G2Wt = document.forms["form"]["G2Wt"+OrderId].value;
		if (G2Wt == "") {
			alertMe(AlertText,"Gem 1 Weight must be filled out");
			return false;
		}		  
	}
	
	if (document.contains(document.getElementById("G3ShapeId"+OrderId))) {
   
		var G3ShapeId = document.forms["form"]["G3ShapeId"+OrderId].value;
		if (G3ShapeId == 0) {
			alertMe(AlertText,"Gem 1 Shape must be selected");
			return false;
		}	 
		var G3SizeId = document.forms["form"]["G3SizeId"+OrderId].value;
		if (G3SizeId == 0) {
			alertMe(AlertText,"Gem 1 Size must be selected");
			return false;
		}
		var G3Count = document.forms["form"]["G3Count"+OrderId].value;
		if (G3Count == "") {
			alertMe(AlertText,"Gem 1 Count must be filled out");
			return false;
		}	
		var G3Wt = document.forms["form"]["G3Wt"+OrderId].value;
		if (G3Wt == "") {
			alertMe(AlertText,"Gem 1 Weight must be filled out");
			return false;
		}	  
	}
	
	if (document.contains(document.getElementById("G4ShapeId"+OrderId))) {
   
		var G4ShapeId = document.forms["form"]["G4ShapeId"+OrderId].value;
		if (G4ShapeId == 0) {
			alertMe(AlertText,"Gem 1 Shape must be selected");
			return false;
		}	 
		var G4SizeId = document.forms["form"]["G4SizeId"+OrderId].value;
		if (G4SizeId == 0) {
			alertMe(AlertText,"Gem 1 Size must be selected");
			return false;
		}
		var G4Count = document.forms["form"]["G4Count"+OrderId].value;
		if (G4Count == "") {
			alertMe(AlertText,"Gem 1 Count must be filled out");
			return false;
		}	
		var G4Wt = document.forms["form"]["G4Wt"+OrderId].value;
		if (G4Wt == "") {
			alertMe(AlertText,"Gem 1 Weight must be filled out");
			return false;
		}	  
	}
	
	if (document.contains(document.getElementById("G5ShapeId"+OrderId))) {
 
		var G5ShapeId = document.forms["form"]["G5ShapeId"+OrderId].value;
		if (G5ShapeId == 0) {
			alertMe(AlertText,"Gem 1 Shape must be selected");
			return false;
		}	 
		var G5SizeId = document.forms["form"]["G5SizeId"+OrderId].value;
		if (G5SizeId == 0) {
			alertMe(AlertText,"Gem 1 Size must be selected");
			return false;
		}
		var G5Count = document.forms["form"]["G5Count"+OrderId].value;
		if (G5Count == "") {
			alertMe(AlertText,"Gem 1 Count must be filled out");
			return false;
		}	
		var G5Wt = document.forms["form"]["G5Wt"+OrderId].value;
		if (G5Wt == "") {
			alertMe(AlertText,"Gem 1 Weight must be filled out");
			return false;
		}	  
  }
         /*
  var Setting = document.forms["form"]["Setting"+OrderId].value;
  if (Setting == 0) {   
    alertMe(AlertText,"Setting must be selected");
    return false;
  } 
  var Casting = document.forms["form"]["Casting"+OrderId].value;
  if (Casting == 0) {   
    alertMe(AlertText,"Casting must be selected");
    return false;
  }
  var Rhodium = document.forms["form"]["Rhodium"+OrderId].value;
  if (Rhodium == 0) {   
    alertMe(AlertText,"Rhodium must be selected");
    return false;
  }
  var OtherCode = document.forms["form"]["OtherCode"+OrderId].value;
  if (OtherCode == 0) {   
    alertMe(AlertText,"OtherCode must be selected");
    return false;
  }
  var Plating = document.forms["form"]["Plating"+OrderId].value;
  if (Plating == 0) {   
    alertMe(AlertText,"Plating must be selected");
    return false;
  }
  var FilingPolishing = document.forms["form"]["FilingPolishing"+OrderId].value;
  if (FilingPolishing == "") {
    alertMe(AlertText,"Filing Polishing must be filled out");
    return false;
  }

  var OtherCost = document.forms["form"]["OtherCost"+OrderId].value;
  if (OtherCost == "") {
    alertMe(AlertText,"Other Cost must be filled out");
    return false;
  }  
 
  var OtherCost = document.forms["form"]["OtherCost"+OrderId].value;
  if (OtherCost == "") {
    alertMe(AlertText,"Other Cost must be filled out");
    return false;
  }   */
  var OtherCost = document.forms["form"]["OtherCost"+OrderId].value;
  var OtherCode = document.forms["form"]["OtherCode"+OrderId].value;
  if (OtherCost > 0 && OtherCode == 0) {   
    alert("OtherCode must be selected");
    return false;
  }
  
  
  return true;
	
  
}
  
</script>
<?php echo $footer; ?>