function swap_image(id,file,dir,path){
	if(dir){
		dir = dir+'/';
	}
	document.getElementById(id).src = path+'images/'+dir+file;
}

function swap_image_restore(id,file,dir,path){
	if(dir){
		dir = dir+'/';
	}
	document.getElementById(id).src = path+'images/'+dir+file;
}

function blank_hidden(id){
	if(document.getElementById(id).style.color != '#000'){
		document.getElementById(id).value = '';
		document.getElementById(id).style.color = '#000';
	}
}

function blank_display(id){
	if(!document.getElementById(id).value){
		document.getElementById(id).style.color = '#ccc';
		document.getElementById(id).value = 'ツアーコードを入力して下さい';
	}
}

function age_disp(value,num){
	if(value == 2 || value == 3){
		document.getElementById('cld'+num).style.display = 'block';
	}else{
		document.getElementById('cld'+num).style.display = 'none';
	}
	if(value == 4){
		document.getElementById('inf'+num).style.display = 'block';
	}else{
		document.getElementById('inf'+num).style.display = 'none';
	}
}

function age_disp_ao(value,num){
	if(value == 2){
		document.getElementById('cld'+num).style.display = 'block';
	}else{
		document.getElementById('cld'+num).style.display = 'none';
	}
	if(value == 3){
		document.getElementById('inf'+num).style.display = 'block';
	}else{
		document.getElementById('inf'+num).style.display = 'none';
	}
}

function input_all_clear(){
	var i = 0;
	var inputs = new Array(
		'jp_family','jp_first','jp_middle',
		'kana_family','kana_first','kana_middle',
		'rome_family','rome_first','rome_middle',
		'zip','addr','addr2',
		'tel','fax','callphone',
		'mail_addr','mp_mail','note'
	);
	
	for(i=0; i<inputs.length; i++){
		document.getElementById(inputs[i]).value = '';
	}
	document.getElementById('sex_0').checked = true;
	document.getElementById('sex_1').checked = false;
	document.getElementById('pref').value = '選択してください';
	document.getElementById('mailmagazine').checked = false;
	
	for(i=1; i<=8; i++){
		document.getElementById('famiry_cmp'+i).value = '';
		document.getElementById('first_cmp'+i).value = '';
		document.getElementById('middle_cmp'+i).value = '';
		document.getElementById('sex_cmp'+i+'_0').checked = true;
		document.getElementById('sex_cmp'+i+'_1').checked = false;
		document.getElementById('age_flg'+i).value = 0;
		document.getElementById('cld_age'+i).value = 2;
		document.getElementById('inf_age'+i).value = 2;
		document.getElementById('rooming'+i).value = 0;
		document.getElementById('cld'+i).style.display = 'none';
		document.getElementById('inf'+i).style.display = 'none';
	}
	
}

function comp_check(chk,no){
	var i = 0;
	if(document.getElementById('comp_no').value){
		var comp_no = document.getElementById('comp_no').value.split('__');
	}else{
		var comp_no = new Array();
	}
	var cnt = comp_no.length;
	if(cnt == 4 && chk == true){
		document.getElementById('chk_'+no).checked = false;
		window.alert('4件以上のツアーは比較できません。');
	}else{
		if(chk == true){
			document.getElementById('tr_'+no).style.backgroundColor = '#ffdfdf';
			comp_no.push(no);
		}else{
			var style_name = document.getElementById('tr_'+no).className;
			var new_comp_no = new Array();
			if(style_name == 'tr_white'){
				document.getElementById('tr_'+no).style.backgroundColor = '#fff';
			}else{
				document.getElementById('tr_'+no).style.backgroundColor = '#eee';
			}
			for(i=0; i<comp_no.length; i++){
				if(comp_no[i] != no){
					new_comp_no.push(comp_no[i]);
				}
			}
			comp_no = new_comp_no;
		}
		comp_no.sort();
		document.getElementById('comp_no').value = comp_no.join('__');
		var join_cn = document.getElementById('comp_no').value;
		var page_nm = document.getElementById('page_nums').value;
		document.getElementById('comp_link').href = 'javascript:comp_view(\''+join_cn+'\')';
		document.getElementById('page_link_next').href = document.getElementById('page_link_next').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
		document.getElementById('page_link_prev').href = document.getElementById('page_link_prev').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
		document.getElementById('bottom_page_link_next').href = document.getElementById('bottom_page_link_next').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
		document.getElementById('bottom_page_link_prev').href = document.getElementById('bottom_page_link_prev').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
		if(page_nm > 1){
			for(i=1; i<=page_nm; i++){
				document.getElementById('page_link_'+i).href = document.getElementById('page_link_'+i).href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
				document.getElementById('bottom_page_link_'+i).href = document.getElementById('bottom_page_link_'+i).href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
			}
		}
		document.getElementById('order_new').href        = document.getElementById('order_new').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
		document.getElementById('order_price_row').href  = document.getElementById('order_price_row').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
		document.getElementById('order_price_high').href = document.getElementById('order_price_high').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
		document.getElementById('order_dpt_short').href  = document.getElementById('order_dpt_short').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
		document.getElementById('order_dpt_long').href   = document.getElementById('order_dpt_long').href.replace(/&comp_no=.*/,'&comp_no='+join_cn);
	}
}

function comp_view(no){
	if(no){
		window.location.href = 'comparison.php?search=on&comp_no='+no;
	}else{
		window.alert("チェックの入ったツアーがありません。");
	}
}