area_array = new Array();
area_array.push("北海道");
area_array.push("青森県");
area_array.push("岩手県");
area_array.push("宮城県");
area_array.push("秋田県");
area_array.push("山形県");
area_array.push("福島県");
area_array.push("茨城県");
area_array.push("栃木県");
area_array.push("群馬県");
area_array.push("埼玉県");
area_array.push("千葉県");
area_array.push("東京都");
area_array.push("神奈川県");
area_array.push("新潟県");
area_array.push("富山県");
area_array.push("石川県");
area_array.push("福井県");
area_array.push("山梨県");
area_array.push("長野県");
area_array.push("岐阜県");
area_array.push("静岡県");
area_array.push("愛知県");
area_array.push("三重県");
area_array.push("滋賀県");
area_array.push("京都府");
area_array.push("大阪府");
area_array.push("兵庫県");
area_array.push("奈良県");
area_array.push("和歌山県");
area_array.push("鳥取県");
area_array.push("島根県");

area_array.push("岡山県");
area_array.push("広島県");
area_array.push("山口県");
area_array.push("徳島県");
area_array.push("香川県");
area_array.push("愛媛県");
area_array.push("高知県");
area_array.push("福岡県");
area_array.push("佐賀県");
area_array.push("長崎県");
area_array.push("熊本県");
area_array.push("大分県");
area_array.push("宮崎県");
area_array.push("鹿児島県");
area_array.push("沖縄県");


var mailcheck = false;
var checkflag = false;


var weeks = new Array('日','月','火','水','木','金','土'); 
var now = new Date(); 
var year = now.getYear(); // 年 
var month = now.getMonth() + 1; // 月 
var day = now.getDate(); // 日 
var week = weeks[ now.getDay() ]; // 曜日 

var hour = now.getHours(); // 時 
var min = now.getMinutes(); // 分 
var sec = now.getSeconds(); // 秒 


if(year < 2000) { year += 1900; } 


function setOption(max,date,tmp_year){
	for(var i=1; i<=max; i++){
		var selected = (i==eval(date) && tmp_year==year) ? " selected" : "";
		document.write('<option value="'+i+'"'+selected+'>'+i+'</option>');
	}
}


function setDialog(num,select){
	//生年月日はセレクトする必要がない
	var tmp_year = (select==0) ? 1900 : year;
	document.write('西暦&nbsp;<input name="year'+num+'" type="text" value="'+tmp_year+'" size="7" maxlength="4" />&nbsp;年&nbsp;');
	document.write('<select name="month'+num+'">');
	setOption(12,"month", tmp_year);
	document.write('</select>&nbsp;月&nbsp;');
	document.write('<select name="day'+num+'">');
	setOption(31,"day", tmp_year);
	document.write('</select>&nbsp;日&nbsp;');
}


function setArea(){
	document.write('<span class="address_item">都道府県</span><select name="address1" class="state"><option value="0" "selected">お選びください</option>');
	for(var i=0; i<47; i++){
		document.write('<option value="'+area_array[i]+'">'+area_array[i]+'</option>');
	}
	document.write('</select>');
}


/*
function show(id,visible){ 
  if(document.getElementById) {//NN6,Mozilla,IE5用
    document.getElementById(id).style.visibility = visible;
  }
  else if(document.all){       //IE4用
    document.all(id).style.visibility = visible;
  }
  else if(document.layers){    //NN4用
    document.layers[id].visibility = (visible=='visible') ?'show' : 'hide';
  }
}
*/




function show(id,display){ 
  if(document.getElementById) {//NN6,Mozilla,IE5用
    document.getElementById(id).style.display = display;
  }
  else if(document.all){       //IE4用
    document.all(id).style.display = display;
  }
  else if(document.layers){    //NN4用
    document.layers[id].display = (display=='block') ?'block' : 'none';
  }
}




/*
function changePage(show_id,hide_id){
	show(show_id,'visible');

	show(hide_id,'hidden');
}
*/


function changePage(show_id,hide_id){
	show(show_id,'block');
	show(hide_id,'none');
}


function setCheckMsg(){
	var alertMsg="";
	var msg = "";


	//--------------------------------
	//		お客様情報
	//--------------------------------
	msg += '■お客様情報\n';
	
	if(document.form1.name.value != ""){
		msg += "お名前: "+document.form1.name.value+'\n';
		outputLAYER("check_name",document.form1.name.value);
	}else{
		alertMsg += "お名前を入力してください"+'\n';
	}
	
	if(document.form1.name2.value != ""){
		msg += "フリガナ: "+document.form1.name2.value+'\n';
		outputLAYER("check_name2",document.form1.name2.value);
	}else{
		alertMsg += "フリガナを入力してください"+'\n';
	}
	
	if(document.form1.email.value != ""){
		msg += "メールアドレス: "+document.form1.email.value+'\n';
		outputLAYER("check_email",document.form1.email.value);
	}else{
		alertMsg += "メールアドレスを入力してください"+'\n';
	}
		
	if(document.form1.company.value != ""){
		msg += "会社名: "+document.form1.company.value+'\n';
		outputLAYER("check_company",document.form1.company.value);
	}else{
		alertMsg += "会社名を入力してください"+'\n';
	}


	if(document.form1.post.value != ""){
		msg += "部署名: "+document.form1.post.value+'\n';
		outputLAYER("check_post",document.form1.post.value);
	}else{
		alertMsg += "部署名: 未入力\n";
	}
/*
	if(document.form1.zip1.value != ""){
		msg += "郵便番号: "+document.form1.zip1.value+'\n';
		outputLAYER("check_zip1",document.form1.zip1.value);
	}else{
		alertMsg += "郵便番号を入力してください"+'\n';
	}


	if(document.form1.zip2.value != ""){
		msg += "郵便番号: "+document.form1.zip2.value+'\n';
		outputLAYER("check_zip2",document.form1.zip2.value);
	}else{
		alertMsg += "郵便番号を入力してください"+'\n';
	}
*/


	if(document.form1.zip1.value != "" && document.form1.zip2.value != ""){
		msg += "郵便番号: "+document.form1.zip1.value +"-"+ document.form1.zip2.value+'\n';
		var zip = document.form1.zip1.value+"-"+document.form1.zip2.value;
		outputLAYER("check_zip",zip);
	}else{
		alertMsg += "郵便番号を入力してください"+'\n';
	}


	if(document.form1.address1.value != ""){
		msg += "都道府県: "+document.form1.address1.value+'\n';
		outputLAYER("check_address1",document.form1.address1.value);
	}else{
		alertMsg += "都道府県を入力してください"+'\n';
	}


	if(document.form1.address2.value != ""){
		msg += "住所: "+document.form1.address2.value+'\n';
		outputLAYER("check_address2",document.form1.address2.value);
	}else{
		alertMsg += "住所を入力してください"+'\n';
	}


/*	if(document.form1.address1.value != "0" && document.form1.address2.value != "" ){
		msg += "住所: "+document.form1.address1.value+document.form1.address2.value+'\n';
		outputLAYER("check_address",document.form1.address1.value+document.form1.address2.value);
	}else{
		alertMsg += "住所を入力してください"+'\n';
	}
*/
/*
	if(document.form1.tel1.value != ""){
		msg += "電話番号: "+document.form1.tel1.value+'\n';
		outputLAYER("check_tel1",document.form1.tel1.value);
	}else{
		alertMsg += "電話番号を入力してください"+'\n';
	}


	if(document.form1.tel2.value != ""){
		msg += "電話番号: "+document.form1.tel2.value+'\n';
		outputLAYER("check_tel2",document.form1.tel2.value);
	}else{
		alertMsg += "電話番号を入力してください"+'\n';
	}




	if(document.form1.tel3.value != ""){
		msg += "電話番号: "+document.form1.tel3.value+'\n';
		outputLAYER("check_tel3",document.form1.tel3.value);
	}else{
		alertMsg += "電話番号を入力してください"+'\n';
	}
*/
	if(document.form1.tel1.value != "" && document.form1.tel2.value != "" && document.form1.tel3.value != ""){
		msg += "電話番号: "+document.form1.tel1.value +"-"+ document.form1.tel2.value +"-"+ document.form1.tel3.value+'\n';
		var tel = document.form1.tel1.value+"-"+document.form1.tel2.value+"-"+document.form1.tel3.value;
		outputLAYER("check_tel",tel);
	}else{
		alertMsg += "電話番号を入力してください"+'\n';
	}




/*
	if(document.form1.fax1.value != ""){
		msg += "FAX番号: "+document.form1.fax1.value+'\n';
		fax + = document.form1.fax1.value;
		//outputLAYER("check_fax1",document.form1.fax1.value);
	}


	if(document.form1.fax2.value != ""){
		msg += "FAX番号: "+document.form1.fax2.value+'\n';
		fax + = "-"+document.form1.fax2.value;
		//outputLAYER("check_fax2",document.form1.fax2.value);
	}


	if(document.form1.fax3.value != ""){
		msg += "FAX番号: "+document.form1.fax3.value+'\n';
		fax + = "-"+document.form1.fax3.value;
		outputLAYER("check_fax",fax);
	}
*/


	if(document.form1.fax1.value != "" && document.form1.fax2.value != "" && document.form1.fax3.value != ""){
		msg += "FAX番号: "+document.form1.fax1.value+"-"+document.form1.fax2.value+"-"+document.form1.fax3.value+'\n';
		var fax = document.form1.fax1.value+"-"+document.form1.fax2.value+"-"+document.form1.fax3.value;
		outputLAYER("check_fax",fax);
	}


	if(document.form1.work1.value != ""){
		msg += "職種: "+document.form1.work1.value+'\n';
		outputLAYER("check_work1",document.form1.work1.value);
	}else{
		alertMsg += "職種: 未入力\n";
	}


	if(document.form1.work2.value != ""){
		msg += "業種: "+document.form1.work2.value+'\n';
		outputLAYER("check_work2",document.form1.work2.value);
	}else{
		alertMsg += "業種: 未入力\n";
	}




	var catalog = document.form1;
	var tmpcatalog = "";
	for(i = 0; i < catalog.elements['catalog'].length ; i++){
		if(catalog.elements['catalog'][i].checked){
			tmpcatalog += catalog.elements['catalog'][i].value+"/";
		}
	}
	if(tmpcatalog != ""){
		msg += "カタログ請求: "+tmpcatalog+"\n";
		outputLAYER("check_catalog",tmpcatalog);
	}






//	--------------------------------
//			ご連絡方法
//	--------------------------------
/*
	if(document.form1.tel1.value != "" && document.form1.tel2.value != "" && document.form1.tel3.value != ""){
		msg += "TEL: "+document.form1.tel1.value+"-"+document.form1.tel2.value+"-"+document.form1.tel3.value+'\n';
		outputLAYER("check_tel",document.form1.tel1.value+"-"+document.form1.tel2.value+"-"+document.form1.tel3.value);
	}else{
		alertMsg += "電話番号を入力してください"+'\n';
	}
	if(document.form1.email.value != "" && mailcheck && checkflag){
		msg += "メールアドレス: "+document.form1.email.value+'\n';
		outputLAYER("check_email",document.form1.email.value);
	}else if(!checkflag && document.form1.email.value != ""){
		alertMsg += "メールアドレスは半角英数字で入力して下さい"+'\n';
	}else if(document.form1.email.value != ""){
		alertMsg += "メールアドレスが正しく入力されていません"+'\n';
	}else{
		alertMsg += "メールアドレスを入力してください"+'\n';
	}
*/
	//--------------------------------
	//		その他ご希望、ご質問等
	//--------------------------------
/*
	msg += '\n■お問い合わせ、ご相談内容\n';


	if(document.form1.subject.value != ""){
		msg += "件名: "+document.form1.subject.value+'\n';
		outputLAYER("check_subject", document.form1.subject.value+'\n');	
	}else{
		msg += "件名: 未入力\n";
	}


	if(document.form1.msg.value != ""){
		msg += "内容: "+document.form1.msg.value+'\n';
		outputLAYER("check_msg", document.form1.msg.value.split('\n').join('<br />')+'\n');
	}else{
		alertMsg += "内容を入力してください"+'\n';
	}
*/
	//--------------------------------
	//		ページ移動
	//--------------------------------


	//alertMsg = ""
	if(alertMsg == ""){
		changePage('check','input');
		msg = '<input id="send_body" name="body" type="hidden" value="'+msg+'" /><input id="mail" name="from" type="hidden" value="'+document.form1.email.value+'" />';
		outputLAYER("mail_body",msg);
	}else{
		alert(alertMsg);
	}


}


function setCheckMsgConect(){
	var alertMsg="";
	var msg = "";


	//--------------------------------
	//		お客様情報
	//--------------------------------
	msg += '■お客様情報\n';


	if(document.form1.name.value != ""){
		msg += "お名前: "+document.form1.name.value+'\n';
		outputLAYER("check_name",document.form1.name.value);
	}else{
		alertMsg += "お名前を入力してください"+'\n';
	}
	
	if(document.form1.name2.value != ""){
		msg += "フリガナ: "+document.form1.name2.value+'\n';
		outputLAYER("check_name2",document.form1.name2.value);
	}else{

		alertMsg += "フリガナを入力してください"+'\n';
	}
	
	if(document.form1.email.value != ""){
		msg += "メールアドレス: "+document.form1.email.value+'\n';
		outputLAYER("check_email",document.form1.email.value);
	}else{
		alertMsg += "メールアドレスを入力してください"+'\n';
	}
		
	if(document.form1.msg.value != ""){
		msg += "内容: "+document.form1.msg.value+'\n';
		outputLAYER("check_msg", document.form1.msg.value.split('\n').join('<br />')+'\n');
	}else{

		alertMsg += "内容を入力してください"+'\n';
	}


	//--------------------------------
	//		ページ移動
	//--------------------------------


	//alertMsg = ""
	if(alertMsg == ""){
		changePage('check','input');
		msg = '<input name="body" type="hidden" value="'+msg+'" /><input name="from" type="hidden" value="'+document.form1.email.value+'" />';
		outputLAYER("mail_body",msg);
	}else{
		alert(alertMsg);
	}
}


function outputLAYER(layName,html){
	if(document.getElementById){        //e5,e6,n6,n7,m1,o7,s1用
		document.getElementById(layName).innerHTML = html;
	} else if(document.all){            //e4用
		document.all(layName).innerHTML=html;
	} else if(document.layers) {        //n4用
		 with(document.layers[layName].document){
			 open();
			 write(html);
			 close();
		}
	}
}


function selectBox(checkbox){
	document.form1[checkbox].checked=true;
}


function check_MA(input){
	var email = z2h_ascii(document.form1[input].value);
	document.form1[input].value = email;
	checkflag = isZen(document.form1[input]);


	if(email.match(/.+@.+\..+/) && checkflag){
		mailcheck = true;
		//alert("メールアドレスが正しく入力されました");
		return 1;
	}else if(checkflag){
		alert("メールアドレスが正しく入力されていません");
		mailcheck = false;
		//document.form1[input].select();
		return 0;
	}
}


function isZen(obj){
    var str=obj.value; /* 入力値 */
    for(var i=0; i<str.length; i++){
        /* 1文字ずつ文字コードをエスケープし、その長さが4文字以上なら全角 */
        var len=escape(str.charAt(i)).length;
        if(len>=4){
            alert("メールアドレスは半角英数字で入力して下さい");
			//obj.select();
	        return false;
        }
    }
    return true;
}


function z2h_ascii(src) {
	var str = new String;
	var len = src.length;
	for (var i = 0; i < len; i++) {
		var c = src.charCodeAt(i);
		if (c >= 65281 && c <= 65374 && c != 65340) {
			str += String.fromCharCode(c - 65248);
		} else if (c == 8217) {
			str += String.fromCharCode(39);
		} else if (c == 8221) {
			str += String.fromCharCode(34);
		} else if (c == 12288) {
			str += String.fromCharCode(32);
		} else if (c == 65507) {
			str += String.fromCharCode(126);
		} else if (c == 65509) {
			str += String.fromCharCode(92);
		} else {
			str += src.charAt(i);
		} 
	}
	return str;
}

