<?php $__env->startSection('content'); ?>

<?php if(Input::get('qm_symbol')): ?>
    <!-- Start of QuoteMedia.com Component Tool call - must be present -->
    <script type="text/javascript"  src="http://app.quotemedia.com/quotetools/jsVarsQuotesSpan.go?webmasterId=102038&symbol=<?php echo strtolower(Input::get('qm_symbol')); ?>&df=MMM+d,+yyyy+hh:mm+a+z"></script>
    <!-- End of QuoteMedia.com Component Tool call -->
    <script type="text/javascript">
	// Strip HTML and PHP tags from a string
    function strip_tags( str )
	{	
		return str.replace(/<\/?[^>]+>/gi, '');
	}
    </script>
<?php endif; ?>

<?php $__env->startSection('sub_menu'); ?>
    <?php echo $__env->make('trade/menu', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('css'); ?>
<link rel="stylesheet" href="http://app.quotemedia.com/css/tools.css">
<?php echo HTML::style('css/quotemedia.css'); ?>
<?php $__env->stopSection(); ?>
    
<div class="row">

    <div class="col-md-10">
        <div class="gray_container standart-15">
        
       		<?php if(Session::has('success')): ?>
                <div class="alert alert-success"><?php echo Session::get('success'); ?></div>
            <?php endif; ?>
            <?php if($errors->has()): ?>
                <div class="alert alert-danger">
                <?php foreach ($errors->all() as $row): ?>
                  <div><?php echo $row; ?></div>
                <?php endforeach; ?>
                </div>
            <?php endif; ?>
            
            <p class="align-cn">Search by ticker symbol or company name.</p>
            
            <script type="text/javascript" src="http://app.quotemedia.com/quotetools/authorization.go?webmasterId=102038&userName=<?php echo $quotemedia->username ?>&password=<?php echo $quotemedia->password ?>&agreementsURL=<?php echo URL::to('trade/agreements'); ?>"></script>
                    
            <div id="qm-smart-lookup"><script type="text/javascript" src="http://app.quotemedia.com/quotetools/quoteEntryBox.go?webmasterId=102038&smartLookup=on&toolWidth=250&targetsym=qm_symbol&targetURL=<?php echo URL::to('trade'); ?>"></script></div>
            
            <?php if(!Input::get('qm_symbol')): ?>
            <div class="sub-me">
				<ul>
					<li> BANQ currently does not provide trading execution in Pink Sheet listed securities.</li>
					<li> $0.99 Window trades begin processing at 11 AM and 2 PM. Actual orders will generally execute within one hour of these times.</li>
					<li> Mutual Funds can be window traded but because of the way mutual funds trade, you will always receive the end of day pricing for buys and sells.</li>
					<li>Pricing for live trades, market, stop, limit and stop/limit orders, can be found <a href="/about-us/pricing/overview">here.</a></li>
				</ul>
			<div>
           	<?php else: ?>
            <p class="align-cn dumper">&nbsp;</p>
            <?php endif; ?>
            
            <?php if(Input::get('qm_symbol')): ?>
			<div class="row buy-background summer-tm">
			    <div class="col-xs-12">
					<h4 class="buy-title"><script type="text/javascript">document.write(strip_tags(qmQuote.longName));</script> (<script type="text/javascript">document.write(strip_tags(qmQuote.symbol));</script>)</h4>
				</div>
			</div>
			<div class="buy-table-area">
				<div id="css-table">
					<div class="col">
						<h4 class="buy-price">$<script type="text/javascript">document.write(strip_tags(qmQuote.last) + '&nbsp;' + qmQuote.change + '&nbsp;(' + qmQuote.changePercent + ')');</script></h4>
						<h5 class="buy-price-time"><script type="text/javascript">document.write('Last Price&nbsp;' + strip_tags(qmQuote.lastTradeTime));</script></h5>
					</div>
					<div class="col col-bg">
						<div class="triangle"></div>
						<p class="info">Ask: <span><script type="text/javascript">document.write(strip_tags(qmQuote.ask) + '&nbsp;x&nbsp;' + strip_tags(qmQuote.askSize));</script></span></p>
						<p class="info">Bid: <span><script type="text/javascript">document.write(strip_tags(qmQuote.bid) + '&nbsp;x&nbsp;' + strip_tags(qmQuote.bidSize));</script></span></p>
						<p class="info">Volume: <script type="text/javascript">document.write(qmQuote.volumeActual.replace(/\B(?=(\d{3})+(?!\d))/g, ","));</script></p>
					</div>
					<div class="col col-bg">
						<p class="info">Open: <span><script type="text/javascript">document.write(strip_tags(qmQuote.open));</script></span></p>
						<p class="info">Previous Close: <span><script type="text/javascript">document.write(strip_tags(qmQuote.close));</script></span></p>
						<p class="info">Mkt Cap: <span><script type="text/javascript">document.write(strip_tags(qmQuote.marketCap));</script></span></p>
					</div>
				</div>
				
                <?php if(Input::get('type') && !Input::old('type')): ?>
                	<div class="buy-cell-url two-new-btn">
						<a href="#" onclick="show('buy_link'); return false;" id="buy_link" class="new-btn-grn<?php echo (Input::get('type') == 'buy')?' active':'' ?>">Buy</a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" class="new-btn-red<?php echo (Input::get('type') == 'sell')?' active':'' ?>" onclick="show('sell_link'); return false;" id="sell_link">Sell</a>
                  	</div>
				<?php else: ?>
                	<div class="buy-cell-url two-new-btn">
						<a class="new-btn-grn<?php echo (Input::old('type') == 'buy' || !Input::old('type'))?' active':'' ?>" href="#" onclick="show('buy_link'); return false;" id="buy_link" >Buy</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="new-btn-red<?php echo (Input::old('type') == 'sell')?' active':'' ?>" href="#" onclick="show('sell_link'); return false;" id="sell_link">Sell</a></div>	
                <?php endif; ?>
                                
                <?php echo Form::open(array('url' => 'trade?qm_symbol='.Input::get('qm_symbol'), 'id' => 'trade_form')); ?>
				<div class="account_application" style="margin-top:40px">
					<div class="row">
						<div class="col-md-8 col-md-offset-3">
							<ul>
								<li>
									<?php if(!empty($accounts)): ?>
										<?php echo Form::select('accountnumber', $accounts, null, array('class' => 'form-control tooltip-info', 'data-toggle' => 'tooltip', 'data-placement' => 'right', 'data-original-title' => 'Select account')); ?>
									<?php endif; ?>
                                    
                                    <?php echo Form::select('orderType', array('D' => 'Direct', 'W' => 'Window'), null, array('class' => 'form-control tooltip-info', 'data-toggle' => 'tooltip', 'data-placement' => 'right', 'data-original-title' => 'Window - Place a window order.
Direct - Place an order for immediate execution.')); ?>
									
									<?php echo Form::select('orderconfig', array('dm' => 'MKT', 'dl' => 'LMT', 'ds' => 'STOP', 'dsl' => 'STOP LMT'), null, array('class' => 'form-control tooltip-info', 'data-toggle' => 'tooltip', 'data-placement' => 'right', 'data-original-title' => 'A flag to indicate the type of order to create.')); ?>
									
									<?php echo Form::select('term', array('0' => 'Day', '1' => 'GTC'), null, array('class' => 'form-control tooltip-info', 'data-toggle' => 'tooltip', 'data-placement' => 'right', 'data-html' => 'true', 'data-original-title' => 'Day. The order is good only for the day.<br />
	GTC. The order is good until canceled (with a 90 day maximum on average)')); ?>
									
                                    <?php echo Form::hidden('ticker', Input::get('qm_symbol')); ?>
                                    <?php echo Form::hidden('type', 'buy'); ?>
									
									<input type="text" name="requestedShareAmt" value="<?php echo Input::old('requestedShareAmt'); ?>" class="form-control tooltip-info" data-toggle="tooltip" data-trigger="focus" data-placement="right" data-original-title="The requested share amount to trade for this security. This should be used in conjunction with a share based indicator" placeholder="Number of shares">
									
									<input type="text" name="limitPrice" value="<?php echo Input::old('limitPrice'); ?>" class="form-control tooltip-info hidden" data-toggle="tooltip" data-trigger="focus" data-placement="right" data-original-title="The limit price to execute at. This is only available for direct orders." placeholder="The limit price">
									
									<input type="text" name="stopPrice" value="<?php echo Input::old('stopPrice'); ?>" class="form-control tooltip-info hidden" data-toggle="tooltip" data-trigger="focus" data-placement="right" data-original-title="The stop price to execute at. This is only available for direct orders." placeholder="The stop price">
									
								</li>						
							</ul>
						</div>
					</div>
				</div>
					
				<div class="wrap_next_step">
					<button type="submit" class="btn next_step">SUBMIT</button>
				</div>
				<?php echo Form::close(); ?>
			</div>
			<?php endif; ?>
		</div>
    </div><!-- /col-md-10 -->
</div><!-- /row -->

<?php $__env->startSection('scripts'); ?>

<script type="text/javascript">
	$(function() {
		$( "select[name='taxlotreliefmethod']" ).change(function () {
			taxlotreliefmethod = $(this).val();	
			if(taxlotreliefmethod == 'WLFS' || taxlotreliefmethod == 'WGFS')
			{
				$("input[name='longTermTaxRate']").removeClass("hidden");	
				$("input[name='shortTermTaxRate']").removeClass("hidden");
			}
			else
			{
				$("input[name='longTermTaxRate']").addClass("hidden");	
				$("input[name='shortTermTaxRate']").addClass("hidden");	
			}
		});
		
		$( "select[name='orderType']" ).change(function () {
			orderType = $(this).val();
						
			if(orderType == 'D')
			{
				$("select[name='orderconfig']").removeClass("hidden");
				$("select[name='term']").removeClass("hidden");
			}
			else{
				$("select[name='orderconfig']").addClass("hidden");			
				$("select[name='stopPrice']").addClass("hidden");	
				$("input[name='limitPrice']").addClass("hidden");
				$("select[name='term']").addClass("hidden");
			}
		});
		
		$( "select[name='orderconfig']" ).change(function () {
			orderconfig = $(this).val();
						
			if(orderconfig == 'dl' || orderconfig == 'dsl')
				$("input[name='limitPrice']").removeClass("hidden");
			else
				$("input[name='limitPrice']").addClass("hidden");	
				
			if(orderconfig == 'ds' || orderconfig == 'dsl')
				$("input[name='stopPrice']").removeClass("hidden");
			else
				$("input[name='stopPrice']").addClass("hidden");				
		});
		
		var orderconfig = $('select[name="orderconfig"] option:selected').val();
		var taxlotreliefmethod = $('select[name="taxlotreliefmethod"] option:selected').val();
		var orderType = $('select[name="orderType"] option:selected').val();
		
		if(orderconfig == 'dl' || orderconfig == 'dsl')
			$("input[name='limitPrice']").removeClass("hidden");
		
		if(orderconfig == 'ds' || orderconfig == 'dsl')
			$("input[name='stopPrice']").removeClass("hidden");
			
		if(taxlotreliefmethod == 'WLFS' || taxlotreliefmethod == 'WGFS')
		{
			$("input[name='longTermTaxRate']").removeClass("hidden");	
			$("input[name='shortTermTaxRate']").removeClass("hidden");	
		}
		
		if(orderType == 'W')
		{
			$("select[name='orderconfig']").addClass("hidden");	
			$("select[name='stopPrice']").addClass("hidden");	
			$("input[name='limitPrice']").addClass("hidden");
			$("select[name='term']").addClass("hidden");
		}
		
	});
	
	<?php if(Input::get('type') && !Input::old('type')): ?>
		<?php if(Input::get('type') == 'sell'): ?>
			var selected = "sell_link";
		<?php else: ?>
			var selected = "buy_link";	
		<?php endif; ?>
	<?php else: ?>
		<?php if(Input::old('type') == 'sell'): ?>
			var selected = "sell_link";
		<?php else: ?>
			var selected = "buy_link";	
		<?php endif; ?>		
	<?php endif; ?>
	function show(a)
	{
		$("#" + selected).css( "color", '#fff').removeClass('active');
		$("#" + a).css( "color", '#000').addClass('active');;    
		
	 	
		if(a == 'buy_link')
		{
			//$('#trade_form').attr('action', '<?php echo URL::to('trade/buy') ?>');
			$("input[name='type']").val('buy');	
		}
		else
		{
			//$('#trade_form').attr('action', '<?php echo URL::to('trade/sell') ?>');
			$("input[name='type']").val('sell');		
		}
		 
		selected = a;
	}
</script>
<?php $__env->stopSection(); ?>

<?php $__env->stopSection(); ?>


