function snc_twosyncsel (){
	this.av = arguments[0];
	$.ajax({
		av: this.av,
		url: this.av.fromURL,
		type: 'GET',
		dataType: 'json',
		timeout: 30000,
		beforeSend: function(){
			var sb = window.document.getElementById(this.av.fromID);
			for(i=sb.length;i>0;i--) sb.remove(i);
			sb.options[0] = new Option('now loading...','');
		},
		error: function(){
			$("#"+this.av.msgID).html('Error loading JSON document('+this.av.fromID+')').hide("fast").show("fast");
		},
		success: function(json){
			var sb = window.document.getElementById(this.av.fromID);
			sb.av = this.av;
			var p=0;
			if(this.av.fromTopSelect){
				sb.options[0] = new Option(this.av.fromTopSelect,((this.av.fromTopSelectValue)?this.av.fromTopSelectValue:''));
				sb.options[0].selected=true;
				p=1;
			}
			
			for(i=0;i<json.result.length;i++){
				sb.options[i+p] = new Option(json.result[i].name,json.result[i].val);
				if(this.av.fromSelected){
					if(this.av.fromSelected == json.result[i].val){
						sb.options[i+p].selected=true;
					}
				}
			}
			if(this.av.toSelected ){
				if(this.av.toInitKey){
					if(this.av.toInitKey != this.av.toTopSelectValue){
// k.ohga get param ..
						$.ajax({
							av: this.av,
							url: this.av.toURL + this.av.toKey + "/" + this.av.toInitKey + '/',
							type: 'GET',
							dataType: 'json',
							timeout: 30000,
							beforeSend: function(){
								var sb = window.document.getElementById(this.av.toID);
								for(i=sb.length;i>0;i--) sb.remove(i);
								sb.options[0] = new Option('now loading...','');
							},
							error: function(){
								$("#"+this.av.msgID).html('Error loading JSON document('+this.av.toID+')').hide("fast").show("fast");
							},
							success: function(json){
								var sb = window.document.getElementById(this.av.toID);
								for(i=sb.length;i>0;i--) sb.remove(i);
								sb.options[0] = new Option(this.av.toTopSelect,((this.av.toTopSelectValue)?this.av.fromTopSelectValue:''));
								for(i=0;i<json.result.length;i++){
									sb.options[i+1] = new Option(json.result[i].name,json.result[i].val);
									if(this.av.toSelected == json.result[i].val){
										sb.options[i+1].selected=true;
									}
								}
							}
						});
					}
				}
			} else {
				var sb = window.document.getElementById(this.av.toID);
				if( sb != null ){
					for(i=sb.length;i>0;i--) sb.remove(i);
					sb.options[0] = new Option(this.av.toTopSelect,((this.av.toTopSelectValue)?this.av.toTopSelectValue:''));
				}
			}


			$("#"+this.av.fromID).change(function(){

				if(this.av.fromTopSelectValue){
					if($("#"+this.av.fromID+" option:selected").attr('value') == this.av.fromTopSelectValue){
						var sb = window.document.getElementById(this.av.toID);
						for(i=sb.length;i>0;i--) sb.remove(i);
						sb.options[0] = new Option(this.av.toTopSelect,this.av.toTopSelectValue);
						return;
					}
				} else {
					if(!$("#"+this.av.fromID+" option:selected").attr('value')){
						var sb = window.document.getElementById(this.av.toID);
						for(i=sb.length;i>0;i--) sb.remove(i);
						sb.options[0] = new Option(this.av.toTopSelect,'');
						return;
					}
				}

				$.ajax({
					av: this.av,
					url: this.av.toURL + this.av.toKey + "/" + $("#"+this.av.fromID+" option:selected").attr('value') + '/',
					type: 'GET',
					dataType: 'json',
					// data: this.av.toKey + "=" + $("#"+this.av.fromID+" option:selected").attr('value'),
					timeout: 30000,
					beforeSend: function(){
						var sb = window.document.getElementById(this.av.toID);
						for(i=sb.length;i>0;i--) sb.remove(i);
						sb.options[0] = new Option('now loading...','');
					},
					error: function(){
						$("#"+this.av.msgID).html('Error loading JSON document('+this.av.toID+')').hide("fast").show("fast");
					},
					success: function(json){
						var sb = window.document.getElementById(this.av.toID);
						for(i=sb.length;i>0;i--) sb.remove(i);
						var p=1;
						sb.options[0] = new Option(this.av.toTopSelect,((this.av.toTopSelectValue)?this.av.toTopSelectValue:''));
						sb.options[0].selected=true;
						for(i=0;i<json.result.length;i++){
							sb.options[i+p] = new Option(json.result[i].name,json.result[i].val);
						}
					}
				});
			});
		}
	});
}

