


//*************************************
//サイズ指定のウィンドウを開く       
//*************************************
function open_new_window(url,width,height,top,left,scrollbars,resizable
						 	,menubar,toolbar,location,directories,status,titlebar){
	
	size 		= 'width=' + width + ',height=' + height;
	move 		= ',top=' + top + ',left=' + left;
	scrollbars 	= ',scrollbars=' + scrollbars;
	resizable 	= ',resizable=' + resizable;
	menubar 	= ',menubar=' + menubar;
	toolbar 	= ',toolbar=' + toolbar;
	location 	= ',location=' + location;
	directories = ',directories=' + directories;
	status 		= ',status=' + status;
	titlebar 	= ',titlebar=' + titlebar;
	
	option = size + move + scrollbars + resizable + menubar + toolbar + location + directories + status + titlebar;
	
	o_colWindow = window.open(url,null,option,"dependent=yes", true);

	return;
}

//*************************************
//言語テキストの表示切替
//*************************************
function display_lang_text(kbn,text){
	
	if ( kbn == 'on' ) {
		$("lang_text").innerHTML = text;
		document.getElementById("lang_text").style.display = "inline";
	} else {
		$("lang_text").innerHTML = '';		
		document.getElementById("lang_text").style.display = "none";
	}
}

//*************************************
//アンケート登録
//*************************************
function input_poll(name,no,box_id){
	
	//AJAXファイルを指定
	ajax_file_path 	= '../../ajax/input_poll.php';
	
	var parameter	= $H({name:name,no:no}).toQueryString();
	
	new Ajax.Request(
			ajax_file_path,
			{
				method			:'post',
				asynchronous	:true,
				postBody		:parameter,
				onComplete		:function(httpObject){
					
					$(box_id).innerHTML	= httpObject.responseText;
					
				},
				onFailure		:function(reg,header){
					

				}
			}
	);
	
	/*
	var myAjax = new Ajax(
			ajax_file_path,
			{
				method			:'get',
				data			:parameter,
                update: $(box_id)
			}
	);
	myAjax.request();
	*/
}


//*************************************
//ディスプレイ　リサイズ
//*************************************
function resize_display(){
	
	//比率
	hiritu = 780/1460;
	
	scrnW 	= screen.width;
	scrnH 	= screen.height;
	
	//resizeTo(scrnW,scrnH);
	
	if ( document.all )
	{
		windowW	= document.body.clientWidth;
		windowH	= document.body.clientHeight;
		
	} else {
		
		windowW	= window.innerWidth;
		windowH	= window.innerHeight;
	}
	
	resizeW = Math.round(windowH/hiritu);
	resizeH = Math.round(scrnW*hiritu);
	
	//if ( resizeH < windowH )
	//	resizeH = windowH;
		
	moveX	= Math.round((scrnW-resizeW)/2);
	moveY	= 0;

	//moveTo(moveX,moveY);
	//resizeTo(resizeW,scrnH);
	
	if ( windowH < resizeH ) 
		document.getElementById('all').style.height = resizeH+"px";
}


//*************************************
//履歴書フォーム パート時間
//*************************************
function display_part_time(value,timeID){
	
	if ( value == 1 )
		document.getElementById(timeID).style.display = "inline";
	else
		document.getElementById(timeID).style.display = "none";
}


//*************************************
//履歴書フォーム 入力チェック
//*************************************
function app_form_check(Form){
	
	var error_msg = "";
	
	//申請職位
	if ( Form.position_applied.value == "" ) {
		error_msg = error_msg + "* Position Applied is required field. \n";
	}
	
	//照片
	//if ( Form.pic.value == "" ) {
	//	error_msg = error_msg + "* Photo is required field. \n";
	//}
	
	//英文姓名
	if ( Form.name_english.value == "" ) {
		error_msg = error_msg + "* Name in English is required field. \n";
	}
	
	//中文姓名
	if ( Form.name_chinese.value == "" ) {
		error_msg = error_msg + "* Name in Chinese is required field. \n";
	}
	
	//身份證/護照號碼出
	if ( Form.passport_no.value == "" ) {
		error_msg = error_msg + "* ID/Passport No is required field. \n";
	}// else if ( isNaN(Form.passport_no.value) ) {
	//	error_msg = error_msg + "* ID/Passport No is number field. \n";
	//}
	
	//出生日期
	if ( Form.birth_day.value == "" || Form.birth_month.value == "" || Form.birth_year.value == "" ) {
		error_msg = error_msg + "* Birthday is required field. \n";
	}
	
	//婚姻状況
	if ( Form.maritalstatus.value == "" ) {
		error_msg = error_msg + "* Marital Status is required field. \n";
	}
	
	//性別
	if ( Form.sex.value == "" ) {
		error_msg = error_msg + "* Sex is required field. \n";
	}
	
	//住宅/聯絡地址
	if ( Form.area.value == "" || Form.address.value == "" ) {
		error_msg = error_msg + "* Res/Corrp Address is required field. \n";
	}
	
	//手提
	if ( Form.mobile_no.value == "" ) {
		error_msg = error_msg + "* Mobile Phone is required field. \n";
	}
	
	//電郵地址
	if ( Form.mail.value == "" ) {
		error_msg = error_msg + "* E-mail is required field. \n";
	}
	
	//教育程度
	for ( i=1; i<=3; i++ ){
		
		if ( 	Form.elements['education'+i+'_s'].value != '' ||
				Form.elements['education'+i+'_l'].value != '' ||
				Form.elements['education'+i+'_a_start_month'].value != '' ||
				Form.elements['education'+i+'_a_start_year'].value != '' ||
				Form.elements['education'+i+'_a_end_month'].value != '' ||
				Form.elements['education'+i+'_a_end_year'].value != ''
		) {
			
			if ( 	Form.elements['education'+i+'_s'].value == '' ||
					Form.elements['education'+i+'_l'].value == '' ||
					Form.elements['education'+i+'_a_start_month'].value == '' ||
					Form.elements['education'+i+'_a_start_year'].value == '' ||
					Form.elements['education'+i+'_a_end_month'].value == '' ||
					Form.elements['education'+i+'_a_end_year'].value == ''
			) {
				
				error_msg = error_msg + "* Please confirm Education Lenvel("+i+"). \n";
			}
		}
	}
	
	//工作經驗
	for ( i=1; i<=3; i++ ){
		
		if ( 	Form.elements['employment'+i+'_c'].value != '' ||
				Form.elements['employment'+i+'_h'].value != '' ||
				Form.elements['employment'+i+'_p_start_month'].value != '' ||
				Form.elements['employment'+i+'_p_start_year'].value != '' ||
				Form.elements['employment'+i+'_p_end_month'].value != '' ||
				Form.elements['employment'+i+'_p_end_year'].value != '' ||
				Form.elements['employment'+i+'_s'].value != '' ||
				Form.elements['employment'+i+'_l'].value != ''
		) {
			
			if ( 	Form.elements['employment'+i+'_c'].value == '' ||
					Form.elements['employment'+i+'_h'].value == '' ||
					Form.elements['employment'+i+'_p_start_month'].value == '' ||
					Form.elements['employment'+i+'_p_start_year'].value == '' ||
					Form.elements['employment'+i+'_p_end_month'].value == '' ||
					Form.elements['employment'+i+'_p_end_year'].value == '' ||
					Form.elements['employment'+i+'_s'].value == '' ||
					Form.elements['employment'+i+'_l'].value == ''
			) {
				
				error_msg = error_msg + "* Please confirm Employment History("+i+"). \n";
			}
		}
	}
	
	//工作地點
	if ( Form.shop1.value != "" ) {
		if ( Form.shop1.value == Form.shop2.value ) {
			error_msg = error_msg + "* Please select a different value about Shop(1) and Shop(2). \n";
		}
		
		if ( Form.shop1.value == Form.shop3.value ) {
			error_msg = error_msg + "* Please select a different value about Shop(1) and Shop(3). \n";
		}
	}
	
	if ( Form.shop2.value != "" ) {
		if ( Form.shop2.value == Form.shop3.value ) {
			error_msg = error_msg + "* Please select a different value about Shop(2) and Shop(3). \n";
		}
	}
	
	//工作可能時間
	for ( i=1; i<=7; i++ ){
		
		if ( i==1 ) week_name = "Mon";
		if ( i==2 ) week_name = "Tue";
		if ( i==3 ) week_name = "Wed";
		if ( i==4 ) week_name = "Thu";
		if ( i==5 ) week_name = "Fri";
		if ( i==6 ) week_name = "Sat";
		if ( i==7 ) week_name = "Sun";
		
		if ( 	Form.elements['part_status'+i].value == 1 ) {
			
			if ( 	Form.elements['part_start_hour'+i].value == '' ||
					Form.elements['part_start_minu'+i].value == '' ||
					Form.elements['part_end_hour'+i].value == '' ||
					Form.elements['part_end_minu'+i].value == ''
			) {
				
				error_msg = error_msg + "* Please confirm Part Time("+week_name+"). \n";
				
			} else if ( eval(Form.elements['part_start_hour'+i].value + Form.elements['part_start_minu'+i].value) >=
				eval(Form.elements['part_end_hour'+i].value + Form.elements['part_end_minu'+i].value) ){
				
				error_msg = error_msg + "* Please confirm Part Time("+week_name+"). \n";
			}
		}
	}
	
	
	if ( error_msg != "") {
		alert(error_msg);
		return false;
	} else {
		Form.submit();
		return true;
	}
}


