
$(document).ready(function() { 
    var options = { 
		url:			'ajaxProcess.php',
        target:        '#contentPanelMiddle',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
            };     

        
 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 

 
    // bind to the form's submit event 
    $('#controlForm').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
 
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    });    
}); 
 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxSubmit method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxSubmit method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 
} 


/*

        // wait for the DOM to be loaded 
        $(document).ready(function() { 
			var options = { 
			type:		'POST',
			target:     '#result', 
			url:        'ajaxProcess.php', 
			success:    function() { 
			
			} 
			}; 
            // bind 'myForm' and provide a simple callback function 
            $('#controlForm').ajaxForm(options); 
        }); 
runOnLoad(function(){
  $("input#control_input").select().focus();
});

*/

//////

runOnLoad(function(){
  $("input#control_input").select().focus();
});





$().ready(function() {

	function log(event, data, formatted) {
		$("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
	}
	
	function formatItem(row) {
		return row[0] + " (<strong>id: " + row[1] + "</strong>)";
	}
	function formatResult(row) {
		return row[0].replace(/(<.+?>)/gi, '');
	}
	
	$("#control_input").autocomplete("ajaxSuggest.php", {
		width: 260,
		selectFirst: false
	});

	
	$(":text, textarea").result(log).next().click(function() {
		$(this).prev().search();
	});
	$("#control_input").result(function(event, data, formatted) {
		if (data)
			$(this).parent().next().find("input").val(data[1]);
	});
	
	$("#scrollChange").click(changeScrollHeight);
	

	
	$("#clear").click(function() {
		$(":input").unautocomplete();
	});
	
	
	
		$("#domainActionValue").fadeOut();
	
});



function changeScrollHeight() {
    var h = parseInt(window.prompt('Please type new scroll height (number in pixels):', jQuery.Autocompleter.defaults.scrollHeight));

}

function domainActionChange(e) {
	if (e.value=='setLabel') {
		$("#domainActionValue").fadeIn();
	}
}

function setSelectedTld(element) {
	
	if ($("#domainTld_" + element).val()=='1') {
		
		$('#domainTldHolder' + element).css("background-image", "url(struct/domain_tld_holder.gif)");
		$('#domainTldHolder' + element).css("color", "#99CC33");
		$("#domainTld_" + element).val('');
	}
	else {
		$('#domainTldHolder' + element).css("background-image", "url(struct/domain_tld_selected.gif)");
		$('#domainTldHolder' + element).css("color", "#FFFFFF");
		$("#domainTld_" + element).val('1');
	}	
 }




