﻿function focusin_color(){

var s =event.srcElement.id;
var r =document.getElementById(s);
r.style.backgroundColor='#ffaaaa';

}

function focusout_color(){

var s =event.srcElement.id;
var r =document.getElementById(s);
r.style.backgroundColor='#ffffff';

}

function submitChk() {
var flag = confirm ( "よろしいですか？\n\nよくない場合は[キャンセル]ボタンを押して下さい");
return flag;
}

function ChgKeyCode(){
if (!(event.srcElement.type == 'button' || event.srcElement.type == 'submit' || event.srcElement.type == 'textarea')){
if (event.keyCode == 13){
event.keyCode = 9;
}
}
}

function link_alert(){
var ag = confirm ( "編集中の内容が失われますが、よろしいですか？\n\nよくない場合は[キャンセル]ボタンを押して下さい");
return ag;
}


function tree(LinkName) {
ls = document.all[LinkName].style;
if(ls.display == 'none') {
ls.display = 'block'
} else {
ls.display = 'none'
}
}

//半角全角桁数
String.prototype.mlength=function(){
var len=0;
for(var i=0;i<this.length;i++){
var code=this.charCodeAt(i);
if(code>255) len++;
len++
}
return len;
}

//見積書の場合
function chkHissu(frm){
/* 必須入力のname属性 */
var hissu=Array('online_cust_company','online_cust_name','online_cust_email');
/* アラート表示用 */
var hissu_nm = Array('会社名','ご担当者名','E-MAIL');
/* 必須入力の数 */
var len=hissu.length;
for(i=0; i<len; i++){
var obj=frm.elements[hissu[i]];

if(obj.value==''){
/* 入力されていなかったらアラート表示 */
alert(hissu_nm[i]+'は必須入力項目です');
/* 未入力のエレメントにフォーカスを当てる */
frm.elements[hissu[i]].focus();
frm.elements[hissu[i]].style.backgroundColor='#ffaaaa';
return false;
}
}

var online_cust_email = document.getElementById('online_cust_email').value;
var Seiki=/[!#-9A-~]+@+[a-z0-9]+.+[^.]$/i;
/* 入力された値がパターンにマッチするか調べる */
if(online_cust_email!=''){
if(online_cust_email.match(Seiki)){
//alert(online_cust_email.match(Seiki)+"\n\nメールアドレスの形式は正しいです");
return true;
}else{
alert('メールアドレスの形式が不正です');
document.form1.online_cust_email.focus();
return false;
}
}else{
/* 何も入力されていない場合はアラート表示 */
alert('メールアドレスを入力してください');
return false;
}

}

//発注の場合
function chkHissu1(frm){
/* 必須入力のname属性 */
var hissu=Array('online_cust_company','online_cust_name','online_cust_email','online_cust_tel1','online_cust_post1','add');
/* アラート表示用 */
var hissu_nm = Array('会社名','ご担当者名','E-MAIL','電話番号','郵便番号','住所');
/* 必須入力の数 */
var len=hissu.length;
for(i=0; i<len; i++){
var obj=frm.elements[hissu[i]];

if(obj.value==''){
/* 入力されていなかったらアラート表示 */
alert(hissu_nm[i]+'は必須入力項目です');
/* 未入力のエレメントにフォーカスを当てる */
frm.elements[hissu[i]].focus();
frm.elements[hissu[i]].style.backgroundColor='#ffaaaa';
return false;
}
}

var online_cust_email = document.getElementById('online_cust_email').value;
var Seiki=/[!#-9A-~]+@+[a-z0-9]+.+[^.]$/i;
/* 入力された値がパターンにマッチするか調べる */
if(online_cust_email!=''){
if(online_cust_email.match(Seiki)){
//alert(online_cust_email.match(Seiki)+"\n\nメールアドレスの形式は正しいです");
return true;
}else{
alert('メールアドレスの形式が不正です');
document.form1.online_cust_email.focus();
return false;
}
}else{
/* 何も入力されていない場合はアラート表示 */
alert('メールアドレスを入力してください');
return false;
}

}


//お問い合わせの場合
function chkHissu2(frm){
/* 必須入力のname属性 */
var hissu=Array('online_cust_company','online_cust_name','online_cust_email','cont');
/* アラート表示用 */
var hissu_nm = Array('会社名','ご担当者名','E-MAIL','内容');
/* 必須入力の数 */
var len=hissu.length;
for(i=0; i<len; i++){
var obj=frm.elements[hissu[i]];

if(obj.value==''){
/* 入力されていなかったらアラート表示 */
alert(hissu_nm[i]+'は必須入力項目です');
/* 未入力のエレメントにフォーカスを当てる */
frm.elements[hissu[i]].focus();
frm.elements[hissu[i]].style.backgroundColor='#ffaaaa';
return false;
}
}

var online_cust_email = document.getElementById('online_cust_email').value;
var Seiki=/[!#-9A-~]+@+[a-z0-9]+.+[^.]$/i;
/* 入力された値がパターンにマッチするか調べる */
if(online_cust_email!=''){
if(online_cust_email.match(Seiki)){
//alert(online_cust_email.match(Seiki)+"\n\nメールアドレスの形式は正しいです");
return true;
}else{
alert('メールアドレスの形式が不正です');
document.form1.online_cust_email.focus();
return false;
}
}else{
/* 何も入力されていない場合はアラート表示 */
alert('メールアドレスを入力してください');
return false;
}

}

function conv(Event,quoi){

if(navigator.appName=='Microsoft Internet Explorer') {
if(!(event.srcElement.type == 'button' || event.srcElement.type == 'submit' || event.srcElement.type == 'textarea')){

if(event.keyCode=='13'){
event.keyCode='9';
}

}

//BSキー
if(event.keyCode=='8'){
event.keyCode='27';
}
//BSキーend

}else{

var cle;
cle = Event.keyCode;

if(cle=='13'){
var target = Event.srcElement ? Event.srcElement : Event.target;
var targetTabIndex = target.tabIndex;
var nextTabIndex = targetTabIndex+1;
var nextElement = getElementByTabIndex(nextTabIndex);

if(targetTabIndex){
nextElement.focus();
Event.cancelBubble = true;
Event.returnValue = false;
if(Event.preventDefault)Event.preventDefault();
if(Event.stopPropagation)Event.stopPropagation();
return false;
}

return true;
}
}
}

function getElementByTabIndex(tabIndex){

var form = document.forms[0];
for(var i=0; i<form.elements.length; i++ ){
var el = form.elements[i];
if(el.tabIndex && el.tabIndex == tabIndex ){
return el;
}
}
return null;
}
