function smartRollover() {

	if(document.getElementsByTagName) {

		var images = document.getElementsByTagName("img");



		for(var i=0; i < images.length; i++) {

			if(images[i].getAttribute("src").match("_off."))

			{

				images[i].onmouseover = function() {

					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));

				}

				images[i].onmouseout = function() {

					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));

				}

			}

		}

	}

}



if(window.addEventListener) {

	window.addEventListener("load", smartRollover, false);

}

else if(window.attachEvent) {

	window.attachEvent("onload", smartRollover);

}


function backToTop() {

	var x1 = x2 = x3 = 0;

	var y1 = y2 = y3 = 0;



	if (document.documentElement) {

		x1 = document.documentElement.scrollLeft || 0;

		y1 = document.documentElement.scrollTop || 0;

	}



	if (document.body) {

		x2 = document.body.scrollLeft || 0;

		y2 = document.body.scrollTop || 0;

	}



	x3 = window.scrollX || 0;

	y3 = window.scrollY || 0;



	var x = Math.max(x1, Math.max(x2, x3));

	var y = Math.max(y1, Math.max(y2, y3));



	window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));



	if (x > 0 || y > 0) {

		window.setTimeout("backToTop()", 25);

	}

}


function win1(){
window.open
("./pop_up/01.html","","width=540,height=550,scrollbars=yes");
}

function win2(){
window.open
("./pop_up/02.html","","width=540,height=550,scrollbars=yes");
}

function win3(){
window.open
("./pop_up/03.html","","width=540,height=550,scrollbars=yes");
}

function win4(){
window.open
("./pop_up/04.html","","width=540,height=550,scrollbars=yes");
}


// プログラム移動
function goPage(pgAct) {
	document.fList.action = pgAct;
	document.fList.submit(true)
}

// コードを伴ったプログラム移動
function goPageWithWork(pgAct, tmp) {
	document.fList.action = pgAct;
	document.fList.work.value = tmp;
	document.fList.submit(true)
}

// コードを伴ったプログラム移動
function goPageWithCD(pgAct, CD) {
	document.fList.editCarCD.value = CD;
	document.fList.action = pgAct;
	document.fList.submit(true)
}

// コードを伴ったプログラム移動
function goPageWithCDandWork(pgAct, CD, tmp) {
	document.fList.target = '_self';
	document.fList.editCarCD.value = CD;
	document.fList.work.value = tmp;
	document.fList.action = pgAct;
	document.fList.submit(true)
}

// コードを伴ったプログラム移動
function goPageWithTarget(pgAct, CD) {
	document.fList.target = CD;
	document.fList.action = pgAct;
	document.fList.submit(true)
}

// ページ移動
function changePage(pgAct, myPage) {
	if (myPage == 0 && (document.fList.myPage.value < 1 || document.fList.myPage.value > __AllPages__))
		alert("ページ指定が不正です。再度確認してみてください。");
	else{
		if (myPage > 0)
			document.fList.myPage.value = myPage;
		document.fList.action = pgAct;
		document.fList.submit(true);
		return false;
	}
}

// ソート指定
function changeSort(sortBy) {
	document.fList.SortBy.value = sortBy;
	document.fList.action = "index.php";
	document.fList.submit(true);
	return false;
}

// ソート指定
function changeSortWithPage(sortBy, pg) {
	document.fList.SortBy.value = sortBy;
	document.fList.action = pg;
	document.fList.submit(true);
	return false;
}

// 一応削除確認
function delCar(pgAct,tmp) {
	if(window.confirm('削除してもよろしいですか？')){
		goPageWithWork(pgAct, tmp);
	}

}

// 画面変更
function changeImage(img) {
	document.getElementById("D_Image").innerHTML
	 = "<img src='" + img + "' width='740' height='555' />";
	
}

// 比較
function hikakuCar(pgAct, CD, tmp) {
	count = 0;
	if (document.fList.elements['wChk[]'].length) {
		for (var i=0;i<document.fList.elements['wChk[]'].length;i++){
			if ((document.fList.elements[i].name=='wChk[]') && (document.fList.elements[i].checked)) {
				count ++;
			}
		}
	}
	if( count == 0 ) {
		alert('車両が選択されていません。');
	}
	else {
		goPageWithCDandWork(pgAct, CD, tmp);
	}
}

// 見積
function inqCar(pgAct, CD) {
	count = 0;
	if (document.fList.elements['wChk[]'].length) {
		for (var i=0;i<document.fList.elements['wChk[]'].length;i++){
			if ((document.fList.elements[i].name=='wChk[]') && (document.fList.elements[i].checked)) {
				count ++;
			}
		}
	}
	else {
		if (document.fList.elements['wChk[]'].checked){
			count ++;
		}
	}
	if( count == 0 ) {
		alert('車両が選択されていません。');
	}
	else {
		goPageWithTarget(pgAct, CD);
	}
}

// コードを伴ったプログラム移動
function goPageWithTargetSingle(pgAct, CD, wCarCD) {
	document.fListSingle.editCarCD.value = wCarCD;
	document.fListSingle.target = CD;
	document.fListSingle.action = pgAct;
	document.fListSingle.submit(true)
}
