{{literal}}function HideAllRepeatFields (){{{/literal}}
	$('#Collection_{{$collection}}_5_row').css({display:'none'});
	$('#Collection_{{$collection}}_6_row').css({display:'none'});
	$('#Collection_{{$collection}}_7_row').css({display:'none'});
	$('#Collection_{{$collection}}_8_row').css({display:'none'});
{{literal}}}{{/literal}}

var fields = new Array();

{{literal}}function GetFieldsForCollection (cid){{{/literal}}
var fields = new Array();

$.ajax({
   type: "GET",
   url: "/o2/admin.php?menu_id=4&module_id=11&collectionid=90&colid=2&cid="+cid,
   async: false,
   cache: false,
   success: function(html){
    
	 eval(html);
	 
	 
   }

 });

return fields;
{{literal}}}{{/literal}}


{{literal}}function ShowAll (cid){{{/literal}}
	
	var fields = GetFieldsForCollection (cid);
	
	var optionsString = '<option value="0">Select Field...</option>';
	for (i in fields)
	{
		
		optionsString = optionsString + "<option value=\""+i+"\">"+fields[i]+"</option>";
	}
	
	
	
	$('#Collection_{{$collection}}_5').html(optionsString);
	$('#Collection_{{$collection}}_6').html(optionsString);
	$('#Collection_{{$collection}}_7').html(optionsString);
	$('#Collection_{{$collection}}_8').html(optionsString);
	
	var selectedValue = $('#Collection_{{$collection}}_5').attr('selvalue');
	if (selectedValue != ''){ $('#Collection_{{$collection}}_5').find('option[value='+selectedValue+']').attr('selected','true'); }
	var selectedValue = $('#Collection_{{$collection}}_6').attr('selvalue');
	if (selectedValue != ''){ $('#Collection_{{$collection}}_6').find('option[value='+selectedValue+']').attr('selected','true'); }
	var selectedValue = $('#Collection_{{$collection}}_7').attr('selvalue');
	if (selectedValue != ''){ $('#Collection_{{$collection}}_7').find('option[value='+selectedValue+']').attr('selected','true'); }
	var selectedValue = $('#Collection_{{$collection}}_8').attr('selvalue');
	if (selectedValue != ''){ $('#Collection_{{$collection}}_8').find('option[value='+selectedValue+']').attr('selected','true'); }
	
	
	$('#Collection_{{$collection}}_5_row').css({display:''});
	$('#Collection_{{$collection}}_6_row').css({display:''});
	$('#Collection_{{$collection}}_7_row').css({display:''});
	$('#Collection_{{$collection}}_8_row').css({display:''});
{{literal}}}{{/literal}}

$('#{{$fieldName}}').change(
			{{literal}}function(){{{/literal}}
				var value = this.value;
				HideAllRepeatFields ();
				
				$('#Collection_{{$collection}}_5').attr('selvalue','');
				$('#Collection_{{$collection}}_6').attr('selvalue','');
				$('#Collection_{{$collection}}_7').attr('selvalue','');
				$('#Collection_{{$collection}}_8').attr('selvalue','');
				
				ShowAll(value);
			{{literal}}}{{/literal}}
);


HideAllRepeatFields ();

{{if $selectedRow.$fieldName neq ''}}
	ShowAll({{$selectedRow.$fieldName}});
	$('#Collection_{{$collection}}_1').parent().append("<a href=\"http://{{$smarty.server.HTTP_HOST}}/rss-feeds/rss-{{$smarty.get.eid}}.rss\" target=\"_blank\">View Feed</a>");

{{/if}}

