{include file='CommonJavaScript.tpl'}
<link rel="stylesheet" type="text/css" href="{$view_styles}/popup.css" media="screen" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/locationadd.css" media="screen" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/grid_listing.css" />
<div class="popup-block">
<div class="clear"></div>
<div class="message_error" id="importGlobalAttributesError" style="display:none;"> {$language.lblSelectItem}</div>
{if $resListAttributes|@count>0}
{form->start name="formImportGlobalOptions" action="" method="post" enctype="multipart/form-data"}
<div>
  <div class="form_listing02 clearfix">  
  <div class="grid_table00">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<th width="30" class="checkbox_column" align="left" valign="middle"> <div class="chekingdiv" >
	<ul>
	<li>{form->checkbox id="ListStatusLinkCheckbox"  class="fixing_left"}</li>
	</ul>
	</div>
	</th>
	<th align="left" valign="middle"  width="40%">Option</th>
	<th align="left" valign="middle" >Apply As Link</th>
	</tr>
	{foreach from=$resListAttributes item="resAttributes"}
	{assign var="customOptionID" value=$resAttributes.customOptionID}
	<tr>
	<td>
	{form->checkbox id="importGlobalOptionIDs_$customOptionID" name="importGlobalOptionIDs" value=$customOptionID class="importGlobalOptionIDs ListAll"}
	</td>
	<td>	
	{$resAttributes.customOptionName}
	</td>
	<td>
	{form->checkbox id="applyaslink_$customOptionID" name="applyaslinkcustomOptionIDs" value=$customOptionID class="importAsLink"}
	</td>
	</tr>
	{/foreach}   
  </table>		
  </div>  
    <div class="submit-block clearfix textto_center"> 
      {form->submit name="submitImportGlobalOptions" class="curve-3" value=$language.lblImportGlobalOptions} {$language.lblOr} 
      {html->anchor id="cancelImportGlobalOptions" caption="{$language.lblCancel}" onclick="parent.$.colorbox.close();"} </div>
   </div>
</div>
{form->hidden name="customOptionIDs" value=""}
{form->hidden name="AsLinkcustomOptionIDs" value=""}
{form->close}
{else}
<div class="message_info"> {$language.msgNoRecords}</div>
{/if}
</div>
<script type="text/javascript">
{literal}
$(document).ready(function () {
	var customOptionIDs = "";
	$(document).on('click', "#ListStatusLinkCheckbox", function () {
        if ($(this).prop("checked") == true) {
            $(".ListAll").prop('checked',true);
        } else {
            $(".ListAll").prop('checked',false);
        }
    });
	 $(document).on('click', ".ListAll", function () {
        var ListAllCount = $(".ListAll").size();
        var ListAllCheckedCount = $(".ListAll:checked").size();
        if (parseInt(ListAllCount) == parseInt(ListAllCheckedCount)) {
            $("#ListStatusLinkCheckbox").prop('checked',true);
        } else {
            $("#ListStatusLinkCheckbox").prop('checked',false);
        }
    });
	 
	 $(document).on('click', ".importAsLink", function ()
	{
	  if ($(this).prop("checked") == true)
	  {
	   $("#importGlobalOptionIDs_"+$(this).val()).prop('checked',true);
	  }
	});
	 
	$("#formImportGlobalOptions").submit(function()
	{
	customOptionIDs = "";
	var AsLinkcustomOptionIDs = "";	
	$(".importGlobalOptionIDs").each(function(index, element) {
        if ($(this).prop("checked") == true) {
		customOptionIDs = customOptionIDs + $(this).val() +",";
		}
	});
	$(".importAsLink").each(function(index, element) {
        if ($(this).prop("checked") == true) {
		AsLinkcustomOptionIDs = AsLinkcustomOptionIDs + $(this).val() +",";
		}
	});
	customOptionIDs= customOptionIDs.substr(0,customOptionIDs.length-1);
	AsLinkcustomOptionIDs= AsLinkcustomOptionIDs.substr(0,AsLinkcustomOptionIDs.length-1);
	$("#customOptionIDs").val(customOptionIDs);
	$("#AsLinkcustomOptionIDs").val(AsLinkcustomOptionIDs);
	if(customOptionIDs=="")
	{
		$("#importGlobalAttributesError").show();
		$('body,html').animate({
        scrollTop: $("#importGlobalAttributesError").offset().top},
        'slow');
		$('#importGlobalAttributesError').fadeTo(3000.7).slideUp(4000);
		return false;	
	}
	});
});
{/literal}
</script>