//
	function voteQuest(url, query, div_id)
	{
		var frm = document.vote_form.answer;
		var val = null;
		for(var i = 0;i < frm.length;i++)
		{
			if(frm[i].checked)
			{
				val = frm[i].value;
				break;
			}
		}
		
		if( val )
		{
			query = query + '&v=' + val;
			var req = new ajaxObject(url);
			req.update(query);
			req.callback = function(responseText)
			{
				document.getElementById(div_id).style.display = 'none';
				document.getElementById('que_result').innerHTML  = responseText;
				document.getElementById('que_result').style.display = 'block';
			}
			req.update();
		}
		else
		{
			alert("回答をチェック！");
		}
	}

//
	function sendAjaxComp( url, query )
	{
		var req = new ajaxObject(url);
		req.update(query);
		req.callback = function(responseText)
		{
			//alert( responseText );
			if( responseText == 'Success' )
			{
				location.href = "./comp.html";
				return;
			}
		}
		req.update();
	}

//
	function submitImage(fname)
	{
		if( fname == 'form_car_mapsearch' )
		{
			var objFrm = document.form_car_mapsearch.__u_car_name2;
			//alert(objFrm.options[objFrm.selectedIndex].value);
			if( objFrm.options[objFrm.selectedIndex].value == '' )
			{
				alert( '車名を選択してください' );
				return false;
			}
			else
			{
				
				document.forms[fname].submit();
			}
		}
		else
		{
			document.forms[fname].submit();
		}
	}

	function uCng(v)
	{
	//alert(v);
		var obj = document.form_car_mapsearch;
		if( !v )
		{
			obj.__City.disabled = true;
			obj.__City.style.backgroundColor='#D4D0C8';
		}
		else
		{
			obj.__City.disabled = false;
			obj.__City.style.backgroundColor='#FFFFFF';
		}
	}
	
	function mCng(v)
	{
	//alert(v);
		var obj = document.carsearch;
		if( !v )
		{
			obj.__u_car_name.disabled = false;
			obj.__u_car_name.style.backgroundColor='#FFFFFF';
			
			obj.__u_car_name2.disabled = true;
			obj.__u_car_name2.style.backgroundColor='#D4D0C8';
			//echoOption('/modules/retUsedCarnames.php','__u_car_maker=ZZ', 'ucarnameoption');
		}
		else
		{
			obj.__u_car_name2.disabled = false;
			obj.__u_car_name2.style.backgroundColor='#FFFFFF';
			echoOption('/modules/retUsedCarnames.php','__u_car_maker=' + v, 'ucarnameoption');
		}
	}
	
	function cCng(v)
	{
	//alert(v);
		var obj = document.carsearch;
		if( !v )
		{
			obj.__u_car_name.disabled = false;
			obj.__u_car_name.style.backgroundColor='#FFFFFF';
		}
		else
		{
			//obj.__u_car_name.value = "";
			obj.__u_car_name.disabled = true;
			obj.__u_car_name.style.backgroundColor='#D4D0C8';
		}
	}
	
	function echoOption( url, query, div_id )
	{
		var obj = document.carsearch;
		var req = new ajaxObject(url);
		req.update(query);
		req.callback = function(responseText)
		{
			document.getElementById(div_id).innerHTML  = responseText;
			obj.__u_car_name2.style.backgroundColor='#FFFFFF';
			obj.__u_car_name2.disabled = false;
		}
		req.update();
	}
	
	
	function chkHighLow( fid, tf )
	{
	//alert(fid);
		var obj = document.carsearch;
		var chk = fid.search(/u_car_price/g);
		switch( chk )
		{
			case -1:
				var objL = obj.__u_car_model;
				var objH = obj.__u_car_model2;
				break;
				
			default:
				var objL = obj.__u_car_price;
				var objH = obj.__u_car_price2;
				break;
		}
		var vl  = objL.options[objL.selectedIndex].value;
		var vh  = objH.options[objH.selectedIndex].value;
		
		if( vl != '' && vh != '' && ( parseInt( vl ) > parseInt( vh ) ) )
		{
			alert( '下限と上限が逆転しています。' );
			if( tf )
			{
				var chk = fid.search(/2$/g);
				switch( chk )
				{
					case -1:
						objL.selectedIndex = 0;
						objL.focus();
						break;
						
					default:
						objH.selectedIndex = 0;
						objH.focus();
						break;
				}
			}
			return false;
		}
		return true;
	}
//

	function sendAjax( url, query )
	{
		var req = new ajaxObject(url);
		req.update(query);
		req.callback = function(responseText)
		{
			//alert(responseText);
		}
		req.update();
	}

	function ajaxObject( url, callbackFunction )
	{
		var that = this;
		this.updating = false;
		this.abort = function()
		{
			if( that.updating )
			{
				that.updating = false;
				that.AJAX.abort();
				that.AJAX = null;
			}
		}
		
		this.update = function( passData, postMethod )
		{
			if( that.updating )
			{
				return false;
			}
			that.AJAX = null;

			if( window.XMLHttpRequest )
			{              
				that.AJAX = new XMLHttpRequest();
			}
			else
			{
				that.AJAX = new ActiveXObject( "Microsoft.XMLHTTP" );
			}

			if( that.AJAX == null )
			{
				return false;
			}
			else
			{
				that.AJAX.onreadystatechange = function()
				{
					if( that.AJAX.readyState == 4 )
					{             
						that.updating = false;
						that.callback( that.AJAX.responseText, that.AJAX.status, that.AJAX.responseXML );
						that.AJAX = null;
					}
				}
				
				that.updating = new Date();
				if( /post/i.test( postMethod ) )
				{
					var uri = urlCall;
					//var uri = + '?' + that.updating.getTime();
					that.AJAX.open( "POST", uri, true );
					that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					that.AJAX.setRequestHeader("Content-Length", passData.length);
					that.AJAX.setRequestHeader("If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT");
					that.AJAX.send( passData );
				}
				else
				{
					var uri = urlCall + '?' + passData;
					//var uri = + '?' + passData + '&amp;timestamp=' + (that.updating.getTime());
					that.AJAX.open( "GET", uri, true );
					that.AJAX.setRequestHeader("If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT");
					that.AJAX.send(null);
				}
				return true;
			}
		}
		var urlCall = url;
		this.callback = callbackFunction || function () { };
	}
