
function choose_big(checkstr){
	var str = new String($F('list_of_ctg_big'));

	splitedbigselect = new Array();
	if (str.match(/,/)){
		splitedbigselect = str.split(",");
	}else{
		splitedbigselect.push(str);
	}

	if( splitedbigselect.length ==1 & splitedbigselect[0] == "" ){
		alert('Non-select Major Category.');
		return false;
	}

	var tempstock = $('store_table').innerHTML;
	$('store_table').innerHTML = $('holdingdiv').innerHTML;
	$('holdingdiv').innerHTML=tempstock;
	

	var temp_listup_selected_bigvalue = "";

	temp_listup_selected_bigvalue += '[Selected Major Categories]<br><div id="selected_biglists">';

	var option_num =0;
	for (i=0; i< splitedbigselect.length; i++){
		var checked_ID='CTGBIGCODE_'+ splitedbigselect[i] ;
		temp_listup_selected_bigvalue += $(checked_ID).innerHTML;

		for (j=0; j<document.mainpage_form.hide_list_of_ctg_small.options.length ; j++){

			if( document.mainpage_form.hide_list_of_ctg_small.options[j].label == splitedbigselect[i] ){
				var get_id = document.mainpage_form.hide_list_of_ctg_small.options[j].id ;
			    var idx    = document.mainpage_form.list_of_ctg_small.length; 
			    document.mainpage_form.list_of_ctg_small.options[idx]=new Option( $(get_id).innerHTML, $(get_id).value); 
			}
		}


		if( i != splitedbigselect.length) {temp_listup_selected_bigvalue +='</br>' ;}
	}


	$('listup_selected_big').style.visibility ="visible";

	if ( checkstr =="dontgotosmall"){
		// This area is that user not choose small ctg.. 
		$('last_submit_area').style.visibility = "visible";
		$('listup_selected_big').innerHTML = temp_listup_selected_bigvalue + '</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="goback_to_big"  value="Back to choice Major" onclick="goback_big()">';
		return true;

	}

	$('listup_selected_big').innerHTML = temp_listup_selected_bigvalue + '</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="goback_to_big"  value="Back to choice Major" onclick="goback_big()">';
	$('list_of_ctg_small').style.visibility ="visible";
	$('small_show_space').style.visibility = "visible";
	$('list_of_ctg_small').size = "15";

	disabledupdate_for_ctgsmall();
}

function  disabledupdate_for_ctgsmall(){

	for(k=0; k< document.mainpage_form.list_of_ctg_small.options.length; k++){
		var tempvalue = document.mainpage_form.list_of_ctg_small.options[k].text;
		var oObj = document.mainpage_form.list_of_ctg_small.options[k];
		if(tempvalue.match("《")){
			oObj.disabled="disabled";
		}
	}
}

function choose_small(){
	var on_flg="";
	for(k=0; k< document.mainpage_form.list_of_ctg_small.options.length; k++){
		var tempvalue = document.mainpage_form.list_of_ctg_small.options[k].text;
		var oObj = document.mainpage_form.list_of_ctg_small.options[k];
		if(tempvalue.match("《") && (oObj.selected)){
			oObj.selected=false;
		}else if ((oObj.selected)){
			on_flg="1";
		}
	}
	if(on_flg){
		$('last_submit_area').style.visibility = "visible";
	}else{
		$('last_submit_area').style.visibility = "hidden";
	}
}



function goback_big(){
	$('listup_selected_big').style.visibility ="hidden";
	$('list_of_ctg_small').style.visibility ="hidden";

	$('small_show_space').style.visibility = "hidden";
	$('list_of_ctg_small').size = "1";
	for(i=document.mainpage_form.list_of_ctg_small.options.length-1;i>=0;i--){
		document.mainpage_form.list_of_ctg_small.options[i]=null;
	}

	var tempstock = $('holdingdiv').innerHTML;
	$('holdingdiv').innerHTML = $('store_table').innerHTML;
	$('store_table').innerHTML = tempstock;

	$('listup_selected_big').innerHTML = "";
	$('last_submit_area').style.visibility = "hidden";

}



function ctgkeyword_check(){
	if( $('keysearch').value == "" ){
		return false;
	}
	var kaigyo = getCRChars();
	var result_arr =  new Array();		//結果表示用の格納配列
	var hit_num = 0;
	var hist_ctgbig="";
	var change_line=0;

	var keyfraze = $('keysearch').value;

	result_arr.push( ( "Search result of [" + keyfraze + "]:" + kaigyo ));

	for (j=0; j<document.mainpage_form.hide_list_of_ctg_small.options.length ; j++){
		if(j!=0){ if(document.mainpage_form.hide_list_of_ctg_small.options[j].label != document.mainpage_form.hide_list_of_ctg_small.options[j-1].label){ change_line=j }  ; }
		var temp_text = document.mainpage_form.hide_list_of_ctg_small.options[j].text;
		if( temp_text.match(keyfraze)){
			var ctgbigcode = document.mainpage_form.hide_list_of_ctg_small.options[j].label;
			for(i=0; i<document.mainpage_form.list_of_ctg_big.options.length; i++){
				if ( document.mainpage_form.list_of_ctg_big.options[i].value == ctgbigcode){
					hit_num ++;
					if(hist_ctgbig != ctgbigcode){
						result_arr.push( kaigyo + "In Major Category of '" + document.mainpage_form.list_of_ctg_big.options[i].text+"'" + kaigyo);
					}
					result_arr.push( "'"+document.mainpage_form.hide_list_of_ctg_small.options[j].text + "'" +  kaigyo );

					hist_ctgbig = ctgbigcode;
				}
			}
		}

	}

	if(result_arr.length == 1){
		alert(result_arr[0] + kaigyo +" your search did not match any categories." + kaigyo + "Try different keywords.");
		
	}else{
		result_arr[0] = "Result " + result_arr[0] + hit_num + " hit.";
		var resultcom = result_arr.join("");
		alert(resultcom);
	
	}

}


	function getCRChars(){
		var theAgent=navigator.userAgent
		if (theAgent.indexOf("Win") >=0){
			return "\r\n"
		} else if(theAgent.indexOf("Mac") >=0){
			return "\r"

		} else {
			return "\n"
		}
	}


	function highlight_info(){
		$('big_show_space_insidediv').style.visibility = "visible";
		$('big_show_space_insidediv').style.backgroundColor="#FFCC99";
	}


	function choose_someprefec(){
		var check_allprf=0;

		if( document.mainpage_form.list_of_prfcrd.options[0].selected == true ){
			check_allprf="1";
		}

		if(check_allprf == "1"){
			for (j=1; j<document.mainpage_form.list_of_prfcrd.options.length ; j++){
				document.mainpage_form.list_of_prfcrd.options[j].selected = false;
			}
		}

	}

	function choose_someemp(){
		var check_noemp=0;

		if( document.mainpage_form.emp_list.options[0].selected == true ){
			check_noemp="1";
		}

		if(check_noemp == "1"){
			for (j=1; j<document.mainpage_form.emp_list.options.length ; j++){
				document.mainpage_form.emp_list.options[j].selected = false;
			}
		}

	}
