//load the jquery DOM object
$(document).ready(function()
{
//alert("111");
	//This function is called, when snet option changed
    //content of this function is deprecated. snetSuggest function should be used instead.
    //'select' here should be replaced with ID of field, because of application has 'select' fields
    //but we should not perform this function for them
	$('select').change(function()
	{

		var str=this.name;
		var subStr=str.substring(4);
		var snetid=this.value;
        //alert(str + ", " + subStr + ", " + snetid);
		//Ajax call to retrieve the values from database
		$.ajax(
		{
			type: "POST",
			url: "/_/System/procedures/snet_suggest.cfm",
			data: "snet_id="+snetid,
			//if there is no eror in ajax call
			success: function(obj) {
				//var txtName='snet_suggest'+subStr;
				var txtName='snetURL_'+subStr;
				$('#'+txtName).val(obj);//=obj;
			}


		});

	});
});

//this function updates objToUpdate field by URL according to snetId value
function snetSuggest(snetId, objToUpdate) {
    $.ajax({
        type: "POST",
        url: "/_/System/procedures/snet_suggest.cfm",
        data: "snet_id="+snetId,
        //if there is no eror in ajax call
        success: function(obj) {
            objToUpdate.val(obj);
        }
    });
}
