<script language="JavaScript" type="text/javascript">
{literal}
var currentcheckcontent,lastcheckcontent;
jQuery(document).ready(function(){
    jQuery("#addfileupload").click(function () {
        jQuery("#fileuploads").append("<input type=\"file\" name=\"attachments[]\" size=\"50\"><br />");
        return false;
    });
});
{/literal}
{if $kbsuggestions}
{literal}
function getticketsuggestions() {
    currentcheckcontent = jQuery("#message").val();
    if (currentcheckcontent!=lastcheckcontent && currentcheckcontent!="") {
        $.post("submitticket.php", { action: "getkbarticles", text: currentcheckcontent },
        function(data){
            if (data) {
                jQuery("#searchresults").html(data);
                jQuery("#searchresults").slideDown();
            }
        });
        lastcheckcontent = currentcheckcontent;
	}
    setTimeout('getticketsuggestions();', 3000);
}
getticketsuggestions();
{/literal}
{/if}
</script>

{if $errormessage}
	<div class="notice notice-error">
		<div class="inside">
			<p>{$errormessage}</p>
		</div>
	</div>
{/if}

<form action="{$smarty.server.PHP_SELF}?step=3" method="post" enctype="multipart/form-data" name="submitticket" id="submitticket">
  <input type="hidden" name="deptid" value="{$deptid}" />
 
		<div class="feildset">
		
			<div class="col1">
		
				<div>
					<label>
						<span>{$LANG.supportticketsclientname}: {if $loggedin}{else}({$LANG.required}){/if}</span>
						{if $loggedin}{$clientname}{else}
              			<input type="text" name="name" value="{$name}" tabindex="1" requred="required" autofocus="autofocus" placeholder="{$LANG.newticket_name}" />
              			{/if}
					</label>
				</div>
				
				<div>
					<label>
						<span>{$LANG.supportticketsclientemail}: {if $loggedin}{else}({$LANG.required}){/if}</span>
						{if $loggedin}{$email}{else}
              			<input type="text" name="email" value="{$email}" tabindex="2" requred="required" placeholder="{$LANG.newticket_email}" />
              			{/if}
					</label>
				</div>
				
				<div>
					<label>
						<span>{$LANG.supportticketsdepartment}</span>
						{$department} (<strong><a href="submitticket.php">change</a></strong>)
					</label>
				</div>
				
				
				<div>
					<label>
						<span>{$LANG.supportticketsticketsubject}: ({$LANG.required})</span>
              			<input type="text" name="subject" value="{$subject}" tabindex="3" requred="required" placeholder="{$LANG.newticket_subject}" />
					</label>
				</div>
				
				<div>
					<label>
						<span>{$LANG.supportticketsticketurgency}:</span>
              			<select name="urgency">
                <option value="High"{if $urgency eq "High"} selected="selected"{/if}>{$LANG.supportticketsticketurgencyhigh}</option>
                <option value="Medium"{if $urgency eq "Medium" || !$urgency} selected="selected"{/if}>{$LANG.supportticketsticketurgencymedium}</option>
                <option value="Low"{if $urgency eq "Low"} selected="selected"{/if}>{$LANG.supportticketsticketurgencylow}</option>
              </select>
              		</label>
				</div>
				
				
				{if $relatedservices}														
				
				<div>
					<label>
						<span>{$LANG.relatedservice}:</span>
              			<select name="relatedservice">
                <option value="">{$LANG.none}</option>
                
{foreach from=$relatedservices item=relatedservice}

                <option value="{$relatedservice.id}">{$relatedservice.name} ({$relatedservice.status})</option>
                
{/foreach}

              </select>
              		</label>
				</div>				
				
				{/if}
				
				<div>
					<label>
						<span>Message ({$LANG.required})</span>
						<textarea name="message" id="message" placeholder="{$LANG.newticket_message}">{$message}</textarea>
					</label>
				</div>
				
				
				<div>
					<label>
						<span>{$LANG.supportticketsticketattachments} - ({$LANG.supportticketsallowedextensions}: {$allowedfiletypes})</span>
						<input type="file" name="attachments[]" />
              <a href="#" id="addfileupload"><img src="images/add.gif" class="absmiddle" alt="" /> {$LANG.addmore}</a><br />
              <div id="fileuploads"></div>
					</label>
				</div>				
				
				
				
			</div>
			
		</div> 
 
 
 
 		{if $customfields}
 		
		<div class="bigheader">
			<h2>{$LANG.newticket_required}</h2>
		</div><!-- .bigheader --> 		

 		
		<div class="feildset">
		
			<div class="col1"> 		
 
          {foreach key=num item=customfield from=$customfields}
          
          <div>
          	<label>
          		<span>{$customfield.name}</span>
          		{$customfield.input}
          	</label>
          </div>
          
          {/foreach} 
          
			</div>
			
		</div>           
          
          
          {/if}

          

  <div id="searchresults" class="highlightbox" style="display:none;"></div>
  
 				{if $capatacha}
				<p class="center"><strong>{$LANG.captchatitle}</strong></p>
				<p class="center">{$LANG.captchaverify}</p>
				{if $capatacha eq "recaptcha"}
				<div align="center">{$recapatchahtml}</div>
				{else}
				<p class="center"><img src="includes/verifyimage.php" align="middle" /> <input type="text" name="code" tabindex="5" class="capcha" /></p>
				{/if}
				{/if} 
  
  <p class="center">
    <input type="submit" value="{$LANG.supportticketsticketsubmit}" class="button1 color2" />
  </p>
</form>