
//trimメソッド追加（全角、半角スペース削除）
String.prototype.allTrim = function() {
	return this.replace(/^[\s\u00A0\u3000]+|[\s\u00A0\u3000]+$/g, '');
}



/* /showa/hp/staticSearch.do用スクリプト */
//キーワード初期値
var CONST_KEYWORD = "キーワードを入力";
//キーワード初期値を返す
function getConstKeyword(){
	return CONST_KEYWORD;
}
//キーワード検索入力チェック.
function chkKeywordLen(text){
	var noKeywordMessage = "キーワードが指定されていません。";

	//前後の空白削除
	var str = text.allTrim();
	if(str.length == 0){
		alert(noKeywordMessage);
		return false;
	}
	//空白ありで文字長チェック
	var len = getTextByte(text);
	var maxByteLength = 60;
	if(len>maxByteLength){
		alert("キーワードは全角３０文字（半角６０文字）以内で入力してください。");
		return false;
	}
	//初期値の場合
	if(str == getConstKeyword()){
		alert(noKeywordMessage);
		return false;
	}

	return true;
}
//文字列バイト長取得.
function getTextByte(str) {
	var count = 0;
	for (i=0; i<str.length; i++) {
		result = escape(str.charAt(i));
		if (result.length < 4){
			count++;
		}else{
			count+=2;
		}
	}
	return count;
} 
//trimメソッド追加（全角、半角スペース削除）
String.prototype.allTrim = function() {
	return this.replace(/^[\s\u00A0\u3000]+|[\s\u00A0\u3000]+$/g, '');
}


function changeDisplay(idname) {
	if(document.getElementById(idname).style.display == 'none') {
		document.getElementById(idname).style.display = 'block';
	} else {
		document.getElementById(idname).style.display = 'none';
	}
}

function toggleImg(idname, imgA, imgB) {
	if($('#' + idname).attr("src") == 'images/' + imgB) {
		$('#' + idname).attr("src", "images/" + imgA);
	} else {
		$('#' + idname).attr("src", "images/" + imgB);
	}
}


function changeDisplay(idname) {
	if(document.getElementById(idname).style.display == 'none') {
		document.getElementById(idname).style.display = 'block';
	} else {
		document.getElementById(idname).style.display = 'none';
	}
}

function toggleImg(idname, imgA, imgB) {
	//if($('#' + idname).attr("src") == 'images/' + imgB) {
	//	$('#' + idname).attr("src", "images/" + imgA);
	//} else {
	//	$('#' + idname).attr("src", "images/" + imgB);
	//}
	var srcName = $('#' + idname).attr("src");
	var name = srcName.substring(srcName.lastIndexOf('/') + 1);
	if (name == imgB) {
		$('#' + idname).attr("src", srcName.substring(0, srcName.lastIndexOf('/')+ 1) + imgA);
	} else {
		$('#' + idname).attr("src", srcName.substring(0, srcName.lastIndexOf('/')+ 1) + imgB);
	}
}

function SelectCheck1() {
	var i;
        for (i = 0; i < document.getElementById("SalesProductSearchForm2").category01.length; i++) {
            if (document.getElementById("SalesProductSearchForm2").category01[i].checked) {
                var checkName = document.getElementById("SalesProductSearchForm2").category01[i].value;
            }
        }
	if (checkName == cValue1) {
		this.checked = false;
		cValue1 = '';
	} else {
		cValue1 = checkName;
	}
}

function SelectCheck2() {
	var i;
        for (i = 0; i < document.getElementById("SalesProductSearchForm2").material.length; i++) {
            if (document.getElementById("SalesProductSearchForm2").material[i].checked) {
                var checkName = document.getElementById("SalesProductSearchForm2").material[i].value;
            }
        }
	if (checkName == cValue2) {
		this.checked = false;
		cValue2 = '';
	} else {
		cValue2 = checkName;
	}
}

function SelectCheck3() {
	var i;
        for (i = 0; i < document.getElementById("SalesProductSearchForm2").category03.length; i++) {
            if (document.getElementById("SalesProductSearchForm2").category03[i].checked) {
                var checkName = document.getElementById("SalesProductSearchForm2").category03[i].value;
            }
        }
	if (checkName == cValue3) {
		this.checked = false;
		cValue3 = '';
	} else {
		cValue3 = checkName;
	}
}

function MM_openWindow(theURL,winName,WW,WH,SCB) {
  var Features = 'status=no,directories=no,menubar=no,resizable=no,toolbar=no,scrollbars=' + SCB + ',width=' + WW + ',height=' + WH;
  subWin_a = window.open(theURL,winName,Features);
  subWin_a.focus()
}
