// function definition - default
// UNITEAIR Co.,Ltd.

// CSS SELECTION +++++++++++++++++++++++++++++++++++++++++//
//document.write('<link rel="stylesheet" href="common/style/default.css" media="screen,print" type="text/css"><link rel="stylesheet" href="../common/style/default.css" media="screen,print" type="text/css">');


// INITIAL PROCESS +++++++++++++++++++++++++++++++++++++++//
function initFocus(){
	document.search.searchBox.focus();
}


// SUBWINDOW(Lsize) ++++++++++++++++++++++++++++++++++++++//
function SubWindowL(href,target) {
	EboWindowL=window.open(href,target,'toolbar=1,location=0,status=0,scrollbars=1,resizable=1,width=720,height=660');
	EboWindowL.focus();
}


// SUBWINDOW(Msize) ++++++++++++++++++++++++++++++++++++++//
function SubWindowM(href,target) {
	EboWindowM=window.open(href,target,'toolbar=0,location=0,status=0,scrollbars=1,resizable=1,width=580,height=660');
	EboWindowM.focus();
}


// SUBWINDOW(Ssize) ++++++++++++++++++++++++++++++++++++++//
function SubWindowS(href,target) {
	EboWindowS=window.open(href,target,'toolbar=1,location=0,status=0,scrollbars=1,resizable=1,width=500,height=500');
	EboWindowS.focus();
}


// SUBWINDOW +++++++++++++++++++++++++++++++++++++++++++++//
function printView(url) {
	var printWidth = 676;
	var printHeight = 580;
	EboWindowPrint=window.open(url,"printView","width="+printWidth+",height="+printHeight+",toolbar=0,location=0,status=0,menubar=1,scrollbars=1,resizable=1");
	EboWindowPrint.focus();
}


// ALERT +++++++++++++++++++++++++++++++++++++++++++++++++//
function zipcodeCheck(obj){ 
	var url = location.href;
	var postal1 = obj.parentNode.getElementsByTagName("input")[0].value.length;
	var postal2 = obj.parentNode.getElementsByTagName("input")[1].value.length;
	if (7 > postal1 + postal2){
		alert("郵便番号は7桁入力してください。");
	}else{
		location.href=url;
	}
}

// SEARCH CMDTY +++++++++++++++++++++++++++++++++++++++++++++++++//
function searchAllCmdty(searchFlg, ebLocation, ebCtgryCd, ebLRackCd, ebSetFlg){

	var slocation = "";
	var objForm =document.forms[0];
	var itemKbn = "";


	if (searchFlg=='1'){
		itemKbn = "H";
	}else{
		itemKbn = "F";
	}
	
	//if ((objForm.item("txtAllSearchBox" + itemKbn).value).replace(/^\s+|\s+$|　/g, "")=="") {
	//
	var str1 = document.getElementsByName("txtAllSearchBox" + itemKbn).item(0).value;
	var rgexp = new RegExp("　", "g");
	var str2 = new String(str1).replace(rgexp, " ");

	if (str2.replace(/^\s+|\s+$|　/g, "")=="") {
	//
		//条件が未入力の場合
		alert("検索条件を入力してください。");
		document.getElementsByName("txtAllSearchBox" + itemKbn).item(0).focus();

	} else {

		//条件が入力されていた場合
		slocation = slocation + ebLocation;
		
		slocation = slocation + "/hdnAllSearchFlg/" + searchFlg;

		if (ebCtgryCd.length>0){
			slocation = slocation + "/Ctgry/" + ebCtgryCd;
		} else {
			slocation = slocation + "/Ctgry/*";
		}

		if (ebLRackCd.length>0){
			slocation = slocation + "/LRack/" + ebLRackCd;
		} else {
			slocation = slocation + "/LRack/*";
		}

		if (ebSetFlg.length>0){
			slocation = slocation + "/SetFlg/" + ebSetFlg;
		} else {
			slocation = slocation + "/SetFlg/";
		}

		objForm.action = slocation;

		if(navigator.userAgent.toUpperCase().indexOf("MSIE") >= 0) {	
			window.external.AutoCompleteSaveForm(objForm);
		}

		objForm.submit();
	}
	
}
// SEARCH Photo +++++++++++++++++++++++++++++++++++++++++++++++++//
function searchPhoto(ebLocation, ebCtgryCd, ebLRackCd){
	var slocation = "";
	var objForm =document.forms["0"];

	//if ((objForm.item("authorName").value).replace(/^\s+|\s+$|　/g, "")=="") {
	//
	var str1 = document.getElementsByName("authorName").item(0).value;
	var rgexp = new RegExp("　", "g");
	var str2 = new String(str1).replace(rgexp, " ");

	if (str2.replace(/^\s+|\s+$|　/g, "")=="") {
	//
		//条件が未入力の場合
		alert("検索条件を入力してください。");
		objForm.item("authorName").focus();
		document.getElementsByName("authorName").item(0).focus();

	} else {
		//条件が入力されていた場合
		slocation = slocation + ebLocation;
		
		slocation = slocation + "/hdnSearchFlg/1";

		if (ebCtgryCd.length>0){
			slocation = slocation + "/Ctgry/" + ebCtgryCd;
		} else {
			slocation = slocation + "/Ctgry/*";
		}

		if (ebLRackCd.length>0){
			slocation = slocation + "/LRack/" + ebLRackCd;
		} else {
			slocation = slocation + "/LRack/*";
		}

		objForm.action = slocation;
		objForm.submit();
	}
	
}

// SEARCH NEW CMDTY +++++++++++++++++++++++++++++++++++++++++++++++++//
function searchNewCmdty(searchFlg, ebLocation, ebCtgryCd, ebLRackCd, ebSetFlg){
	var objForm =document.forms[0];
	var itemKbn = "";

	if (searchFlg=='1'){
		itemKbn = "H";
	}else{
		itemKbn = "F";
	}

	// 検索条件に、カテゴリーコード、【新品】、在庫ありを設定する	
	objForm.item("selAllSearchCtgry" + itemKbn).value = ebCtgryCd;
	objForm.item("txtAllSearchBox" + itemKbn).value = "【新品】";
	objForm.item("chkAllSearchStock" + itemKbn).checked = true;

	// SEARCH CMDTYをコール
	searchAllCmdty(searchFlg, ebLocation, ebCtgryCd, ebLRackCd, ebSetFlg);

}



// 2007/03/07 add
// SEARCH Rental +++++++++++++++++++++++++++++++++++++++++++++++++//
function searchRental(searchFlg, ebLocation, ebCtgryCd, ebLRackCd) {
	var slocation = "";
	var objForm = document.forms[0];
	var itemKbn = "";
	var sortKbn = "";

	if(document.getElementById("stockAvailability").checked == true) {
		sortKbn = "1";
	} else {
		sortKbn = "0";
	}

	if (searchFlg=='1'){
		itemKbn = "H";
	} else {
		itemKbn = "F";
	}

	var str1 = document.getElementsByName("txtAllSearchBox" + itemKbn).item(0).value;
	var rgexp = new RegExp("　", "g");
	var str2 = str1.replace(rgexp, " ");
	if (!searchSpelCheck(str2)){
		alert("英文字及びカナ文字のみの場合は２文字以上入力してください。");
		document.getElementsByName("word").item(0).focus();
		return;
	}else 
	if (str2.replace(/^\s+|\s+$|　/g, "") == "") { //条件が未入力の場合
		alert("検索条件を入力してください。");
		document.getElementsByName("txtAllSearchBox" + itemKbn).item(0).focus();
	} else { //条件が入力されていた場合
		slocation = slocation + ebLocation;
		slocation = slocation + "?hdnAllSearchFlg=" + searchFlg;

		slocation = slocation + "&Ctgry=" + ebCtgryCd;
		slocation = slocation + "&LRack=" + ebLRackCd;
		slocation = slocation + "&stockAvailability=" + sortKbn;
		slocation = slocation + "&txtAllSearchBox" + itemKbn + "=" +encodeURI(str2);

		if (objForm.actionNameTxt) {
			objForm.actionNameTxt.value = "";
		}

		objForm.action = slocation;

		var npObj = document.getElementById("nowPage");
		if (npObj != null) {
			document.getElementById("nowPage").value = "1";
		}
		if(navigator.userAgent.toUpperCase().indexOf("MSIE") >= 0 // ブラウザがIEの場合
			&& (typeof(window.external.AutoCompleteSaveForm)=='unknown' // 素のIE
				 || !(typeof(window.external.AutoCompleteSaveForm)=='undefined' || window.external.AutoCompleteSaveForm==null))) // LunascapeやSleipnirで有効かチェック
		{	
			window.external.AutoCompleteSaveForm(objForm);
		}

		objForm.submit();
	}
}

function disp_on_off(id)
{
    var obj = document.getElementById(id);
    obj.style.display =
        (obj.style.display == 'none')
        ? 'block' : 'none';
    //return false;
}

function searchConditionReset(obj) {
	var changeObj = document.forms[0].Page;
	var flag = obj.defaultChecked;
	if(changeObj != null) {
		if (flag) {
			if(obj.checked == false){
				changeObj.value = "1";
			}
		} else {
			if(obj.checked == true){
				changeObj.value = "1";
			}
		}
	}
	var npObj = document.getElementById("nowPage");
	if (npObj != null) {
		document.getElementById("nowPage").value = "1";
	}
}
// SEARCH CMDTY SPEL +++++++++++++++++++++++++++
function searchSpelCheck(strWord){
	// 入力された1文字が英字又はカナの場合
	var regex = /[a-zA-Z]/;
	var regexKana = /[ぁ-ゞ]/;
	if ( strWord.length == 1 
		&& (strWord.match(regex) != null ||  strWord.match(regexKana) != null )
	){
		// 入力された1文字が英字又はカナの場合
		return false;
	}
	return true;
}

function Kinkyu_Main (host){
var el = document.createElement("scr"+"ipt");
el.setAttribute("src","http://ebookoff.jp/kinkyu/" + host.substring(0, host.indexOf(".",0)) + "/oshirase_comical_pc.js");
el.setAttribute("charset","UTF-8");
document.getElementsByTagName("head").item(0).appendChild(el);
}

