ajax	= null;
check	= false;
wait	= false;

function match_check_girl(cid){
	if(check){
		check	= false;
		return true;
	}
	
	if(!wait){
		var time	= get_rand();
			
		var	param	= "club_id="+cid+"&stamp="+time;
		var inputs	= Array("style_id","tail","bust_cup_id","time_zone_id","free");
		for(var i=0; i<inputs.length; i++){
			var	elm	= document.getElementsByName(inputs[i])[0];
			param	+= "&"+inputs[i]+"="+elm.value;
		}
		
		ajax	= new AJAX;
		ajax.SetOnloadEvent(resule_callback);
		ajax.Open("POST","search_check.php",true);
		ajax.SetRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.Send(param);
		
		wait	= true;
	}

	return false;
}

function resule_callback(){
	var response	= ajax.GetResponse();
	wait	= false;
	if(response > 0){
		check	= true;
		document.getElementById("topform").submit();
	}
	else{
		check	= false;
		alert("検索結果が見当たりません。\n条件を変更して再度検索を実行してください。");
	}
}

function get_rand(){
	var now		= new Date();
	var	rand	= Math.floor(Math.random() * 10000);
	var	result	= "" + now.getYear() + now.getMonth() + now.getDay() + now.getHours() + now.getMinutes() + rand;
	now	= null;
	return result;
}

