<a href='#popupDialog' data-rel='popup' data-position-to='window' data-role='button' data-icon='external-link' data-transition='pop' data-inline='true'>Add product</a>

<script type='text/javascript'>$(document).ready(function() {refresh_prods(); });</script>
<div id='ajaxreturn'>Please wait...</div>

<div data-role='popup' id='popupDialog' data-theme='b'>
	<div data-role='header' data-theme='b'>
		<h1>Add new product</h1>
	</div>
	<div data-role='content' data-theme='b'>
		<form action='' method='post' data-ajax="false" id='formaddprod' onsubmit="return addproduct()">
                <ul data-role="listview" data-inset="true">
	            <li data-role="list-divider">Existing product</li>
                    <li data-role="fieldcontain">
                        <label for="select-choice-1b" class="select">Select</label>
                        <select name="select-choice-1" id="selected_prod" data-native-menu="true" onchange='changeprod()'>
                            <option value=""></option>
							<?$res=mysql_query("SELECT * FROM `products` group by title,price order by title")or die(mysql_error());
								while($row=mysql_fetch_array($res)){?>
						<option value='<?=$row['id']?>'><?=substr(strip_tags($row['title']),0,40)?></option>
					<?}?>
                        </select>
                    </li>				
	            <li data-role="list-divider">New product</li>				
					<li data-role="fieldcontain">
                        <label for="product_name">Product name:</label>
                        <input type="text" name="product_name" id="product_name" class='req' value="<?=$_POST['client_name']?>" data-clear-btn="true" placeholder="">
                    </li>										
					<li data-role="fieldcontain">
                        <label for="name2b">Description:</label>
                         <textarea cols="40" rows="8" name="product_description" class='req' id="product_description" placeholder=""><?=$_POST['client_address']?></textarea>
                    </li>
					<li data-role="fieldcontain">
                        <label for="product_price">Price:</label>
                        <input type="text" name="product_price" id="product_price" class='req' value="<?=$_POST['client_location']?>" data-clear-btn="true" placeholder="">
                    </li>					
					<li data-role="fieldcontain">
                        <label for="product_price">Qty:</label>
                        <input type="text" name="product_qty" id="product_qty" class='req' value="1" data-clear-btn="true" placeholder="">
                    </li>	
					<li data-role="fieldcontain">
                        <fieldset data-role="controlgroup">
                            <legend>Taxes</legend>
			<?
				$res=mysql_query("select * from taxes where hidden='0' order by name")or die(mysql_error());
					while($row=mysql_fetch_array($res)){?>
	                    <input type="checkbox" name="tax[]" id="checkbox<?=$row['id']?>" value='<?=$row['value']?>' <?if($row['default']==1)echo "checked"?>>
                        <label for="checkbox<?=$row['id']?>"><?=$row['name']?></label>				
					<?}?>							
                        </fieldset>	
					</li>	
	                    <li>
                        <fieldset class="ui-grid-a">
                                <div class="ui-block-a"><button type="button" data-theme="b" onclick="$('#popupDialog').dialog('close'). ">Cancel</button></div>
                                <div class="ui-block-b"><button type="submit" name='addprod' data-theme="b">Add</button></div>
                        </fieldset>
                    </li>				
			</ul>
			</form>		
	</div>
</div>
<div style='clear:both;'></div>
		<form action='new_invoice.php' method='post' data-ajax="false">
                <ul data-role="listview">					
	                    <li>
                        <fieldset class="ui-grid-a">
                                <div class="ui-block-a"><button type="submit" data-theme="b" onclick="top.location='index.php'">Cancel</button></div>
                                <div class="ui-block-b"><button type="submit" name='step2'>Finish</button></div>
                        </fieldset>
                    </li>				
			</ul>
			</form>