<link rel="stylesheet" type="text/css" href="{$view_styles}/form-list.css" />
<script type="text/javascript">
 var emailmsg='{$language.errEmailID}';
$('#subscEmailID').each(function() {										
			var email = $('#subscEmailID').val();			
			if(email == emailmsg)
			{
			var default_value = $(this).val();			
			$(this).focus(function() {	
				if(this.value == default_value) {	
					this.value = '';	
				}	
			});	
			$(this).blur(function() {	
				if(this.value == '') {	
					this.value = default_value;	
				}	
			});
			}
			else
			{	
				return false
			}
		});

</script> 
{if isset($elementType) && is_array($elementType)}
{if in_array('state',$elementType) && in_array('country',$elementType)}
	<script>
	var stateCache={};
	function listStateAjax(countryFieldID,elements)
		{
		elements=elements.split(",");
		var stateFieldID=elements[0];
		var provinceFieldID=elements[1];
		
		var countryID=$(""+countryFieldID).val();
		$("[rel='"+provinceFieldID+"']").val('');
		if(countryID>0){	
			if($.isEmptyObject(stateCache[countryID])){
				var data = new Object();
				data.countryID 	= countryID;
				data.stateID 	= $("[rel='"+stateFieldID+"']").val();
				$.ajax({
					url: GLOBAL_BASE_PATH + "/form/ajaxState/",
					type: "POST",
					cache: true,
					data: data,
					success: function (data) {
						data=$.trim(data);
						stateCache[countryID]=data;
						if(data!=''){
							$("#li_"+stateFieldID).removeClass('hide');
							$("#li_"+provinceFieldID).addClass('hide');
							$("[rel='"+provinceFieldID+"']").val('-');
							var label=$("[rel='"+stateFieldID+"']").attr('label');
							$("[rel='"+stateFieldID+"']").html("<option value>"+label+"</option>"+data);
						}
						else{
							$("#li_"+stateFieldID).addClass('hide');
							$("#li_"+provinceFieldID).removeClass('hide');
							$("[rel='"+stateFieldID+"']").html("<option value=0>"+label+"</option>");
						} 
						/*var label=$("[rel='"+stateFieldID+"']").attr('label');
						$("[rel='"+stateFieldID+"']").html("<option value>"+label+"</option>"+data);*/
					}
					});
			}
			else{
				var data=stateCache[countryID];
				if(data!=''){
					$("#li_"+stateFieldID).removeClass('hide');
					$("#li_"+provinceFieldID).addClass('hide');
					var label=$("[rel='"+stateFieldID+"']").attr('label');
					$("[rel='"+stateFieldID+"']").html("<option value>"+label+"</option>"+data);
					$("[rel='"+provinceFieldID+"']").val('-');
				}
				else{
					$("#li_"+stateFieldID).addClass('hide');
					$("#li_"+provinceFieldID).removeClass('hide');
					$("[rel='"+stateFieldID+"']").html("<option value=0>"+label+"</option>");
				}
				/* var label=$("[rel='"+stateFieldID+"']").attr('label');
				$("[rel='"+stateFieldID+"']").html("<option value>"+label+"</option>"+data); */
			}
		}
		else if(countryID==0){
			$("[rel='"+stateFieldID+"']").html("<option value='0'>{$language.lblOther}</option>"+data);
		}
		if(countryID==''){
			var label=$("[rel='"+stateFieldID+"']").attr('label');
			$("[rel='"+stateFieldID+"']").html("<option >"+label+"</option>");
		}
	
	}
	</script>
	{/if}
{/if}

	
        <div class="form-listing-frd"> 
            <!-- Begin : Header --> 
            <br />
            <!-- End : Header -->
            <a name="formFocus"></a>
              <h3 >{$resultForm['formName']|default:''}</h3>
              <span class="sepline"><span>&nbsp;</span> </span>
            
			{if !$formDisable|default:''}
			<!-- Begin : Visa Payment --> 
			  {assign var="labelPlacement" value=$resultForm['labelPlacement']|default:''}
			  {assign var="submitButtonValue" value=$resultForm['submitButtonValue']|default:''}
			  {assign var="fieldAlignment" value=$resultForm['fieldAlignment']|default:''}
			  {assign var="formKey" value=$resultForm['formKey']|default:''}
			  {assign var="fieldAlignment" value=$resultForm['fieldAlignment']|default:''}
			  {assign var="elementRule" value=$resultForm['elementRule']|json_decode}
			  {assign var="enableCaptcha" value=$resultForm['enableCaptcha']|default:''}
			  {assign var="enableAgreement" value=$resultForm['enableAgreement']|default:''}
			  {assign var="agreementText" value=$resultForm['agreementText']|default:''}
              {form->start name="oorjitForm_{$formKey}" method="post" enctype="multipart/form-data"}
			  <fieldset>
				<div class="{$fieldAlignment}">
					<ul class="clearfix">
					{assign var="increment" value=1}
					{foreach $resultElement as $key=>$element}
						{assign var="formElementID" value=$element['formElementID']|default:''}
						{assign var="formID" value=$element['formID']|default:''}
						{assign var="attributeType" value=$element['attributeType']|default:''}
						{assign var="nextAttributeType" value=$resultElement[$key+1]['attributeType']|default:''}
						{assign var="uniqueID" value=$element['uniqueID']|default:''}
						{assign var="formElementLabel" value=$element['formElementLabel']|default:''}
						{assign var="attributeOrder" value=$element['attributeOrder']|default:''}
						{assign var="validateRule" value=$element['validateRule']|default:''}
						{assign var="extraAttributes" value=$element['extraAttributes']|json_decode}
						{assign var="fieldSize" value=$extraAttributes->defaults->size|default:''}
						{assign var="layout" value=$extraAttributes->defaults->layout|default:''}
						{assign var="allowedExtensions" value=$extraAttributes->defaults->allowedExtensions|default:''}
						{assign var="fieldLayout" value=$extraAttributes->fieldLayout|default:''}
						{assign var="allowUserChoice" value=$extraAttributes->allowUserChoice|default:''}
						{assign var="linkWith" value=$extraAttributes->linkWith|default:''}
						{assign var="formElementDetailID" value=$element['formElementDetailID']|default:''}
						{assign var="formElementDesc" value=$element['formElementDesc']|default:''}
						{assign var="formElementSubText" value=$element['formElementSubText']|default:''}
						{assign var="formElementPlaceHolder" value=$element['formElementPlaceHolder']|default:''}
						{assign var="formElementValue" value=$element['formElementValue']|default:''}
						{assign var="options" value=$element['options']|default:''}
						{assign var="optionID" value=$element['formElementOptionID']|default:''}
						{assign var="formValidationMessage" value=$element['formValidationMessage']|default:''}
						{assign var="formElementName" value=$attributeType|cat:"_"|cat:$formElementID}
						
						{if $attributeType!='province'}
							{assign var="increment" value=$increment+1}
						{/if}
						
						
						{if $attributeType=='submit' && isset($enableCaptcha) && $enableCaptcha=='Yes' && isset($enable_captcha) && $enable_captcha=='Yes'}
						<li class="clearfix fltNo">
							<div class="label clearfix">
									<label>
										{$language.lblSecurityCode}
									</label>
							
								<span class="mndty">*</span>
							
							</div>
                            <div class="field captcha">
									<img width="100"  height="25" hspace="0"  class="flt-left"  id="captchaCode" marginwidth="0" marginheight="0"  />
								
								
									<img src="{$view_images}/reload_icon_captcha.png" hspace="0" class="flt-left"  vspace="0" id="reload_icon_captcha" style="cursor:pointer;"  marginheight="0" height="18" marginwidth="0"/>
								{form->textbox id="oorjitFormSecurityCode" autocomplete="off" name="oorjitFormSecurityCode"  class="form-control textbox   width-100px" maxlength="12" validate="required~*hidImageCaptchaCode->compare->value" validate_event="submit" error=$language.errBusSecurityCode|cat:'~*'|cat:$language.errSecurityCode}
								<span style="display:none">
									{form->textbox id="hidImageCaptchaCode"   name="hidImageCaptchaCode" class="hidden-variable"}
								</span>
							</div>

											
							<script type="text/javascript">
							//<![CDATA[
							$(document).ready(function(){
								$('#oorjitForm_{$formKey}').on('submit',function() {
										$('#reload_icon_captcha').trigger('click');
								});
							});
							//]]>
							</script> 

							
						</li>
							
						{/if}
						{if $enableAgreement=='Yes' && $attributeType=='submit'}
							<li class="clearfix fltNo " id="li_{$uniqueID}" data-name="agreement" >
							<div class="label clearfix">
										<label>
											&nbsp;
										</label>
																											
									</div>
							<div class="cms_area default-style field   ">
										<p>
										{form->checkbox    
										name=$formElementName  
										rel=$uniqueID
										caption="{$agreementText}*"
										value="1"
										validate="required"
										error="{$language.errAgreement}"} 
										</p> 
									</div>
							</li>
						{/if}
					
						<li class="clearfix {if $attributeType=='submit'} fltNo {/if} {if $attributeType=='province'} hide{/if}" id="li_{$uniqueID}" data-name="{$formElementName}" data-elementid="{$formElementID}">
							{if $attributeType!='submit' && $attributeType!='html' && $attributeType!='agreement' }
									<div class="label clearfix">
										<label>
											{$formElementLabel} 
										</label>
									{if $formElementSubText!=''}
										<span class="icon-set info-icon" title="{$formElementSubText}"></span>
									{/if}
									{if $validateRule|strstr:"required"}
										<span class="mndty">*</span>
									{/if}
									
									</div>

							{/if}
							
							
							<div class="field {$fieldSize} {$layout} "> 
								{if 	$attributeType=='text'		||
										$attributeType=='email'		||
										$attributeType=='text_opt'	||
										$attributeType=='province'	||
										$attributeType=='website'	
								}
								
									{form->textbox 
										name=$formElementName  
										rel=$uniqueID
										class="form-control textbox {$fieldSize}" 
										validate="$validateRule" 
										value="$formElementValue"
										error=$formValidationMessage} 
									
								{else if $attributeType=='password'}
								
									{form->password 
										name=$formElementName 
										rel=$uniqueID
										class=" form-controltextbox {$fieldSize}" 
										validate="$validateRule" 
										value="$formElementValue"
										error=$formValidationMessage} 
									
								{else if $attributeType=='date'}
								
									{form->textbox 
										name=$formElementName 
										rel=$uniqueID
										class="form-control textbox {$fieldSize}" 
										validate="$validateRule" 
										value="$formElementValue"
										error=$formValidationMessage} 
									<script type="text/javascript">
											//<![CDATA[
                                            $(document).ready(function(){
												$("#{$formElementName}").datepicker();
											});
											//]]>
									</script>	
								
								{else if $attributeType=='file'}
									
									{foreach $allowedExtensions as $key=>$ext}
										{if $key>0}
											{assign var='extension' value=$extension|cat:","|cat:$ext}
										{else}
											{assign var='extension' value=$ext}
										{/if}
									{/foreach}
									{if $extension!=''}
										{if $formElementValue!=''}
											{assign var='validateRule' value="{$validateRule}~*{$formElementValue}~*{$formElementName}->isFileType->{$extension}"}
										{else}
											{assign var='validateRule' value="{$validateRule}~*{$formElementName}->isFileType->{$extension}"}
										{/if}
										{if $formValidationMessage!=''}
											{assign var='formValidationMessage' value=$formValidationMessage|cat:"~*"|cat:$language.errFileExtension|cat:"-"|cat:$extension}
										{else}
											{assign var='formValidationMessage' value=$language.errFileExtension|cat:"-"|cat:$extension}
										{/if}
									{/if}
									{form->upload 
										name=$formElementName
										rel=$uniqueID 
										class="textbox {$fieldSize}" 
										validate="$validateRule" 
										value="$formElementValue"
										error=$formValidationMessage} 
								
								{else if $attributeType=='select'}
								
									{form->select 
										name=$formElementName
										rel=$uniqueID
										class="form-control listbox {$fieldSize}"
										validate="$validateRule" 
										value="$optionID"	 
										options=$options
										error=$formValidationMessage} 
								
								{else if $attributeType=='select_multiple'}
								
									{form->select 
										name=$formElementName 
										rel=$uniqueID
										class="form-control listbox {$fieldSize}"
										validate="$validateRule" 
										value="$optionID"	
										options=$options
										multiple="multiple"
										error=$formValidationMessage} 
								
								{else if $attributeType=='radio'}
									<div class="col">{form->radio     
										name=$formElementName  
										rel=$uniqueID
										class="{$fieldSize}"
										seperator="</div><div class='col'>"
										validate="$validateRule" 
										value="$optionID"	
										options=$options
										error=$formValidationMessage} 
								</div>
								{else if $attributeType=='checkbox'}
								
									<div class="col">{form->checkbox    
										name=$formElementName  
										rel=$uniqueID
										class="{$fieldSize}"
										seperator="</div><div class='col'>"
										validate="$validateRule" 
										value="$optionID"	
										options=$options
										error=$formValidationMessage} 
								</div>
								{else if $attributeType=='image'}
								
									{form->upload_image 
										name=$formElementName 
										rel=$uniqueID
										value="" 
										validate="$validateRule" 
										error=$formValidationMessage}
										

										
								{else if $attributeType=='country'}
									
									{if $linkWith!=''}
										
										{form->select 
											name=$formElementName  
											rel=$uniqueID
											class="form-control listbox {$fieldSize}"
											validate="$validateRule" 
											value="$optionID"	
											options=$options
											caption="->{$language.lblSelect}"
											onchange="listStateAjax('#{$formElementName}','{$linkWith}')"
											error=$formValidationMessage} 
											<script type="text/javascript">
											//<![CDATA[
                                            listStateAjax('#{$formElementName}','{$linkWith}');
											//]]>
											</script>

									{else}
										{form->select 
											name=$formElementName  
											rel=$uniqueID
											class=" form-control listbox {$fieldSize}"
											validate="$validateRule" 
											value="$optionID"	
											options=$options
											caption="->{$language.lblSelect}"
											error=$formValidationMessage} 
									{/if}
								
								{else if $attributeType=='state'}
									
									{form->select 
										name=$formElementName  
										rel=$uniqueID
										class="form-control listbox {$fieldSize}"
										validate="$validateRule" 
										value="$optionID"	
										options="->{$formElementValue}"
										label="{$formElementValue}"
										error=$formValidationMessage} 

								{else if $attributeType=='businesstype'}		
										
										{form->select 
										name=$formElementName  
										rel=$uniqueID
										class="form-control listbox {$fieldSize}"
										validate="$validateRule" 
										value="$optionID"	
										content=$options
										error=$formValidationMessage} 
										
								{else if $attributeType=='textarea'}
								
									{form->textarea 
										name=$formElementName  
										rel=$uniqueID
										class="form-control textarea01 {$fieldSize}" 
										rows="5" 
										validate="$validateRule"
										cols="45"
										value="$formElementValue"
										error=$formValidationMessage} 
									
										
								{else if $attributeType=='submit'}
								
									{form->submit 
										name="submitForm"  
										class="custom-button01 btn btn-primary"
										value={$submitButtonValue}} 
									
								{else if $attributeType=='html'}
								
									<h2>{$formElementLabel} </h2>
									<div class="cms_area default-style">
										<p>
											{$formElementDesc|html_entity_decode}
										</p> 
									</div>
								{else if $attributeType=='agreement'}
								
									<h2>{$formElementLabel} </h2>
									<div class="cms_area default-style">
										{if $validateRule|strstr:"required"}
										<span class="mndty">*</span>
										{/if}
										<p>
										{if $formElementSubText!=''}
										<span class="icon-set info-icon" title="{$formElementSubText}"></span>
										{/if}
										{form->checkbox    
										name=$formElementName  
										rel=$uniqueID
										options={$formElementDesc|html_entity_decode}
										validate="$validateRule"
										error=$formValidationMessage} 
										</p> 
									</div>
								{/if}
							</div>
						</li>
						{if ($fieldAlignment=='top_align_two_column' || $fieldAlignment=='left_align_two_column') && $increment%2 && $nextAttributeType!='province'}
							<li class="element-three clearfix"></li>
						{/if}
					{/foreach}
					</ul>
                    </div>
              </fieldset>
              {form->close} </div>
			{else}
				<h3>{$disableFormMessage}</h3>
			{/if}

		
		{form->validate_script form="oorjitForm_{$formKey|default:''}"} 
    
<!-- End : Outer Pane --> 
{html->messages_script id="common_message_form"}
{include file='CommonJavaScriptBottom.tpl'  }
{html->script_group_start name="{$compiled_js_path}/forminclude.js"}
  
   {html->script src="{$common_frontend_js}/captcha.page.js"}
   {html->script src="{$common_js}/uploadImage.plugin.js"}
 {html->script_group_end} 

<script>
{foreach $elementRule as $rule}
	$("[name='{$rule->elementTrigger}']").change(function(){
		{if $rule->elementTriggerRule=='IS'}
		
			{if $rule->recieverAction=='SHOW'}
				if(this.value=='{$rule->elementTriggerValue}'){
					$("#li_{$rule->reciever}").show();
				}
				else{
					$("#li_{$rule->reciever}").hide();
				}
			{/if}
			
			{if $rule->recieverAction=='HIDE'}
				if(this.value=='{$rule->elementTriggerValue}'){
					$("#li_{$rule->reciever}").hide();
				}
				else{
					$("#li_{$rule->reciever}").show();
				}
			{/if}
		{/if}
	});
	
	{if $rule->recieverAction=='SHOW'}
		$("#li_{$rule->reciever}").hide();
	{else if $rule->recieverAction=='HIDE'}
		$("#li_{$rule->reciever}").show();
	{/if}
{/foreach}
var editImageTitle	="{$language.lbleditImageTitle}";

</script>

