

$(function() 
{	
	var icons = {
         header: "iconclosed",    // custom icon class
         activeHeader: "iconopen" // custom icon class
     };
     $("#testresults").accordion({
         icons: icons,
		 heightStyle: "content",
		 collapsible: true
     });
	 
	$( "#admincontrol" ).accordion({
      heightStyle: "content",
	  collapsible: true,
	  active: false,
	  icons: icons,
	  activate: function(event, ui) {
          if(ui.newHeader.attr('id') == "h-colsetup")
			  initDomainFields();
		  else if(ui.newHeader.attr('id') == "h-useradmin")
			  init_useradmin();
		  else if(ui.newHeader.attr('id') == "h-apisetup")
			  init_regapisetup();
		  else if(ui.newHeader.attr('id') == "h-errorlogs")
			  init_errorlogs();
		  else if(ui.newHeader.attr('id') == "h-auditlog")
			  init_auditlog();
		  else if(ui.newHeader.attr('id') == "h-emailsetup")
			  init_emailsetup();
		  else if(ui.newHeader.attr('id') == "h-scheduler")
			  init_scheduler();
		  else if(ui.newHeader.attr('id') == "h-adminreports")
			  init_adminreports();
		  else if(ui.newHeader.attr('id') == "h-dnsalerts")
			  init_dnsalerts();
		  else if(ui.newHeader.attr('id') == "h-authentication")
			  init_authentication();
		  else if(ui.newHeader.attr('id') == "h-samlsetup")
			  init_samlsetup();
		  else if(ui.newHeader.attr('id') == "h-branding")
			  init_branding();
		  else if(ui.newHeader.attr('id') == "h-security")
			  init_security();
		  else if(ui.newHeader.attr('id') == "h-whoissetup")
			  init_whoissetup();
		  else if(ui.newHeader.attr('id') == "h-suffixlist")
			  init_suffixlist();
		  else if(ui.newHeader.attr('id') == "h-rdapsetup")
			  init_rdapsetup();
		  else if(ui.newHeader.attr('id') == "h-setupmisc")
			  init_setupmisc();
		}
    });

	initEnterKeyHandler("rdapsetup-tld", "rdapsetup-get-server");
	
	var ht = $(window).height();
	var maxheight = ht - $('#data-header').height() - $('#data-footer').height() - 50;
	$('#useradmin').css('max-height', maxheight);
	
	$('#useradmin').css('overflow', 'inherit');
	$('#uadmin_rights').multipleSelect();
	$('#dns_monitor_records').multipleSelect();
	
	if(typeof user_details != "undefined") {
		if(user_details['uid'] >= 0) {
			var datastr = get_ajax_datastr("list", "category", "user");
			datastr += "&id=0";
			ajax_call(datastr, ajax_init_catlist, null);
			showServerTime();
			setInterval(function() {showServerTime();}, 30000);
		}
	}

	alertdelay = 5;
	$("#alert-frequency-slider").slider({
		min: 0,
		max: 60,
		step: 5,
		value: alertdelay,
		slide: function( event, ui ) {
			$( "#alert-frequency-value" ).html( ui.value );
		}
	});
	$( "#alert-frequency-value" ).html(alertdelay);
	
	initEnterKeyHandler("auditlog-filter", "auditlog-run-filter");
	$('#auditlog-run-filter').off('click');
	$('#auditlog-run-filter').click(function() {
		init_auditlog();
	});
	
});

